summaryrefslogtreecommitdiffstats
path: root/vpp-api-test
diff options
context:
space:
mode:
authorAndrej Kozemcak <akozemca@cisco.com>2016-07-27 10:33:38 +0200
committerFlorin Coras <florin.coras@gmail.com>2016-07-27 13:23:24 +0000
commita8691754d2f7cdd960c3d8dc5fbff6367e9c36b8 (patch)
treeb1715a03db89657278630c21b6e4363a905e55e4 /vpp-api-test
parent683d3ee1b136060ef38290b6ab3a21c9a4730c4f (diff)
VAT add_locator_set api support multiple locators
Change-Id: I22df3d4407bd7fdd953783f00605380a2d6fb46e Signed-off-by: Andrej Kozemcak <akozemca@cisco.com>
Diffstat (limited to 'vpp-api-test')
-rw-r--r--vpp-api-test/vat/api_format.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c
index 3b2c91cf449..a2200660798 100644
--- a/vpp-api-test/vat/api_format.c
+++ b/vpp-api-test/vat/api_format.c
@@ -10488,6 +10488,14 @@ static int api_get_node_graph (vat_main_t * vam)
W;
}
+/** Used for transferring locators via VPP API */
+typedef CLIB_PACKED(struct
+{
+ u32 sw_if_index; /**< locator sw_if_index */
+ u8 priority; /**< locator priority */
+ u8 weight; /**< locator weight */
+}) ls_locator_t;
+
static int
api_lisp_add_del_locator_set(vat_main_t * vam)
{
@@ -10497,6 +10505,8 @@ api_lisp_add_del_locator_set(vat_main_t * vam)
u8 is_add = 1;
u8 *locator_set_name = NULL;
u8 locator_set_name_set = 0;
+ ls_locator_t locator, * locators = 0;
+ u32 sw_if_index, priority, weight;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
@@ -10504,18 +10514,32 @@ api_lisp_add_del_locator_set(vat_main_t * vam)
is_add = 0;
} else if (unformat(input, "locator-set %s", &locator_set_name)) {
locator_set_name_set = 1;
+ } else if (unformat(input, "sw_if_index %u p %u w %u",
+ &sw_if_index, &priority, &weight)) {
+ locator.sw_if_index = htonl(sw_if_index);
+ locator.priority = priority;
+ locator.weight = weight;
+ vec_add1(locators, locator);
+ } else if (unformat(input, "iface %U p %u w %u", unformat_sw_if_index,
+ vam, &sw_if_index, &priority, &weight)) {
+ locator.sw_if_index = htonl(sw_if_index);
+ locator.priority = priority;
+ locator.weight = weight;
+ vec_add1(locators, locator);
} else
break;
}
if (locator_set_name_set == 0) {
errmsg ("missing locator-set name");
+ vec_free(locators);
return -99;
}
if (vec_len(locator_set_name) > 64) {
errmsg ("locator-set name too long\n");
vec_free(locator_set_name);
+ vec_free(locators);
return -99;
}
vec_add1(locator_set_name, 0);
@@ -10528,6 +10552,11 @@ api_lisp_add_del_locator_set(vat_main_t * vam)
vec_len(locator_set_name));
vec_free(locator_set_name);
+ mp->locator_num = vec_len (locators);
+ clib_memcpy (mp->locators, locators,
+ (sizeof (ls_locator_t) * vec_len (locators)));
+ vec_free (locators);
+
/* send it... */
S;
@@ -13147,7 +13176,9 @@ _(trace_profile_add, "id <nn> trace-type <0x1f|0x3|0x9|0x11|0x19> " \
_(trace_profile_apply, "id <nn> <ip6-address>/<width>" \
" vrf_id <nn> add | pop | none") \
_(trace_profile_del, "") \
-_(lisp_add_del_locator_set, "locator-set <locator_name> [del]") \
+_(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
+ " sw_if_index <sw_if_index> p <priority> " \
+ "w <weight>] [del]") \
_(lisp_add_del_locator, "locator-set <locator_name> " \
"iface <intf> | sw_if_index <sw_if_index> " \
"p <priority> w <weight> [del]") \
ight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * 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.
 */
/**
 * @brief The BIER inline functions acting on the bier header
 */

#ifndef __BIER_HDR_INLINES_H__
#define __BIER_HDR_INLINES_H__

#include <vppinfra/byte_order.h>
#include <vppinfra/string.h>

#include <vnet/bier/bier_types.h>
#include <vnet/bier/bier_bit_string.h>
#include <vnet/ip/ip6_packet.h>

/**
 * Special Value of the BIER RX interface
 */
#define BIER_RX_ITF (~0 - 1)

/**
 * Mask and shift values for the fields incorporated
 * into the header's first word
 */
#define BIER_HDR_1ST_NIBBLE_MASK    0xf0000000
#define BIER_HDR_VERSION_FIELD_MASK 0x0f000000
#define BIER_HDR_LEN_FIELD_MASK     0x00f00000
#define BIER_HDR_ENTROPY_FIELD_MASK 0x000fffff

#define BIER_HDR_1ST_NIBBLE_SHIFT    28
#define BIER_HDR_VERSION_FIELD_SHIFT 24
#define BIER_HDR_LEN_FIELD_SHIFT     20
#define BIER_HDR_ENTROPY_FIELD_SHIFT  0

#define BIER_HDR_1ST_NIBBLE_VALUE 0x5

/**
 * Mask and shift values for fields in the headers training word
 */
#define BIER_HDR_PROTO_FIELD_MASK   0x003f
#define BIER_HDR_OAM_FIELD_MASK     0xc000
#define BIER_HDR_DSCP_FIELD_MASK    0x0fc0
#define BIER_HDR_DSCP_FIELD_SHIFT   6
#define BIER_HDR_PROTO_FIELD_SHIFT  0
#define BIER_HDR_OAM_FIELD_SHIFT    14

static inline bier_hdr_version_t
bier_hdr_get_version (const bier_hdr_t *bier_hdr)
{
    return ((bier_hdr->bh_first_word &
             BIER_HDR_VERSION_FIELD_MASK) >>
            BIER_HDR_VERSION_FIELD_SHIFT);
}

static inline bier_hdr_len_id_t
bier_hdr_get_len_id (const bier_hdr_t *bier_hdr)
{
    return ((bier_hdr->bh_first_word &
             BIER_HDR_LEN_FIELD_MASK) >>
            BIER_HDR_LEN_FIELD_SHIFT);
}

static inline bier_hdr_entropy_t
bier_hdr_get_entropy (const bier_hdr_t *bier_hdr)
{
    return ((bier_hdr->bh_first_word &
             BIER_HDR_ENTROPY_FIELD_MASK) >>
            BIER_HDR_ENTROPY_FIELD_SHIFT);
}

static inline void
bier_hdr_1st_nibble (bier_hdr_t *hdr)
{
    hdr->bh_first_word &= ~(BIER_HDR_1ST_NIBBLE_MASK);
    hdr->bh_first_word |= (BIER_HDR_1ST_NIBBLE_VALUE <<
                           BIER_HDR_1ST_NIBBLE_SHIFT);
}

static inline u8
bier_hdr_get_1st_nibble (bier_hdr_t *hdr)
{
    return ((hdr->bh_first_word & BIER_HDR_1ST_NIBBLE_MASK) >>
            BIER_HDR_1ST_NIBBLE_SHIFT);
}

static inline void
bier_hdr_set_version (bier_hdr_t *hdr,
                      bier_hdr_version_t version)
{
    hdr->bh_first_word &= ~(BIER_HDR_VERSION_FIELD_MASK);
    hdr->bh_first_word |= (version << BIER_HDR_VERSION_FIELD_SHIFT);
}

static inline void
bier_hdr_set_len_id (bier_hdr_t *hdr,
                     bier_hdr_len_id_t len)
{
    hdr->bh_first_word &= ~(BIER_HDR_LEN_FIELD_MASK);
    hdr->bh_first_word |= (len << BIER_HDR_LEN_FIELD_SHIFT);
}

static inline void
bier_hdr_set_entropy (bier_hdr_t *hdr,
                      bier_hdr_entropy_t entropy)
{
    entropy = entropy & BIER_HDR_ENTROPY_FIELD_MASK;
    hdr->bh_first_word &= ~(BIER_HDR_ENTROPY_FIELD_MASK);
    hdr->bh_first_word |= (entropy << BIER_HDR_ENTROPY_FIELD_SHIFT);
}

#define BIER_HDR_FIRST_WORD(version, len, entropy)          \
    ((BIER_HDR_1ST_NIBBLE_VALUE <<                          \
      BIER_HDR_1ST_NIBBLE_SHIFT) |                          \
     (version << BIER_HDR_VERSION_FIELD_SHIFT) |            \
     (len     << BIER_HDR_LEN_FIELD_SHIFT)     |            \
     ((entropy & BIER_HDR_ENTROPY_FIELD_MASK)               \
      << BIER_HDR_ENTROPY_FIELD_SHIFT))

static inline void
bier_hdr_ntoh (bier_hdr_t *bier_hdr)
{
    bier_hdr->bh_first_word = clib_net_to_host_u32(bier_hdr->bh_first_word);
    bier_hdr->bh_oam_dscp_proto = clib_net_to_host_u16(bier_hdr->bh_oam_dscp_proto);
    bier_hdr->bh_bfr_id = clib_net_to_host_u16(bier_hdr->bh_bfr_id);
}

static inline void
bier_hdr_hton (bier_hdr_t *bier_hdr)
{
    bier_hdr->bh_first_word = clib_host_to_net_u32(bier_hdr->bh_first_word);
    bier_hdr->bh_oam_dscp_proto = clib_host_to_net_u16(bier_hdr->bh_oam_dscp_proto);
    bier_hdr->bh_bfr_id = clib_host_to_net_u16(bier_hdr->bh_bfr_id);
}

static inline bier_hdr_src_id_t
bier_hdr_get_src_id (const bier_hdr_t *bier_hdr)
{
    return (bier_hdr->bh_bfr_id);
}

static inline void
bier_hdr_set_src_id (bier_hdr_t *bier_hdr,
                     bier_hdr_src_id_t src_id)
{
    bier_hdr->bh_bfr_id = src_id;
}
static inline void
bier_hdr_set_proto_id (bier_hdr_t *bier_hdr,
                       bier_hdr_proto_id_t proto)
{
    bier_hdr->bh_oam_dscp_proto &= ~(BIER_HDR_PROTO_FIELD_MASK);
    bier_hdr->bh_oam_dscp_proto |= (proto << BIER_HDR_PROTO_FIELD_SHIFT);
}

static inline bier_hdr_proto_id_t
bier_hdr_get_proto_id (const bier_hdr_t *bier_hdr)
{
    return ((bier_hdr->bh_oam_dscp_proto & BIER_HDR_PROTO_FIELD_MASK) >>
            BIER_HDR_PROTO_FIELD_SHIFT);
}

static inline void
bier_hdr_clear (bier_hdr_t *bier_hdr)
{
    clib_memset(&bier_hdr->bh_bit_string, 0,
           bier_hdr_len_id_to_num_buckets(
               bier_hdr_get_len_id(bier_hdr)));
}

static inline void
bier_hdr_init (bier_hdr_t *bier_hdr,
               bier_hdr_version_t version,
               bier_hdr_proto_id_t proto,
               bier_hdr_len_id_t len,
               bier_hdr_entropy_t entropy,
               bier_bp_t src)
{
    bier_hdr_1st_nibble(bier_hdr);
    bier_hdr_set_version(bier_hdr, version);
    bier_hdr_set_len_id(bier_hdr, len);
    bier_hdr_set_entropy(bier_hdr, entropy);
    bier_hdr_set_proto_id(bier_hdr, proto);
    bier_hdr_set_src_id(bier_hdr, src);
    bier_hdr_clear(bier_hdr);
}

static inline size_t
bier_hdr_str_num_bytes (const bier_hdr_t *bier_hdr)
{
    return (bier_hdr_len_id_to_num_bytes(
                bier_hdr_get_len_id(bier_hdr)));
}

static inline size_t
bier_hdr_num_bytes (const bier_hdr_t *bier_hdr)
{
    return (sizeof(bier_hdr_t) +
            bier_hdr_str_num_bytes(bier_hdr));
}

static inline void
bier_bit_string_init_from_hdr (bier_hdr_t *bier_hdr,
                               bier_bit_string_t *bit_string)
{
    bit_string->bbs_len = bier_hdr_str_num_bytes(bier_hdr);
    bit_string->bbs_buckets = bier_hdr->bh_bit_string;
}

#endif