X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvat%2Fapi_format.c;h=4b2602d0f3f8e278f0b5ce7bc493641c72e11944;hb=2df39094d20ae60d2e04316f4ec058f81778cf64;hp=c9c62c76e2cbb95dbbc95296c423910cd9e8f16a;hpb=f953dfc8e01426ce93588e9013c112e48a9a8463;p=vpp.git diff --git a/src/vat/api_format.c b/src/vat/api_format.c index c9c62c76e2c..4b2602d0f3f 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -7810,10 +7810,16 @@ api_tap_create_v2 (vat_main_t * vam) vl_api_tap_create_v2_t *mp; u8 mac_address[6]; u8 random_mac = 1; - u8 name_set = 0; - u8 *tap_name; - u8 *net_ns = 0; - u8 net_ns_set = 0; + u32 id = ~0; + u8 *host_if_name = 0; + u8 *host_ns = 0; + u8 host_mac_addr[6]; + u8 host_mac_addr_set = 0; + u8 *host_bridge = 0; + ip4_address_t host_ip4_addr; + u32 host_ip4_prefix_len = 0; + ip6_address_t host_ip6_addr; + u32 host_ip6_prefix_len = 0; int ret; int rx_ring_sz = 0, tx_ring_sz = 0; @@ -7826,10 +7832,23 @@ api_tap_create_v2 (vat_main_t * vam) { random_mac = 0; } - else if (unformat (i, "name %s", &tap_name)) - name_set = 1; - else if (unformat (i, "host-ns %s", &net_ns)) - net_ns_set = 1; + else if (unformat (i, "id %s", &id)) + ; + else if (unformat (i, "host-if-name %s", &host_if_name)) + ; + else if (unformat (i, "host-ns %s", &host_ns)) + ; + else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address, + host_mac_addr)) + host_mac_addr_set = 1; + else if (unformat (i, "host-bridge %s", &host_bridge)) + ; + else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address, + &host_ip4_addr, &host_ip4_prefix_len)) + ; + else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address, + &host_ip6_addr, &host_ip6_prefix_len)) + ; else if (unformat (i, "rx-ring-size %d", &rx_ring_sz)) ; else if (unformat (i, "tx-ring-size %d", &tx_ring_sz)) @@ -7838,19 +7857,29 @@ api_tap_create_v2 (vat_main_t * vam) break; } - if (name_set == 0) + if (vec_len (host_if_name) > 63) { - errmsg ("missing tap name. "); + errmsg ("tap name too long. "); return -99; } - if (vec_len (tap_name) > 63) + if (vec_len (host_ns) > 63) { - errmsg ("tap name too long. "); + errmsg ("host name space too long. "); return -99; } - if (vec_len (net_ns) > 63) + if (vec_len (host_bridge) > 63) { - errmsg ("host name space too long. "); + errmsg ("host bridge name too long. "); + return -99; + } + if (host_ip4_prefix_len > 32) + { + errmsg ("host ip4 prefix length not valid. "); + return -99; + } + if (host_ip6_prefix_len > 128) + { + errmsg ("host ip6 prefix length not valid. "); return -99; } if (!is_pow2 (rx_ring_sz)) @@ -7874,21 +7903,38 @@ api_tap_create_v2 (vat_main_t * vam) return -99; } - vec_add1 (tap_name, 0); - /* Construct the API message */ M (TAP_CREATE_V2, mp); mp->use_random_mac = random_mac; - clib_memcpy (mp->mac_address, mac_address, 6); - clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name)); - mp->net_ns_set = net_ns_set; + + mp->id = id; + mp->host_namespace_set = host_ns != 0; + mp->host_bridge_set = host_bridge != 0; + mp->host_ip4_addr_set = host_ip4_prefix_len != 0; + mp->host_ip6_addr_set = host_ip6_prefix_len != 0; mp->rx_ring_sz = rx_ring_sz; mp->tx_ring_sz = tx_ring_sz; - if (net_ns) - clib_memcpy (mp->net_ns, net_ns, vec_len (net_ns)); - vec_free (tap_name); + if (random_mac) + clib_memcpy (mp->mac_address, mac_address, 6); + if (host_mac_addr_set) + clib_memcpy (mp->host_mac_addr, host_mac_addr, 6); + if (host_if_name) + clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name)); + if (host_ns) + clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns)); + if (host_bridge) + clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge)); + if (host_ip4_prefix_len) + clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4); + if (host_ip4_prefix_len) + clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16); + + + vec_free (host_ns); + vec_free (host_if_name); + vec_free (host_bridge); /* send it... */ S (mp);