DHCP client option 61 "client_id"
[vpp.git] / src / vnet / dhcp / client.c
index 7c3f7f6..25ab317 100644 (file)
@@ -194,7 +194,7 @@ int dhcp_client_for_us (u32 bi, vlib_buffer_t * b,
       /* OK, we own the address (etc), add to the routing table(s) */
       if (c->state == DHCP_REQUEST)
         {
-          void (*fp)(u32, u32, u8 *, u8, u8 *, u8 *, u8 *) = c->event_callback;
+          void (*fp)(u32, u32, u8 *, u8, u8, u8 *, u8 *, u8 *) = c->event_callback;
 
           dhcp_client_acquire_address (dcm, c);
 
@@ -236,6 +236,7 @@ int dhcp_client_for_us (u32 bi, vlib_buffer_t * b,
             (*fp) (c->client_index,  /* clinet index */
                    c->pid,
                    c->hostname,
+                   c->subnet_mask_width,
                    0, /* is_ipv6 */
                    (u8 *)&c->leased_address,  /* host IP address */
                    (u8 *)&c->router_address,  /* router IP address */
@@ -413,6 +414,16 @@ send_dhcp_pkt (dhcp_client_main_t * dcm, dhcp_client_t * c,
       o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
     }
 
+  /* send option 61, client_id */
+  if (vec_len (c->client_identifier))
+    {
+      o->option = 61;
+      o->length = vec_len (c->client_identifier);
+      clib_memcpy (o->data, c->client_identifier,
+                   vec_len (c->client_identifier));
+      o = (dhcp_option_t *) (((uword) o) + (o->length + 2));
+    }
+
   /* $$ maybe send the client s/w version if anyone cares */
 
   /* 
@@ -820,6 +831,7 @@ int dhcp_client_add_del (dhcp_client_add_del_args_t * a)
                                      1,
                                      FIB_ROUTE_PATH_FLAG_NONE);
       }
+      dhcp_client_release_address (dcm, c);
       ip4_sw_interface_enable_disable (c->sw_if_index, 0);
 
       vec_free (c->option_55_data);
@@ -836,6 +848,7 @@ int
 dhcp_client_config (vlib_main_t * vm,
                     u32 sw_if_index,
                     u8 * hostname,
+                    u8 * client_id,
                     u32 is_add,
                     u32 client_index,
                     void * event_callback,
@@ -852,7 +865,9 @@ dhcp_client_config (vlib_main_t * vm,
   a->event_callback = event_callback;
   vec_validate(a->hostname, strlen((char *)hostname) - 1);
   strncpy((char *)a->hostname, (char *)hostname, vec_len(a->hostname));
-  a->client_identifier = format (0, "vpe 1.0%c", 0);
+  vec_validate(a->client_identifier, strlen((char *)client_id) - 1);
+  strncpy((char *)a->client_identifier, (char *)client_id, vec_len(a->client_identifier));
+
   /* 
    * Option 55 request list. These data precisely match
    * the Ubuntu dhcp client. YMMV.