diff options
author | 2016-07-19 15:27:58 +0200 | |
---|---|---|
committer | 2016-07-21 13:34:56 +0000 | |
commit | 03c4f99105ad2fe072c3696ba6412fe4fb70a8ae (patch) | |
tree | 282762058437c4e39d4443f14b6c6c5b583942ac /vnet/vnet/lisp-cp | |
parent | 404ca6e1c483b87b1bba5b4ff4f3b24de8e6c31a (diff) |
Fix CLI for adding LISP fwd entries
Change-Id: Ib707d252e624e3c1c4ac261fd3cef17b097633e5
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'vnet/vnet/lisp-cp')
-rw-r--r-- | vnet/vnet/lisp-cp/lisp_types.c | 57 | ||||
-rw-r--r-- | vnet/vnet/lisp-cp/lisp_types.h | 3 |
2 files changed, 46 insertions, 14 deletions
diff --git a/vnet/vnet/lisp-cp/lisp_types.c b/vnet/vnet/lisp-cp/lisp_types.c index 62900ec795c..c1c959c55a1 100644 --- a/vnet/vnet/lisp-cp/lisp_types.c +++ b/vnet/vnet/lisp-cp/lisp_types.c @@ -198,25 +198,54 @@ unformat_gid_address (unformat_input_t * input, va_list * args) ip_prefix_t ippref; memset (&ippref, 0, sizeof (ippref)); - memset (a, 0, sizeof (a[0])); + memset(a, 0, sizeof(a[0])); - while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) + if (unformat (input, "%U", unformat_ip_prefix, &ippref)) { - if (unformat (input, "%U", unformat_ip_prefix, &ippref)) - { - clib_memcpy (&gid_address_ippref(a), &ippref, sizeof (ippref)); - gid_address_type(a) = GID_ADDR_IP_PREFIX; - } - else if (unformat (input, "%U", unformat_mac_address, mac)) + clib_memcpy (&gid_address_ippref(a), &ippref, sizeof(ippref)); + gid_address_type(a) = GID_ADDR_IP_PREFIX; + } + else if (unformat (input, "%U", unformat_mac_address, mac)) + { + clib_memcpy (gid_address_mac(a), mac, sizeof(mac)); + gid_address_type(a) = GID_ADDR_MAC; + } + else if (unformat (input, "[%d]", &vni)) + gid_address_vni(a) = vni; + else + return 0; + + return 1; +} + +uword +unformat_negative_mapping_action (unformat_input_t * input, va_list * args) +{ + u32 * action = va_arg(*args, u32 *); + u8 * s = 0; + + if (unformat (input, "%s", &s)) + { + int len = vec_len(s); + clib_warning ("len = %d", len); + if (!strcmp ((char *) s, "no-action")) + action[0] = ACTION_NONE; + if (!strcmp ((char *) s, "natively-forward")) + action[0] = ACTION_NATIVELY_FORWARDED; + if (!strcmp ((char *) s, "send-map-request")) + action[0] = ACTION_SEND_MAP_REQUEST; + else if (!strcmp ((char *) s, "drop")) + action[0] = ACTION_DROP; + else { - clib_memcpy (gid_address_mac(a), mac, sizeof (mac)); - gid_address_type(a) = GID_ADDR_MAC; + clib_warning("invalid action: '%s'", s); + action[0] = ACTION_DROP; + return 0; } - else if (unformat (input, "[%d]", &vni)) - gid_address_vni(a) = vni; - else - return 0; } + else + return 0; + return 1; } diff --git a/vnet/vnet/lisp-cp/lisp_types.h b/vnet/vnet/lisp-cp/lisp_types.h index f7225908dd6..ef86f71bdf3 100644 --- a/vnet/vnet/lisp-cp/lisp_types.h +++ b/vnet/vnet/lisp-cp/lisp_types.h @@ -244,4 +244,7 @@ typedef struct u8 local; } mapping_t; +uword +unformat_negative_mapping_action (unformat_input_t * input, va_list * args); + #endif /* VNET_LISP_GPE_LISP_TYPES_H_ */ |