/*
 * Copyright (c) 2017 SUSE LLC.
 * 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";

define geneve_add_del_tunnel
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 is_ipv6;
  u8 local_address[16];
  u8 remote_address[16];
  u32 mcast_sw_if_index;
  u32 encap_vrf_id;
  u32 decap_next_index;
  u32 vni;
};

define geneve_add_del_tunnel_reply
{
  u32 context;
  i32 retval;
  u32 sw_if_index;
};

define geneve_tunnel_dump
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
};

define geneve_tunnel_details
{
  u32 context;
  u32 sw_if_index;
  u8 src_address[16];
  u8 dst_address[16];
  u32 mcast_sw_if_index;
  u32 encap_vrf_id;
  u32 decap_next_index;
  u32 vni;
  u8 is_ipv6;
};

/** \brief Interface set geneve-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-geneve-bypass, else ipv4-geneve-bypass
    @param enable - if non-zero enable, else disable
*/
autoreply define sw_interface_set_geneve_bypass
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u8 is_ipv6;
  u8 enable;
};
