These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / roms / SLOF / clients / net-snk / app / netlib / dhcpv6.h
1 /******************************************************************************
2  * Copyright (c) 2013 IBM Corporation
3  * All rights reserved.
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
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 #ifndef _DHCPV6_H_
14 #define _DHCPV6_H_
15
16 #include <stdint.h>
17 #include <netlib/ethernet.h>
18
19 #define DHCPV6_STATELESS 0
20 #define DHCPV6_STATEFUL  1
21
22 /* DHCP port numbers */
23 #define DHCP_CLIENT_PORT        546
24 #define DHCP_SERVER_PORT        547
25
26 /* DHCPv6 message types  */
27 #define DHCP_SOLICIT              1
28 #define DHCP_ADVERTISE            2
29 #define DHCP_REQUEST              3
30 #define DHCP_CONFIRM              4
31 #define DHCP_RENEW                5
32 #define DHCP_REBIND               6
33 #define DHCP_REPLY                7
34 #define DHCP_RELEASE              8
35 #define DHCP_DECLINE              9
36 #define DHCP_RECONFIGURE         10
37 #define DHCP_INFORMATION_REQUEST 11
38 #define RELAY_FORW               12
39 #define RELAY_REPL               13
40
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
64
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
73
74 /* DUID types   */
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 */
78
79 /* Prototypes */
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);
83
84 struct dhcp6_gen_option {
85         uint16_t code;
86         uint16_t length;
87 };
88
89 struct client_identifier {
90         uint16_t code;
91         uint16_t length;
92         uint16_t duid_type;
93         uint16_t hardware_type;
94         uint8_t mac[6];
95 };
96
97 struct server_identifier {
98         uint16_t code;
99         uint16_t length;
100         uint16_t duid_type;
101         uint16_t hardware_type;
102         uint32_t time;
103         uint8_t mac[6];
104 };
105
106 #define DHCPV6_OPTREQUEST_NUMOPTS 3
107
108 struct dhcp_info_request {
109         struct client_identifier client_id;
110         struct elapsed_time {
111                 uint16_t code;
112                 uint16_t length;
113                 uint16_t time;
114         } el_time;
115         struct option_request {
116                 uint16_t code;
117                 uint16_t length;
118                 uint16_t option_code[DHCPV6_OPTREQUEST_NUMOPTS];
119         } option_request_option;
120 };
121
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;
126 };
127
128 struct dhcp_dns {
129         uint16_t code;
130         uint16_t length;
131         uint8_t p_ip6[16];
132         uint8_t s_ip6[16];
133 }__attribute((packed));
134
135 struct dhcp_dns_list {
136         uint16_t code;
137         uint16_t length;
138         uint8_t domain[256];
139 }__attribute((packed));
140
141 struct dhcp_boot_url {
142         uint16_t type;
143         uint16_t length;
144         uint8_t url[256];
145 };
146
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;
152 };
153
154 #endif