diff options
author | Jakub Grajciar <jgrajcia@cisco.com> | 2020-02-26 11:01:43 +0100 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2020-02-26 12:45:11 +0000 |
commit | 23a386b71b287bc95000a8980856c5dbe7cdaf5a (patch) | |
tree | 0125b67cacdf2c15ceaae7c3fde0b3f0d9ca90e3 /src/vat/api_format.c | |
parent | d26b8607c9f9a4385bf7af0a01b1a42efaed5053 (diff) |
vat: add ip api types parser definitions
build vat with src/vnet/ip/ip_types_api.c
Type: fix
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Change-Id: Iab0f18bf7a89cf9512beab0629bc3a349edec383
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'src/vat/api_format.c')
-rw-r--r-- | src/vat/api_format.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c index 2cb459b3868..57211855331 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -264,6 +264,26 @@ unformat_ethernet_type_host_byte_order (unformat_input_t * input, return 0; } +/* Parse an IP46 address. */ +uword +unformat_ip46_address (unformat_input_t * input, va_list * args) +{ + ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); + ip46_type_t type = va_arg (*args, ip46_type_t); + if ((type != IP46_TYPE_IP6) && + unformat (input, "%U", unformat_ip4_address, &ip46->ip4)) + { + ip46_address_mask_ip4 (ip46); + return 1; + } + else if ((type != IP46_TYPE_IP4) && + unformat (input, "%U", unformat_ip6_address, &ip46->ip6)) + { + return 1; + } + return 0; +} + /* Parse an IP6 address. */ uword unformat_ip6_address (unformat_input_t * input, va_list * args) @@ -759,6 +779,16 @@ set_ip4_address (vl_api_address_t * a, u32 v) } } +void +ip_set (ip46_address_t * dst, void *src, u8 is_ip4) +{ + if (is_ip4) + dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32; + else + clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src, + sizeof (ip6_address_t)); +} + static void increment_mac_address (u8 * mac) { |