aboutsummaryrefslogtreecommitdiffstats
path: root/src/vat
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-01-14 10:30:50 -0500
committerDave Barach <dave@barachs.net>2017-01-14 10:36:37 -0500
commit2feaffcb4af8e311b56328015bcfd82f5b15626c (patch)
tree59cdebbb5c0a4d3c41b8bea8c69a2328b97182f6 /src/vat
parent878c609889dcdc58538d40d8b3f662320f88573d (diff)
Provision linux stack ip4 and ip6 addresses for tap interfaces
To simplify system configuration. Converted existing code to use an argument structure, instead of [one or two too many] discrete parameters. Change-Id: I3eddfa74eeed918c1b04a6285fba494651594332 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vat')
-rw-r--r--src/vat/api_format.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 176fe836..1babaf40 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -5790,6 +5790,12 @@ api_tap_connect (vat_main_t * vam)
u8 name_set = 0;
u8 *tap_name;
u8 *tag = 0;
+ ip4_address_t ip4_address;
+ u32 ip4_mask_width;
+ int ip4_address_set = 0;
+ ip6_address_t ip6_address;
+ u32 ip6_mask_width;
+ int ip6_address_set = 0;
memset (mac_address, 0, sizeof (mac_address));
@@ -5806,6 +5812,12 @@ api_tap_connect (vat_main_t * vam)
name_set = 1;
else if (unformat (i, "tag %s", &tag))
;
+ else if (unformat (i, "address %U/%d",
+ unformat_ip4_address, &ip4_address, &ip4_mask_width))
+ ip4_address_set = 1;
+ else if (unformat (i, "address %U/%d",
+ unformat_ip6_address, &ip6_address, &ip6_mask_width))
+ ip6_address_set = 1;
else
break;
}
@@ -5837,6 +5849,19 @@ api_tap_connect (vat_main_t * vam)
if (tag)
clib_memcpy (mp->tag, tag, vec_len (tag));
+ if (ip4_address_set)
+ {
+ mp->ip4_address_set = 1;
+ clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
+ mp->ip4_mask_width = ip4_mask_width;
+ }
+ if (ip6_address_set)
+ {
+ mp->ip6_address_set = 1;
+ clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
+ mp->ip6_mask_width = ip6_mask_width;
+ }
+
vec_free (tap_name);
vec_free (tag);