/*
 * Copyright (c) 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.
 */

/** \file

    This file defines vpp BIER control-plane API messages which are generally
    called through a shared memory interface.
*/
vl_api_version 1.0.0

/** \brief BIER Table Indentifier
    @param bt_set - The BIER set
    @param bt_sub_domain - the sud-domain
    @param bt_bit_header_length - the number of bits in the header length
*/
typeonly define bier_table_id
{
  u8 bt_set;
  u8 bt_sub_domain;
  u8 bt_hdr_len_id;
};

/** \brief BIER Table Add / del route
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bt_tbl_id - The BIER table-id the route is added in
    @param bt_label - The MPLS label for the table (0 or all ones means not set)
                      If the label is not set, then it is assumed that non-MPLS
		      encoding is used.
    @param bt_is_add - Is this a route add or delete
*/
autoreply define bier_table_add_del
{
  u32 client_index;
  u32 context;
  vl_api_bier_table_id_t bt_tbl_id;
  u32 bt_label;
  u8 bt_is_add;
};

define bier_table_dump
{
  u32 client_index;
  u32 context;
};

define bier_table_details
{
  u32 context;
  u32 bt_label;
  vl_api_bier_table_id_t bt_tbl_id;
};

/** \brief FIB path
    @param sw_if_index - index of the interface
    @param weight - The weight, for UCMP
    @param preference - The preference of the path. lowest preference is prefered
    @param is_local - local if non-zero, else remote
    @param is_drop - Drop the packet
    @param is_udp_encap - The path describes a UDP-o-IP encapsulation.
    @param afi - the afi of the next hop, IP46_TYPE_IP4=1, IP46_TYPE_IP6=2
    @param next_hop[16] - the next hop address
    @param next_hop_id - Used when the path resolves via an object that has a unique
                         identifier. e.g. the UDP encap object

    WARNING: this type is replicated, pending cleanup completion
*/
typeonly define fib_path3
{
  u32 sw_if_index;
  u32 table_id;
  u8 weight;
  u8 preference;
  u8 is_local;
  u8 is_drop;
  u8 is_udp_encap;
  u8 afi;
  u8 next_hop[16];
  u32 next_hop_id;
  u32 rpf_id;
  u8 n_labels;
  u32 label_stack[16];
};

/** \brief BIER Route Add / del route
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param br_bp - The Bit-position value
    @param br_tbl_id - The BIER table-id the route is added in
    @param br_is_add - Is this a route add or delete
    @param br_is_replace - Are the paths specfied replacing those already
                           present or are they to be combined.
    @param br_n_paths - The number of paths
    @param br_paths - The array of paths
*/
autoreply define bier_route_add_del
{
  u32 client_index;
  u32 context;
  u32 br_bp;
  u8 br_is_add;
  u8 br_is_replace;
  vl_api_bier_table_id_t br_tbl_id;
  u8 br_n_paths;
  vl_api_fib_path3_t br_paths[br_n_paths];
};

define bier_route_dump
{
  u32 client_index;
  u32 context;
  vl_api_bier_table_id_t br_tbl_id;
};

define bier_route_details
{
  u32 client_index;
  u32 context;
  u16 br_bp;
  vl_api_bier_table_id_t br_tbl_id;
  u32 br_n_paths;
  vl_api_fib_path3_t br_paths[br_n_paths];
};

/** \brief BIER Imposition Add
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bi_tbl_id - The BIER table-id used to forward post encap
    @param bi_src - The source Bit-position in the encap.
    @param bi_n_bytes - The number of bytes in the following bit-string
    @param bi_bytes - The bit-string represented as a byte array (MSB first)
*/
define bier_imp_add
{
  u32 client_index;
  u32 context;
  vl_api_bier_table_id_t bi_tbl_id;
  u16 bi_src;
  u8 bi_n_bytes;
  u8 bi_bytes[bi_n_bytes];
};

/** \brief Reply for BIER route add / del request
    @param context - returned sender context, to match reply w/ request
    @param retval - return code
    @param bi_index - The index of the created imposition object.
*/
define bier_imp_add_reply
{
  u32 context;
  i32 retval;
  u32 bi_index;
};

/** \brief BIER Imposition Del
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bi_index - The index of the imposition object (as returned
		      from the ADD)
*/
autoreply define bier_imp_del
{
  u32 client_index;
  u32 context;
  u32 bi_index;
};

define bier_imp_dump
{
  u32 client_index;
  u32 context;
};

define bier_imp_details
{
  u32 client_index;
  u32 context;
  vl_api_bier_table_id_t bi_tbl_id;
  u16 bi_src;
  u8 bi_n_bytes;
  u8 bi_bytes[bi_n_bytes];
};

/** \brief BIER Disposition Table Add / del route
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bt_tbl_id - The BIER Disposition table-id.
*/
autoreply define bier_disp_table_add_del
{
  u32 client_index;
  u32 context;
  u32 bdt_tbl_id;
  u8 bdt_is_add;
};

define bier_disp_table_dump
{
  u32 client_index;
  u32 context;
};

define bier_disp_table_details
{
  u32 context;
  u32 bdt_tbl_id;
};

/** \brief BIER Disposition Entry Add / del
    @param client_index - opaque cookie to identify the sender
    @param context - sender context, to match reply w/ request
    @param bde_bp - The Bit-position value for the entry, i.e. the sender's
                    Use 0 for the default (match any source) entry.
    @param bde_tbl_id - The BIER dispositiontable-id the route is added in
    @param bde_next_hop_sw_if_index - the nextop interface
    @param bde_is_add - Is this a route add or delete
    @param bde_payload_proto - The payload protocol for which the next-hop
			       is added
    @param bde_paths - The outgoing paths for the entry
*/
autoreply define bier_disp_entry_add_del
{
  u32 client_index;
  u32 context;
  u16 bde_bp;
  u32 bde_tbl_id;
  u8 bde_is_add;
  u8 bde_payload_proto;
  u8 bde_n_paths;
  vl_api_fib_path3_t bde_paths[bde_n_paths];
};

define bier_disp_entry_dump
{
  u32 client_index;
  u32 context;
  u32 bde_tbl_id;
};

define bier_disp_entry_details
{
  u32 context;
  u16 bde_bp;
  u32 bde_tbl_id;
  u8 bde_is_add;
  u8 bde_payload_proto;
  u8 bde_n_paths;
  vl_api_fib_path3_t bde_paths[bde_n_paths];
};

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