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

import "vnet/interface_types.api";
import "vnet/ip/ip_types.api";

define vxlan_gpe_add_del_tunnel
{
  u32 client_index;
  u32 context;
  vl_api_address_t local;
  vl_api_address_t remote;
  vl_api_interface_index_t mcast_sw_if_index;
  u32 encap_vrf_id;
  u32 decap_vrf_id;
  vl_api_ip_proto_t protocol;
  u32 vni;
  bool is_add [default=true];
};

define vxlan_gpe_add_del_tunnel_reply
{
  u32 context;
  i32 retval;
  vl_api_interface_index_t sw_if_index;
};

define vxlan_gpe_tunnel_dump
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
};

define vxlan_gpe_tunnel_details
{
  u32 context;
  vl_api_interface_index_t sw_if_index;
  vl_api_address_t local;
  vl_api_address_t remote;
  u32 vni;
  vl_api_ip_proto_t protocol;
  vl_api_interface_index_t mcast_sw_if_index;
  u32 encap_vrf_id;
  u32 decap_vrf_id;
  bool is_ipv6;
};

/** \brief Interface set vxlan-gpe-bypass request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - interface used to reach neighbor
    @param is_ipv6 - if non-zero, enable ipv6-vxlan-bypass, else ipv4-vxlan-bypass
    @param enable - if non-zero enable, else disable
*/
autoreply define sw_interface_set_vxlan_gpe_bypass
{
  u32 client_index;
  u32 context;
  vl_api_interface_index_t sw_if_index;
  bool is_ipv6;
  bool enable [default=true];
};

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