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 int32_t dhcpv6 ( char *ret_buffer, void *fn_ip);
81 uint32_t handle_dhcpv6(uint8_t * , int32_t);
83 struct dhcp6_gen_option {
88 struct client_identifier {
92 uint16_t hardware_type;
96 struct server_identifier {
100 uint16_t hardware_type;
105 struct dhcp_info_request {
106 struct client_identifier client_id;
107 struct elapsed_time {
112 struct option_request {
115 uint16_t option_code[5];
116 } option_request_option;
119 struct dhcp_message_header {
120 uint8_t type; /* Message type */
121 uint8_t transaction_id[3]; /* Transaction id */
122 struct dhcp_info_request option;
130 }__attribute((packed));
132 struct dhcp_dns_list {
136 }__attribute((packed));
138 struct dhcp_boot_url {
144 struct dhcp6_received_options {
150 struct dhcp_message_reply {
151 uint8_t type; /* Message type */
152 uint8_t transaction_id[3]; /* Transaction id */
153 struct client_identifier client_id;
154 struct server_identifier server_id;