/*
 * 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.
*/
option version = "1.1.0";
import "vnet/fib/fib_types.api";

/** \brief BIER Table Identifier
    @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 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 specified replacing those already
                           present or are they to be combined.
			   is_replace = 1 and n_paths=0 implies delete the
			   route and all paths;
    @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_path_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 context;
  u16 br_bp;
  vl_api_bier_table_id_t br_tbl_id;
  u32 br_n_paths;
  vl_api_fib_path_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.
                        VPP only supports BSL of 1024 and less, so this is
			a u8 field.
    @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 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 disposition table-id the route is added in
    @param bde_next_hop_sw_if_index - the next hop 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_path_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_path_t bde_paths[bde_n_paths];
};

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