/*
 * 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";
import "vnet/ip/ip_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;
  vl_api_prefix_t mb_prefix;
};

typedef mpls_tunnel
{
  u32 mt_sw_if_index;
  u32 mt_tunnel_index;
  u8 mt_l2_only;
  u8 mt_is_multicast;
  u8 mt_n_paths;
  vl_api_fib_path_t mt_paths[mt_n_paths];
};
define mpls_tunnel_add_del
{
  u32 client_index;
  u32 context;
  u8 mt_is_add;
  vl_api_mpls_tunnel_t mt_tunnel;
};

/** \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;
  vl_api_mpls_tunnel_t mt_tunnel;
};

/** \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.
*/
typedef mpls_table
{
  u32 mt_table_id;
  u8  mt_name[64];
};
autoreply define mpls_table_add_del
{
  u32 client_index;
  u32 context;
  u8  mt_is_add;
  vl_api_mpls_table_t mt_table;
};

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

define mpls_table_details
{
  u32 context;
  vl_api_mpls_table_t mt_table;
};

/** \brief MPLS Route
    @param mr_label - The MPLS label value
    @param mr_eos - The End of stack bit
    @param mr_eos_proto - If EOS then this is the DPO packect's proto post pop
    @param mr_table_id - The MPLS table-id the route is added in
    @param mr_is_add - Is this a route add or delete
    @param mr_is_multicast - Is this a multicast route
    @param mr_n_paths - The number of paths
    @param mr_paths - The paths
*/
typedef mpls_route
{
  u32 mr_table_id;
  u32 mr_label;
  u8 mr_eos;
  u8 mr_eos_proto;
  u8 mr_is_multicast;
  u8 mr_n_paths;
  vl_api_fib_path_t mr_paths[mr_n_paths];
};

/** \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_table_id - The MPLS table-id the route is added in
    @param mr_is_add - Is this a route add or delete
    @param mr_is_multipath - Is this route update a multipath - i.e. is this
                             a path addition to an existing route
    @param mr_route - The Route
*/
define mpls_route_add_del
{
  u32 client_index;
  u32 context;
  u8 mr_is_add;
  u8 mr_is_multipath;
  vl_api_mpls_route_t mr_route;
};

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_route_dump
{
  u32 client_index;
  u32 context;
  vl_api_mpls_table_t table;
};

/** \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_route_details
{
  u32 context;
  vl_api_mpls_route_t mr_route;
};

/** \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:
 */
 
