io6Library
WIZnet Dual Stack TCP/IP Ethernet Controller Driver
dhcpv6.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
40 //
41 //*****************************************************************************
42 
43 #include "dhcpv6.h"
44 #include <stdlib.h>
45 #include <stdio.h>
46 #include <string.h>
47 
48 /* If you want to display debug & procssing message, Define _DHCP_DEBUG_ in dhcp.h */
49 #define _DHCP6_DEBUG_
50 #ifdef _DHCP6_DEBUG_
51 #include <stdio.h>
52 #endif
53 
54 /* DHCP6 state machine. */
55 #define STATE_DHCP6_INIT 0
56 #define STATE_DHCP6_SOLICIT 1
57 #define STATE_DHCP6_REQUEST 2
58 #define STATE_DHCP6_LEASED 3
59 #define STATE_DHCP6_REREQUEST 4
60 #define STATE_DHCP6_RELEASE 5
61 #define STATE_DHCP6_STOP 6
62 
63 /* DHCP6 message type */
64 #define DHCP6_SOLICIT 1
65 #define DHCP6_ADVERTISE 2
66 #define DHCP6_REQUEST 3
67 #define DHCP6_CONFIRM 4
68 #define DHCP6_RENEW 5
69 #define DHCP6_REBIND 6
70 #define DHCP6_REPLY 7
71 #define DHCP6_RELEASE 8
72 #define DHCP6_DECLINE 9
73 #define DHCP6_RECONFIGURE 10
74 #define DHCP6_INFO_REQUEST 11
75 
76 uint8_t DNS6_Address[16] = {
77  0,
78 };
79 //todo
80 
81 /*
82  * @brief DHCPv6 option (cf. RFC3315)
83  */
84 enum
85 {
88  OPT_IANA = 3,
89  OPT_IATA = 4,
95  OPT_AUTH = 11,
109  OPT_IAPD = 25,
117 };
118 
119 /*
120  * @brief DHCP message format
121  */
122 typedef struct
123 {
124  uint8_t *OPT;
125 } __attribute__((packed)) RIP_MSG;
126 
127 uint8_t DHCP_SOCKET; // Socket number for DHCP
128 
129 // Network information from DHCP Server
130 uint8_t DHCP_allocated_ip[16] = {
131  0,
132 }; // IP address from DHCPv6
133 int8_t dhcp_state = STATE_DHCP6_INIT; // DHCP state
134 int8_t dhcp_retry_count = 0;
135 
136 volatile uint32_t dhcp_tick_1s = 0; // unit 1 second
138 
139 uint32_t DHCP_XID; // Any number
140 
141 RIP_MSG pDHCPMSG; // Buffer pointer for DHCP processing
142 
144 
145 uint8_t DHCP_CHADDR[6]; // DHCP Client MAC address.
146 
147 /* send DISCOVER message to DHCP server */
148 void send_DHCP_SOLICIT(void);
149 uint8_t send_DHCP_REQUEST(void);
150 
151 /* check the timeout in DHCP process */
152 uint8_t check_DHCP_timeout(void);
153 
154 /* Intialize to timeout process. */
155 void reset_DHCP_timeout(void);
156 
157 uint16_t DUID_type_s;
159 uint8_t Time_s[4];
161 uint8_t Server_MAC[6];
162 uint8_t recv_IP[16];
163 uint32_t PreLifeTime;
164 uint32_t ValidLifeTime;
165 uint16_t code;
166 uint8_t IAID[4];
167 uint8_t T1[4];
168 uint8_t T2[4];
169 uint16_t iana_len;
170 uint16_t iaaddr_len;
171 uint16_t statuscode_len;
173 uint16_t serverid_len;
174 uint16_t clientid_len;
175 uint8_t status_msg[] = "";
176 
177 unsigned size;
178 unsigned num;
179 unsigned num2 = 0;
180 unsigned growby;
181 
188 void InitDhcpOption(unsigned asize, unsigned agrowby)
189 {
190  size = asize;
191  growby = agrowby;
192  num = 0;
193 }
194 
200 void AppendDhcpOption(uint8_t value)
201 {
202  uint32_t need;
203 
204  need = num + 1;
205  if (need > size)
206  {
207  size++;
208  }
209  pDHCPMSG.OPT[num] = value;
210  num++;
211 }
212 
218 void DumpDhcpOption(char *sMark)
219 {
220  unsigned i;
221  printf("%20s => size=%02d,num=%02d : ", sMark, size, num);
222  for (i = num2; i < num; i++)
223  {
224  printf("%.2x ", pDHCPMSG.OPT[i]);
225  }
226  printf("\r\n");
227  num2 = num;
228 }
229 
235 void DHCP_Option_Select(uint8_t option)
236 {
237  switch (option)
238  case OPT_CLIENTID:
239  case OPT_SERVERID:
240  case OPT_IANA:
241  case OPT_IATA:
242  case OPT_IAADDR:
243  case OPT_REQUEST:
244  case OPT_PREFERENCE:
245  case OPT_ELAPSED_TIME:
246  case OPT_RELAY_MSG:
247  case OPT_AUTH:
248  case OPT_UNICAST:
249  case OPT_STATUS_CODE:
250  case OPT_RAPID_COMMIT:
251  case OPT_USER_CLASS:
252  case OPT_VENDOR_CLASS:
253  case OPT_VENDOR_OPTS:
254  case OPT_INTERFACE_ID:
255  case OPT_RECONF_MSG:
256  case OPT_RECONF_ACCEPT:
257  case SIP_Server_DNL:
258  case SIP_Server_V6ADDR:
260  case Domain_Search_List:
261  case OPT_IAPD:
262  case OPT_IAPREFIX:
263  case OPT_NIS_SERVERS:
264  case OPT_NISP_SERVERS:
265  case OPT_NIS_DOMAIN_NAME:
267  case FQ_DOMAIN_NAME:
268  break;
269 }
270 
276 {
277  uint16_t j;
278  uint8_t ip[16];
279  uint8_t rip_msg_size;
280 
281  size = 0;
282  num = 0;
283  growby = 0;
284 
285  InitDhcpOption(34, 1);
286  DumpDhcpOption("option init");
287 
289  AppendDhcpOption((uint8_t)((DHCP_XID & 0x00FF0000) >> 16));
290  AppendDhcpOption((uint8_t)((DHCP_XID & 0x00FF0000) >> 8));
291  AppendDhcpOption((uint8_t)((DHCP_XID & 0x00FF0000) >> 0));
292  DumpDhcpOption("Type&XID");
293 
294  // Elapsed time
295  // AppendDhcpOption(0x00);AppendDhcpOption(OPT_ELAPSED_TIME);
296  // AppendDhcpOption(0x00);AppendDhcpOption(0x02);
297  // AppendDhcpOption(0x0c);AppendDhcpOption(0x1c);DumpDhcpOption("Option Elapsed Time");
298 
299  // Client Identifier
300  AppendDhcpOption(0x00);
302  AppendDhcpOption(0x00);
303  AppendDhcpOption(0x0a); //length
304  AppendDhcpOption(0x00);
305  AppendDhcpOption(0x03); //DUID_Type
306  AppendDhcpOption(0x00);
307  AppendDhcpOption(0x01); //Hard_Type
309  AppendDhcpOption(DHCP_CHADDR[1]); // MAC Addr
314  DumpDhcpOption("Option Client ID");
315 
316  // Identity Association for Non-temporary Address
317  AppendDhcpOption(0x00);
319  AppendDhcpOption(0x00);
320  AppendDhcpOption(0x0c); // length
321  AppendDhcpOption(0x03);
322  AppendDhcpOption(0x00); // IAID
323  AppendDhcpOption(0x08);
324  AppendDhcpOption(0xdc);
325  AppendDhcpOption(0x00);
326  AppendDhcpOption(0x00); // T1
327  AppendDhcpOption(0x00);
328  AppendDhcpOption(0x00);
329  AppendDhcpOption(0x00);
330  AppendDhcpOption(0x00); // T2
331  AppendDhcpOption(0x00);
332  AppendDhcpOption(0x00);
333  DumpDhcpOption("Option IANA");
334 
335  // Fully Qualified Domain Name
336  // AppendDhcpOption(0x00);AppendDhcpOption(39);
337  // AppendDhcpOption(0x00);AppendDhcpOption(0x06); // length
338  // AppendDhcpOption(0x00);AppendDhcpOption(0x04);
339  // AppendDhcpOption(0x44);AppendDhcpOption(0x45);
340  // AppendDhcpOption(0x44);AppendDhcpOption(0x59);DumpDhcpOption("Option FQ Domain Name");
341 
342  // Vendor Class
343  // AppendDhcpOption(0x00);AppendDhcpOption(16);
344  // AppendDhcpOption(0x00);AppendDhcpOption(0x0e); // length
345  // AppendDhcpOption(0x00);AppendDhcpOption(0x00);
346  // AppendDhcpOption(0x01);AppendDhcpOption(0x37);
347  // AppendDhcpOption(0x00);AppendDhcpOption(0x08);
348  // AppendDhcpOption(0x4d);AppendDhcpOption(0x53);
349  // AppendDhcpOption(0x46);AppendDhcpOption(0x54);
350  // AppendDhcpOption(0x20);AppendDhcpOption(0x35);
351  // AppendDhcpOption(0x2e);AppendDhcpOption(0x30);DumpDhcpOption("Option Vendor Class");
352 
353  // Option Request
354  // AppendDhcpOption(0x00);AppendDhcpOption(OPT_REQUEST);
355  // AppendDhcpOption(0x00);AppendDhcpOption(0x08); // length
356  // AppendDhcpOption(0x00);AppendDhcpOption(OPT_VENDOR_OPTS);
357  // AppendDhcpOption(0x00);AppendDhcpOption(DNS_RecursiveNameServer);
358  // AppendDhcpOption(0x00);AppendDhcpOption(Domain_Search_List);
359  // AppendDhcpOption(0x00);AppendDhcpOption(FQ_DOMAIN_NAME);DumpDhcpOption("Option Request");
360 
361  // send broadcasting packet
362  ip[0] = 0xff;
363  ip[1] = 0x02;
364 
365  for (j = 2; j < 13; j++)
366  ip[j] = 0x00;
367 
368  ip[13] = 0x01;
369  ip[14] = 0x00;
370  ip[15] = 0x02;
371 
372  rip_msg_size = size;
373 
374 #ifdef _DHCP_DEBUG_
375  printf("> Send DHCP_DISCOVER\r\n");
376 #endif
377 
378  sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG.OPT, rip_msg_size, ip, DHCP_SERVER_PORT, 16);
379 
380 #ifdef _DHCP_DEBUG_
381  printf("> %d, %d\r\n", ret, rip_msg_size);
382 #endif
383 
384  //return ret
385 }
386 
392 uint8_t send_DHCP_REQUEST(void)
393 {
394  //uint16_t i;
395  uint16_t j;
396  uint8_t ip[16];
397  uint8_t rip_msg_size;
398  uint8_t ret = 1;
399 
400  size = 0;
401  num = 0;
402  growby = 0;
403 
404  if (iana_len == 0)
405  {
406  return 9;
407  }
408  printf("req : %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x \r\n", recv_IP[0], recv_IP[1], recv_IP[2], recv_IP[3], recv_IP[4], recv_IP[5], recv_IP[6], recv_IP[7], recv_IP[8], recv_IP[9], recv_IP[10], recv_IP[11], recv_IP[12], recv_IP[13], recv_IP[14], recv_IP[15]);
409 
410  InitDhcpOption(60, 1);
411  DumpDhcpOption("option init");
412 
414  AppendDhcpOption((uint8_t)((DHCP_XID & 0x00FF0000) >> 16));
415  AppendDhcpOption((uint8_t)((DHCP_XID & 0x0000FF00) >> 8));
416  AppendDhcpOption((uint8_t)((DHCP_XID & 0x000000FF) >> 0));
417  DumpDhcpOption("Type&XID");
418 
419  // Elapsed time
420  //AppendDhcpOption(0x00);AppendDhcpOption(OPT_ELAPSED_TIME);
421  //AppendDhcpOption(0x00);AppendDhcpOption(0x02);
422  //AppendDhcpOption(0x0c);AppendDhcpOption(0x1c);DumpDhcpOption("Option Elapsed Time");
423 
424  // Identity Association for Non-temporary Address
425  AppendDhcpOption(0x00);
427  AppendDhcpOption((uint8_t)(iana_len >> 8));
428  AppendDhcpOption((uint8_t)iana_len); // length
430  AppendDhcpOption(IAID[1]); // IAID
433  AppendDhcpOption(T1[0]);
434  AppendDhcpOption(T1[1]); // T1
435  AppendDhcpOption(T1[2]);
436  AppendDhcpOption(T1[3]);
437  AppendDhcpOption(T2[0]);
438  AppendDhcpOption(T2[1]); // T2
439  AppendDhcpOption(T2[2]);
440  AppendDhcpOption(T2[3]);
441  DumpDhcpOption("Option IANA");
442 
443  // IA Address
444  AppendDhcpOption(0x00);
446  AppendDhcpOption((uint8_t)(iaaddr_len >> 8));
447  AppendDhcpOption((uint8_t)iaaddr_len); // length
449  AppendDhcpOption(recv_IP[1]); // IP
464  AppendDhcpOption((uint8_t)(PreLifeTime >> 24));
465  AppendDhcpOption((uint8_t)(PreLifeTime >> 16));
466  AppendDhcpOption((uint8_t)(PreLifeTime >> 8));
467  AppendDhcpOption((uint8_t)PreLifeTime);
468  AppendDhcpOption((uint8_t)(ValidLifeTime >> 24));
469  AppendDhcpOption((uint8_t)(ValidLifeTime >> 16));
470  AppendDhcpOption((uint8_t)(ValidLifeTime >> 8));
472  DumpDhcpOption("Option IA_addr");
473 
474  // Status code
475 #if 0
476  // 20190318
477  AppendDhcpOption(0x00);AppendDhcpOption(OPT_STATUS_CODE);DumpDhcpOption("Option status_code type");
478  AppendDhcpOption((uint8_t)(Lstatuscode_len>>8));AppendDhcpOption((uint8_t)Lstatuscode_len); DumpDhcpOption("Option status_code length");// length
479  AppendDhcpOption((uint8_t)(code>>8));AppendDhcpOption((uint8_t)code); DumpDhcpOption("Option status_code code");// code
480 #endif
481  // for(i=0; i<(statuscode_len-2); i++)
482  // AppendDhcpOption(status_msg[i]);
483  // DumpDhcpOption("Option status_code msg");
484 
485 #if 0
486  // 20190318
497 #endif
498 
499  // Client Identifier
500  AppendDhcpOption(0x00);
502  AppendDhcpOption(0x00);
503  AppendDhcpOption(0x0a); //length
504  AppendDhcpOption(0x00);
505  AppendDhcpOption(0x03); //DUID_Type
506  AppendDhcpOption(0x00);
507  AppendDhcpOption(0x01); //Hard_Type
509  AppendDhcpOption(DHCP_CHADDR[1]); // MAC Addr
514  DumpDhcpOption("Option Client ID");
515  // AppendDhcpOption(0x00);AppendDhcpOption(OPT_CLIENTID);
516  // AppendDhcpOption((uint8_t)(clientid_len>>8));AppendDhcpOption((uint8_t)clientid_len); //length
517  // AppendDhcpOption((uint8_t)(DUID_type>>8));AppendDhcpOption((uint8_t)DUID_type); //DUID_Type
518  // AppendDhcpOption((uint8_t)(Hardware_type>>8));AppendDhcpOption((uint8_t)Hardware_type); //Hard_Type
519  // AppendDhcpOption(DHCP_CHADDR[0]);AppendDhcpOption(DHCP_CHADDR[1]); // MAC Addr
520  // AppendDhcpOption(DHCP_CHADDR[2]);AppendDhcpOption(DHCP_CHADDR[3]);
521  // AppendDhcpOption(DHCP_CHADDR[4]);AppendDhcpOption(DHCP_CHADDR[5]);DumpDhcpOption("Option Client ID");
522 
523  //Server Identifier
524  AppendDhcpOption(0x00);
526  AppendDhcpOption((uint8_t)(serverid_len >> 8));
527  AppendDhcpOption((uint8_t)serverid_len); //length
528  AppendDhcpOption((uint8_t)(DUID_type_s >> 8));
529  AppendDhcpOption((uint8_t)DUID_type_s); //DUID_Type
530  AppendDhcpOption((uint8_t)(Hardware_type_s >> 8));
531  AppendDhcpOption((uint8_t)Hardware_type_s); //Hard_Type
532 #if 0
533  // 20190318
536 #endif
538  AppendDhcpOption(Server_MAC[1]); // MAC Addr
543  DumpDhcpOption("Option Server ID");
544 
545  // Fully Qualified Domain Name
546  // AppendDhcpOption(0x00);AppendDhcpOption(39);
547  // AppendDhcpOption(0x00);AppendDhcpOption(0x06); // length
548  // AppendDhcpOption(0x00);AppendDhcpOption(0x04);
549  // AppendDhcpOption(0x44);AppendDhcpOption(0x45);
550  // AppendDhcpOption(0x44);AppendDhcpOption(0x59);DumpDhcpOption("Option FQ Domain Name");
551 
552  // Vendor Class
553  // AppendDhcpOption(0x00);AppendDhcpOption(16);
554  // AppendDhcpOption(0x00);AppendDhcpOption(0x0e); // length
555  // AppendDhcpOption(0x00);AppendDhcpOption(0x00);
556  // AppendDhcpOption(0x01);AppendDhcpOption(0x37);
557  // AppendDhcpOption(0x00);AppendDhcpOption(0x08);
558  // AppendDhcpOption(0x4d);AppendDhcpOption(0x53);
559  // AppendDhcpOption(0x46);AppendDhcpOption(0x54);
560  // AppendDhcpOption(0x20);AppendDhcpOption(0x35);
561  // AppendDhcpOption(0x2e);AppendDhcpOption(0x30);DumpDhcpOption("Option Vendor Class");
562 
563  // Option Request
564  // AppendDhcpOption(0x00);AppendDhcpOption(OPT_REQUEST);
565  // AppendDhcpOption(0x00);AppendDhcpOption(0x08); // length
566  // AppendDhcpOption(0x00);AppendDhcpOption(OPT_VENDOR_OPTS);
567  // AppendDhcpOption(0x00);AppendDhcpOption(DNS_RecursiveNameServer);
568  // AppendDhcpOption(0x00);AppendDhcpOption(Domain_Search_List);
569  // AppendDhcpOption(0x00);AppendDhcpOption(FQ_DOMAIN_NAME);DumpDhcpOption("Option Request");
570 
571  // send broadcasting packet
572  ip[0] = 0xff;
573  ip[1] = 0x02;
574 
575  for (j = 2; j < 13; j++)
576  ip[j] = 0x00;
577 
578  ip[13] = 0x01;
579  ip[14] = 0x00;
580  ip[15] = 0x02;
581 
582  rip_msg_size = size;
583 
584 #ifdef _DHCP_DEBUG_
585  printf("> Send DHCP_REQUEST\r\n");
586 #endif
587 
588  sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG.OPT, rip_msg_size, ip, DHCP_SERVER_PORT, 16);
589 #ifdef _DHCP_DEBUG_
590  printf("> %d, %d\r\n", ret, rip_msg_size);
591 #endif
592 
593  return ret;
594 }
595 
601 uint8_t send_DHCP_INFOREQ(void)
602 {
603  //uint16_t i;
604  uint16_t j;
605  uint8_t ip[16];
606  uint8_t rip_msg_size;
607  uint8_t ret = 0;
608 
609  size = 0;
610  num = 0;
611  growby = 0;
612 
613  //printf("req : %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x \r\n",recv_IP[0],recv_IP[1],recv_IP[2],recv_IP[3],recv_IP[4],recv_IP[5],recv_IP[6],recv_IP[7],recv_IP[8],recv_IP[9],recv_IP[10],recv_IP[11],recv_IP[12],recv_IP[13],recv_IP[14],recv_IP[15]);
614  InitDhcpOption(30, 1);
615  DumpDhcpOption("option init");
616 
618  AppendDhcpOption((uint8_t)((DHCP_XID & 0x00FF0000) >> 16));
619  AppendDhcpOption((uint8_t)((DHCP_XID & 0x0000FF00) >> 8));
620  AppendDhcpOption((uint8_t)((DHCP_XID & 0x000000FF) >> 0));
621  DumpDhcpOption("Type&XID");
622 
623  // // Elapsed time
624  // AppendDhcpOption(0x00);AppendDhcpOption(OPT_ELAPSED_TIME);
625  // AppendDhcpOption(0x00);AppendDhcpOption(0x02);
626  // AppendDhcpOption(0x0c);AppendDhcpOption(0x1c);DumpDhcpOption("Option Elapsed Time");
627 
628  // Client Identifier
629  AppendDhcpOption(0x00);
631  AppendDhcpOption(0x00);
632  AppendDhcpOption(0x0a); //length
633  AppendDhcpOption(0x00);
634  AppendDhcpOption(0x03); //DUID_Type
635  AppendDhcpOption(0x00);
636  AppendDhcpOption(0x01); //Hard_Type
638  AppendDhcpOption(DHCP_CHADDR[1]); // MAC Addr
643  DumpDhcpOption("Option Client ID");
644 
645  // Option Request
646  AppendDhcpOption(0x00);
648  AppendDhcpOption(0x00);
649  AppendDhcpOption(0x06); // length
650  //AppendDhcpOption(0x00);AppendDhcpOption(OPT_VENDOR_OPTS);
651  AppendDhcpOption(0x00);
653  AppendDhcpOption(0x00);
655  AppendDhcpOption(0x00);
657  DumpDhcpOption("Option Request");
658 
659  // send broadcasting packet
660  ip[0] = 0xff;
661  ip[1] = 0x02;
662 
663  for (j = 2; j < 13; j++)
664  ip[j] = 0x00;
665 
666  ip[13] = 0x01;
667  ip[14] = 0x00;
668  ip[15] = 0x02;
669 
670  rip_msg_size = size;
671 
672 #ifdef _DHCP_DEBUG_
673  printf("> Send DHCP_REQUEST\r\n");
674 #endif
675 
676  sendto(DHCP_SOCKET, (uint8_t *)pDHCPMSG.OPT, rip_msg_size, ip, DHCP_SERVER_PORT, 16);
677 
678 #ifdef _DHCP_DEBUG_
679  printf("> %d, %d\r\n", ret, rip_msg_size);
680 #endif
681 
682  return ret;
683 }
684 
690 int8_t parseDHCPMSG(void)
691 {
692  uint8_t svr_addr[16];
693  uint16_t svr_port;
694  uint8_t addlen;
695  uint16_t len;
696  uint8_t *p;
697  uint8_t *e;
698  uint8_t type, i;
699  uint16_t opt_len;
700  uint32_t end_point;
701 
702  if ((len = getSn_RX_RSR(DHCP_SOCKET)) > 0)
703  {
704  len = recvfrom(DHCP_SOCKET, (uint8_t *)pDHCPMSG.OPT, len, svr_addr, (uint16_t *)&svr_port, &addlen);
705 #ifdef _DHCP6_DEBUG_
706  printf("DHCP message : %.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x(%d) %d received. \r\n", svr_addr[0], svr_addr[1], svr_addr[2], svr_addr[3], svr_addr[4], svr_addr[5], svr_addr[6], svr_addr[7], svr_addr[8], svr_addr[9], svr_addr[10], svr_addr[11], svr_addr[12], svr_addr[13], svr_addr[14], svr_addr[15], svr_port, len);
707 #endif
708  }
709  else
710  {
711  return 0;
712  }
713 
714  type = 0;
715  p = (uint8_t *)(pDHCPMSG.OPT);
716  e = p + len;
717 #ifdef _DHCP6_DEBUG_
718  printf("in server port %x\r\n", *p);
719 #endif
720  i = 0;
721  /*
722  while(p<e){
723  printf("%.2x ",*p);
724  i8f(i%16 == 1){
725  printf("\r\n");
726  }
727  p++;i++;
728  }
729  i=0;*/
730 
731  switch (*p)
732  {
733  case DHCP6_ADVERTISE:
734  case DHCP6_REPLY:
735  {
736 #ifdef _DHCP6_DEBUG_
737  printf("in ADVER or REPLY(7) type : %x \r\n", *p);
738 #endif
739  type = *p++; // type
740  p++; // xid[0]
741  p++; // xid[1]
742  p++; // xid[2]
743  while (p < e)
744  {
745  p++;
746  switch (*p)
747  {
748  case OPT_CLIENTID:
749  {
750 #ifdef _DHCP6_DEBUG_
751  printf("in clientid \r\n");
752 #endif
753  p++;
754 
755  opt_len = (*p++ << 8);
756  clientid_len = opt_len + (*p++);
757 #ifdef _DHCP6_DEBUG_
758  printf("opt_len : %.4x\r\n", clientid_len);
759 #endif
760  end_point = (uint32_t)p + clientid_len;
761 
762  while ((uint32_t)p != end_point)
763  {
764  p++;
765  }
766  break;
767  }
768 
769  case OPT_IANA:
770  {
771 #ifdef _DHCP6_DEBUG_
772  printf("in iana \r\n");
773 #endif
774  p++;
775  opt_len = (*p++ << 8);
776  iana_len = opt_len + (*p++);
777  end_point = (uint32_t)p + iana_len;
778 
779  //IAID
780  IAID[0] = *p++;
781  IAID[1] = *p++;
782  IAID[2] = *p++;
783  IAID[3] = *p++;
784  //T1
785  T1[0] = *p++;
786  T1[1] = *p++;
787  T1[2] = *p++;
788  T1[3] = *p++;
789  //T2
790  T2[0] = *p++;
791  T2[1] = *p++;
792  T2[2] = *p++;
793  T2[3] = *p++;
794  //IA_NA-options
795  while ((uint32_t)p < end_point)
796  {
797  p++;
798  switch (*p)
799  {
800  case OPT_IAADDR:
801  {
802 #ifdef _DHCP6_DEBUG_
803  printf("in IA addr \r\n");
804 #endif
805  p++;
806  opt_len = (*p++ << 8);
807  iaaddr_len = opt_len + (*p++);
808  recv_IP[0] = *p++;
809  recv_IP[1] = *p++;
810  recv_IP[2] = *p++;
811  recv_IP[3] = *p++;
812  recv_IP[4] = *p++;
813  recv_IP[5] = *p++;
814  recv_IP[6] = *p++;
815  recv_IP[7] = *p++;
816  recv_IP[8] = *p++;
817  recv_IP[9] = *p++;
818  recv_IP[10] = *p++;
819  recv_IP[11] = *p++;
820  recv_IP[12] = *p++;
821  recv_IP[13] = *p++;
822  recv_IP[14] = *p++;
823  recv_IP[15] = *p++;
824 
825  PreLifeTime = (*p++ << 24);
826  PreLifeTime += (*p++ << 16);
827  PreLifeTime += (*p++ << 8);
828  PreLifeTime += (*p++);
829  ValidLifeTime = (*p++ << 24);
830  ValidLifeTime += (*p++ << 16);
831  ValidLifeTime += (*p++ << 8);
832  ValidLifeTime += (*p++);
833 
834  printf("IANA : %.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x \r\n", recv_IP[0], recv_IP[1], recv_IP[2], recv_IP[3], recv_IP[4], recv_IP[5], recv_IP[6], recv_IP[7], recv_IP[8], recv_IP[9], recv_IP[10], recv_IP[11], recv_IP[12], recv_IP[13], recv_IP[14], recv_IP[15]);
835  break;
836  }
837 
838  case OPT_STATUS_CODE:
839  {
840 #ifdef _DHCP6_DEBUG_
841  printf("in status code \r\n");
842 #endif
843  p++;
844  opt_len = (*p++ << 8);
845  statuscode_len = opt_len + (*p++);
847 #ifdef _DHCP6_DEBUG_
848  printf("status_len : %x\r\n", statuscode_len);
849  printf("Lstatus_len : %x\r\n", Lstatuscode_len);
850 #endif
851  code = (*p++ << 8);
852  code = code + (*p++);
853  //printf("status_code : %x\r\n", code);
854  //for(i=0; i<(statuscode_len-2); i++)
855  // status_msg[i] = *p++;
856  //printf("status_msg : %s \r\n", status_msg);
857 
858  p += statuscode_len - 2;
859  break;
860  }
861 
862  default:
863  {
864 #ifdef _DHCP6_DEBUG_
865  printf("in default \r\n");
866 #endif
867  p++;
868  opt_len = (*p++ << 8);
869  opt_len = opt_len + (*p++);
870  p += opt_len;
871  break;
872  }
873  }
874  }
875  break;
876  }
877 
878  case OPT_IATA:
879  {
880 #ifdef _DHCP6_DEBUG_
881  printf("in iata \r\n");
882 #endif
883  p++;
884  opt_len = (*p++ << 8);
885  opt_len = opt_len + (*p++);
886  //IA_TA-options
887  p += opt_len;
888  break;
889  }
890 
891  case OPT_SERVERID:
892  {
893 #ifdef _DHCP6_DEBUG_
894  printf("in serverid \r\n");
895 #endif
896 
897  p++;
898  opt_len = (*p++ << 8);
899  serverid_len = opt_len + (*p++);
900 #ifdef _DHCP6_DEBUG_
901  printf("opt_len : %.4x\r\n", serverid_len);
902 #endif
903  end_point = (uint32_t)p + serverid_len;
904 
905  DUID_type_s = (*p++ << 8);
906  DUID_type_s = DUID_type_s + (*p++);
907 #ifdef _DHCP6_DEBUG_
908  printf("DUID_type : %.4x\r\n", DUID_type_s);
909 #endif
910  if (DUID_type_s == 0x02)
911  {
912  Enterprise_num_s = (*p++ << 24);
913  Enterprise_num_s = Enterprise_num_s + (*p++ << 16);
914  Enterprise_num_s = Enterprise_num_s + (*p++ << 8);
916  }
917  else
918  {
919  Hardware_type_s = (*p++ << 8);
920  Hardware_type_s = Hardware_type_s + (*p++);
921 #ifdef _DHCP6_DEBUG_
922  printf("Hardware_type : %.4x\r\n", Hardware_type_s);
923 #endif
924  }
925 
926  if (DUID_type_s == 0x01)
927  {
928  Time_s[0] = *p++;
929  Time_s[1] = *p++;
930  Time_s[2] = *p++;
931  Time_s[3] = *p++;
932 #ifdef _DHCP6_DEBUG_
933  printf("Time : ");
934  for (i = 0; i < 4; i++)
935  printf("%.2x", Time_s[i]);
936  printf("\r\n");
937 #endif
938  }
939 
940  Server_MAC[0] = *p++;
941  Server_MAC[1] = *p++;
942  Server_MAC[2] = *p++;
943  Server_MAC[3] = *p++;
944  Server_MAC[4] = *p++;
945  Server_MAC[5] = *p++;
946 
947 #ifdef _DHCP6_DEBUG_
948  printf("Server_MAC : ");
949  for (i = 0; i < 6; i++)
950  printf("%.2x", Server_MAC[i]);
951  printf("\r\n");
952 #endif
953  while ((uint32_t)p != end_point)
954  {
955  p++;
956  }
957  break;
958  }
959 
961  {
962 #ifdef _DHCP6_DEBUG_
963  printf("in DNS Recursive Name Server \r\n");
964 #endif
965  p++;
966  opt_len = (*p++ << 8);
967  opt_len = opt_len + (*p++);
968  end_point = (uint32_t)p + opt_len;
969 
970  DNS6_Address[0] = *p++;
971  DNS6_Address[1] = *p++;
972  DNS6_Address[2] = *p++;
973  DNS6_Address[3] = *p++;
974  DNS6_Address[4] = *p++;
975  DNS6_Address[5] = *p++;
976  DNS6_Address[6] = *p++;
977  DNS6_Address[7] = *p++;
978  DNS6_Address[8] = *p++;
979  DNS6_Address[9] = *p++;
980  DNS6_Address[10] = *p++;
981  DNS6_Address[11] = *p++;
982  DNS6_Address[12] = *p++;
983  DNS6_Address[13] = *p++;
984  DNS6_Address[14] = *p++;
985  DNS6_Address[15] = *p++;
986 
987  while ((uint32_t)p < end_point)
988  {
989  p++;
990  }
991 
992  break;
993  }
994 
995  case Domain_Search_List:
996  {
997 #ifdef _DHCP6_DEBUG_
998  printf("in Domain Search List \r\n");
999 #endif
1000  p++;
1001  opt_len = (*p++ << 8);
1002  opt_len = opt_len + (*p++);
1003  end_point = (uint32_t)p + opt_len;
1004 
1005  while ((uint32_t)p < end_point)
1006  {
1007  p++;
1008  }
1009 
1010  break;
1011  }
1012 
1013  default:
1014  {
1015 #ifdef _DHCP6_DEBUG_
1016  printf("in default \r\n");
1017 #endif
1018  p++;
1019  opt_len = (*p++ << 8);
1020  opt_len = opt_len + (*p++);
1021  p += opt_len;
1022  break;
1023  }
1024  }
1025  }
1026  }
1027  }
1028  return type;
1029 }
1030 
1036 uint8_t DHCP_run2(void)
1037 {
1038  uint8_t type;
1039  uint8_t ret;
1040 
1042  {
1043  return DHCP_STOPPED; // Check DHCP6 STOP State
1044  }
1045 
1046  if (getSn_SR(DHCP_SOCKET) != SOCK_UDP)
1047  { // Check DHCP SOCKET == UDP
1048  WIZCHIP_WRITE(_Sn_TTLR_(DHCP_SOCKET), 0x01); // hop limit 1
1050  }
1051  ret = DHCP_RUNNING;
1052  type = parseDHCPMSG();
1053  switch (dhcp_state)
1054  {
1055  case STATE_DHCP6_INIT:
1058  break;
1059  case STATE_DHCP6_RELEASE:
1060  return DHCP_IP_LEASED;
1061  default:
1062  break;
1063  }
1064 
1065  return ret;
1066 }
1067 
1074 uint8_t DHCP_run(wiz_NetInfo *netinfo)
1075 {
1076  uint8_t type;
1077  uint8_t ret;
1078  uint8_t i;
1079 
1081  return DHCP_STOPPED; // Check DHCP6 STOP State
1082 
1083  if (getSn_SR(DHCP_SOCKET) != SOCK_UDP)
1084  { // Check DHCP SOCKET == UDP
1085  WIZCHIP_WRITE(_Sn_TTLR_(DHCP_SOCKET), 0x01); // hop limit 1
1087  }
1088 
1089  ret = DHCP_RUNNING;
1090  type = parseDHCPMSG();
1091  printf("type:%d, dhcp_state :%d\r\n", type, dhcp_state);
1092  switch (dhcp_state)
1093  {
1094  case STATE_DHCP6_INIT:
1095  DHCP_allocated_ip[0] = 0;
1096  DHCP_allocated_ip[1] = 0;
1097  DHCP_allocated_ip[2] = 0;
1098  DHCP_allocated_ip[3] = 0;
1099  DHCP_allocated_ip[4] = 0;
1100  DHCP_allocated_ip[5] = 0;
1101  DHCP_allocated_ip[6] = 0;
1102  DHCP_allocated_ip[7] = 0;
1103  DHCP_allocated_ip[8] = 0;
1104  DHCP_allocated_ip[9] = 0;
1105  DHCP_allocated_ip[10] = 0;
1106  DHCP_allocated_ip[11] = 0;
1107  DHCP_allocated_ip[12] = 0;
1108  DHCP_allocated_ip[13] = 0;
1109  DHCP_allocated_ip[14] = 0;
1110  DHCP_allocated_ip[15] = 0;
1111 
1114  break;
1115  case STATE_DHCP6_SOLICIT:
1116  if (type == DHCP6_ADVERTISE)
1117  {
1118 #ifdef _DHCP6_DEBUG_
1119  printf("> Receive DHCP_ADVERTISE\r\n");
1120 #endif
1121 
1122  DHCP_allocated_ip[0] = recv_IP[0];
1123  DHCP_allocated_ip[1] = recv_IP[1];
1124  DHCP_allocated_ip[2] = recv_IP[2];
1125  DHCP_allocated_ip[3] = recv_IP[3];
1126  DHCP_allocated_ip[4] = recv_IP[4];
1127  DHCP_allocated_ip[5] = recv_IP[5];
1128  DHCP_allocated_ip[6] = recv_IP[6];
1129  DHCP_allocated_ip[7] = recv_IP[7];
1130  DHCP_allocated_ip[8] = recv_IP[8];
1131  DHCP_allocated_ip[9] = recv_IP[9];
1132  DHCP_allocated_ip[10] = recv_IP[10];
1133  DHCP_allocated_ip[11] = recv_IP[11];
1134  DHCP_allocated_ip[12] = recv_IP[12];
1135  DHCP_allocated_ip[13] = recv_IP[13];
1136  DHCP_allocated_ip[14] = recv_IP[14];
1137  DHCP_allocated_ip[15] = recv_IP[15];
1138 
1139  ret = send_DHCP_REQUEST();
1140  if (ret == 9)
1141  {
1142  return 0;
1143  }
1145  } //else ret = check_DHCP_timeout();
1146  break;
1147  case STATE_DHCP6_REQUEST:
1148  // 20190318
1149  //NETUNLOCK();
1150 
1151  memcpy(netinfo->gua, recv_IP, 16);
1152 
1153  //NETLOCK();
1154  return DHCP_IP_LEASED;
1155  default:
1156  break;
1157  }
1158  return ret;
1159 }
1160 
1165 void DHCP_stop(void)
1166 {
1167  close(DHCP_SOCKET);
1169 }
1170 
1176 uint8_t check_DHCP_timeout(void)
1177 {
1178  uint8_t ret = DHCP_RUNNING;
1179 
1181  {
1183  {
1184  switch (dhcp_state)
1185  {
1186  case STATE_DHCP6_SOLICIT:
1187  {
1188 #ifdef _DHCP6_DEBUG_
1189  printf("<<timeout>> state : STATE_DHCP_DISCOVER\r\n");
1190 #endif
1192  break;
1193  }
1194  default:
1195  {
1196  break;
1197  }
1198  }
1199 
1200  dhcp_tick_1s = 0;
1202  dhcp_retry_count++;
1203  }
1204  }
1205  else
1206  { // timeout occurred
1207 
1208  switch (dhcp_state)
1209  {
1210  case STATE_DHCP6_SOLICIT:
1212  ret = DHCP_FAILED;
1213  break;
1214  default:
1215  break;
1216  }
1218  }
1219  return ret;
1220 }
1221 
1228 void DHCP_init(uint8_t s, uint8_t *buf)
1229 {
1230  uint8_t zeroip[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1232  if ((DHCP_CHADDR[0] | DHCP_CHADDR[1] | DHCP_CHADDR[2] | DHCP_CHADDR[3] | DHCP_CHADDR[4] | DHCP_CHADDR[5]) == 0x00)
1233  {
1234 #ifdef _DHCP6_DEBUG_
1235  printf("DHCP_init-set MAC\r\n");
1236 #endif
1237  // assing temporary mac address, you should be set SHAR before call this function.
1238  DHCP_CHADDR[0] = 0x00;
1239  DHCP_CHADDR[1] = 0x08;
1240  DHCP_CHADDR[2] = 0xdc;
1241  DHCP_CHADDR[3] = 0x00;
1242  DHCP_CHADDR[4] = 0x00;
1243  DHCP_CHADDR[5] = 0x00;
1245  }
1246 
1247  DHCP_SOCKET = s; // SOCK_DHCP
1248 
1249  memset(buf, 0, sizeof(buf));
1250  pDHCPMSG.OPT = buf;
1251  DHCP_XID = 0x515789;
1252 
1255 }
1256 
1262 {
1263  dhcp_tick_1s = 0;
1265  dhcp_retry_count = 0;
1266 }
1267 
1273 {
1274  dhcp_tick_1s++;
1275 }
serverid_len
uint16_t serverid_len
Definition: dhcpv6.c:173
parseDHCPMSG
int8_t parseDHCPMSG(void)
Definition: dhcpv6.c:690
_Sn_TTLR_
#define _Sn_TTLR_(N)
SOCKETn IP Time to live(TTL) Register Address [R=W][0x80].
Definition: w6100.h:1136
sendto
datasize_t sendto(uint8_t sn, uint8_t *buf, datasize_t len, uint8_t *addr, uint16_t port, uint8_t addrlen)
Send datagram to the peer specifed by destination IP address and port number passed as parameter.
Definition: socket.c:372
OPT_REQUEST
@ OPT_REQUEST
Definition: dhcpv6.c:91
DNS6_Address
uint8_t DNS6_Address[16]
Definition: dhcpv6.c:76
OPT_IANA
@ OPT_IANA
Definition: dhcpv6.c:88
OPT_VENDOR_CLASS
@ OPT_VENDOR_CLASS
Definition: dhcpv6.c:100
WIZCHIP_WRITE
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb)
It writes 1 byte value to a register.
DHCP_run
uint8_t DHCP_run(wiz_NetInfo *netinfo)
Definition: dhcpv6.c:1074
OPT_NIS_DOMAIN_NAME
@ OPT_NIS_DOMAIN_NAME
Definition: dhcpv6.c:113
socket
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag)
Open a socket.
Definition: socket.c:101
send_DHCP_SOLICIT
void send_DHCP_SOLICIT(void)
Definition: dhcpv6.c:275
OPT_RELAY_MSG
@ OPT_RELAY_MSG
Definition: dhcpv6.c:94
DHCP6_ADVERTISE
#define DHCP6_ADVERTISE
OFFER message in OPT of RIP_MSG.
Definition: dhcpv6.c:65
Time_s
uint8_t Time_s[4]
Definition: dhcpv6.c:159
growby
unsigned growby
Definition: dhcpv6.c:180
wiz_NetInfo_t::gua
uint8_t gua[16]
Source Global Unicast Address.
Definition: wizchip_conf.h:449
DHCP6_REQUEST
#define DHCP6_REQUEST
REQUEST message in OPT of RIP_MSG.
Definition: dhcpv6.c:66
Lstatuscode_len
uint16_t Lstatuscode_len
Definition: dhcpv6.c:172
OPT_INTERFACE_ID
@ OPT_INTERFACE_ID
Definition: dhcpv6.c:102
SIP_Server_DNL
@ SIP_Server_DNL
Definition: dhcpv6.c:105
OPT_USER_CLASS
@ OPT_USER_CLASS
Definition: dhcpv6.c:99
dhcp_state
int8_t dhcp_state
Definition: dhcpv6.c:133
DUID_type_s
uint16_t DUID_type_s
Definition: dhcpv6.c:157
clientid_len
uint16_t clientid_len
Definition: dhcpv6.c:174
OPT_IATA
@ OPT_IATA
Definition: dhcpv6.c:89
check_DHCP_timeout
uint8_t check_DHCP_timeout(void)
Definition: dhcpv6.c:1176
num2
unsigned num2
Definition: dhcpv6.c:179
OPT_SERVERID
@ OPT_SERVERID
Definition: dhcpv6.c:87
recv_IP
uint8_t recv_IP[16]
Definition: dhcpv6.c:162
DumpDhcpOption
void DumpDhcpOption(char *sMark)
Definition: dhcpv6.c:218
OPT_VENDOR_OPTS
@ OPT_VENDOR_OPTS
Definition: dhcpv6.c:101
getSn_RX_RSR
datasize_t getSn_RX_RSR(uint8_t s)
DHCP_Option_Select
void DHCP_Option_Select(uint8_t option)
Definition: dhcpv6.c:235
send_DHCP_INFOREQ
uint8_t send_DHCP_INFOREQ(void)
Definition: dhcpv6.c:601
dhcp_tick_next
uint32_t dhcp_tick_next
Definition: dhcpv6.c:137
SOCK_UDP
#define SOCK_UDP
UDP SOCKETn status.
Definition: w6100.h:2893
DHCP_IP_LEASED
@ DHCP_IP_LEASED
Stand by.
Definition: dhcpv6.h:73
pDHCPMSG
RIP_MSG pDHCPMSG
Definition: dhcpv6.c:141
DHCP6_REPLY
#define DHCP6_REPLY
RELEASE message in OPT of RIP_MSG. No use.
Definition: dhcpv6.c:70
ValidLifeTime
uint32_t ValidLifeTime
Definition: dhcpv6.c:164
Domain_Search_List
@ Domain_Search_List
Definition: dhcpv6.c:108
OPT_PREFERENCE
@ OPT_PREFERENCE
Definition: dhcpv6.c:92
send_DHCP_REQUEST
uint8_t send_DHCP_REQUEST(void)
Definition: dhcpv6.c:392
DHCP_SERVER_PORT
#define DHCP_SERVER_PORT
DHCP server port number.
Definition: dhcpv6.h:59
OPT_STATUS_CODE
@ OPT_STATUS_CODE
Definition: dhcpv6.c:97
OPT_IAPREFIX
@ OPT_IAPREFIX
Definition: dhcpv6.c:110
Server_MAC
uint8_t Server_MAC[6]
Definition: dhcpv6.c:161
OPT_RAPID_COMMIT
@ OPT_RAPID_COMMIT
Definition: dhcpv6.c:98
reset_DHCP_timeout
void reset_DHCP_timeout(void)
Definition: dhcpv6.c:1261
DHCP_CLIENT_PORT
#define DHCP_CLIENT_PORT
DHCP client port number.
Definition: dhcpv6.h:60
DHCP_CHADDR
uint8_t DHCP_CHADDR[6]
Definition: dhcpv6.c:145
iana_len
uint16_t iana_len
Definition: dhcpv6.c:169
OPT_LIFETIME
@ OPT_LIFETIME
Definition: dhcpv6.c:115
Enterprise_num_s
uint32_t Enterprise_num_s
Definition: dhcpv6.c:160
DHCP_init
void DHCP_init(uint8_t s, uint8_t *buf)
Definition: dhcpv6.c:1228
size
unsigned size
Definition: dhcpv6.c:177
DHCP_run2
uint8_t DHCP_run2(void)
Definition: dhcpv6.c:1036
getSHAR
#define getSHAR(shar)
Definition: w6100.h:3598
DHCP_time_handler
void DHCP_time_handler(void)
Definition: dhcpv6.c:1272
OPT_UNICAST
@ OPT_UNICAST
Definition: dhcpv6.c:96
DHCP6_INFO_REQUEST
#define DHCP6_INFO_REQUEST
INFORM message in OPT of RIP_MSG. No use.
Definition: dhcpv6.c:74
STATE_DHCP6_REQUEST
#define STATE_DHCP6_REQUEST
send REQEUST and wait ACK or NACK
Definition: dhcpv6.c:57
__attribute__::OPT
uint8_t * OPT
Option.
Definition: dhcpv6.c:124
STATE_DHCP6_SOLICIT
#define STATE_DHCP6_SOLICIT
send DISCOVER and wait OFFER
Definition: dhcpv6.c:56
OPT_RECONF_ACCEPT
@ OPT_RECONF_ACCEPT
Definition: dhcpv6.c:104
dhcp_tick_1s
volatile uint32_t dhcp_tick_1s
Definition: dhcpv6.c:136
RIP_MSG::OPT
uint8_t OPT[OPT_SIZE]
Option.
Definition: dhcpv4.c:188
T2
uint8_t T2[4]
Definition: dhcpv6.c:168
IAID
uint8_t IAID[4]
Definition: dhcpv6.c:166
RIP_MSG
Definition: dhcpv4.c:173
dhcpv6.h
SIP_Server_V6ADDR
@ SIP_Server_V6ADDR
Definition: dhcpv6.c:106
T1
uint8_t T1[4]
Definition: dhcpv6.c:167
DHCP_STOPPED
@ DHCP_STOPPED
Stop procssing DHCP protocol.
Definition: dhcpv6.h:74
OPT_IAPD
@ OPT_IAPD
Definition: dhcpv6.c:109
status_msg
uint8_t status_msg[]
Definition: dhcpv6.c:175
OPT_ELAPSED_TIME
@ OPT_ELAPSED_TIME
Definition: dhcpv6.c:93
DHCP6_SOLICIT
#define DHCP6_SOLICIT
DISCOVER message in OPT of RIP_MSG.
Definition: dhcpv6.c:64
DNS_RecursiveNameServer
@ DNS_RecursiveNameServer
Definition: dhcpv6.c:107
STATE_DHCP6_RELEASE
#define STATE_DHCP6_RELEASE
No use.
Definition: dhcpv6.c:60
iaaddr_len
uint16_t iaaddr_len
Definition: dhcpv6.c:170
DHCP_stop
void DHCP_stop(void)
Definition: dhcpv6.c:1165
code
uint16_t code
Definition: dhcpv6.c:165
FQ_DOMAIN_NAME
@ FQ_DOMAIN_NAME
Definition: dhcpv6.c:116
close
int8_t close(uint8_t sn)
Close a SOCKET.
Definition: socket.c:186
getSn_SR
#define getSn_SR(sn)
Definition: w6100.h:3837
OPT_NISP_DOMAIN_NAME
@ OPT_NISP_DOMAIN_NAME
Definition: dhcpv6.c:114
__attribute__
Definition: dhcpv6.c:122
OPT_RECONF_MSG
@ OPT_RECONF_MSG
Definition: dhcpv6.c:103
MAX_DHCP_RETRY
#define MAX_DHCP_RETRY
Maxium retry count.
Definition: dhcpv6.h:55
OPT_NIS_SERVERS
@ OPT_NIS_SERVERS
Definition: dhcpv6.c:111
HOST_NAME
uint8_t HOST_NAME[]
Definition: dhcpv6.c:143
Sn_MR_UDP6
#define Sn_MR_UDP6
IPv6 UDP mode.
Definition: w6100.h:2450
InitDhcpOption
void InitDhcpOption(unsigned asize, unsigned agrowby)
Definition: dhcpv6.c:188
STATE_DHCP6_STOP
#define STATE_DHCP6_STOP
Stop procssing DHCP.
Definition: dhcpv6.c:61
wiz_NetInfo_t
Network Information for _WIZCHIP_.
Definition: wizchip_conf.h:442
OPT_NISP_SERVERS
@ OPT_NISP_SERVERS
Definition: dhcpv6.c:112
setSHAR
#define setSHAR(shar)
Definition: w6100.h:3595
OPT_AUTH
@ OPT_AUTH
Definition: dhcpv6.c:95
DHCP_allocated_ip
uint8_t DHCP_allocated_ip[16]
Definition: dhcpv6.c:130
Hardware_type_s
uint16_t Hardware_type_s
Definition: dhcpv6.c:158
OPT_IAADDR
@ OPT_IAADDR
Definition: dhcpv6.c:90
DHCP_WAIT_TIME
#define DHCP_WAIT_TIME
Wait Time 10s.
Definition: dhcpv6.h:56
DCHP_HOST_NAME
#define DCHP_HOST_NAME
Definition: dhcpv6.h:62
DHCP_XID
uint32_t DHCP_XID
Definition: dhcpv6.c:139
STATE_DHCP6_INIT
#define STATE_DHCP6_INIT
Initialize.
Definition: dhcpv6.c:55
num
unsigned num
Definition: dhcpv6.c:178
statuscode_len
uint16_t statuscode_len
Definition: dhcpv6.c:171
OPT_CLIENTID
@ OPT_CLIENTID
Definition: dhcpv6.c:86
DHCP_RUNNING
@ DHCP_RUNNING
Procssing DHCP proctocol.
Definition: dhcpv6.h:70
AppendDhcpOption
void AppendDhcpOption(uint8_t value)
Definition: dhcpv6.c:200
DHCP_FAILED
@ DHCP_FAILED
Procssing Fail.
Definition: dhcpv6.h:69
recvfrom
datasize_t recvfrom(uint8_t sn, uint8_t *buf, datasize_t len, uint8_t *addr, uint16_t *port, uint8_t *addrlen)
Receive datagram from a peer.
Definition: socket.c:441
dhcp_retry_count
int8_t dhcp_retry_count
Definition: dhcpv6.c:134
PreLifeTime
uint32_t PreLifeTime
Definition: dhcpv6.c:163
DHCP_SOCKET
uint8_t DHCP_SOCKET
Definition: dhcpv6.c:127