FD.io VPP  v18.10-34-gcce845e
Vector Packet Processing
dhcp6_pd_client_cp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/vnet.h>
17 #include <vlibmemory/api.h>
18 #include <vnet/vnet_msg_enum.h>
19 #include <vnet/dhcp/dhcp6_packet.h>
21 #include <vnet/ip/ip.h>
22 #include <vnet/ip/ip6.h>
23 #include <float.h>
24 #include <math.h>
25 #include <string.h>
26 
27 #define vl_typedefs /* define message structures */
28 #include <vnet/vnet_all_api_h.h>
29 #undef vl_typedefs
30 
31 #define vl_endianfun /* define message structures */
32 #include <vnet/vnet_all_api_h.h>
33 #undef vl_endianfun
34 
36 
37 #define foreach_dhcp6_pd_client_cp_msg \
38 _(DHCP6_PD_CLIENT_ENABLE_DISABLE, dhcp6_pd_client_enable_disable) \
39 _(IP6_ADD_DEL_ADDRESS_USING_PREFIX, ip6_add_del_address_using_prefix)
40 
41 #define vl_api_dhcp6_pd_client_enable_disable_t_print vl_noop_handler
42 #define vl_api_ip6_add_del_address_using_prefix_t_print vl_noop_handler
43 
44 typedef struct
45 {
47  uword opaque_data; // used by prefix publisher
54 
55 typedef struct
56 {
57  u8 enabled;
59  u32 server_index;
60  u32 T1;
61  u32 T2;
62  f64 T1_due_time;
63  f64 T2_due_time;
65  u8 rebinding;
67 
68 typedef struct
69 {
74 
75  /* convenience */
81 
83 
84 typedef struct
85 {
89 
91 
92 typedef struct
93 {
94  /* config */
99 
100  /* state */
103 
104 typedef struct
105 {
109 
111 
112 enum
113 {
116 };
117 
120 {
122 
123  if (prefix_group_index >=
125  return ~0;
126 
127  return apm->active_prefix_index_by_prefix_group_index[prefix_group_index];
128 }
129 
132  u32 prefix_index)
133 {
135  static const u32 empty = ~0;
136 
137  ASSERT (prefix_group_index != ~0);
138 
139  if (prefix_index == ~0
140  && prefix_group_index >=
142  return;
143 
145  prefix_group_index, empty);
146  apm->active_prefix_index_by_prefix_group_index[prefix_group_index] =
147  prefix_index;
148 }
149 
152 {
155  u32 prefix_index;
156 
157  prefix_index = prefix_info - pm->prefix_pool;
158  return clib_bitmap_get (rm->prefix_ownership_bitmap, prefix_index);
159 }
160 
163 {
166  u32 prefix_index;
167 
168  prefix_index = prefix_info - pm->prefix_pool;
170  clib_bitmap_set (rm->prefix_ownership_bitmap, prefix_index, value);
171 }
172 
173 static void
174 cp_ip6_address_prefix_add_del_handler (u32 prefix_index, u8 is_add);
175 
176 static void
177 notify_prefix_add_del (u32 prefix_index, u8 is_add)
178 {
179  // TODO: use registries
180  cp_ip6_address_prefix_add_del_handler (prefix_index, is_add);
181 }
182 
183 static void
185  u8 msg_type, prefix_info_t * prefix_list,
186  u8 start)
187 {
191  u32 i;
192 
193  ASSERT (sw_if_index < vec_len (rm->client_state_by_sw_if_index) &&
194  rm->client_state_by_sw_if_index[sw_if_index].enabled);
195  client_state_t *client_state =
197 
198  params.sw_if_index = sw_if_index;
199  params.server_index = server_index;
200  params.msg_type = msg_type;
201  if (start)
202  {
203  if (msg_type == DHCPV6_MSG_SOLICIT)
204  {
205  params.irt = 1;
206  params.mrt = 120;
207  }
208  else if (msg_type == DHCPV6_MSG_REQUEST)
209  {
210  params.irt = 1;
211  params.mrt = 30;
212  params.mrc = 10;
213  }
214  else if (msg_type == DHCPV6_MSG_RENEW)
215  {
216  params.irt = 10;
217  params.mrt = 600;
218  f64 current_time = vlib_time_now (rm->vlib_main);
219  i32 diff_time = client_state->T2 - current_time;
220  if (diff_time < 0)
221  diff_time = 0;
222  params.mrd = diff_time;
223  }
224  else if (msg_type == DHCPV6_MSG_REBIND)
225  {
226  params.irt = 10;
227  params.mrt = 600;
228  f64 current_time = vlib_time_now (rm->vlib_main);
229  i32 diff_time = rm->max_valid_due_time - current_time;
230  if (diff_time < 0)
231  diff_time = 0;
232  params.mrd = diff_time;
233  }
234  else if (msg_type == DHCPV6_MSG_RELEASE)
235  {
236  params.mrc = 1;
237  }
238  }
239 
240  params.T1 = 0;
241  params.T2 = 0;
242  if (vec_len (prefix_list) != 0)
243  vec_validate (prefixes, vec_len (prefix_list) - 1);
244  for (i = 0; i < vec_len (prefix_list); i++)
245  {
246  prefix_info_t *prefix = &prefix_list[i];
247  pref = &prefixes[i];
248  pref->valid_lt = prefix->valid_lt;
249  pref->preferred_lt = prefix->preferred_lt;
250  pref->prefix = prefix->prefix;
251  pref->prefix_length = prefix->prefix_length;
252  }
253  params.prefixes = prefixes;
254 
255  dhcp6_pd_send_client_message (rm->vlib_main, sw_if_index, !start, &params);
256 
257  vec_free (params.prefixes);
258 }
259 
260 static void interrupt_process (void);
261 
262 static u32
264 {
266  clib_error_t *rv;
267 
268  rv = enable_ip6_interface (rm->vlib_main, sw_if_index);
269 
270  return rv != 0;
271 }
272 
273 static u8
275 {
276  if (len >= 64)
277  {
278  if (prefix1->as_u64[0] != prefix2->as_u64[0])
279  return 0;
280  if (len == 64)
281  return 1;
282  return clib_net_to_host_u64 (prefix1->as_u64[1]) >> (128 - len) ==
283  clib_net_to_host_u64 (prefix2->as_u64[1]) >> (128 - len);
284  }
285  return clib_net_to_host_u64 (prefix1->as_u64[0]) >> (64 - len) ==
286  clib_net_to_host_u64 (prefix2->as_u64[0]) >> (64 - len);
287 }
288 
289 static clib_error_t *
291 {
294  vlib_main_t *vm = rm->vlib_main;
295  client_state_t *client_state;
298  u32 n_prefixes;
299  vl_api_dhcp6_pd_prefix_info_t *api_prefix;
300  u32 inner_status_code;
301  u32 status_code;
302  u32 server_index;
303  f64 current_time;
304  clib_error_t *error = 0;
305  u32 i;
306 
307  current_time = vlib_time_now (vm);
308 
309  sw_if_index = ntohl (mp->sw_if_index);
310 
311  if (sw_if_index >= vec_len (rm->client_state_by_sw_if_index))
312  return 0;
313 
314  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
315 
316  if (!client_state->enabled)
317  return 0;
318 
319  server_index = ntohl (mp->server_index);
320 
321  n_prefixes = ntohl (mp->n_prefixes);
322 
323  inner_status_code = ntohs (mp->inner_status_code);
324  status_code = ntohs (mp->status_code);
325 
326  if (mp->msg_type == DHCPV6_MSG_ADVERTISE
327  && client_state->server_index == ~0)
328  {
329  prefix_info_t *prefix_list = 0, *prefix_info;
330  u8 prefix_length;
331 
332  if (inner_status_code == DHCPV6_STATUS_NOPREFIX_AVAIL)
333  {
335  ("Advertise message arrived with NoPrefixAvail status code");
336  return 0;
337  }
338 
339  if (n_prefixes > 0)
340  vec_validate (prefix_list, n_prefixes - 1);
341  for (i = 0; i < n_prefixes; i++)
342  {
343  api_prefix = &mp->prefixes[i];
344  prefix = (ip6_address_t *) api_prefix->prefix;
345  prefix_length = api_prefix->prefix_length;
346 
347  prefix_info = &prefix_list[i];
348  prefix_info->prefix = *prefix;
349  prefix_info->prefix_length = prefix_length;
350  prefix_info->preferred_lt = 0;
351  prefix_info->valid_lt = 0;
352  }
353 
354  client_state->server_index = server_index;
355 
356  send_client_message_start_stop (sw_if_index, server_index,
357  DHCPV6_MSG_REQUEST, prefix_list, 1);
358  vec_free (prefix_list);
359  }
360 
361  if (mp->msg_type != DHCPV6_MSG_REPLY)
362  return 0;
363 
364  if (!client_state->rebinding && client_state->server_index != server_index)
365  {
366  clib_warning ("Reply message arrived with Server ID different "
367  "from that in Request or Renew message");
368  return 0;
369  }
370 
371  if (inner_status_code == DHCPV6_STATUS_NOPREFIX_AVAIL)
372  {
373  clib_warning ("Reply message arrived with NoPrefixAvail status code");
374  if (n_prefixes > 0)
375  {
377  ("Invalid Reply message arrived: It contains NoPrefixAvail "
378  "status code but also contains prefixes");
379  return 0;
380  }
381  }
382 
383  if (status_code == DHCPV6_STATUS_UNSPEC_FAIL)
384  {
385  clib_warning ("Reply message arrived with UnspecFail status code");
386  return 0;
387  }
388 
389  send_client_message_start_stop (sw_if_index, server_index,
390  mp->msg_type, 0, 0);
391 
392  for (i = 0; i < n_prefixes; i++)
393  {
394  prefix_info_t *prefix_info = 0;
395  u8 prefix_length;
396  u32 valid_time;
397  u32 preferred_time;
398 
399  api_prefix = &mp->prefixes[i];
400 
401  prefix = (ip6_address_t *) api_prefix->prefix;
402  prefix_length = api_prefix->prefix_length;
403 
405  continue;
406 
407  valid_time = ntohl (api_prefix->valid_time);
408  preferred_time = ntohl (api_prefix->preferred_time);
409  prefix_length = api_prefix->prefix_length;
410 
411  if (preferred_time > valid_time)
412  continue;
413 
414  u8 address_prefix_present = 0;
415  /* *INDENT-OFF* */
416  pool_foreach (prefix_info, pm->prefix_pool,
417  ({
418  if (is_dhcpv6_pd_prefix (prefix_info) &&
419  prefix_info->opaque_data == sw_if_index &&
420  prefix_info->prefix_length == prefix_length &&
421  ip6_prefixes_equal (&prefix_info->prefix, prefix, prefix_length))
422  {
423  address_prefix_present = 1;
424  goto prefix_pool_foreach_out;
425  }
426  }));
427  /* *INDENT-ON* */
428  prefix_pool_foreach_out:
429 
430  if (address_prefix_present)
431  {
432  prefix_info->preferred_lt = preferred_time;
433  prefix_info->valid_lt = valid_time;
434  prefix_info->due_time = current_time + valid_time;
435  if (prefix_info->due_time > rm->max_valid_due_time)
436  rm->max_valid_due_time = prefix_info->due_time;
437  continue;
438  }
439 
440  if (valid_time == 0)
441  continue;
442 
443  pool_get (pm->prefix_pool, prefix_info);
444  prefix_info->prefix_group_index = client_state->prefix_group_index;
445  set_is_dhcpv6_pd_prefix (prefix_info, 1);
446  prefix_info->opaque_data = sw_if_index;
447  prefix_info->prefix_length = prefix_length;
448  prefix_info->prefix = *prefix;
449  prefix_info->preferred_lt = preferred_time;
450  prefix_info->valid_lt = valid_time;
451  prefix_info->due_time = current_time + valid_time;
452  if (prefix_info->due_time > rm->max_valid_due_time)
453  rm->max_valid_due_time = prefix_info->due_time;
455 
456  u32 prefix_index = prefix_info - pm->prefix_pool;
457  notify_prefix_add_del (prefix_index, 1);
458  }
459 
460  client_state->server_index = server_index;
461  client_state->T1 = ntohl (mp->T1);
462  client_state->T2 = ntohl (mp->T2);
463  if (client_state->T1 != 0)
464  client_state->T1_due_time = current_time + client_state->T1;
465  if (client_state->T2 != 0)
466  client_state->T2_due_time = current_time + client_state->T2;
467  client_state->rebinding = 0;
468 
470 
471  return error;
472 }
473 
474 static prefix_info_t *
476 {
478  prefix_info_t *prefix_info, *prefix_list = 0;;
479 
480  /* *INDENT-OFF* */
481  pool_foreach (prefix_info, pm->prefix_pool,
482  ({
483  if (is_dhcpv6_pd_prefix (prefix_info) &&
484  prefix_info->opaque_data == sw_if_index)
485  {
486  u32 pos = vec_len (prefix_list);
487  vec_validate (prefix_list, pos);
488  clib_memcpy (&prefix_list[pos], prefix_info, sizeof (*prefix_info));
489  }
490  }));
491  /* *INDENT-ON* */
492 
493  return prefix_list;
494 }
495 
497 
498 static uword
500  vlib_frame_t * f)
501 {
504  prefix_info_t *prefix_info;
505  client_state_t *client_state;
506  f64 sleep_time = 1e9;
507  f64 current_time;
508  f64 due_time;
509  uword event_type;
510  uword *event_data = 0;
511  int i;
512 
513  while (1)
514  {
515  vlib_process_wait_for_event_or_clock (vm, sleep_time);
516  event_type = vlib_process_get_events (vm, &event_data);
517  vec_reset_length (event_data);
518 
519  if (event_type == DHCPV6_PD_EVENT_DISABLE)
520  {
521  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_DISABLED);
522  sleep_time = 1e9;
523  continue;
524  }
525 
526  current_time = vlib_time_now (vm);
527  do
528  {
529  due_time = current_time + 1e9;
530  /* *INDENT-OFF* */
531  pool_foreach (prefix_info, pm->prefix_pool,
532  ({
533  if (is_dhcpv6_pd_prefix (prefix_info))
534  {
535  if (prefix_info->due_time > current_time)
536  {
537  if (prefix_info->due_time < due_time)
538  due_time = prefix_info->due_time;
539  }
540  else
541  {
542  u32 prefix_index = prefix_info - pm->prefix_pool;
543  notify_prefix_add_del (prefix_index, 0);
544  u32 sw_if_index = prefix_info->opaque_data;
545  set_is_dhcpv6_pd_prefix (prefix_info, 0);
546  pool_put (pm->prefix_pool, prefix_info);
547  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
548  if (--client_state->prefix_count == 0)
549  {
550  client_state->rebinding = 0;
551  client_state->server_index = ~0;
552  send_client_message_start_stop (sw_if_index, ~0,
553  DHCPV6_MSG_SOLICIT,
554  0, 1);
555  }
556  }
557  }
558  }));
559  /* *INDENT-ON* */
560  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
561  {
563  if (cs->enabled && cs->server_index != ~0)
564  {
565  if (cs->T2_due_time > current_time)
566  {
567  if (cs->T2_due_time < due_time)
568  due_time = cs->T2_due_time;
569  if (cs->T1_due_time > current_time)
570  {
571  if (cs->T1_due_time < due_time)
572  due_time = cs->T1_due_time;
573  }
574  else
575  {
576  cs->T1_due_time = DBL_MAX;
577  prefix_info_t *prefix_list;
578  prefix_list = create_prefix_list (i);
581  prefix_list, 1);
582  vec_free (prefix_list);
583  }
584  }
585  else
586  {
587  cs->T2_due_time = DBL_MAX;
588  prefix_info_t *prefix_list;
589  prefix_list = create_prefix_list (i);
590  cs->rebinding = 1;
593  prefix_list, 1);
594  vec_free (prefix_list);
595  }
596  }
597  }
598  current_time = vlib_time_now (vm);
599  }
600  while (due_time < current_time);
601 
602  sleep_time = due_time - current_time;
603  }
604 
605  return 0;
606 }
607 
608 /* *INDENT-OFF* */
610  .function = dhcp6_pd_client_cp_process,
611  .type = VLIB_NODE_TYPE_PROCESS,
612  .name = "dhcp6-pd-client-cp-process",
613 };
614 /* *INDENT-ON* */
615 
616 static void
618 {
620  vlib_main_t *vm = rm->vlib_main;
621 
624 }
625 
626 static void
628 {
630  vlib_main_t *vm = rm->vlib_main;
631 
634 }
635 
636 static void
638 {
640  vlib_main_t *vm = rm->vlib_main;
641  vlib_node_t *node;
642 
643  node = vec_elt (vm->node_main.nodes, rm->node_index);
644 
645  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_POLLING);
646  vlib_start_process (vm, node->runtime_index);
647 }
648 
649 static u32
650 cp_ip6_construct_address (ip6_address_info_t * address_info, u32 prefix_index,
651  ip6_address_t * r_addr)
652 {
655  u64 mask, addr0, pref;
656 
657  addr0 = clib_net_to_host_u64 (address_info->address.as_u64[0]);
658  prefix = &pm->prefix_pool[prefix_index];
659  if (prefix->prefix_length > 64)
660  {
661  clib_warning ("Prefix length is bigger that 64 bits");
662  return 1;
663  }
664  mask = ((u64) 1 << (64 - prefix->prefix_length)) - 1;
665  addr0 &= mask;
666  pref = clib_host_to_net_u64 (prefix->prefix.as_u64[0]);
667  pref &= ~mask;
668  addr0 |= pref;
669  r_addr->as_u64[0] = clib_host_to_net_u64 (addr0);
670  r_addr->as_u64[1] = address_info->address.as_u64[1];
671 
672  return 0;
673 }
674 
675 static void
677 {
679  u32 prefix_index;
681  clib_error_t *error;
682 
683  if (address_info->prefix_group_index != ~0)
684  prefix_index =
686  (address_info->prefix_group_index);
687  else
688  prefix_index = ~0;
689 
690  if (is_add && !address_info->configured_in_data_plane)
691  {
692  if (prefix_index != ~0)
693  {
694  if (cp_ip6_construct_address (address_info, prefix_index, &addr) !=
695  0)
696  return;
697  error =
698  ip6_add_del_interface_address (vm, address_info->sw_if_index,
699  &addr, address_info->prefix_length,
700  0 /* add */ );
701  if (error)
702  clib_warning ("Failed adding IPv6 address: %U",
703  format_clib_error, error);
704  else
705  address_info->configured_in_data_plane = 1;
706  }
707  else
708  {
709  if (address_info->prefix_group_index == ~0)
710  {
711  error =
712  ip6_add_del_interface_address (vm, address_info->sw_if_index,
713  &address_info->address,
714  address_info->prefix_length,
715  0 /* add */ );
716  if (error)
717  clib_warning ("Failed adding IPv6 address: %U",
718  format_clib_error, error);
719  else
720  address_info->configured_in_data_plane = 1;
721  }
722  }
723  }
724  else if (!is_add && address_info->configured_in_data_plane)
725  {
726  if (prefix_index == ~0)
727  {
728  if (address_info->prefix_group_index == ~0)
729  {
730  error =
731  ip6_add_del_interface_address (vm, address_info->sw_if_index,
732  &address_info->address,
733  address_info->prefix_length,
734  1 /* del */ );
735  if (error)
736  clib_warning ("Failed deleting IPv6 address: %U",
737  format_clib_error, error);
738  address_info->configured_in_data_plane = 0;
739  }
740  else
741  clib_warning ("Deleting address with prefix "
742  "but active prefix index is not set");
743  }
744  else
745  {
746  if (cp_ip6_construct_address (address_info, prefix_index, &addr) !=
747  0)
748  return;
749  error =
750  ip6_add_del_interface_address (vm, address_info->sw_if_index,
751  &addr, address_info->prefix_length,
752  1 /* del */ );
753  if (error)
754  clib_warning ("Failed deleting IPv6 address: %U",
755  format_clib_error, error);
756  address_info->configured_in_data_plane = 0;
757  }
758  }
759 }
760 
761 static u32
763  u32 ignore_prefix_index)
764 {
766  prefix_info_t *prefix_info;
767 
768  /* *INDENT-OFF* */
769  pool_foreach (prefix_info, pm->prefix_pool,
770  ({
771  if (prefix_info->prefix_group_index == prefix_group_index &&
772  prefix_info - pm->prefix_pool != ignore_prefix_index)
773  return prefix_info - pm->prefix_pool;
774  }));
775  /* *INDENT-ON* */
776  return ~0;
777 }
778 
779 static void
781 {
784  ip6_address_info_t *address_info;
786  u32 new_prefix_index;
787  u32 prefix_group_index;
788  u32 i;
789 
790  prefix = &pm->prefix_pool[prefix_index];
791  prefix_group_index = prefix->prefix_group_index;
792 
793  if (is_add)
794  {
796  (prefix_group_index) == ~0)
797  {
799  (prefix_group_index, prefix_index);
800  for (i = 0; i < vec_len (apm->addresses); i++)
801  {
802  address_info = &apm->addresses[i];
803  if (address_info->prefix_group_index == prefix_group_index)
804  cp_ip6_address_add_del_now (address_info, 1 /* add */ );
805  }
806  }
807  }
808  else
809  {
811  (prefix_group_index) == prefix_index)
812  {
813  for (i = 0; i < vec_len (apm->addresses); i++)
814  {
815  address_info = &apm->addresses[i];
816  if (address_info->prefix_group_index == prefix_group_index)
817  cp_ip6_address_add_del_now (address_info, 0 /* del */ );
818  }
820  (prefix_group_index, ~0);
821  new_prefix_index =
822  cp_ip6_address_find_new_active_prefix (prefix_group_index,
823  prefix_index);
824  if (new_prefix_index != ~0)
825  {
827  (prefix_group_index, new_prefix_index);
828  for (i = 0; i < vec_len (apm->addresses); i++)
829  {
830  address_info = &apm->addresses[i];
831  if (address_info->prefix_group_index == prefix_group_index)
832  cp_ip6_address_add_del_now (address_info, 1 /* add */ );
833  }
834  }
835  }
836  }
837 }
838 
839 static u32
841 {
843  u32 free_index = ~0;
844  u8 *name_dup;
845  u32 i;
846 
847  for (i = 0; i < vec_len (pm->prefix_group_name_by_index); i++)
848  {
849  if (pm->prefix_group_name_by_index[i] == 0)
850  free_index = i;
851  else if (0 ==
852  strcmp ((const char *) pm->prefix_group_name_by_index[i],
853  (const char *) name))
854  return i;
855  }
856  if (!create)
857  return ~0;
858  name_dup = (u8 *) strdup ((const char *) name);
859  if (free_index != ~0)
860  {
861  pm->prefix_group_name_by_index[free_index] = name_dup;
862  return free_index;
863  }
864  else
865  {
866  vec_add1 (pm->prefix_group_name_by_index, name_dup);
867  return vec_len (pm->prefix_group_name_by_index) - 1;
868  }
869 }
870 
871 static int
872 cp_ip6_address_add_del (u32 sw_if_index, const u8 * prefix_group,
873  ip6_address_t address, u8 prefix_length, u8 is_add)
874 {
875 
877  vnet_main_t *vnm = vnet_get_main ();
878  ip6_address_info_t *address_info;
879  u32 prefix_group_index;
880  u32 n;
881 
882  if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
883  {
884  clib_warning ("Invalid sw_if_index");
885  return VNET_API_ERROR_INVALID_VALUE;
886  }
887 
888  if (prefix_group != 0 && prefix_group[0] != '\0')
889  {
890  if (strnlen ((const char *) prefix_group, 64) == 64)
891  return VNET_API_ERROR_INVALID_VALUE;
892 
893  prefix_group_index = prefix_group_find_or_create (prefix_group, 1);
894  }
895  else
896  prefix_group_index = ~0;
897 
898  n = vec_len (apm->addresses);
899 
900  vec_foreach (address_info, apm->addresses)
901  {
902  if (address_info->sw_if_index == sw_if_index &&
903  address_info->prefix_group_index == prefix_group_index &&
904  address_info->prefix_length == prefix_length &&
905  0 == memcmp (&address_info->address, &address, 16))
906  {
907  if (is_add)
908  return VNET_API_ERROR_DUPLICATE_IF_ADDRESS;
909  cp_ip6_address_add_del_now (address_info, 0 /* del */ );
910  *address_info = apm->addresses[n - 1];
911  _vec_len (apm->addresses) = n - 1;
912  return 0;
913  }
914  }
915 
916  if (!is_add)
917  return VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE;
918 
919  vec_validate (apm->addresses, n);
920  address_info = &apm->addresses[n];
921  address_info->sw_if_index = sw_if_index;
922  address_info->prefix_group_index = prefix_group_index;
923  address_info->address = address;
924  address_info->prefix_length = prefix_length;
925  cp_ip6_address_add_del_now (address_info, 1 /* add */ );
926 
927  return 0;
928 }
929 
930 static void
933 {
934  vl_api_ip6_add_del_address_using_prefix_reply_t *rmp;
937  u8 prefix_length;
938  int rv = 0;
939 
941 
942  sw_if_index = ntohl (mp->sw_if_index);
943 
944  memcpy (address.as_u8, mp->address, 16);
945  prefix_length = mp->prefix_length;
946 
947  rv =
948  cp_ip6_address_add_del (sw_if_index, mp->prefix_group, address,
949  prefix_length, mp->is_add);
950 
952 
953  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
954 }
955 
956 static clib_error_t *
958  unformat_input_t * input,
959  vlib_cli_command_t * cmd)
960 {
961  vnet_main_t *vnm = vnet_get_main ();
962  clib_error_t *error = 0;
963  u32 sw_if_index = ~0;
964  u8 *prefix_group = 0;
966  u32 prefix_length;
967  u8 address_set = 0;
968  u8 add = 1;
969 
971  {
972  if (unformat
973  (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index));
974  else if (unformat (input, "prefix group %s", &prefix_group));
975  else
976  if (unformat
977  (input, "%U/%d", unformat_ip6_address, &address, &prefix_length))
978  address_set = 1;
979  else if (unformat (input, "del"))
980  add = 0;
981  else
982  {
983  error = clib_error_return (0, "unexpected input `%U'",
984  format_unformat_error, input);
985  goto done;
986  }
987  }
988 
989  if (sw_if_index == ~0)
990  error = clib_error_return (0, "Missing sw_if_index");
991  else if (address_set == 0)
992  error = clib_error_return (0, "Missing address");
993  else
994  {
996  (sw_if_index, prefix_group, address, prefix_length, add) != 0)
997  error = clib_error_return (0, "Error adding or removing address");
998  }
999 
1000 done:
1001  return error;
1002 }
1003 
1004 /*?
1005  * This command is used to add/delete IPv6 address
1006  * potentially using available prefix from specified prefix group
1007  *
1008  * @cliexpar
1009  * @parblock
1010  * Example of how to add IPv6 address:
1011  * @cliexcmd{set ip6 address GigabitEthernet2/0/0
1012  * prefix group my-prefix-group ::7/64}
1013  * Example of how to delete IPv6 address:
1014  * @cliexcmd{set ip6 address GigabitEthernet2/0/0
1015  * prefix group my-prefix-group ::7/64 del}
1016  * @endparblock
1017 ?*/
1018 /* *INDENT-OFF* */
1020  .path = "set ip6 address",
1021  .short_help = "set ip6 address <interface> [prefix group <string>] "
1022  "<address> [del]",
1024 };
1025 /* *INDENT-ON* */
1026 
1027 static clib_error_t *
1029  unformat_input_t * input,
1030  vlib_cli_command_t * cmd)
1031 {
1034  ip6_address_info_t *address_info;
1035  const u8 *prefix_group;
1036  clib_error_t *error = 0;
1037  int i;
1038 
1039  for (i = 0; i < vec_len (apm->addresses); i++)
1040  {
1041  address_info = &apm->addresses[i];
1042  if (address_info->prefix_group_index == ~0)
1043  prefix_group = (const u8 *) "NONE";
1044  else
1045  prefix_group =
1047  vlib_cli_output (vm,
1048  "sw_if_index: %u, prefix_group: %s, address: %U/%d",
1049  address_info->sw_if_index, prefix_group,
1050  format_ip6_address, &address_info->address,
1051  address_info->prefix_length);
1052  }
1053 
1054  return error;
1055 }
1056 
1057 /* *INDENT-OFF* */
1059  .path = "show ip6 addresses",
1060  .short_help = "show ip6 addresses",
1062 };
1063 /* *INDENT-ON* */
1064 
1065 static clib_error_t *
1067  unformat_input_t * input,
1068  vlib_cli_command_t * cmd)
1069 {
1071  clib_error_t *error = 0;
1072  prefix_info_t *prefix_info;
1073  const u8 *prefix_group;
1074  f64 current_time = vlib_time_now (vm);
1075 
1076  /* *INDENT-OFF* */
1077  pool_foreach (prefix_info, pm->prefix_pool,
1078  ({
1079  prefix_group =
1080  pm->prefix_group_name_by_index[prefix_info->prefix_group_index];
1081  vlib_cli_output (vm, "opaque_data: %lu, prefix: %U/%d, prefix group: %s, "
1082  "preferred lifetime: %u, valid lifetime: %u "
1083  "(%f remaining)",
1084  prefix_info->opaque_data, format_ip6_address,
1085  &prefix_info->prefix, prefix_info->prefix_length,
1086  prefix_group,
1087  prefix_info->preferred_lt, prefix_info->valid_lt,
1088  prefix_info->due_time - current_time);
1089  }));
1090  /* *INDENT-ON* */
1091 
1092  return error;
1093 }
1094 
1095 /* *INDENT-OFF* */
1097  .path = "show ip6 prefixes",
1098  .short_help = "show ip6 prefixes",
1100 };
1101 /* *INDENT-ON* */
1102 
1103 static clib_error_t *
1105  unformat_input_t * input,
1106  vlib_cli_command_t * cmd)
1107 {
1110  clib_error_t *error = 0;
1111  client_state_t *cs;
1112  f64 current_time = vlib_time_now (vm);
1113  const u8 *prefix_group;
1114  char buf1[256];
1115  char buf2[256];
1116  const char *rebinding;
1117  u32 i;
1118 
1119  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
1120  {
1121  cs = &rm->client_state_by_sw_if_index[i];
1122  if (cs->enabled)
1123  {
1124  if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time)
1125  {
1126  sprintf (buf1, "%u remaining",
1127  (u32) round (cs->T1_due_time - current_time));
1128  }
1129  else
1130  sprintf (buf1, "timeout");
1131  if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time)
1132  sprintf (buf2, "%u remaining",
1133  (u32) round (cs->T2_due_time - current_time));
1134  else
1135  sprintf (buf2, "timeout");
1136  if (cs->rebinding)
1137  rebinding = ", REBINDING";
1138  else
1139  rebinding = "";
1140  prefix_group =
1142  if (cs->T1)
1143  vlib_cli_output (vm,
1144  "sw_if_index: %u, prefix group: %s, T1: %u (%s), "
1145  "T2: %u (%s), server index: %d%s", i,
1146  prefix_group, cs->T1, buf1, cs->T2, buf2,
1147  cs->server_index, rebinding);
1148  else
1149  vlib_cli_output (vm, "sw_if_index: %u, prefix group: %s%s", i,
1150  prefix_group, rebinding);
1151  }
1152  }
1153 
1154  return error;
1155 }
1156 
1157 /* *INDENT-OFF* */
1159  .path = "show ip6 pd clients",
1160  .short_help = "show ip6 pd clients",
1162 };
1163 /* *INDENT-ON* */
1164 
1165 static int
1167  u8 enable)
1168 {
1171  vnet_main_t *vnm = rm->vnet_main;
1172  client_state_t *client_state;
1173  static client_state_t empty_config = {
1174  0
1175  };
1176  prefix_info_t *prefix_info;
1177  prefix_info_t *prefix_list = 0;
1178  u32 prefix_group_index;
1179 
1180  if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
1181  {
1182  clib_warning ("Invalid sw_if_index");
1183  return VNET_API_ERROR_INVALID_VALUE;
1184  }
1185 
1187  empty_config);
1188  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
1189 
1190  u8 old_enabled = client_state->enabled;
1191 
1192  if (enable)
1193  {
1194  if (strnlen ((const char *) prefix_group, 64) == 64
1195  || prefix_group[0] == '\0')
1196  return VNET_API_ERROR_INVALID_VALUE;
1197  prefix_group_index =
1198  prefix_group_find_or_create (prefix_group, !old_enabled);
1199  if (old_enabled
1200  && prefix_group_index != client_state->prefix_group_index)
1201  return VNET_API_ERROR_INVALID_VALUE;
1202  }
1203 
1204  if (!old_enabled && enable)
1205  {
1206  client_state->enabled = 1;
1207  client_state->prefix_group_index = prefix_group_index;
1208  ASSERT (client_state->prefix_group_index != ~0);
1209  client_state->server_index = ~0;
1210 
1211  rm->n_clients++;
1212  if (rm->n_clients == 1)
1213  {
1214  enable_process ();
1216  }
1217 
1218  ip6_enable (sw_if_index);
1220  0, 1);
1221  }
1222  else if (old_enabled && !enable)
1223  {
1224  send_client_message_start_stop (sw_if_index, ~0, ~0, 0, 0);
1225 
1226  rm->n_clients--;
1227  if (rm->n_clients == 0)
1228  {
1230  disable_process ();
1231  }
1232 
1233  vec_validate (prefix_list, 0);
1234 
1235  /* *INDENT-OFF* */
1236  pool_foreach (prefix_info, pm->prefix_pool,
1237  ({
1238  if (is_dhcpv6_pd_prefix (prefix_info) &&
1239  prefix_info->opaque_data == sw_if_index)
1240  {
1241  ASSERT (sw_if_index < vec_len (rm->client_state_by_sw_if_index) &&
1242  rm->client_state_by_sw_if_index[sw_if_index].enabled);
1243  client_state_t *client_state =
1244  &rm->client_state_by_sw_if_index[sw_if_index];
1245  prefix_list[0] = *prefix_info;
1246  send_client_message_start_stop (sw_if_index,
1247  client_state->server_index,
1248  DHCPV6_MSG_RELEASE, prefix_list,
1249  1);
1250  u32 prefix_index = prefix_info - pm->prefix_pool;
1251  notify_prefix_add_del (prefix_index, 0);
1252  set_is_dhcpv6_pd_prefix (prefix_info, 0);
1253  pool_put (pm->prefix_pool, prefix_info);
1254  }
1255  }));
1256  /* *INDENT-ON* */
1257 
1258  vec_free (prefix_list);
1259 
1260  memset (client_state, 0, sizeof (*client_state));
1261  }
1262 
1263  return 0;
1264 }
1265 
1266 static clib_error_t *
1268  vm,
1270  * input, vlib_cli_command_t * cmd)
1271 {
1273  vnet_main_t *vnm = rm->vnet_main;
1274  clib_error_t *error = 0;
1275  u8 *prefix_group = 0;
1276  u32 sw_if_index = ~0;
1277  u8 enable = 1;
1278 
1279  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1280  {
1281  if (unformat
1282  (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
1283  ;
1284  else if (unformat (input, "prefix group %s", &prefix_group));
1285  else if (unformat (input, "disable"))
1286  enable = 0;
1287  else
1288  {
1289  error = clib_error_return (0, "unexpected input `%U'",
1290  format_unformat_error, input);
1291  goto done;
1292  }
1293  }
1294 
1295  if (prefix_group == 0 && enable)
1296  error = clib_error_return (0, "Prefix group must be set when enabling");
1297  else if (sw_if_index != ~0)
1298  {
1299  if (dhcp6_pd_client_enable_disable (sw_if_index, prefix_group, enable)
1300  != 0)
1301  error = clib_error_return (0, "Invalid sw_if_index or prefix group");
1302  }
1303  else
1304  error = clib_error_return (0, "Missing sw_if_index");
1305 
1306 done:
1307  vec_free (prefix_group);
1308 
1309  return error;
1310 }
1311 
1312 /*?
1313  * This command is used to enable/disable DHCPv6 PD client
1314  * on particular interface.
1315  *
1316  * @cliexpar
1317  * @parblock
1318  * Example of how to enable DHCPv6 PD client:
1319  * @cliexcmd{dhcp6 pd client GigabitEthernet2/0/0 prefix group my-pd-group}
1320  * Example of how to disable DHCPv6 PD client:
1321  * @cliexcmd{dhcp6 pd client GigabitEthernet2/0/0 disable}
1322  * @endparblock
1323 ?*/
1324 /* *INDENT-OFF* */
1326  .path = "dhcp6 pd client",
1327  .short_help = "dhcp6 pd client <interface> (prefix group <string> | disable)",
1329 };
1330 /* *INDENT-ON* */
1331 
1332 static void
1335 {
1336  vl_api_dhcp6_pd_client_enable_disable_reply_t *rmp;
1337  u32 sw_if_index;
1338  int rv = 0;
1339 
1340  VALIDATE_SW_IF_INDEX (mp);
1341 
1342  sw_if_index = ntohl (mp->sw_if_index);
1343 
1344  rv =
1345  dhcp6_pd_client_enable_disable (sw_if_index, mp->prefix_group,
1346  mp->enable);
1347 
1349 
1350  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
1351 }
1352 
1353 #define vl_msg_name_crc_list
1354 #include <vnet/dhcp/dhcp6_pd_client_cp.api.h>
1355 #undef vl_msg_name_crc_list
1356 
1357 static void
1359 {
1360 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1361  foreach_vl_msg_name_crc_dhcp6_pd_client_cp;
1362 #undef _
1363 }
1364 
1365 static clib_error_t *
1367 {
1369  api_main_t *am = &api_main;
1370 
1371  rm->vlib_main = vm;
1372  rm->vnet_main = vnet_get_main ();
1373  rm->api_main = am;
1375 
1376 #define _(N,n) \
1377  vl_msg_api_set_handlers(VL_API_##N, #n, \
1378  vl_api_##n##_t_handler, \
1379  vl_noop_handler, \
1380  vl_api_##n##_t_endian, \
1381  vl_api_##n##_t_print, \
1382  sizeof(vl_api_##n##_t), 0/* do NOT trace! */);
1384 #undef _
1385 
1386  /*
1387  * Set up the (msg_name, crc, message-id) table
1388  */
1390 
1391  return 0;
1392 }
1393 
1395 
1396 /*
1397  * fd.io coding-style-patch-verification: ON
1398  *
1399  * Local Variables:
1400  * eval: (c-set-style "gnu")
1401  * End:
1402  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:437
typedef address
Definition: ip_types.api:35
u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
static void notify_prefix_add_del(u32 prefix_index, u8 is_add)
vlib_node_registration_t dhcp6_pd_client_cp_process_node
(constructor) VLIB_REGISTER_NODE (dhcp6_pd_client_cp_process_node)
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:699
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
vl_api_dhcp6_pd_prefix_info_t prefixes[n_prefixes]
Definition: dhcp.api:413
static void cp_ip6_address_prefix_add_del_handler(u32 prefix_index, u8 is_add)
ip6_address_t prefix
static u32 cp_ip6_address_find_new_active_prefix(u32 prefix_group_index, u32 ignore_prefix_index)
u8 as_u8[16]
Definition: ip6_packet.h:48
u64 as_u64[2]
Definition: ip6_packet.h:51
unsigned long u64
Definition: types.h:89
static_always_inline u8 is_dhcpv6_pd_prefix(prefix_info_t *prefix_info)
static void send_client_message_start_stop(u32 sw_if_index, u32 server_index, u8 msg_type, prefix_info_t *prefix_list, u8 start)
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:227
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:523
Enable/disable DHCPv6 PD client on interface.
dhcp6_pd_send_client_message_params_prefix_t * prefixes
int i
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
Definition: bitmap.h:167
void dhcp6_pd_send_client_message(vlib_main_t *vm, u32 sw_if_index, u8 stop, dhcp6_pd_send_client_message_params_t *params)
static void setup_message_id_table(api_main_t *am)
unformat_function_t unformat_vnet_sw_interface
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:228
vhost_vring_addr_t addr
Definition: vhost_user.h:121
static vlib_cli_command_t ip6_pd_clients_show_command
(constructor) VLIB_CLI_COMMAND (ip6_pd_clients_show_command)
unsigned char u8
Definition: types.h:56
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
static ip6_address_with_prefix_main_t ip6_address_with_prefix_main
memset(h->entries, 0, sizeof(h->entries[0])*entries)
const u8 ** prefix_group_name_by_index
static void cp_ip6_address_add_del_now(ip6_address_info_t *address_info, u8 is_add)
#define static_always_inline
Definition: clib.h:95
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:443
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type...
Definition: node_funcs.h:542
u32 sw_if_index
Definition: vxlan_gbp.api:39
vlib_node_t ** nodes
Definition: node.h:697
#define clib_error_return(e, args...)
Definition: error.h:99
static clib_error_t * dhcp6_pd_client_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t()*input, vlib_cli_command_t *cmd)
unsigned int u32
Definition: types.h:88
static_always_inline void active_prefix_index_by_prefix_group_index_set(u32 prefix_group_index, u32 prefix_index)
static u32 ip6_enable(u32 sw_if_index)
static vlib_cli_command_t ip6_address_add_del_command
(constructor) VLIB_CLI_COMMAND (ip6_address_add_del_command)
VNET_DHCP6_PD_REPLY_EVENT_FUNCTION(dhcp6_pd_reply_event_handler)
Struct representing DHCPv6 PD prefix.
Definition: dhcp.api:230
static int cp_ip6_address_add_del(u32 sw_if_index, const u8 *prefix_group, ip6_address_t address, u8 prefix_length, u8 is_add)
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:960
struct _unformat_input_t unformat_input_t
#define REPLY_MACRO(t)
static int dhcp6_pd_client_enable_disable(u32 sw_if_index, const u8 *prefix_group, u8 enable)
u8 name[64]
Definition: memclnt.api:151
static void interrupt_process(void)
static void disable_process(void)
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:201
unformat_function_t unformat_ip6_address
Definition: format.h:91
#define BAD_SW_IF_INDEX_LABEL
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:155
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
u32 runtime_index
Definition: node.h:291
static clib_error_t * cp_ip6_prefixes_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * ip6_pd_clients_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_ip6_address
Definition: format.h:93
vlib_main_t * vm
Definition: buffer.c:294
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:339
static prefix_info_t * create_prefix_list(u32 sw_if_index)
#define clib_warning(format, args...)
Definition: error.h:59
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
Definition: bitmap.h:197
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
signed int i32
Definition: types.h:77
#define ASSERT(truth)
static u32 cp_ip6_construct_address(ip6_address_info_t *address_info, u32 prefix_index, ip6_address_t *r_addr)
static_always_inline u32 active_prefix_index_by_prefix_group_index_get(u32 prefix_group_index)
static u8 ip6_prefixes_equal(ip6_address_t *prefix1, ip6_address_t *prefix2, u8 len)
Tell client about a DHCPv6 PD server reply event.
Definition: dhcp.api:400
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
Definition: node_funcs.h:147
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
Definition: ip6_packet.h:321
static clib_error_t * dhcp6_pd_reply_event_handler(vl_api_dhcp6_pd_reply_event_t *mp)
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
#define vec_elt(v, i)
Get vector value at index i.
static dhcp6_pd_client_cp_main_t dhcp6_pd_client_cp_main
prefix_info_t * prefix_pool
static_always_inline void set_is_dhcpv6_pd_prefix(prefix_info_t *prefix_info, u8 value)
static uword vnet_sw_interface_is_api_valid(vnet_main_t *vnm, u32 sw_if_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static clib_error_t * cp_ip6_addresses_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vlib_node_main_t node_main
Definition: main.h:134
static clib_error_t * dhcp_pd_client_cp_init(vlib_main_t *vm)
u64 uword
Definition: types.h:112
static uword dhcp6_pd_client_cp_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
typedef prefix
Definition: ip_types.api:40
static u32 prefix_group_find_or_create(const u8 *name, u8 create)
void dhcp6_clients_enable_disable(u8 enable)
static vlib_cli_command_t ip6_prefixes_show_command
(constructor) VLIB_CLI_COMMAND (ip6_prefixes_show_command)
Add/delete IPv6 address optionally using available prefix.
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
uword clib_bitmap_t
Definition: bitmap.h:50
clib_bitmap_t * prefix_ownership_bitmap
static void vl_api_dhcp6_pd_client_enable_disable_t_handler(vl_api_dhcp6_pd_client_enable_disable_t *mp)
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * ip6_add_del_interface_address(vlib_main_t *vm, u32 sw_if_index, ip6_address_t *address, u32 address_length, u32 is_del)
Definition: ip6_forward.c:193
static void vl_api_ip6_add_del_address_using_prefix_t_handler(vl_api_ip6_add_del_address_using_prefix_t *mp)
static vlib_cli_command_t dhcp6_pd_client_enable_disable_command
(constructor) VLIB_CLI_COMMAND (dhcp6_pd_client_enable_disable_command)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
Definition: vec.h:486
void vlib_start_process(vlib_main_t *vm, uword process_index)
Definition: main.c:1347
static void enable_process(void)
api_main_t api_main
Definition: api_shared.c:35
static ip6_prefix_main_t ip6_prefix_main
#define foreach_dhcp6_pd_client_cp_msg
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:725
static vlib_cli_command_t ip6_addresses_show_command
(constructor) VLIB_CLI_COMMAND (ip6_addresses_show_command)
static clib_error_t * cp_ip6_address_add_del_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170
#define VALIDATE_SW_IF_INDEX(mp)
client_state_t * client_state_by_sw_if_index