dhcp ip: DSCP settings for transmitted DHCP packets
[vpp.git] / src / vnet / dhcp / dhcp6_pd_client_cp.c
index a2a0618..a157b16 100644 (file)
@@ -45,7 +45,6 @@ typedef struct
 {
   u32 prefix_group_index;
   uword opaque_data;           // used by prefix publisher
-  u32 TODO;
   ip6_address_t prefix;
   u8 prefix_length;
   u32 preferred_lt;
@@ -365,7 +364,7 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
   if (!client_state->rebinding && client_state->server_index != server_index)
     {
       clib_warning ("Reply message arrived with Server ID different "
-                   "from that in Request of Renew message");
+                   "from that in Request or Renew message");
       return 0;
     }
 
@@ -433,6 +432,8 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
          prefix_info->preferred_lt = preferred_time;
          prefix_info->valid_lt = valid_time;
          prefix_info->due_time = current_time + valid_time;
+         if (prefix_info->due_time > rm->max_valid_due_time)
+           rm->max_valid_due_time = prefix_info->due_time;
          continue;
        }
 
@@ -448,6 +449,8 @@ dhcp6_pd_reply_event_handler (vl_api_dhcp6_pd_reply_event_t * mp)
       prefix_info->preferred_lt = preferred_time;
       prefix_info->valid_lt = valid_time;
       prefix_info->due_time = current_time + valid_time;
+      if (prefix_info->due_time > rm->max_valid_due_time)
+       rm->max_valid_due_time = prefix_info->due_time;
       rm->client_state_by_sw_if_index[sw_if_index].prefix_count++;
 
       u32 prefix_index = prefix_info - pm->prefix_pool;
@@ -963,26 +966,33 @@ cp_ip6_address_add_del_command_function (vlib_main_t * vm,
   u32 prefix_length;
   u8 address_set = 0;
   u8 add = 1;
+  unformat_input_t _line_input, *line_input = &_line_input;
 
-  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+  if (!unformat_user (input, unformat_line_input, line_input))
+    return 0;
+
+  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
       if (unformat
-         (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
-      else if (unformat (input, "prefix group %s", &prefix_group));
+         (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
+      else if (unformat (line_input, "prefix group %s", &prefix_group));
       else
-       if (unformat
-           (input, "%U/%d", unformat_ip6_address, &address, &prefix_length))
+       if (unformat (line_input, "%U/%d", unformat_ip6_address,
+                     &address, &prefix_length))
        address_set = 1;
-      else if (unformat (input, "del"))
+      else if (unformat (line_input, "del"))
        add = 0;
       else
        {
          error = clib_error_return (0, "unexpected input `%U'",
-                                    format_unformat_error, input);
+                                    format_unformat_error, line_input);
+         unformat_free (line_input);
          goto done;
        }
     }
 
+  unformat_free (line_input);
+
   if (sw_if_index == ~0)
     error = clib_error_return (0, "Missing sw_if_index");
   else if (address_set == 0)
@@ -1254,7 +1264,7 @@ dhcp6_pd_client_enable_disable (u32 sw_if_index, const u8 * prefix_group,
 
       vec_free (prefix_list);
 
-      memset (client_state, 0, sizeof (*client_state));
+      clib_memset (client_state, 0, sizeof (*client_state));
     }
 
   return 0;
@@ -1272,19 +1282,23 @@ dhcp6_pd_client_enable_disable_command_fn (vlib_main_t *
   u8 *prefix_group = 0;
   u32 sw_if_index = ~0;
   u8 enable = 1;
+  unformat_input_t _line_input, *line_input = &_line_input;
+
+  if (!unformat_user (input, unformat_line_input, line_input))
+    return 0;
 
-  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
       if (unformat
-         (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
+         (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
        ;
-      else if (unformat (input, "prefix group %s", &prefix_group));
-      else if (unformat (input, "disable"))
+      else if (unformat (line_input, "prefix group %s", &prefix_group));
+      else if (unformat (line_input, "disable"))
        enable = 0;
       else
        {
          error = clib_error_return (0, "unexpected input `%U'",
-                                    format_unformat_error, input);
+                                    format_unformat_error, line_input);
          goto done;
        }
     }
@@ -1302,6 +1316,7 @@ dhcp6_pd_client_enable_disable_command_fn (vlib_main_t *
 
 done:
   vec_free (prefix_group);
+  unformat_free (line_input);
 
   return error;
 }