/*
 * 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.
 */

option version = "2.0.0";

/** \brief Punt definition
    @param ipv - L3 protocol 4 - IPv4, 6 - IPv6, ~0 - All
    @param l4_protocol - L4 protocol to be punted
    @param l4_port - TCP/UDP port to be punted
*/
typeonly define punt
{
    u8 ipv;
    u8 l4_protocol;
    u16 l4_port;
};

/** \brief Punt traffic to the host
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - add punt if non-zero, else delete
    @param punt - punt definition, only UDP (0x11) is supported
*/
autoreply define set_punt {
    u32 client_index;
    u32 context;
    u8 is_add;
    vl_api_punt_t punt;
};

define punt_dump
{
    u32 client_index;
    u32 context;
    u8 is_ipv6;
};

define punt_details
{
    u32 context;
    vl_api_punt_t punt;
};

/** \brief Punt traffic to the host via socket
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param header_version - expected meta data header version (currently 1)
    @param punt - punt definition
*/
define punt_socket_register {
    u32 client_index;
    u32 context;
    u32 header_version;
    vl_api_punt_t punt;
    u8 pathname[108]; /* Linux sun_path defined to be 108 bytes, see unix(7) */
};

define punt_socket_register_reply
{
    u32 context;
    i32 retval;
    u8 pathname[64];
};

define punt_socket_dump
{
    u32 client_index;
    u32 context;
    u8 is_ipv6;
};

define punt_socket_details
{
    u32 context;
    vl_api_punt_t punt;
    u8 pathname[108];
};

autoreply define punt_socket_deregister {
    u32 client_index;
    u32 context;
    vl_api_punt_t punt;
};

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