FD.io VPP  v19.04.4-rc0-5-ge88582fac
Vector Packet Processing
dhcp6_ia_na_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 
26 #define vl_typedefs /* define message structures */
27 #include <vnet/vnet_all_api_h.h>
28 #undef vl_typedefs
29 
30 #define vl_endianfun /* define message structures */
31 #include <vnet/vnet_all_api_h.h>
32 #undef vl_endianfun
33 
35 
36 #define foreach_dhcp6_client_cp_msg \
37 _(DHCP6_CLIENT_ENABLE_DISABLE, dhcp6_client_enable_disable)
38 
39 #define vl_api_dhcp6_client_enable_disable_t_print vl_noop_handler
40 
41 typedef struct
42 {
49 
50 typedef struct
51 {
61 
62 typedef struct
63 {
68 
69  /* convenience */
75 
77 
78 enum
79 {
82 };
83 
84 static void
86  u8 msg_type, address_info_t * address_list,
87  u8 start)
88 {
90  dhcp6_send_client_message_params_t params = { 0, };
92  u32 i;
93 
94  ASSERT (sw_if_index < vec_len (rm->client_state_by_sw_if_index) &&
95  rm->client_state_by_sw_if_index[sw_if_index].enabled);
96  client_state_t *client_state =
98 
99  params.sw_if_index = sw_if_index;
100  params.server_index = server_index;
101  params.msg_type = msg_type;
102  if (start)
103  {
104  if (msg_type == DHCPV6_MSG_SOLICIT)
105  {
106  params.irt = 1;
107  params.mrt = 120;
108  }
109  else if (msg_type == DHCPV6_MSG_REQUEST)
110  {
111  params.irt = 1;
112  params.mrt = 30;
113  params.mrc = 10;
114  }
115  else if (msg_type == DHCPV6_MSG_RENEW)
116  {
117  params.irt = 10;
118  params.mrt = 600;
119  f64 current_time = vlib_time_now (rm->vlib_main);
120  i32 diff_time = client_state->T2 - current_time;
121  if (diff_time < 0)
122  diff_time = 0;
123  params.mrd = diff_time;
124  }
125  else if (msg_type == DHCPV6_MSG_REBIND)
126  {
127  params.irt = 10;
128  params.mrt = 600;
129  f64 current_time = vlib_time_now (rm->vlib_main);
130  i32 diff_time = rm->max_valid_due_time - current_time;
131  if (diff_time < 0)
132  diff_time = 0;
133  params.mrd = diff_time;
134  }
135  else if (msg_type == DHCPV6_MSG_RELEASE)
136  {
137  params.mrc = 1;
138  }
139  }
140 
141  params.T1 = 0;
142  params.T2 = 0;
143  if (vec_len (address_list) != 0)
144  vec_validate (addresses, vec_len (address_list) - 1);
145  for (i = 0; i < vec_len (address_list); i++)
146  {
147  address_info_t *address = &address_list[i];
148  addr = &addresses[i];
149  addr->valid_lt = address->valid_lt;
150  addr->preferred_lt = address->preferred_lt;
151  addr->address = address->address;
152  }
153  params.addresses = addresses;
154 
155  dhcp6_send_client_message (rm->vlib_main, sw_if_index, !start, &params);
156 
157  vec_free (params.addresses);
158 }
159 
160 static void interrupt_process (void);
161 
162 static u32
164 {
166  clib_error_t *rv;
167 
168  rv = enable_ip6_interface (rm->vlib_main, sw_if_index);
169 
170  return rv != 0;
171 }
172 
173 static u8
175 {
176  if (address1->as_u64[0] != address2->as_u64[0])
177  return 0;
178  return address1->as_u64[1] == address2->as_u64[1];
179 }
180 
181 static clib_error_t *
183 {
185  vlib_main_t *vm = rm->vlib_main;
186  client_state_t *client_state;
189  u32 n_addresses;
190  vl_api_dhcp6_address_info_t *api_address;
191  u32 inner_status_code;
192  u32 status_code;
193  u32 server_index;
194  f64 current_time;
195  clib_error_t *error = 0;
196  u32 i;
197 
198  current_time = vlib_time_now (vm);
199 
200  sw_if_index = ntohl (mp->sw_if_index);
201 
202  if (sw_if_index >= vec_len (rm->client_state_by_sw_if_index))
203  return 0;
204 
205  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
206 
207  if (!client_state->enabled)
208  return 0;
209 
210  server_index = ntohl (mp->server_index);
211 
212  n_addresses = ntohl (mp->n_addresses);
213 
214  inner_status_code = ntohs (mp->inner_status_code);
215  status_code = ntohs (mp->status_code);
216 
217  if (mp->msg_type == DHCPV6_MSG_ADVERTISE
218  && client_state->server_index == ~0)
219  {
220  address_info_t *address_list = 0, *address_info;
221 
222  if (inner_status_code == DHCPV6_STATUS_NOADDRS_AVAIL)
223  {
225  ("Advertise message arrived with NoAddrsAvail status code");
226  return 0;
227  }
228 
229  if (n_addresses > 0)
230  vec_validate (address_list, n_addresses - 1);
231  for (i = 0; i < n_addresses; i++)
232  {
233  api_address = &mp->addresses[i];
234  address = (ip6_address_t *) api_address->address;
235 
236  address_info = &address_list[i];
237  address_info->address = *address;
238  address_info->preferred_lt = 0;
239  address_info->valid_lt = 0;
240  }
241 
242  client_state->server_index = server_index;
243 
244  send_client_message_start_stop (sw_if_index, server_index,
245  DHCPV6_MSG_REQUEST, address_list, 1);
246  vec_free (address_list);
247  }
248 
249  if (mp->msg_type != DHCPV6_MSG_REPLY)
250  return 0;
251 
252  if (!client_state->rebinding && client_state->server_index != server_index)
253  {
254  clib_warning ("Reply message arrived with Server ID different "
255  "from that in Request or Renew message");
256  return 0;
257  }
258 
259  if (inner_status_code == DHCPV6_STATUS_NOADDRS_AVAIL)
260  {
261  clib_warning ("Reply message arrived with NoAddrsAvail status code");
262  if (n_addresses > 0)
263  {
265  ("Invalid Reply message arrived: It contains NoAddrsAvail "
266  "status code but also contains addresses");
267  return 0;
268  }
269  }
270 
271  if (status_code == DHCPV6_STATUS_UNSPEC_FAIL)
272  {
273  clib_warning ("Reply message arrived with UnspecFail status code");
274  return 0;
275  }
276 
277  send_client_message_start_stop (sw_if_index, server_index,
278  mp->msg_type, 0, 0);
279 
280  for (i = 0; i < n_addresses; i++)
281  {
282  address_info_t *address_info = 0;
283  u32 valid_time;
284  u32 preferred_time;
285 
286  api_address = &mp->addresses[i];
287 
288  address = (ip6_address_t *) api_address->address;
289 
290  if (ip6_address_is_link_local_unicast (address))
291  continue;
292 
293  valid_time = ntohl (api_address->valid_time);
294  preferred_time = ntohl (api_address->preferred_time);
295 
296  if (preferred_time > valid_time)
297  continue;
298 
299  u8 address_already_present = 0;
300  /* *INDENT-OFF* */
301  pool_foreach (address_info, rm->address_pool,
302  ({
303  if (address_info->sw_if_index != sw_if_index)
304  ;
305  else if (!ip6_addresses_equal (&address_info->address, address))
306  ;
307  else
308  {
309  address_already_present = 1;
310  goto address_pool_foreach_out;
311  }
312  }));
313  /* *INDENT-ON* */
314  address_pool_foreach_out:
315 
316  if (address_already_present)
317  {
318  address_info->preferred_lt = preferred_time;
319  address_info->valid_lt = valid_time;
320  address_info->due_time = current_time + valid_time;
321  if (address_info->due_time > rm->max_valid_due_time)
322  rm->max_valid_due_time = address_info->due_time;
323  continue;
324  }
325 
326  if (valid_time == 0)
327  continue;
328 
329  pool_get (rm->address_pool, address_info);
330  address_info->sw_if_index = sw_if_index;
331  address_info->address = *address;
332  address_info->preferred_lt = preferred_time;
333  address_info->valid_lt = valid_time;
334  address_info->due_time = current_time + valid_time;
335  if (address_info->due_time > rm->max_valid_due_time)
336  rm->max_valid_due_time = address_info->due_time;
338 
339  error = ip6_add_del_interface_address (vm, sw_if_index,
340  &address_info->address, 64, 0);
341  if (error)
342  clib_warning ("Failed to add interface address");
343  }
344 
345  client_state->server_index = server_index;
346  client_state->T1 = ntohl (mp->T1);
347  client_state->T2 = ntohl (mp->T2);
348  if (client_state->T1 != 0)
349  client_state->T1_due_time = current_time + client_state->T1;
350  if (client_state->T2 != 0)
351  client_state->T2_due_time = current_time + client_state->T2;
352  client_state->rebinding = 0;
353 
355 
356  return error;
357 }
358 
359 static address_info_t *
361 {
363  address_info_t *address_info, *address_list = 0;;
364 
365  /* *INDENT-OFF* */
366  pool_foreach (address_info, rm->address_pool,
367  ({
368  if (address_info->sw_if_index == sw_if_index)
369  {
370  u32 pos = vec_len (address_list);
371  vec_validate (address_list, pos);
372  clib_memcpy (&address_list[pos], address_info, sizeof (*address_info));
373  }
374  }));
375  /* *INDENT-ON* */
376 
377  return address_list;
378 }
379 
381 
382 static uword
384  vlib_frame_t * f)
385 {
387  address_info_t *address_info;
388  client_state_t *client_state;
389  f64 sleep_time = 1e9;
390  clib_error_t *error;
391  f64 current_time;
392  f64 due_time;
393  uword event_type;
394  uword *event_data = 0;
395  int i;
396 
397  while (1)
398  {
399  vlib_process_wait_for_event_or_clock (vm, sleep_time);
400  event_type = vlib_process_get_events (vm, &event_data);
401  vec_reset_length (event_data);
402 
403  if (event_type == RD_CP_EVENT_DISABLE)
404  {
405  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_DISABLED);
406  sleep_time = 1e9;
407  continue;
408  }
409 
410  current_time = vlib_time_now (vm);
411  do
412  {
413  due_time = current_time + 1e9;
414  /* *INDENT-OFF* */
415  pool_foreach (address_info, rm->address_pool,
416  ({
417  if (address_info->due_time > current_time)
418  {
419  if (address_info->due_time < due_time)
420  due_time = address_info->due_time;
421  }
422  else
423  {
424  u32 sw_if_index = address_info->sw_if_index;
425  error = ip6_add_del_interface_address (vm, sw_if_index,
426  &address_info->address,
427  64, 1);
428  if (error)
429  clib_warning ("Failed to delete interface address");
430  pool_put (rm->address_pool, address_info);
431  /* make sure ip6 stays enabled */
432  ip6_enable (sw_if_index);
433  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
434  if (--client_state->address_count == 0)
435  {
436  client_state->rebinding = 0;
437  client_state->server_index = ~0;
438  send_client_message_start_stop (sw_if_index, ~0,
439  DHCPV6_MSG_SOLICIT,
440  0, 1);
441  }
442  }
443  }));
444  /* *INDENT-ON* */
445  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
446  {
448  if (cs->enabled && cs->server_index != ~0)
449  {
450  if (cs->T2_due_time > current_time)
451  {
452  if (cs->T2_due_time < due_time)
453  due_time = cs->T2_due_time;
454  if (cs->T1_due_time > current_time)
455  {
456  if (cs->T1_due_time < due_time)
457  due_time = cs->T1_due_time;
458  }
459  else
460  {
461  cs->T1_due_time = DBL_MAX;
462  address_info_t *address_list;
463  address_list = create_address_list (i);
464  cs->rebinding = 1;
467  address_list, 1);
468  vec_free (address_list);
469  }
470  }
471  else
472  {
473  cs->T2_due_time = DBL_MAX;
474  address_info_t *address_list;
475  address_list = create_address_list (i);
476  cs->rebinding = 1;
479  address_list, 1);
480  vec_free (address_list);
481  }
482  }
483  }
484  current_time = vlib_time_now (vm);
485  }
486  while (due_time < current_time);
487 
488  sleep_time = due_time - current_time;
489  }
490 
491  return 0;
492 }
493 
494 /* *INDENT-OFF* */
496  .function = dhcp6_client_cp_process,
497  .type = VLIB_NODE_TYPE_PROCESS,
498  .name = "dhcp6-client-cp-process",
499 };
500 /* *INDENT-ON* */
501 
502 static void
504 {
506  vlib_main_t *vm = rm->vlib_main;
507 
510 }
511 
512 static void
514 {
516  vlib_main_t *vm = rm->vlib_main;
517 
520 }
521 
522 static void
524 {
526  vlib_main_t *vm = rm->vlib_main;
527  vlib_node_t *node;
528 
529  node = vec_elt (vm->node_main.nodes, rm->node_index);
530 
531  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_POLLING);
532  vlib_start_process (vm, node->runtime_index);
533 }
534 
535 static clib_error_t *
537  unformat_input_t * input,
538  vlib_cli_command_t * cmd)
539 {
541  clib_error_t *error = 0;
542  address_info_t *address_info;
543  f64 current_time = vlib_time_now (vm);
544 
545  /* *INDENT-OFF* */
546  pool_foreach (address_info, dm->address_pool,
547  ({
548  vlib_cli_output (vm, "address: %U, "
549  "preferred lifetime: %u, valid lifetime: %u "
550  "(%f remaining)",
551  format_ip6_address, &address_info->address,
552  address_info->preferred_lt, address_info->valid_lt,
553  address_info->due_time - current_time);
554  }));
555  /* *INDENT-ON* */
556 
557  return error;
558 }
559 
560 /* *INDENT-OFF* */
561 VLIB_CLI_COMMAND (dhcp6_addresses_show_command, static) = {
562  .path = "show dhcp6 addresses",
563  .short_help = "show dhcp6 addresses",
565 };
566 /* *INDENT-ON* */
567 
568 static clib_error_t *
570  unformat_input_t * input,
571  vlib_cli_command_t * cmd)
572 {
574  clib_error_t *error = 0;
575  client_state_t *cs;
576  f64 current_time = vlib_time_now (vm);
577  char buf1[256];
578  char buf2[256];
579  const char *rebinding;
580  u32 i;
581 
582  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
583  {
584  cs = &rm->client_state_by_sw_if_index[i];
585  if (cs->enabled)
586  {
587  if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time)
588  {
589  sprintf (buf1, "%u remaining",
590  (u32) round (cs->T1_due_time - current_time));
591  }
592  else
593  sprintf (buf1, "timeout");
594  if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time)
595  sprintf (buf2, "%u remaining",
596  (u32) round (cs->T2_due_time - current_time));
597  else
598  sprintf (buf2, "timeout");
599  if (cs->rebinding)
600  rebinding = ", REBINDING";
601  else
602  rebinding = "";
603  if (cs->T1)
604  vlib_cli_output (vm,
605  "sw_if_index: %u, T1: %u (%s), "
606  "T2: %u (%s), server index: %d%s", i,
607  cs->T1, buf1, cs->T2, buf2,
608  cs->server_index, rebinding);
609  else
610  vlib_cli_output (vm, "sw_if_index: %u%s", i, rebinding);
611  }
612  }
613 
614  return error;
615 }
616 
617 /* *INDENT-OFF* */
618 VLIB_CLI_COMMAND (dhcp6_clients_show_command, static) = {
619  .path = "show dhcp6 clients",
620  .short_help = "show dhcp6 clients",
622 };
623 /* *INDENT-ON* */
624 
625 static int
627 {
629  vnet_main_t *vnm = rm->vnet_main;
630  vlib_main_t *vm = rm->vlib_main;
631  client_state_t *client_state;
632  client_state_t empty_config = { 0 };
633  address_info_t *address_info;
634  clib_error_t *error;
635 
636  if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
637  {
638  clib_warning ("Invalid sw_if_index");
639  return 1;
640  }
641 
643  empty_config);
644  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
645 
646  u8 old_enabled = client_state->enabled;
647  if (enable)
648  client_state->enabled = 1;
649  client_state->server_index = ~0;
650 
651  if (!old_enabled && enable)
652  {
653  rm->n_clients++;
654  if (rm->n_clients == 1)
655  {
656  enable_process ();
658  }
659 
660  ip6_enable (sw_if_index);
662  0, 1);
663  }
664  else if (old_enabled && !enable)
665  {
666  send_client_message_start_stop (sw_if_index, ~0, ~0, 0, 0);
667 
668  rm->n_clients--;
669  if (rm->n_clients == 0)
670  {
672  disable_process ();
673  }
674 
675  /* *INDENT-OFF* */
676  pool_foreach (address_info, rm->address_pool,
677  ({
678  if (address_info->sw_if_index == sw_if_index)
679  {
680  ASSERT (sw_if_index < vec_len (rm->client_state_by_sw_if_index) &&
681  rm->client_state_by_sw_if_index[sw_if_index].enabled);
682  client_state_t *client_state =
683  &rm->client_state_by_sw_if_index[sw_if_index];
684  send_client_message_start_stop (sw_if_index,
685  client_state->server_index,
686  DHCPV6_MSG_RELEASE, address_info,
687  1);
688  error = ip6_add_del_interface_address (vm, sw_if_index,
689  &address_info->address,
690  64, 1);
691  if (error)
692  clib_warning ("Failed to delete interface address");
693  pool_put (rm->address_pool, address_info);
694  }
695  }));
696  /* *INDENT-ON* */
697  }
698 
699  if (!enable)
700  client_state->enabled = 0;
701 
702  return 0;
703 }
704 
705 static clib_error_t *
707  unformat_input_t * input,
708  vlib_cli_command_t * cmd)
709 {
711  vnet_main_t *vnm = rm->vnet_main;
712  clib_error_t *error = 0;
713  u32 sw_if_index = ~0;
714  u8 enable = 1;
715  unformat_input_t _line_input, *line_input = &_line_input;
716 
717  if (!unformat_user (input, unformat_line_input, line_input))
718  return 0;
719 
720  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
721  {
722  if (unformat
723  (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
724  ;
725  else if (unformat (line_input, "disable"))
726  enable = 0;
727  else
728  {
729  error = clib_error_return (0, "unexpected input `%U'",
730  format_unformat_error, line_input);
731  goto done;
732  }
733  }
734 
735  unformat_free (line_input);
736 
737  if (sw_if_index != ~0)
738  {
739  if (dhcp6_client_enable_disable (sw_if_index, enable) != 0)
740  error = clib_error_return (0, "Invalid sw_if_index");
741  }
742  else
743  error = clib_error_return (0, "Missing sw_if_index");
744 
745 done:
746  return error;
747 }
748 
749 /*?
750  * This command is used to enable/disable DHCPv6 client
751  * on particular interface.
752  *
753  * @cliexpar
754  * @parblock
755  * Example of how to enable DHCPv6 client:
756  * @cliexcmd{dhcp6 client GigabitEthernet2/0/0}
757  * Example of how to disable DHCPv6 client:
758  * @cliexcmd{dhcp6 client GigabitEthernet2/0/0 disable}
759  * @endparblock
760 ?*/
761 /* *INDENT-OFF* */
762 VLIB_CLI_COMMAND (dhcp6_client_enable_disable_command, static) = {
763  .path = "dhcp6 client",
764  .short_help = "dhcp6 client <interface> [disable]",
766 };
767 /* *INDENT-ON* */
768 
769 static void
772 {
773  vl_api_dhcp6_client_enable_disable_reply_t *rmp;
775  int rv = 0;
776 
778 
779  sw_if_index = ntohl (mp->sw_if_index);
780 
781  rv = dhcp6_client_enable_disable (sw_if_index, mp->enable);
782 
784 
785  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
786 }
787 
788 #define vl_msg_name_crc_list
789 #include <vnet/dhcp/dhcp6_ia_na_client_cp.api.h>
790 #undef vl_msg_name_crc_list
791 
792 static void
794 {
795 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
796  foreach_vl_msg_name_crc_dhcp6_ia_na_client_cp;
797 #undef _
798 }
799 
800 static clib_error_t *
802 {
804  api_main_t *am = &api_main;
805 
806  rm->vlib_main = vm;
807  rm->vnet_main = vnet_get_main ();
808  rm->api_main = am;
810 
811 #define _(N,n) \
812  vl_msg_api_set_handlers(VL_API_##N, #n, \
813  vl_api_##n##_t_handler, \
814  vl_noop_handler, \
815  vl_api_##n##_t_endian, \
816  vl_api_##n##_t_print, \
817  sizeof(vl_api_##n##_t), 0/* do NOT trace! */);
819 #undef _
820 
821  /*
822  * Set up the (msg_name, crc, message-id) table
823  */
825 
826  return 0;
827 }
828 
830 
831 /*
832  * fd.io coding-style-patch-verification: ON
833  *
834  * Local Variables:
835  * eval: (c-set-style "gnu")
836  * End:
837  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
u32 sw_if_index
Definition: ipsec_gre.api:37
static int dhcp6_client_enable_disable(u32 sw_if_index, u8 enable)
typedef address
Definition: ip_types.api:30
static u8 ip6_addresses_equal(ip6_address_t *address1, ip6_address_t *address2)
VNET_DHCP6_REPLY_EVENT_FUNCTION(dhcp6_reply_event_handler)
static address_info_t * create_address_list(u32 sw_if_index)
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:673
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
u64 as_u64[2]
Definition: ip6_packet.h:51
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:255
static void enable_process(void)
static u32 ip6_enable(u32 sw_if_index)
int i
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:983
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * dhcp6_client_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:236
vhost_vring_addr_t addr
Definition: vhost_user.h:121
unsigned char u8
Definition: types.h:56
static dhcp6_client_cp_main_t dhcp6_client_cp_main
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
double f64
Definition: types.h:142
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:493
#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:516
static clib_error_t * dhcp_client_cp_init(vlib_main_t *vm)
static clib_error_t * dhcp6_reply_event_handler(vl_api_dhcp6_reply_event_t *mp)
vlib_node_t ** nodes
Definition: node.h:697
#define clib_error_return(e, args...)
Definition: error.h:99
vl_api_dhcp6_address_info_t addresses[n_addresses]
Definition: dhcp.api:382
unsigned int u32
Definition: types.h:88
static void interrupt_process(void)
unformat_function_t unformat_line_input
Definition: format.h:282
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:934
struct _unformat_input_t unformat_input_t
static void vl_api_dhcp6_client_enable_disable_t_handler(vl_api_dhcp6_client_enable_disable_t *mp)
#define REPLY_MACRO(t)
static clib_error_t * dhcp6_clients_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:202
#define BAD_SW_IF_INDEX_LABEL
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
ip6_address_t address
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
u32 runtime_index
Definition: node.h:282
vlib_main_t * vm
Definition: buffer.c:312
dhcp6_send_client_message_params_address_t * addresses
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
static void disable_process(void)
#define clib_warning(format, args...)
Definition: error.h:59
clib_error_t * enable_ip6_interface(vlib_main_t *vm, u32 sw_if_index)
Enable/disable DHCPv6 client on interface.
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
signed int i32
Definition: types.h:77
#define ASSERT(truth)
Struct representing DHCPv6 address.
Definition: dhcp.api:217
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:148
static uword ip6_address_is_link_local_unicast(const ip6_address_t *a)
Definition: ip6_packet.h:328
void dhcp6_send_client_message(vlib_main_t *vm, u32 sw_if_index, u8 stop, dhcp6_send_client_message_params_t *params)
static clib_error_t * dhcp6_addresses_show_command_function(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define foreach_dhcp6_client_cp_msg
#define vec_elt(v, i)
Get vector value at index i.
Tell client about a DHCPv6 server reply event.
Definition: dhcp.api:369
static uword vnet_sw_interface_is_api_valid(vnet_main_t *vnm, u32 sw_if_index)
static void send_client_message_start_stop(u32 sw_if_index, u32 server_index, u8 msg_type, address_info_t *address_list, u8 start)
static uword dhcp6_client_cp_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_main_t node_main
Definition: main.h:135
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:162
void dhcp6_clients_enable_disable(u8 enable)
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
vlib_node_registration_t dhcp6_client_cp_process_node
(constructor) VLIB_REGISTER_NODE (dhcp6_client_cp_process_node)
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:197
#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:1577
static void setup_message_id_table(api_main_t *am)
api_main_t api_main
Definition: api_shared.c:35
client_state_t * client_state_by_sw_if_index
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:762
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)