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

/** \brief add or delete lisp 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 loc_num - number of locators
    @param lcl_locs - array of local locators
    @param rmt_locs - array of remote locators
    @param action - negative action when 0 locators configured
*/
define lisp_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;
  u32 loc_num;
  u8 lcl_locs[loc_num];
  u8 rmt_locs[loc_num];
  u8 action;
};

/** \brief Reply for gpe_fwd_entry add/del
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
*/
define lisp_gpe_add_del_fwd_entry_reply
{
  u32 context;
  i32 retval;
};

/** \brief enable or disable lisp-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
*/
define lisp_gpe_enable_disable
{
  u32 client_index;
  u32 context;
  u8 is_en;
};

/** \brief Reply for gpe enable/disable
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
*/
define lisp_gpe_enable_disable_reply
{
  u32 context;
  i32 retval;
};

/** \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
*/
define lisp_gpe_add_del_iface
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 is_l2;
  u32 dp_table;
  u32 vni;
};

/** \brief Reply for gpe_iface add/del
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
*/
define lisp_gpe_add_del_iface_reply
{
  u32 context;
  i32 retval;
};

define lisp_gpe_tunnel_details
{
  u32 context;
  u32 tunnels;
  u8 is_ipv6;
  u8 source_ip[16];
  u8 destination_ip[16];
  u32 encap_fib_id;
  u32 decap_fib_id;
  u32 dcap_next;
  u8 lisp_ver;
  u8 next_protocol;
  u8 flags;
  u8 ver_res;
  u8 res;
  u32 iid;
};

/** \brief Request for gpe tunnel summary status
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
 */
define lisp_gpe_tunnel_dump
{
  u32 client_index;
  u32 context;
};

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