/*
 * 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 IPv6 segment routing tunnel add / del request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - add the tunnel if non-zero, else delete it
    @param name[] - tunnel name (len. 64)
    @param src_address[] -
    @param dst_address[] -
    @param dst_mask_width -
    @param inner_vrf_id -
    @param outer_vrf_id -
    @param flags_net_byte_order -
    @param n_segments -
    @param n_tags -
    @param segs_and_tags[] -
    @param policy_name[] - name of policy to associate this tunnel to (len. 64)
*/
define sr_tunnel_add_del
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 name[64];
  u8 src_address[16];
  u8 dst_address[16];
  u8 dst_mask_width;
  u32 inner_vrf_id;
  u32 outer_vrf_id;
  u16 flags_net_byte_order;
  u8 n_segments;
  u8 n_tags;
  u8 policy_name[64];
  u8 segs_and_tags[0];
};

/** \brief IPv6 segment routing tunnel add / del response
    @param context - sender context, to match reply w/ request
    @param retval - return value for request
*/
define sr_tunnel_add_del_reply
{
  u32 context;
  i32 retval;
};

/** \brief IPv6 segment routing policy add / del request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - add the tunnel if non-zero, else delete it
    @param name[] - policy name (len. 64)
    @param tunnel_names[] -
*/
define sr_policy_add_del
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 name[64];
  u8 tunnel_names[0];
};

/** \brief IPv6 segment routing policy add / del response
    @param context - sender context, to match reply w/ request
    @param retval - return value for request 
 
    
*/
define sr_policy_add_del_reply
{
  u32 context;
  i32 retval;
};

/** \brief IPv6 segment routing multicast map to policy add / del request
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param is_add - add the tunnel if non-zero, else delete it
    @param multicast_address[] - IP6 multicast address
    @param policy_name[] = policy name (len.64)
*/
define sr_multicast_map_add_del
{
  u32 client_index;
  u32 context;
  u8 is_add;
  u8 multicast_address[16];
  u8 policy_name[64];
};

/** \brief IPv6 segment routing multicast map to policy add / del response
    @param context - sender context, to match reply w/ request
    @param retval - return value for request
*/
define sr_multicast_map_add_del_reply
{
  u32 context;
  i32 retval;
};

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