1 /******************************************************************************
2 * Copyright (c) 2013 IBM Corporation
4 * This program and the accompanying materials
5 * are made available under the terms of the BSD License
6 * which accompanies this distribution, and is available at
7 * http://www.opensource.org/licenses/bsd-license.php
10 * IBM Corporation - initial implementation
11 *****************************************************************************/
17 #include <netlib/ethernet.h>
19 #define DHCPV6_STATELESS 0
20 #define DHCPV6_STATEFUL 1
22 /* DHCP port numbers */
23 #define DHCP_CLIENT_PORT 546
24 #define DHCP_SERVER_PORT 547
26 /* DHCPv6 message types */
27 #define DHCP_SOLICIT 1
28 #define DHCP_ADVERTISE 2
29 #define DHCP_REQUEST 3
30 #define DHCP_CONFIRM 4
34 #define DHCP_RELEASE 8
35 #define DHCP_DECLINE 9
36 #define DHCP_RECONFIGURE 10
37 #define DHCP_INFORMATION_REQUEST 11
41 /* DHCPv6 option types */
42 #define DHCPV6_OPTION_CLIENTID 0x0001
43 #define DHCPV6_OPTION_SERVERID 0x0002
44 #define DHCPV6_OPTION_IA_NA 3
45 #define DHCPV6_OPTION_IA_TA 4
46 #define DHCPV6_OPTION_IAADDR 5
47 #define DHCPV6_OPTION_ORO 6
48 #define DHCPV6_OPTION_PREFEREN 7
49 #define DHCPV6_OPTION_ELAPSED_TIME 8
50 #define DHCPV6_OPTION_RELAY_MS 9
51 #define DHCPV6_OPTION_AUTH 11
52 #define DHCPV6_OPTION_UNICAST 12
53 #define DHCPV6_OPTION_STATUS_C 13
54 #define DHCPV6_OPTION_RAPID_CO 14
55 #define DHCPV6_OPTION_USER_CLA 15
56 #define DHCPV6_OPTION_VENDOR_C 16
57 #define DHCPV6_OPTION_VENDOR_O 17
58 #define DHCPV6_OPTION_INTERFAC 18
59 #define DHCPV6_OPTION_RECONF_M 19
60 #define DHCPV6_OPTION_RECONF_A 20
61 #define DHCPV6_OPTION_DNS_SERVERS 23
62 #define DHCPV6_OPTION_DOMAIN_LIST 24
63 #define DHCPV6_OPTION_BOOT_URL 59
65 /* DHCPv6 status codes */
66 #define DHCP_STATUSCODE_SUCCESS 0
67 #define DHCP_STATUSCODE_UNSPECFAIL 1
68 #define DHCP_STATUSCODE_NOADDRAVAIL 2
69 #define DHCP_STATUSCODE_NOBINDING 3
70 #define DHCP_STATUSCODE_NOTONLINK 4
71 #define DHCP_STATUSCODE_USEMULTICAST 5
72 #define DHCPV6_STATE_SELECT 6
75 #define DUID_LLT 1 /* DUID based on Link-layer Address Plus Time */
76 #define DUID_EN 2 /* DUID based on Assigned by Vendor Based on Enterprise Number */
77 #define DUID_LL 3 /* DUID based on Link-layer Address */
80 void dhcpv6_generate_transaction_id(void);
81 int32_t dhcpv6 ( char *ret_buffer, void *fn_ip);
82 uint32_t handle_dhcpv6(uint8_t * , int32_t);
84 struct dhcp6_gen_option {
89 struct client_identifier {
93 uint16_t hardware_type;
97 struct server_identifier {
101 uint16_t hardware_type;
106 #define DHCPV6_OPTREQUEST_NUMOPTS 3
108 struct dhcp_info_request {
109 struct client_identifier client_id;
110 struct elapsed_time {
115 struct option_request {
118 uint16_t option_code[DHCPV6_OPTREQUEST_NUMOPTS];
119 } option_request_option;
122 struct dhcp_message_header {
123 uint8_t type; /* Message type */
124 uint8_t transaction_id[3]; /* Transaction id */
125 struct dhcp_info_request option;
133 }__attribute((packed));
135 struct dhcp_dns_list {
139 }__attribute((packed));
141 struct dhcp_boot_url {
147 struct dhcp_message_reply {
148 uint8_t type; /* Message type */
149 uint8_t transaction_id[3]; /* Transaction id */
150 struct client_identifier client_id;
151 struct server_identifier server_id;