diff options
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/dhcp/client.c | 28 | ||||
-rw-r--r-- | src/vnet/dhcp/client.h | 1 | ||||
-rw-r--r-- | src/vnet/dhcp/dhcp.api | 10 | ||||
-rw-r--r-- | src/vnet/dhcp/dhcp_api.c | 13 |
4 files changed, 45 insertions, 7 deletions
diff --git a/src/vnet/dhcp/client.c b/src/vnet/dhcp/client.c index aac3ad3eab6..1d5352194ba 100644 --- a/src/vnet/dhcp/client.c +++ b/src/vnet/dhcp/client.c @@ -248,7 +248,14 @@ dhcp_client_for_us (u32 bi, vlib_buffer_t * b, c->router_address.as_u32 = router_address; } break; - + case 6: /* domain server address */ + { + vec_free (c->domain_server_address); + vec_validate (c->domain_server_address, + o->length / sizeof (ip4_address_t) - 1); + clib_memcpy (c->domain_server_address, o->data, o->length); + } + break; case 12: /* hostname */ { /* Replace the existing hostname if necessary */ @@ -315,6 +322,7 @@ dhcp_client_for_us (u32 bi, vlib_buffer_t * b, c->router_address.as_u32 = 0; c->lease_renewal_interval = 0; c->dhcp_server.as_u32 = 0; + vec_free (c->domain_server_address); break; } @@ -814,17 +822,26 @@ format_dhcp_client (u8 * s, va_list * va) dhcp_client_main_t *dcm = va_arg (*va, dhcp_client_main_t *); dhcp_client_t *c = va_arg (*va, dhcp_client_t *); int verbose = va_arg (*va, int); + ip4_address_t *addr; s = format (s, "[%d] %U state %U ", c - dcm->clients, format_vnet_sw_if_index_name, dcm->vnet_main, c->sw_if_index, format_dhcp_client_state, c->state); if (c->leased_address.as_u32) - s = format (s, "addr %U/%d gw %U\n", - format_ip4_address, &c->leased_address, - c->subnet_mask_width, format_ip4_address, &c->router_address); + { + s = format (s, "addr %U/%d gw %U\n", + format_ip4_address, &c->leased_address, + c->subnet_mask_width, format_ip4_address, + &c->router_address); + + vec_foreach (addr, c->domain_server_address) + s = format (s, "dns %U ", format_ip4_address, addr); + } else - s = format (s, "no address\n"); + { + s = format (s, "no address\n"); + } if (verbose) { @@ -962,6 +979,7 @@ dhcp_client_add_del (dhcp_client_add_del_args_t * a) } dhcp_client_release_address (dcm, c); + vec_free (c->domain_server_address); vec_free (c->option_55_data); vec_free (c->hostname); vec_free (c->client_identifier); diff --git a/src/vnet/dhcp/client.h b/src/vnet/dhcp/client.h index 72cbf66733f..2b5341d76ad 100644 --- a/src/vnet/dhcp/client.h +++ b/src/vnet/dhcp/client.h @@ -64,6 +64,7 @@ typedef struct dhcp_client_t_ ip4_address_t dhcp_server; u32 subnet_mask_width; /* option 1 */ ip4_address_t router_address; /* option 3 */ + ip4_address_t *domain_server_address; /* option 6 */ u32 lease_renewal_interval; /* option 51 */ u32 lease_lifetime; /* option 59 */ diff --git a/src/vnet/dhcp/dhcp.api b/src/vnet/dhcp/dhcp.api index ac1e68509e7..033c7a34fed 100644 --- a/src/vnet/dhcp/dhcp.api +++ b/src/vnet/dhcp/dhcp.api @@ -96,6 +96,14 @@ autoreply define dhcp_client_config vl_api_dhcp_client_t client; }; +/** \brief Struct representing domain server + @param address - IP address +*/ +typeonly manual_print manual_endian define domain_server +{ + u8 address[16]; +}; + /** \brief Data learned by the client during the DHCP process @param sw_if_index - the interface on which the client is configured @param state - the state of the lease (see dhcp_client_state_t) @@ -115,6 +123,8 @@ typeonly define dhcp_lease u8 host_address[16]; u8 router_address[16]; u8 host_mac[6]; + u8 count; + vl_api_domain_server_t domain_server[count]; }; /** \brief Tell client about a DHCP completion event diff --git a/src/vnet/dhcp/dhcp_api.c b/src/vnet/dhcp/dhcp_api.c index c96c3e1e085..d71ffe93c2d 100644 --- a/src/vnet/dhcp/dhcp_api.c +++ b/src/vnet/dhcp/dhcp_api.c @@ -218,6 +218,7 @@ dhcp_client_lease_encode (vl_api_dhcp_lease_t * lease, const dhcp_client_t * client) { size_t len; + u8 i; lease->is_ipv6 = 0; // only support IPv6 clients lease->sw_if_index = ntohl (client->sw_if_index); @@ -227,8 +228,16 @@ dhcp_client_lease_encode (vl_api_dhcp_lease_t * lease, lease->hostname[len] = 0; lease->mask_width = client->subnet_mask_width; - clib_memcpy (&lease->host_address[0], (u8 *) & client->leased_address, 4); - clib_memcpy (&lease->router_address[0], (u8 *) & client->router_address, 4); + clib_memcpy (&lease->host_address[0], (u8 *) & client->leased_address, + sizeof (ip4_address_t)); + clib_memcpy (&lease->router_address[0], (u8 *) & client->router_address, + sizeof (ip4_address_t)); + + lease->count = vec_len (client->domain_server_address); + for (i = 0; i < lease->count; i++) + clib_memcpy (&lease->domain_server[i].address, + (u8 *) & client->domain_server_address[i], + sizeof (ip4_address_t)); if (NULL != client->l2_rewrite) clib_memcpy (&lease->host_mac[0], client->l2_rewrite + 6, 6); |