aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vat/ip_types.c19
-rw-r--r--src/vnet/ip/ip_types.c19
2 files changed, 20 insertions, 18 deletions
diff --git a/src/vat/ip_types.c b/src/vat/ip_types.c
index cdfcbc07de3..abcd2eaf648 100644
--- a/src/vat/ip_types.c
+++ b/src/vat/ip_types.c
@@ -41,16 +41,17 @@ uword
unformat_ip_address (unformat_input_t * input, va_list * args)
{
ip_address_t *a = va_arg (*args, ip_address_t *);
+ ip_address_t tmp, *p_tmp = &tmp;
- if (unformat_user (input, unformat_ip46_address, &ip_addr_46 (a),
- IP46_TYPE_ANY))
- {
- ip_addr_version (a) =
- ip46_address_is_ip4 (&ip_addr_46 (a)) ? AF_IP4 : AF_IP6;
- return 1;
- }
-
- return 0;
+ clib_memset (p_tmp, 0, sizeof (*p_tmp));
+ if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (p_tmp)))
+ ip_addr_version (p_tmp) = AF_IP4;
+ else if (unformat_user (input, unformat_ip6_address, &ip_addr_v6 (p_tmp)))
+ ip_addr_version (p_tmp) = AF_IP6;
+ else
+ return 0;
+ *a = *p_tmp;
+ return 1;
}
u8 *
diff --git a/src/vnet/ip/ip_types.c b/src/vnet/ip/ip_types.c
index 88b3f7b9820..ec80a96f15c 100644
--- a/src/vnet/ip/ip_types.c
+++ b/src/vnet/ip/ip_types.c
@@ -41,16 +41,17 @@ uword
unformat_ip_address (unformat_input_t * input, va_list * args)
{
ip_address_t *a = va_arg (*args, ip_address_t *);
+ ip_address_t tmp, *p_tmp = &tmp;
- if (unformat_user (input, unformat_ip46_address, &ip_addr_46 (a),
- IP46_TYPE_ANY))
- {
- ip_addr_version (a) =
- ip46_address_is_ip4 (&ip_addr_46 (a)) ? AF_IP4 : AF_IP6;
- return 1;
- }
-
- return 0;
+ clib_memset (p_tmp, 0, sizeof (*p_tmp));
+ if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (p_tmp)))
+ ip_addr_version (p_tmp) = AF_IP4;
+ else if (unformat_user (input, unformat_ip6_address, &ip_addr_v6 (p_tmp)))
+ ip_addr_version (p_tmp) = AF_IP6;
+ else
+ return 0;
+ *a = *p_tmp;
+ return 1;
}
u8 *