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

/** \brief GPE locator structure
    @param is_ip4 - whether addr is IPv4 or v6
    @param weight - locator weight
    @param addr - IPv4/6 address
*/
typeonly manual_print manual_endian define gpe_locator
{
  u8 is_ip4;
  u8 weight;
  u8 addr[16];
};

/** \brief add or delete GPE tunnel
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - add address if non-zero, else delete
    @param eid_type -
      0 : ipv4
      1 : ipv6
      2 : mac
    @param rmt_eid - remote eid
    @param lcl_eid - local eid
    @param rmt_len - remote prefix len
    @param lcl_len - local prefix len
    @param vni - virtual network identifier
    @param dp_table - vrf/bridge domain id
    @param action - negative action when 0 locators configured
    @param loc_num - number of locators
    @param locs - array of remote locators
*/
manual_print manual_endian define gpe_add_del_fwd_entry
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 eid_type;
  u8 rmt_eid[16];
  u8 lcl_eid[16];
  u8 rmt_len;
  u8 lcl_len;
  u32 vni;
  u32 dp_table;
  u8 action;
  u32 loc_num;
  vl_api_gpe_locator_t locs[loc_num];
};

define gpe_add_del_fwd_entry_reply
{
  u32 context;
  i32 retval;
  u32 fwd_entry_index;
};

/** \brief enable or disable gpe protocol
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_en - enable protocol if non-zero, else disable
*/
autoreply define gpe_enable_disable
{
  u32 client_index;
  u32 context;
  u8 is_en;
};

/** \brief add or delete gpe_iface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - add address if non-zero, else delete
*/
autoreply define gpe_add_del_iface
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 is_l2;
  u32 dp_table;
  u32 vni;
};

define gpe_fwd_entry_vnis_get
{
  u32 client_index;
  u32 context;
};

manual_print manual_endian define gpe_fwd_entry_vnis_get_reply
{
  u32 context;
  i32 retval;
  u32 count;
  u32 vnis[count];
};

define gpe_fwd_entries_get
{
  u32 client_index;
  u32 context;
  u32 vni;
};

typeonly manual_print manual_endian define gpe_fwd_entry
{
  u32 fwd_entry_index;
  u32 dp_table;
  u8 eid_type;
  u8 leid_prefix_len;
  u8 reid_prefix_len;
  u8 leid[16];
  u8 reid[16];
  u32 vni;
  u8 action;
};

manual_print manual_endian define gpe_fwd_entries_get_reply
{
  u32 context;
  i32 retval;
  u32 count;
  vl_api_gpe_fwd_entry_t entries[count];
};

define gpe_fwd_entry_path_dump
{
  u32 client_index;
  u32 context;
  u32 fwd_entry_index;
};

manual_endian manual_print define gpe_fwd_entry_path_details
{
  u32 context;
  vl_api_gpe_locator_t lcl_loc;
  vl_api_gpe_locator_t rmt_loc;
};

/** \brief Set GPE encapsulation mode
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param mode - LISP (value 0) or VXLAN (value 1)
*/
autoreply define gpe_set_encap_mode
{
  u32 client_index;
  u32 context;
  u8 mode;
};

/** \brief get GPE encapsulation mode
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param mode - LISP (value 0) or VXLAN (value 1)
*/
define gpe_get_encap_mode
{
  u32 client_index;
  u32 context;
};

/** \brief Reply for set_encap_mode
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param encap_mode - GPE encapsulation mode
*/
define gpe_get_encap_mode_reply
{
  u32 context;
  i32 retval;
  u8 encap_mode;
};

/** \brief Add native fwd rpath
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param is_add - flag to indicate add or del
    @param table_id - table id for route path
    @param nh_sw_if_index - next-hop sw_if_index (~0 if not set)
    @param is_ip4 - flag to indicate if nh is ip4
    @param nh_addr - next hop ip address
*/
autoreply define gpe_add_del_native_fwd_rpath
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u32 table_id;
  u32 nh_sw_if_index;
  u8 is_ip4;
  u8 nh_addr[16];
};

/** \brief get GPE native fwd rpath
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
*/
define gpe_native_fwd_rpaths_get
{
  u32 client_index;
  u32 context;
  u8 is_ip4;
};

/** \brief Reply for get native fwd rpath
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param table_id - table id for route path
    @param nh_sw_if_index - next-hop sw_if_index (~0 if not set)
    @param nh_addr - next hop address
*/
typeonly manual_print manual_endian define gpe_native_fwd_rpath
{
  u32 fib_index;
  u32 nh_sw_if_index;
  u8 is_ip4;
  u8 nh_addr[16];
};

manual_print manual_endian define gpe_native_fwd_rpaths_get_reply
{
  u32 context;
  i32 retval;
  u32 count;
  vl_api_gpe_native_fwd_rpath_t entries[count];
};

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