dhcpv6_client_fsm.c
Go to the documentation of this file.
1 /**
2  * @file dhcpv6_client_fsm.c
3  * @brief DHCPv6 client finite state machine
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2026 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.6.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL DHCPV6_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "ipv6/ipv6.h"
37 #include "ipv6/ipv6_misc.h"
38 #include "dhcpv6/dhcpv6_client.h"
41 #include "dhcpv6/dhcpv6_common.h"
42 #include "dhcpv6/dhcpv6_debug.h"
43 #include "debug.h"
44 
45 //Check TCP/IP stack configuration
46 #if (IPV6_SUPPORT == ENABLED && DHCPV6_CLIENT_SUPPORT == ENABLED)
47 
48 
49 /**
50  * @brief INIT state
51  *
52  * This is the initialization state, where a client begins the process of
53  * acquiring a lease. It also returns here when a lease ends, or when a
54  * lease negotiation fails
55  *
56  * @param[in] context Pointer to the DHCPv6 client context
57  **/
58 
60 {
61  systime_t delay;
62  NetInterface *interface;
63 
64  //Point to the underlying network interface
65  interface = context->interface;
66 
67  //Check whether the DHCPv6 client is running
68  if(context->running)
69  {
70  //Wait for the link to be up before starting DHCPv6 configuration
71  if(interface->linkState)
72  {
73  //Make sure that a valid link-local address has been assigned to the
74  //interface
76  {
77  //Flush the list of IPv6 addresses from the client's IA
79 
80  //The first Solicit message from the client on the interface must be
81  //delayed by a random amount of time between 0 and SOL_MAX_DELAY
82  delay = netGenerateRandRange(context->netContext, 0,
84 
85  //Record the time at which the client started
86  //the address acquisition process
87  context->configStartTime = osGetSystemTime();
88  //Clear flag
89  context->timeoutEventDone = FALSE;
90 
91  //Switch to the SOLICIT state
93  }
94  }
95  }
96 }
97 
98 
99 /**
100  * @brief SOLICIT state
101  *
102  * A client uses the Solicit message to discover DHCPv6 servers
103  *
104  * @param[in] context Pointer to the DHCPv6 client context
105  **/
106 
108 {
109  systime_t time;
110 
111  //Get current time
112  time = osGetSystemTime();
113 
114  //Check current time
115  if(timeCompare(time, context->timestamp + context->timeout) >= 0)
116  {
117  //Check retransmission counter
118  if(context->retransmitCount == 0)
119  {
120  //Reset server preference value
121  context->serverPreference = -1;
122 
123  //Generate a 24-bit transaction ID
124  context->transactionId = netGenerateRand(context->netContext) &
125  0x00FFFFFF;
126 
127  //Send a Solicit message
129 
130  //Save the time at which the message was sent
131  context->exchangeStartTime = time;
132  context->timestamp = time;
133 
134  //If the client is waiting for an Advertise message, the first RT must
135  //be selected to be strictly greater than IRT
136  context->timeout = netGenerateRandRange(context->netContext,
139 
140  //Increment retransmission counter
141  context->retransmitCount++;
142  }
143  else
144  {
145  //Check whether a valid Advertise message has been received
146  if(context->serverPreference >= 0)
147  {
148  //Continue configuration procedure
150  }
151  else
152  {
153  //Send a Solicit message
155 
156  //Save the time at which the message was sent
157  context->timestamp = time;
158 
159  //The RT is doubled for each subsequent retransmission
160  context->timeout = netGenerateRandRange(context->netContext,
161  context->timeout * 2 - context->timeout / 10,
162  context->timeout * 2 + context->timeout / 10);
163 
164  //MRT specifies an upper bound on the value of RT
165  if(context->timeout > DHCPV6_CLIENT_SOL_MAX_RT)
166  {
167  //Each computation of a new RT includes a randomization factor
168  context->timeout = netGenerateRandRange(context->netContext,
171  }
172 
173  //Increment retransmission counter
174  context->retransmitCount++;
175  }
176  }
177  }
178 
179  //Manage DHCPv6 configuration timeout
180  dhcpv6ClientCheckTimeout(context);
181 }
182 
183 
184 /**
185  * @brief REQUEST state
186  *
187  * The client uses a Request message to populate IAs with addresses and obtain
188  * other configuration information. The client includes one or more more IA
189  * options in the Request message. The server then returns addresses and other
190  * information about the IAs to the client in IA options in a Reply message
191  *
192  * @param[in] context Pointer to the DHCPv6 client context
193  **/
194 
196 {
197  systime_t time;
198 
199  //Get current time
200  time = osGetSystemTime();
201 
202  //Check current time
203  if(timeCompare(time, context->timestamp + context->timeout) >= 0)
204  {
205  //Check retransmission counter
206  if(context->retransmitCount == 0)
207  {
208  //Generate a 24-bit transaction ID
209  context->transactionId = netGenerateRand(context->netContext) &
210  0x00FFFFFF;
211 
212  //Send a Request message
214 
215  //Save the time at which the message was sent
216  context->exchangeStartTime = time;
217  context->timestamp = time;
218 
219  //Initial retransmission timeout
220  context->timeout = netGenerateRandRange(context->netContext,
223 
224  //Increment retransmission counter
225  context->retransmitCount++;
226  }
227  else if(context->retransmitCount < DHCPV6_CLIENT_REQ_MAX_RC)
228  {
229  //Send a Request message
231 
232  //Save the time at which the message was sent
233  context->timestamp = time;
234 
235  //The RT is doubled for each subsequent retransmission
236  context->timeout = netGenerateRandRange(context->netContext,
237  context->timeout * 2 - context->timeout / 10,
238  context->timeout * 2 + context->timeout / 10);
239 
240  //MRT specifies an upper bound on the value of RT
241  if(context->timeout > DHCPV6_CLIENT_REQ_MAX_RT)
242  {
243  //Each computation of a new RT includes a randomization factor
244  context->timeout = netGenerateRandRange(context->netContext,
247  }
248 
249  //Increment retransmission counter
250  context->retransmitCount++;
251  }
252  else
253  {
254  //If the client does not receive a response within a reasonable period
255  //of time, then it restarts the initialization procedure
257  }
258  }
259 
260  //Manage DHCPv6 configuration timeout
261  dhcpv6ClientCheckTimeout(context);
262 }
263 
264 
265 /**
266  * @brief INIT-CONFIRM state
267  *
268  * When a client that already has a valid lease starts up after a power-down
269  * or reboot, it starts here instead of the INIT state
270  *
271  * @param[in] context Pointer to the DHCPv6 client context
272  **/
273 
275 {
276  systime_t delay;
277  NetInterface *interface;
278 
279  //Point to the underlying network interface
280  interface = context->interface;
281 
282  //Check whether the DHCPv6 client is running
283  if(context->running)
284  {
285  //Wait for the link to be up before starting DHCPv6 configuration
286  if(interface->linkState)
287  {
288  //Make sure that a valid link-local address has been assigned to the
289  //interface
291  {
292  //The first Confirm message from the client on the interface must be
293  //delayed by a random amount of time between 0 and CNF_MAX_DELAY
294  delay = netGenerateRandRange(context->netContext, 0,
296 
297  //Record the time at which the client started the address
298  //acquisition process
299  context->configStartTime = osGetSystemTime();
300  //Clear flag
301  context->timeoutEventDone = FALSE;
302 
303  //Switch to the CONFIRM state
305  }
306  }
307  }
308 }
309 
310 
311 /**
312  * @brief CONFIRM state
313  *
314  * Whenever a client may have moved to a new link, the prefixes from the
315  * addresses assigned to the interfaces on that link may no longer be
316  * appropriate for the link to which the client is attached. In such the
317  * client must initiate a Confirm/Reply message exchange
318  *
319  * @param[in] context Pointer to the DHCPv6 client context
320  **/
321 
323 {
324  systime_t time;
325 
326  //Get current time
327  time = osGetSystemTime();
328 
329  //Check current time
330  if(timeCompare(time, context->timestamp + context->timeout) >= 0)
331  {
332  //Check retransmission counter
333  if(context->retransmitCount == 0)
334  {
335  //Generate a 24-bit transaction ID
336  context->transactionId = netGenerateRand(context->netContext) &
337  0x00FFFFFF;
338 
339  //Send a Confirm message
341 
342  //Save the time at which the client sent the first message
343  context->exchangeStartTime = time;
344  context->timestamp = time;
345 
346  //Initial retransmission timeout
347  context->timeout = netGenerateRandRange(context->netContext,
350 
351  //Increment retransmission counter
352  context->retransmitCount++;
353  }
354  else
355  {
356  //Send a Confirm message
358 
359  //Save the time at which the message was sent
360  context->timestamp = time;
361 
362  //The RT is doubled for each subsequent retransmission
363  context->timeout = netGenerateRandRange(context->netContext,
364  context->timeout * 2 - context->timeout / 10,
365  context->timeout * 2 + context->timeout / 10);
366 
367  //MRT specifies an upper bound on the value of RT
368  if(context->timeout > DHCPV6_CLIENT_CNF_MAX_RT)
369  {
370  //Each computation of a new RT includes a randomization factor
371  context->timeout = netGenerateRandRange(context->netContext,
374  }
375 
376  //Increment retransmission counter
377  context->retransmitCount++;
378  }
379  }
380  else
381  {
382  //Check retransmission counter
383  if(context->retransmitCount > 0)
384  {
385  //The message exchange fails once MRD seconds have elapsed since the
386  //client first transmitted the message
387  if(timeCompare(time, context->exchangeStartTime + DHCPV6_CLIENT_CNF_MAX_RD) >= 0)
388  {
389  //If the client receives no responses before the message transmission
390  //process terminates, the client should continue to use any IP
391  //addresses using the last known lifetimes for those addresses
393  }
394  }
395  }
396 
397  //Manage DHCPv6 configuration timeout
398  dhcpv6ClientCheckTimeout(context);
399 }
400 
401 
402 /**
403  * @brief DAD state
404  *
405  * The client perform duplicate address detection on each of the addresses
406  * in any IAs it receives in the Reply message before using that address for
407  * traffic
408  *
409  * @param[in] context Pointer to the DHCPv6 client context
410  **/
411 
413 {
414  uint_t i;
415  Ipv6AddrState state;
416  Dhcpv6ClientAddrEntry *entry;
417 
418  //Loop through the IPv6 addresses recorded by the DHCPv6 client
419  for(i = 0; i < DHCPV6_CLIENT_ADDR_LIST_SIZE; i++)
420  {
421  //Point to the current entry
422  entry = &context->ia.addrList[i];
423 
424  //Check the IPv6 address is a tentative address?
425  if(entry->validLifetime > 0)
426  {
427  //Get the state of the current IPv6 address
428  state = ipv6GetAddrState(context->interface, &entry->addr);
429 
430  //Duplicate Address Detection in progress?
431  if(state == IPV6_ADDR_STATE_TENTATIVE)
432  {
433  //Exit immediately
434  return;
435  }
436  //Duplicate Address Detection failed?
437  else if(state == IPV6_ADDR_STATE_INVALID)
438  {
439  //Switch to the DECLINE state
441  //Exit immediately
442  return;
443  }
444  }
445  }
446 
447  //Dump current DHCPv6 configuration for debugging purpose
448  dhcpv6ClientDumpConfig(context);
449  //Switch to the BOUND state
451 }
452 
453 
454 /**
455  * @brief BOUND state
456  *
457  * Client has a valid lease and is in its normal operating state
458  *
459  * @param[in] context Pointer to the DHCPv6 client context
460  **/
461 
463 {
464  systime_t t1;
465  systime_t time;
466 
467  //Get current time
468  time = osGetSystemTime();
469 
470  //A client will never attempt to extend the lifetime of any address in an
471  //IA with T1 set to 0xffffffff
472  if(context->ia.t1 != DHCPV6_INFINITE_TIME)
473  {
474  //Convert T1 to milliseconds
475  if(context->ia.t1 < (MAX_DELAY / 1000))
476  {
477  t1 = context->ia.t1 * 1000;
478  }
479  else
480  {
481  t1 = MAX_DELAY;
482  }
483 
484  //Check the time elapsed since the lease was obtained
485  if(timeCompare(time, context->leaseStartTime + t1) >= 0)
486  {
487  //Record the time at which the client started the address renewal
488  //process
489  context->configStartTime = time;
490 
491  //Enter the RENEW state
493  }
494  }
495 }
496 
497 
498 /**
499  * @brief RENEW state
500  *
501  * The client sends a Renew message to the server that originally provided
502  * the client's addresses and configuration parameters to extend the lifetimes
503  * on the addresses assigned to the client and to update other configuration
504  * parameters
505  *
506  * @param[in] context Pointer to the DHCPv6 client context
507  **/
508 
510 {
511  systime_t t2;
512  systime_t time;
513 
514  //Get current time
515  time = osGetSystemTime();
516 
517  //Check current time
518  if(timeCompare(time, context->timestamp + context->timeout) >= 0)
519  {
520  //Check retransmission counter
521  if(context->retransmitCount == 0)
522  {
523  //Generate a 24-bit transaction ID
524  context->transactionId = netGenerateRand(context->netContext) &
525  0x00FFFFFF;
526 
527  //Send a Renew message
529 
530  //Save the time at which the message was sent
531  context->exchangeStartTime = time;
532  context->timestamp = time;
533 
534  //Initial retransmission timeout
535  context->timeout = netGenerateRandRange(context->netContext,
538  }
539  else
540  {
541  //Send a Renew message
543 
544  //Save the time at which the message was sent
545  context->timestamp = time;
546 
547  //The RT is doubled for each subsequent retransmission
548  context->timeout = netGenerateRandRange(context->netContext,
549  context->timeout * 2 - context->timeout / 10,
550  context->timeout * 2 + context->timeout / 10);
551 
552  //MRT specifies an upper bound on the value of RT
553  if(context->timeout > DHCPV6_CLIENT_REN_MAX_RT)
554  {
555  //Each computation of a new RT includes a randomization factor
556  context->timeout = netGenerateRandRange(context->netContext,
559  }
560  }
561 
562  //Increment retransmission counter
563  context->retransmitCount++;
564  }
565  else
566  {
567  //A client will never attempt to use a Rebind message to locate a
568  //different server to extend the lifetime of any address in an IA
569  //with T2 set to 0xffffffff
570  if(context->ia.t2 != DHCPV6_INFINITE_TIME)
571  {
572  //Convert T2 to milliseconds
573  if(context->ia.t2 < (MAX_DELAY / 1000))
574  {
575  t2 = context->ia.t2 * 1000;
576  }
577  else
578  {
579  t2 = MAX_DELAY;
580  }
581 
582  //Check whether T2 timer has expired
583  if(timeCompare(time, context->leaseStartTime + t2) >= 0)
584  {
585  //Switch to the REBIND state
587  }
588  }
589  }
590 }
591 
592 
593 /**
594  * @brief REBIND state
595  *
596  * The client sends a Rebind message to any available server to extend the
597  * lifetimes on the addresses assigned to the client and to update other
598  * configuration parameters. This message is sent after a client receives no
599  * response to a Renew message
600  *
601  * @param[in] context Pointer to the DHCPv6 client context
602  **/
603 
605 {
606  uint_t i;
607  systime_t time;
608  NetInterface *interface;
609  Dhcpv6ClientAddrEntry *entry;
610 
611  //Point to the underlying network interface
612  interface = context->interface;
613 
614  //Get current time
615  time = osGetSystemTime();
616 
617  //Check current time
618  if(timeCompare(time, context->timestamp + context->timeout) >= 0)
619  {
620  //Check retransmission counter
621  if(context->retransmitCount == 0)
622  {
623  //Generate a 24-bit transaction ID
624  context->transactionId = netGenerateRand(context->netContext) &
625  0x00FFFFFF;
626 
627  //Send a Rebind message
629 
630  //Save the time at which the message was sent
631  context->exchangeStartTime = time;
632  context->timestamp = time;
633 
634  //Initial retransmission timeout
635  context->timeout = netGenerateRandRange(context->netContext,
638  }
639  else
640  {
641  //Send a Rebind message
643 
644  //Save the time at which the message was sent
645  context->timestamp = time;
646 
647  //The RT is doubled for each subsequent retransmission
648  context->timeout = netGenerateRandRange(context->netContext,
649  context->timeout * 2 - context->timeout / 10,
650  context->timeout * 2 + context->timeout / 10);
651 
652  //MRT specifies an upper bound on the value of RT
653  if(context->timeout > DHCPV6_CLIENT_REB_MAX_RT)
654  {
655  //Each computation of a new RT includes a randomization factor
656  context->timeout = netGenerateRandRange(context->netContext,
659  }
660  }
661 
662  //Increment retransmission counter
663  context->retransmitCount++;
664  }
665  else
666  {
667  //Loop through the IPv6 addresses recorded by the DHCPv6 client
668  for(i = 0; i < DHCPV6_CLIENT_ADDR_LIST_SIZE; i++)
669  {
670  //Point to the current entry
671  entry = &context->ia.addrList[i];
672 
673  //Valid IPv6 address?
674  if(entry->validLifetime > 0)
675  {
676  //Check whether the valid lifetime has expired
677  if(ipv6GetAddrState(interface, &entry->addr) == IPV6_ADDR_STATE_INVALID)
678  {
679  //Restart DHCPv6 configuration
681  }
682  }
683  }
684  }
685 }
686 
687 
688 /**
689  * @brief RELEASE state
690  *
691  * To release one or more addresses, a client sends a Release message to the
692  * server
693  *
694  * @param[in] context Pointer to the DHCPv6 client context
695  **/
696 
698 {
699  systime_t time;
700 
701  //Get current time
702  time = osGetSystemTime();
703 
704  //Check current time
705  if(timeCompare(time, context->timestamp + context->timeout) >= 0)
706  {
707  //Check retransmission counter
708  if(context->retransmitCount == 0)
709  {
710  //Generate a 24-bit transaction ID
711  context->transactionId = netGenerateRand(context->netContext) &
712  0x00FFFFFF;
713 
714  //Send a Release message
716 
717  //Save the time at which the message was sent
718  context->exchangeStartTime = time;
719  context->timestamp = time;
720 
721  //Initial retransmission timeout
722  context->timeout = netGenerateRandRange(context->netContext,
725 
726  //Increment retransmission counter
727  context->retransmitCount++;
728  }
729  else if(context->retransmitCount < DHCPV6_CLIENT_REL_MAX_RC)
730  {
731  //Send a Release message
733 
734  //Save the time at which the message was sent
735  context->timestamp = time;
736 
737  //The RT is doubled for each subsequent retransmission
738  context->timeout = netGenerateRandRange(context->netContext,
739  context->timeout * 2 - context->timeout / 10,
740  context->timeout * 2 + context->timeout / 10);
741 
742  //Increment retransmission counter
743  context->retransmitCount++;
744  }
745  else
746  {
747  //Implementations should retransmit one or more times, but may choose
748  //to terminate the retransmission procedure early
749  context->running = FALSE;
750 
751  //Reinitialize state machine
753  }
754  }
755 }
756 
757 
758 /**
759  * @brief DECLINE state
760  *
761  * If a client detects that one or more addresses assigned to it by a server
762  * are already in use by another node, the client sends a Decline message to
763  * the server to inform it that the address is suspect
764  *
765  * @param[in] context Pointer to the DHCPv6 client context
766  **/
767 
769 {
770  systime_t time;
771 
772  //Get current time
773  time = osGetSystemTime();
774 
775  //Check current time
776  if(timeCompare(time, context->timestamp + context->timeout) >= 0)
777  {
778  //Check retransmission counter
779  if(context->retransmitCount == 0)
780  {
781  //Generate a 24-bit transaction ID
782  context->transactionId = netGenerateRand(context->netContext) &
783  0x00FFFFFF;
784 
785  //Send a Decline message
787 
788  //Save the time at which the message was sent
789  context->exchangeStartTime = time;
790  context->timestamp = time;
791 
792  //Initial retransmission timeout
793  context->timeout = netGenerateRandRange(context->netContext,
796 
797  //Increment retransmission counter
798  context->retransmitCount++;
799  }
800  else if(context->retransmitCount < DHCPV6_CLIENT_DEC_MAX_RC)
801  {
802  //Send a Decline message
804 
805  //Save the time at which the message was sent
806  context->timestamp = time;
807 
808  //The RT is doubled for each subsequent retransmission
809  context->timeout = netGenerateRandRange(context->netContext,
810  context->timeout * 2 - context->timeout / 10,
811  context->timeout * 2 + context->timeout / 10);
812 
813  //Increment retransmission counter
814  context->retransmitCount++;
815  }
816  else
817  {
818  //If the client does not receive a response within a reasonable period
819  //of time, then it restarts the initialization procedure
821  }
822  }
823 }
824 
825 #endif
@ IPV6_ADDR_STATE_TENTATIVE
An address whose uniqueness on a link is being verified.
Definition: ipv6.h:194
IPv6 (Internet Protocol Version 6)
void dhcpv6ClientStateInitConfirm(Dhcpv6ClientContext *context)
INIT-CONFIRM state.
@ DHCPV6_MSG_TYPE_DECLINE
Definition: dhcpv6_common.h:98
#define DHCPV6_CLIENT_REN_MAX_RT
@ DHCPV6_MSG_TYPE_SOLICIT
Definition: dhcpv6_common.h:90
#define DHCPV6_CLIENT_REL_TIMEOUT
#define DHCPV6_CLIENT_REB_MAX_RT
@ DHCPV6_STATE_REQUEST
uint32_t netGenerateRand(NetContext *context)
Generate a random 32-bit value.
Definition: net_misc.c:956
Definitions common to DHCPv6 client, server and relay agent.
Ipv6AddrState ipv6GetAddrState(NetInterface *interface, const Ipv6Addr *addr)
Get the state of the specified IPv6 address.
Definition: ipv6_misc.c:76
@ DHCPV6_MSG_TYPE_REBIND
Definition: dhcpv6_common.h:95
void dhcpv6ClientStateDecline(Dhcpv6ClientContext *context)
DECLINE state.
@ DHCPV6_STATE_REBIND
#define DHCPV6_INFINITE_TIME
Definition: dhcpv6_common.h:53
void dhcpv6ClientCheckTimeout(Dhcpv6ClientContext *context)
Manage DHCPv6 configuration timeout.
void dhcpv6ClientFlushAddrList(Dhcpv6ClientContext *context)
Flush the list of IPv6 addresses from the IA.
@ DHCPV6_STATE_INIT
#define DHCPV6_CLIENT_CNF_MAX_DELAY
#define DHCPV6_CLIENT_REN_TIMEOUT
#define DHCPV6_CLIENT_ADDR_LIST_SIZE
Definition: dhcpv6_client.h:54
Helper functions for DHCPv6 client.
#define timeCompare(t1, t2)
Definition: os_port.h:40
@ IPV6_ADDR_STATE_INVALID
An address that is not assigned to any interface.
Definition: ipv6.h:193
Ipv6Addr addr
IPv6 address.
void dhcpv6ClientStateInit(Dhcpv6ClientContext *context)
INIT state.
#define DHCPV6_CLIENT_DEC_TIMEOUT
#define FALSE
Definition: os_port.h:46
#define DHCPV6_CLIENT_SOL_MAX_RT
Definition: dhcpv6_client.h:75
void dhcpv6ClientDumpConfig(Dhcpv6ClientContext *context)
Dump DHCPv6 configuration for debugging purpose.
#define DHCPV6_CLIENT_CNF_MAX_RD
#define DHCPV6_CLIENT_DEC_MAX_RC
Ipv6AddrState
IPv6 address state.
Definition: ipv6.h:192
@ DHCPV6_STATE_SOLICIT
uint32_t validLifetime
Valid lifetime.
DHCPv6 client (Dynamic Host Configuration Protocol for IPv6)
@ DHCPV6_MSG_TYPE_RELEASE
Definition: dhcpv6_common.h:97
IA address entry.
#define NetInterface
Definition: net.h:40
void dhcpv6ClientStateRenew(Dhcpv6ClientContext *context)
RENEW state.
uint32_t netGenerateRandRange(NetContext *context, uint32_t min, uint32_t max)
Generate a random value in the specified range.
Definition: net_misc.c:983
Helper functions for IPv6.
#define Dhcpv6ClientContext
@ DHCPV6_MSG_TYPE_RENEW
Definition: dhcpv6_common.h:94
uint32_t t2
void dhcpv6ClientStateDad(Dhcpv6ClientContext *context)
DAD state.
void dhcpv6ClientStateRequest(Dhcpv6ClientContext *context)
REQUEST state.
@ DHCPV6_STATE_BOUND
#define DHCPV6_CLIENT_CNF_TIMEOUT
void dhcpv6ClientStateRebind(Dhcpv6ClientContext *context)
REBIND state.
error_t dhcpv6ClientSendMessage(Dhcpv6ClientContext *context, Dhcpv6MessageType type)
Send Solicit message.
uint32_t systime_t
System time.
@ DHCPV6_STATE_RENEW
uint32_t time
#define DHCPV6_CLIENT_REQ_MAX_RT
Definition: dhcpv6_client.h:89
void dhcpv6ClientStateConfirm(Dhcpv6ClientContext *context)
CONFIRM state.
uint32_t t1
DHCPv6 client finite state machine.
@ DHCPV6_STATE_DECLINE
Ipv6AddrState ipv6GetLinkLocalAddrState(NetInterface *interface)
Get the state of the link-local address.
Definition: ipv6.c:330
void dhcpv6ClientStateSolicit(Dhcpv6ClientContext *context)
SOLICIT state.
@ DHCPV6_STATE_CONFIRM
@ DHCPV6_MSG_TYPE_CONFIRM
Definition: dhcpv6_common.h:93
#define DHCPV6_CLIENT_REB_TIMEOUT
void dhcpv6ClientStateRelease(Dhcpv6ClientContext *context)
RELEASE state.
void dhcpv6ClientStateBound(Dhcpv6ClientContext *context)
BOUND state.
#define DHCPV6_CLIENT_SOL_MAX_DELAY
Definition: dhcpv6_client.h:61
#define MAX_DELAY
Definition: os_port.h:77
#define DHCPV6_CLIENT_REL_MAX_RC
@ IPV6_ADDR_STATE_PREFERRED
An address assigned to an interface whose use is unrestricted.
Definition: ipv6.h:195
#define DHCPV6_CLIENT_REQ_TIMEOUT
Definition: dhcpv6_client.h:82
unsigned int uint_t
Definition: compiler_port.h:57
TCP/IP stack core.
#define DHCPV6_CLIENT_CNF_MAX_RT
void dhcpv6ClientChangeState(Dhcpv6ClientContext *context, Dhcpv6State newState, systime_t delay)
Update DHCPv6 FSM state.
Debugging facilities.
Data logging functions for debugging purpose (DHCPv6)
@ DHCPV6_MSG_TYPE_REQUEST
Definition: dhcpv6_common.h:92
#define DHCPV6_CLIENT_SOL_TIMEOUT
Definition: dhcpv6_client.h:68
systime_t osGetSystemTime(void)
Retrieve system time.
#define DHCPV6_CLIENT_REQ_MAX_RC
Definition: dhcpv6_client.h:96