/*
 * 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.1.0";
import "vnet/fib/fib_types.api";

/** \brief Bind/Unbind an MPLS local label to an IP prefix. i.e. create
           a per-prefix label entry.
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param mb_mpls_table_id - The MPLS table-id the MPLS entry will be added in
    @param mb_label - The MPLS label value to bind
    @param mb_ip_table_id - The IP table-id of the IP prefix to bind to.
    @param mb_is_bind - Bind or unbind
    @param mb_is_ip4 - The prefix to bind to is IPv4
    @param mb_address_length - Length of IP prefix
    @param mb_address[16] - IP prefix/
*/
autoreply define mpls_ip_bind_unbind
{
  u32 client_index;
  u32 context;
  u32 mb_mpls_table_id;
  u32 mb_label;
  u32 mb_ip_table_id;
  u8 mb_is_bind;
  u8 mb_is_ip4;
  u8 mb_address_length;
  u8 mb_address[16];
};

define mpls_tunnel_add_del
{
  u32 client_index;
  u32 context;
  u32 mt_sw_if_index;
  u8 mt_is_add;
  u8 mt_l2_only;
  u8 mt_is_multicast;
  u8 mt_next_hop_proto_is_ip4;
  u8 mt_next_hop_weight;
  u8 mt_next_hop_preference;
  u8 mt_next_hop[16];
  u8 mt_next_hop_n_out_labels;
  u32 mt_next_hop_via_label;
  u32 mt_next_hop_sw_if_index;
  u32 mt_next_hop_table_id;
  vl_api_fib_mpls_label_t mt_next_hop_out_label_stack[mt_next_hop_n_out_labels];
};

/** \brief Reply for MPLS tunnel add / del request
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param sw_if_index - SW interface index of the tunnel created
*/
define mpls_tunnel_add_del_reply
{
  u32 context;
  i32 retval;
  u32 sw_if_index;
  u32 tunnel_index;
};

/** \brief Dump mpls eth tunnel table
    @param client_index - opaque cookie to identify the sender
    @param sw_if_index - sw_if_index of the MPLS tunnel
                         (as returned from the create)
*/
define mpls_tunnel_dump
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
};

/** \brief mpls tunnel details
*/
manual_endian manual_print define mpls_tunnel_details
{
  u32 context;
  u32 mt_sw_if_index;
  u32 mt_tunnel_index;
  u8 mt_l2_only;
  u8 mt_is_multicast;
  u32 mt_count;
  vl_api_fib_path_t mt_paths[mt_count];
};

/** \brief MPLS Route Add / del route
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param mt_table_id - The MPLS table-id the route is added in
    @param mt_is_add - Is this a route add or delete
    @param mt_name - A client provided name/tag for the table. If this
                     is not set by the client, then VPP will generate
		     something meaningfull.
*/
autoreply define mpls_table_add_del
{
  u32 client_index;
  u32 context;
  u32 mt_table_id;
  u8  mt_is_add;
  u8  mt_name[64];
};

/** \brief MPLS Route Add / del route
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param mr_label - The MPLS label value
    @param mr_eos - The End of stack bit
    @param mr_table_id - The MPLS table-id the route is added in
    @param mr_classify_table_index - If this is a classify route, 
                                     this is the classify table index
                                        create them
    @param mr_is_add - Is this a route add or delete
    @param mr_is_classify - Is this route result a classify
    @param mr_is_multicast - Is this a multicast route
    @param mr_is_multipath - Is this route update a multipath - i.e. is this
                             a path addition to an existing route
    @param mr_is_resolve_host - Recurse resolution constraint via a host prefix
    @param mr_is_resolve_attached - Recurse resolution constraint via attached prefix
    @param mr_is_interface_rx - Interface Receive path
    @param mr_is_interface_rx - RPF-ID Receive path. The next-hop interface
                                is used as the RPF-ID
    @param mr_next_hop_proto - The next-hop protocol, of type dpo_proto_t
    @param mr_next_hop_weight - The weight, for UCMP
    @param mr_next_hop[16] - the nextop address
    @param mr_next_hop_sw_if_index - the next-hop SW interface
    @param mr_next_hop_table_id - the next-hop table-id (if appropriate)
    @param mr_next_hop_n_out_labels - the number of labels in the label stack
    @param mr_next_hop_out_label_stack - the next-hop output label stack, outer most first
    @param next_hop_via_label - The next-hop is a resolved via a local label
*/
define mpls_route_add_del
{
  u32 client_index;
  u32 context;
  u32 mr_label;
  u8 mr_eos;
  u32 mr_table_id;
  u32 mr_classify_table_index;
  u8 mr_is_add;
  u8 mr_is_classify;
  u8 mr_is_multicast;
  u8 mr_is_multipath;
  u8 mr_is_resolve_host;
  u8 mr_is_resolve_attached;
  u8 mr_is_interface_rx;
  u8 mr_is_rpf_id;
  u8 mr_next_hop_proto;
  u8 mr_next_hop_weight;
  u8 mr_next_hop_preference;
  u8 mr_next_hop[16];
  u8 mr_next_hop_n_out_labels;
  u32 mr_next_hop_sw_if_index;
  u32 mr_next_hop_table_id;
  u32 mr_next_hop_via_label;
  vl_api_fib_mpls_label_t mr_next_hop_out_label_stack[mr_next_hop_n_out_labels];
};

define mpls_route_add_del_reply
{
  u32 context;
  i32 retval;
  u32 stats_index;
};

/** \brief Dump MPLS fib table
    @param client_index - opaque cookie to identify the sender
*/
define mpls_fib_dump
{
  u32 client_index;
  u32 context;
};

/** \brief mpls FIB table response
    @param table_id - MPLS fib table id
    @param s_bit - End-of-stack bit
    @param label - MPLS label value
    @param count - the number of fib_path in path
    @param path  - array of of fib_path structures
*/
manual_endian manual_print define mpls_fib_details
{
  u32 context;
  u32 table_id;
  u8  table_name[64];
  u8  eos_bit;
  u32 label;
  u32 count;
  vl_api_fib_path_t path[count];
};

/** \brief Enable or Disable MPLS on and interface
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param sw_if_index - index of the interface
    @param enable - if non-zero enable, else disable
*/
autoreply define sw_interface_set_mpls_enable
{
  u32 client_index;
  u32 context;
  u32 sw_if_index;
  u8 enable;
};

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