/*
 * Copyright (c) 2015-2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/** \file

    This file defines packet-generator interface APIs.
*/

option version = "2.0.0";

import "vnet/interface_types.api";

/** \brief PacketGenerator create interface request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param interface_id - interface index
    @param gso_enabled - enable gso on this interface
    @param gso_size - gso size on this interface
*/
define pg_create_interface
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t interface_id;
  bool gso_enabled;
  u32 gso_size;
};

/** \brief PacketGenerator create interface response
    @param context - sender context, to match reply w/ request
    @param retval - return value for request
*/
define pg_create_interface_reply
{
  u32 context;
  i32 retval;
  vl_api_interface_index_t sw_if_index;
};

/** \brief PacketGenerator interface enable/disable packet coalesce
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param interface_id - interface index
    @param coalesce_enabled - enable/disable packet coalesce on this interface
*/
autoreply define pg_interface_enable_disable_coalesce
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  bool coalesce_enabled;
  option status="in_progress";
};

/** \brief PacketGenerator capture packets on given interface request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param interface_id - pg interface index
    @param is_enabled - 1 if enabling streams, 0 if disabling
    @param count - number of packets to be captured
    @param pcap_file_name - pacp file name to store captured packets
*/
autoreply define pg_capture
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t interface_id;
  bool is_enabled [default=true];
  u32 count;
  string pcap_file_name[];
};

/** \brief Enable / disable packet generator request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_enabled - 1 if enabling streams, 0 if disabling
    @param stream_name - stream name to be enable/disabled, if not specified handle all streams
*/
autoreply define pg_enable_disable
{
  u32 client_index;
  u32 context;
  bool is_enabled [default=true];
  string stream_name[];
};

/*
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
