/*
 * 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 = "1.0.0";

/** \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
*/
define pg_create_interface
{
  u32 client_index;
  u32 context;
  u32 interface_id;
};

/** \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;
  u32 sw_if_index;
};

/** \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 - pacp file name to store captured packets
*/
autoreply define pg_capture
{
  u32 client_index;
  u32 context;
  u32 interface_id;
  u8 is_enabled;
  u32 count;
  u32 pcap_name_length;
  u8 pcap_file_name[pcap_name_length];
};

/** \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 - stream name to be enable/disabled, if not specified handle all streams
*/
autoreply define pg_enable_disable
{
  u32 client_index;
  u32 context;
  u8 is_enabled;
  u32 stream_name_length;
  u8 stream_name[stream_name_length];
};

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