summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip4_format.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-03-16 01:25:27 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2018-05-10 15:45:03 +0000
commita35cc14d37466f0737fa928d25697fbfe6e7d657 (patch)
tree7242bb0bc9feebc35a2b1ab56986bc2a7ddb0ceb /src/vnet/ip/ip4_format.c
parentcd330c878dfdb9f52b372007a5086138b12d89f7 (diff)
vnet: device flow offload infra
Change-Id: Ibea4a96bdec5e368301a03d8b11a0712fa0265e0 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/ip/ip4_format.c')
-rw-r--r--src/vnet/ip/ip4_format.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/vnet/ip/ip4_format.c b/src/vnet/ip/ip4_format.c
index 3f2221022c7..0a2d7d293d5 100644
--- a/src/vnet/ip/ip4_format.c
+++ b/src/vnet/ip/ip4_format.c
@@ -56,6 +56,21 @@ format_ip4_address_and_length (u8 * s, va_list * args)
return format (s, "%U/%d", format_ip4_address, a, l);
}
+u8 *
+format_ip4_address_and_mask (u8 * s, va_list * args)
+{
+ ip4_address_and_mask_t *am = va_arg (*args, ip4_address_and_mask_t *);
+
+ if (am->addr.as_u32 == 0 && am->mask.as_u32 == 0)
+ return format (s, "any");
+
+ if (am->mask.as_u32 == ~0)
+ return format (s, "%U", format_ip4_address, &am->addr);
+
+ return format (s, "%U/%U", format_ip4_address, &am->addr,
+ format_ip4_address, &am->mask);
+}
+
/* Parse an IP4 address %d.%d.%d.%d. */
uword
unformat_ip4_address (unformat_input_t * input, va_list * args)
@@ -77,6 +92,27 @@ unformat_ip4_address (unformat_input_t * input, va_list * args)
return 1;
}
+uword
+unformat_ip4_address_and_mask (unformat_input_t * input, va_list * args)
+{
+ ip4_address_and_mask_t *am = va_arg (*args, ip4_address_and_mask_t *);
+ u32 addr = 0, mask = 0;
+
+ if (unformat (input, "any"))
+ ;
+ else if (unformat (input, "%U/%U", unformat_ip4_address, &addr,
+ unformat_ip4_address, &mask))
+ ;
+ else if (unformat (input, "%U", unformat_ip4_address, &addr))
+ mask = ~0;
+ else
+ return 0;
+
+ am->addr.as_u32 = addr;
+ am->mask.as_u32 = mask;
+ return 1;
+}
+
/* Format an IP4 header. */
u8 *
format_ip4_header (u8 * s, va_list * args)