FD.io VPP  v19.08.3-2-gbabecb413
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;
321  /* Renew the lease at the preferred time, if non-zero */
322  address_info->due_time += (preferred_time > 0) ?
323  preferred_time : valid_time;
324 
325  if (address_info->due_time > rm->max_valid_due_time)
326  rm->max_valid_due_time = address_info->due_time;
327  continue;
328  }
329 
330  if (valid_time == 0)
331  continue;
332 
333  pool_get (rm->address_pool, address_info);
334  address_info->sw_if_index = sw_if_index;
335  address_info->address = *address;
336  address_info->preferred_lt = preferred_time;
337  address_info->valid_lt = valid_time;
338  address_info->due_time = current_time;
339  /* Renew the lease at the preferred time, if non-zero */
340  address_info->due_time += (preferred_time > 0) ?
341  preferred_time : valid_time;
342 
343  if (address_info->due_time > rm->max_valid_due_time)
344  rm->max_valid_due_time = address_info->due_time;
346 
347  error = ip6_add_del_interface_address (vm, sw_if_index,
348  &address_info->address, 64, 0);
349  if (error)
350  clib_warning ("Failed to add interface address");
351  }
352 
353  client_state->server_index = server_index;
354  client_state->T1 = ntohl (mp->T1);
355  client_state->T2 = ntohl (mp->T2);
356  if (client_state->T1 != 0)
357  client_state->T1_due_time = current_time + client_state->T1;
358  if (client_state->T2 != 0)
359  client_state->T2_due_time = current_time + client_state->T2;
360  client_state->rebinding = 0;
361 
363 
364  return error;
365 }
366 
367 static address_info_t *
369 {
371  address_info_t *address_info, *address_list = 0;;
372 
373  /* *INDENT-OFF* */
374  pool_foreach (address_info, rm->address_pool,
375  ({
376  if (address_info->sw_if_index == sw_if_index)
377  {
378  u32 pos = vec_len (address_list);
379  vec_validate (address_list, pos);
380  clib_memcpy (&address_list[pos], address_info, sizeof (*address_info));
381  }
382  }));
383  /* *INDENT-ON* */
384 
385  return address_list;
386 }
387 
389 
390 static uword
392  vlib_frame_t * f)
393 {
395  address_info_t *address_info;
396  client_state_t *client_state;
397  f64 sleep_time = 1e9;
398  clib_error_t *error;
399  f64 current_time;
400  f64 due_time;
401  uword event_type;
402  uword *event_data = 0;
403  int i;
404 
405  while (1)
406  {
407  vlib_process_wait_for_event_or_clock (vm, sleep_time);
408  event_type = vlib_process_get_events (vm, &event_data);
409  vec_reset_length (event_data);
410 
411  if (event_type == RD_CP_EVENT_DISABLE)
412  {
413  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_DISABLED);
414  sleep_time = 1e9;
415  continue;
416  }
417 
418  current_time = vlib_time_now (vm);
419  do
420  {
421  due_time = current_time + 1e9;
422  /* *INDENT-OFF* */
423  pool_foreach (address_info, rm->address_pool,
424  ({
425  if (address_info->due_time > current_time)
426  {
427  if (address_info->due_time < due_time)
428  due_time = address_info->due_time;
429  }
430  else
431  {
432  u32 sw_if_index = address_info->sw_if_index;
433  error = ip6_add_del_interface_address (vm, sw_if_index,
434  &address_info->address,
435  64, 1);
436  if (error)
437  clib_warning ("Failed to delete interface address");
438  pool_put (rm->address_pool, address_info);
439  /* make sure ip6 stays enabled */
440  ip6_enable (sw_if_index);
441  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
442  if (--client_state->address_count == 0)
443  {
444  client_state->rebinding = 0;
445  client_state->server_index = ~0;
446  send_client_message_start_stop (sw_if_index, ~0,
447  DHCPV6_MSG_SOLICIT,
448  0, 1);
449  }
450  }
451  }));
452  /* *INDENT-ON* */
453  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
454  {
456  if (cs->enabled && cs->server_index != ~0)
457  {
458  if (cs->T2_due_time > current_time)
459  {
460  if (cs->T2_due_time < due_time)
461  due_time = cs->T2_due_time;
462  if (cs->T1_due_time > current_time)
463  {
464  if (cs->T1_due_time < due_time)
465  due_time = cs->T1_due_time;
466  }
467  else
468  {
469  cs->T1_due_time = DBL_MAX;
470  address_info_t *address_list;
471  address_list = create_address_list (i);
472  cs->rebinding = 1;
475  address_list, 1);
476  vec_free (address_list);
477  }
478  }
479  else
480  {
481  cs->T2_due_time = DBL_MAX;
482  address_info_t *address_list;
483  address_list = create_address_list (i);
484  cs->rebinding = 1;
487  address_list, 1);
488  vec_free (address_list);
489  }
490  }
491  }
492  current_time = vlib_time_now (vm);
493  }
494  while (due_time < current_time);
495 
496  sleep_time = due_time - current_time;
497  }
498 
499  return 0;
500 }
501 
502 /* *INDENT-OFF* */
504  .function = dhcp6_client_cp_process,
505  .type = VLIB_NODE_TYPE_PROCESS,
506  .name = "dhcp6-client-cp-process",
507 };
508 /* *INDENT-ON* */
509 
510 static void
512 {
514  vlib_main_t *vm = rm->vlib_main;
515 
518 }
519 
520 static void
522 {
524  vlib_main_t *vm = rm->vlib_main;
525 
528 }
529 
530 static void
532 {
534  vlib_main_t *vm = rm->vlib_main;
535  vlib_node_t *node;
536 
537  node = vec_elt (vm->node_main.nodes, rm->node_index);
538 
539  vlib_node_set_state (vm, rm->node_index, VLIB_NODE_STATE_POLLING);
540  vlib_start_process (vm, node->runtime_index);
541 }
542 
543 static clib_error_t *
545  unformat_input_t * input,
546  vlib_cli_command_t * cmd)
547 {
549  clib_error_t *error = 0;
550  address_info_t *address_info;
551  f64 current_time = vlib_time_now (vm);
552 
553  /* *INDENT-OFF* */
554  pool_foreach (address_info, dm->address_pool,
555  ({
556  vlib_cli_output (vm, "address: %U, "
557  "preferred lifetime: %u, valid lifetime: %u "
558  "(%f remaining)",
559  format_ip6_address, &address_info->address,
560  address_info->preferred_lt, address_info->valid_lt,
561  address_info->due_time - current_time);
562  }));
563  /* *INDENT-ON* */
564 
565  return error;
566 }
567 
568 /* *INDENT-OFF* */
569 VLIB_CLI_COMMAND (dhcp6_addresses_show_command, static) = {
570  .path = "show dhcp6 addresses",
571  .short_help = "show dhcp6 addresses",
573 };
574 /* *INDENT-ON* */
575 
576 static clib_error_t *
578  unformat_input_t * input,
579  vlib_cli_command_t * cmd)
580 {
582  clib_error_t *error = 0;
583  client_state_t *cs;
584  f64 current_time = vlib_time_now (vm);
585  u8 *buf1 = 0;
586  u8 *buf2 = 0;
587  const char *rebinding;
588  u32 i;
589 
590  for (i = 0; i < vec_len (rm->client_state_by_sw_if_index); i++)
591  {
592  cs = &rm->client_state_by_sw_if_index[i];
593  if (cs->enabled)
594  {
595  vec_reset_length (buf1);
596  vec_reset_length (buf2);
597  if (cs->T1_due_time != DBL_MAX && cs->T1_due_time > current_time)
598  {
599  buf1 = format (buf1, "%u remaining",
600  (u32) round (cs->T1_due_time - current_time));
601  }
602  else
603  buf1 = format (buf1, "timeout");
604  if (cs->T2_due_time != DBL_MAX && cs->T2_due_time > current_time)
605  buf2 = format (buf2, "%u remaining",
606  (u32) round (cs->T2_due_time - current_time));
607  else
608  buf2 = format (buf2, "timeout");
609  if (cs->rebinding)
610  rebinding = ", REBINDING";
611  else
612  rebinding = "";
613  if (cs->T1)
614  vlib_cli_output (vm,
615  "sw_if_index: %u, T1: %u (%v), "
616  "T2: %u (%v), server index: %d%s", i,
617  cs->T1, buf1, cs->T2, buf2,
618  cs->server_index, rebinding);
619  else
620  vlib_cli_output (vm, "sw_if_index: %u%s", i, rebinding);
621  }
622  }
623 
624  vec_free (buf1);
625  vec_free (buf2);
626 
627  return error;
628 }
629 
630 /* *INDENT-OFF* */
631 VLIB_CLI_COMMAND (dhcp6_clients_show_command, static) = {
632  .path = "show dhcp6 clients",
633  .short_help = "show dhcp6 clients",
635 };
636 /* *INDENT-ON* */
637 
638 static int
640 {
642  vnet_main_t *vnm = rm->vnet_main;
643  vlib_main_t *vm = rm->vlib_main;
644  client_state_t *client_state;
645  client_state_t empty_config = { 0 };
646  address_info_t *address_info;
647  clib_error_t *error;
648 
649  if (!vnet_sw_interface_is_api_valid (vnm, sw_if_index))
650  {
651  clib_warning ("Invalid sw_if_index");
652  return 1;
653  }
654 
656  empty_config);
657  client_state = &rm->client_state_by_sw_if_index[sw_if_index];
658 
659  u8 old_enabled = client_state->enabled;
660  if (enable)
661  client_state->enabled = 1;
662  client_state->server_index = ~0;
663 
664  if (!old_enabled && enable)
665  {
666  rm->n_clients++;
667  if (rm->n_clients == 1)
668  {
669  enable_process ();
671  }
672 
673  ip6_enable (sw_if_index);
675  0, 1);
676  }
677  else if (old_enabled && !enable)
678  {
679  send_client_message_start_stop (sw_if_index, ~0, ~0, 0, 0);
680 
681  rm->n_clients--;
682  if (rm->n_clients == 0)
683  {
685  disable_process ();
686  }
687 
688  /* *INDENT-OFF* */
689  pool_foreach (address_info, rm->address_pool,
690  ({
691  if (address_info->sw_if_index == sw_if_index)
692  {
693  ASSERT (sw_if_index < vec_len (rm->client_state_by_sw_if_index) &&
694  rm->client_state_by_sw_if_index[sw_if_index].enabled);
695  client_state_t *client_state =
696  &rm->client_state_by_sw_if_index[sw_if_index];
697  send_client_message_start_stop (sw_if_index,
698  client_state->server_index,
699  DHCPV6_MSG_RELEASE, address_info,
700  1);
701  error = ip6_add_del_interface_address (vm, sw_if_index,
702  &address_info->address,
703  64, 1);
704  if (error)
705  clib_warning ("Failed to delete interface address");
706  pool_put (rm->address_pool, address_info);
707  }
708  }));
709  /* *INDENT-ON* */
710  }
711 
712  if (!enable)
713  client_state->enabled = 0;
714 
715  return 0;
716 }
717 
718 static clib_error_t *
720  unformat_input_t * input,
721  vlib_cli_command_t * cmd)
722 {
724  vnet_main_t *vnm = rm->vnet_main;
725  clib_error_t *error = 0;
726  u32 sw_if_index = ~0;
727  u8 enable = 1;
728  unformat_input_t _line_input, *line_input = &_line_input;
729 
730  if (!unformat_user (input, unformat_line_input, line_input))
731  return 0;
732 
733  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
734  {
735  if (unformat
736  (line_input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
737  ;
738  else if (unformat (line_input, "disable"))
739  enable = 0;
740  else
741  {
742  error = clib_error_return (0, "unexpected input `%U'",
743  format_unformat_error, line_input);
744  goto done;
745  }
746  }
747 
748  unformat_free (line_input);
749 
750  if (sw_if_index != ~0)
751  {
752  if (dhcp6_client_enable_disable (sw_if_index, enable) != 0)
753  error = clib_error_return (0, "Invalid sw_if_index");
754  }
755  else
756  error = clib_error_return (0, "Missing sw_if_index");
757 
758 done:
759  return error;
760 }
761 
762 /*?
763  * This command is used to enable/disable DHCPv6 client
764  * on particular interface.
765  *
766  * @cliexpar
767  * @parblock
768  * Example of how to enable DHCPv6 client:
769  * @cliexcmd{dhcp6 client GigabitEthernet2/0/0}
770  * Example of how to disable DHCPv6 client:
771  * @cliexcmd{dhcp6 client GigabitEthernet2/0/0 disable}
772  * @endparblock
773 ?*/
774 /* *INDENT-OFF* */
775 VLIB_CLI_COMMAND (dhcp6_client_enable_disable_command, static) = {
776  .path = "dhcp6 client",
777  .short_help = "dhcp6 client <interface> [disable]",
779 };
780 /* *INDENT-ON* */
781 
782 static void
785 {
786  vl_api_dhcp6_client_enable_disable_reply_t *rmp;
788  int rv = 0;
789 
791 
792  sw_if_index = ntohl (mp->sw_if_index);
793 
794  rv = dhcp6_client_enable_disable (sw_if_index, mp->enable);
795 
797 
798  REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
799 }
800 
801 #define vl_msg_name_crc_list
802 #include <vnet/dhcp/dhcp6_ia_na_client_cp.api.h>
803 #undef vl_msg_name_crc_list
804 
805 static void
807 {
808 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
809  foreach_vl_msg_name_crc_dhcp6_ia_na_client_cp;
810 #undef _
811 }
812 
813 static clib_error_t *
815 {
817  api_main_t *am = &api_main;
818 
819  rm->vlib_main = vm;
820  rm->vnet_main = vnet_get_main ();
821  rm->api_main = am;
823 
824 #define _(N,n) \
825  vl_msg_api_set_handlers(VL_API_##N, #n, \
826  vl_api_##n##_t_handler, \
827  vl_noop_handler, \
828  vl_api_##n##_t_endian, \
829  vl_api_##n##_t_print, \
830  sizeof(vl_api_##n##_t), 0/* do NOT trace! */);
832 #undef _
833 
834  /*
835  * Set up the (msg_name, crc, message-id) table
836  */
838 
839  return 0;
840 }
841 
843 
844 /*
845  * fd.io coding-style-patch-verification: ON
846  *
847  * Local Variables:
848  * eval: (c-set-style "gnu")
849  * End:
850  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
static int dhcp6_client_enable_disable(u32 sw_if_index, u8 enable)
typedef address
Definition: ip_types.api:83
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:46
u64 as_u64[2]
Definition: ip6_packet.h:51
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:279
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:989
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
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:147
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
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
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:699
#define clib_error_return(e, args...)
Definition: error.h:99
vl_api_dhcp6_address_info_t addresses[n_addresses]
Definition: dhcp.api:396
unsigned int u32
Definition: types.h:88
static void interrupt_process(void)
unformat_function_t unformat_line_input
Definition: format.h:283
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:203
#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:145
u32 runtime_index
Definition: node.h:283
vlib_main_t * vm
Definition: buffer.c:323
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:161
signed int i32
Definition: types.h:77
#define ASSERT(truth)
Struct representing DHCPv6 address.
Definition: dhcp.api:231
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:326
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:383
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:158
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:163
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:289
#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:1587
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:772
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
#define VALIDATE_SW_IF_INDEX(mp)