Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / include / ipxe / dhcpv6.h
1 #ifndef _IPXE_DHCPV6_H
2 #define _IPXE_DHCPV6_H
3
4 /** @file
5  *
6  * Dynamic Host Configuration Protocol for IPv6
7  *
8  */
9
10 FILE_LICENCE ( GPL2_OR_LATER );
11
12 #include <stdint.h>
13 #include <ipxe/in.h>
14 #include <ipxe/uuid.h>
15
16 /** DHCPv6 server port */
17 #define DHCPV6_SERVER_PORT 547
18
19 /** DHCPv6 client port */
20 #define DHCPV6_CLIENT_PORT 546
21
22 /**
23  * A DHCPv6 option
24  *
25  */
26 struct dhcpv6_option {
27         /** Code */
28         uint16_t code;
29         /** Length of the data field */
30         uint16_t len;
31         /** Data */
32         uint8_t data[0];
33 } __attribute__ (( packed ));
34
35 /** DHCP unique identifier based on UUID (DUID-UUID) */
36 struct dhcpv6_duid_uuid {
37         /** Type */
38         uint16_t type;
39         /** UUID */
40         union uuid uuid;
41 } __attribute__ (( packed ));
42
43 /** DHCP unique identifier based on UUID (DUID-UUID) */
44 #define DHCPV6_DUID_UUID 4
45
46 /** DHCPv6 client or server identifier option */
47 struct dhcpv6_duid_option {
48         /** Option header */
49         struct dhcpv6_option header;
50         /** DHCP unique identifier (DUID) */
51         uint8_t duid[0];
52 } __attribute__ (( packed ));
53
54 /** DHCPv6 client identifier option */
55 #define DHCPV6_CLIENT_ID 1
56
57 /** DHCPv6 server identifier option */
58 #define DHCPV6_SERVER_ID 2
59
60 /** DHCPv6 identity association for non-temporary address (IA_NA) option */
61 struct dhcpv6_ia_na_option {
62         /** Option header */
63         struct dhcpv6_option header;
64         /** Identity association identifier (IAID) */
65         uint32_t iaid;
66         /** Renew time (in seconds) */
67         uint32_t renew;
68         /** Rebind time (in seconds) */
69         uint32_t rebind;
70         /** IA_NA options */
71         struct dhcpv6_option options[0];
72 } __attribute__ (( packed ));
73
74 /** DHCPv6 identity association for non-temporary address (IA_NA) option */
75 #define DHCPV6_IA_NA 3
76
77 /** DHCPv6 identity association address (IAADDR) option */
78 struct dhcpv6_iaaddr_option {
79         /** Option header */
80         struct dhcpv6_option header;
81         /** IPv6 address */
82         struct in6_addr address;
83         /** Preferred lifetime (in seconds) */
84         uint32_t preferred;
85         /** Valid lifetime (in seconds) */
86         uint32_t valid;
87         /** IAADDR options */
88         struct dhcpv6_option options[0];
89 } __attribute__ (( packed ));
90
91 /** DHCPv6 identity association address (IAADDR) option */
92 #define DHCPV6_IAADDR 5
93
94 /** DHCPv6 option request option */
95 struct dhcpv6_option_request_option {
96         /** Option header */
97         struct dhcpv6_option header;
98         /** Requested options */
99         uint16_t requested[0];
100 } __attribute__ (( packed ));
101
102 /** DHCPv6 option request option */
103 #define DHCPV6_OPTION_REQUEST 6
104
105 /** DHCPv6 elapsed time option */
106 struct dhcpv6_elapsed_time_option {
107         /** Option header */
108         struct dhcpv6_option header;
109         /** Elapsed time, in centiseconds */
110         uint16_t elapsed;
111 } __attribute__ (( packed ));
112
113 /** DHCPv6 elapsed time option */
114 #define DHCPV6_ELAPSED_TIME 8
115
116 /** DHCPv6 status code option */
117 struct dhcpv6_status_code_option {
118         /** Option header */
119         struct dhcpv6_option header;
120         /** Status code */
121         uint16_t status;
122         /** Status message */
123         char message[0];
124 } __attribute__ (( packed ));
125
126 /** DHCPv6 status code option */
127 #define DHCPV6_STATUS_CODE 13
128
129 /** DHCPv6 user class */
130 struct dhcpv6_user_class {
131         /** Length */
132         uint16_t len;
133         /** User class string */
134         char string[0];
135 } __attribute__ (( packed ));
136
137 /** DHCPv6 user class option */
138 struct dhcpv6_user_class_option {
139         /** Option header */
140         struct dhcpv6_option header;
141         /** User class */
142         struct dhcpv6_user_class user_class[0];
143 } __attribute__ (( packed ));
144
145 /** DHCPv6 user class option */
146 #define DHCPV6_USER_CLASS 15
147
148 /** DHCPv6 DNS recursive name server option */
149 #define DHCPV6_DNS_SERVERS 23
150
151 /** DHCPv6 domain search list option */
152 #define DHCPV6_DOMAIN_LIST 24
153
154 /** DHCPv6 bootfile URI option */
155 #define DHCPV6_BOOTFILE_URL 59
156
157 /** DHCPv6 bootfile parameters option */
158 #define DHCPV6_BOOTFILE_PARAM 60
159
160 /** DHCPv6 syslog server option
161  *
162  * This option code has not yet been assigned by IANA.  Please update
163  * this definition once an option code has been assigned.
164  */
165 #define DHCPV6_LOG_SERVERS 0xffffffffUL
166
167 /**
168  * Any DHCPv6 option
169  *
170  */
171 union dhcpv6_any_option {
172         struct dhcpv6_option header;
173         struct dhcpv6_duid_option duid;
174         struct dhcpv6_ia_na_option ia_na;
175         struct dhcpv6_iaaddr_option iaaddr;
176         struct dhcpv6_option_request_option option_request;
177         struct dhcpv6_elapsed_time_option elapsed_time;
178         struct dhcpv6_status_code_option status_code;
179         struct dhcpv6_user_class_option user_class;
180 };
181
182 /**
183  * A DHCPv6 header
184  *
185  */
186 struct dhcpv6_header {
187         /** Message type */
188         uint8_t type;
189         /** Transaction ID */
190         uint8_t xid[3];
191         /** Options */
192         struct dhcpv6_option options[0];
193 } __attribute__ (( packed ));
194
195 /** DHCPv6 solicitation */
196 #define DHCPV6_SOLICIT 1
197
198 /** DHCPv6 advertisement */
199 #define DHCPV6_ADVERTISE 2
200
201 /** DHCPv6 request */
202 #define DHCPV6_REQUEST 3
203
204 /** DHCPv6 reply */
205 #define DHCPV6_REPLY 7
206
207 /** DHCPv6 information request */
208 #define DHCPV6_INFORMATION_REQUEST 11
209
210 /** DHCPv6 settings block name */
211 #define DHCPV6_SETTINGS_NAME "dhcpv6"
212
213 /**
214  * Construct all-DHCP-relay-agents-and-servers multicast address
215  *
216  * @v addr              Zeroed address to construct
217  */
218 static inline void ipv6_all_dhcp_relay_and_servers ( struct in6_addr *addr ) {
219         addr->s6_addr16[0] = htons ( 0xff02 );
220         addr->s6_addr[13] = 1;
221         addr->s6_addr[15] = 2;
222 }
223
224 extern int start_dhcpv6 ( struct interface *job, struct net_device *netdev,
225                           int stateful );
226
227 #endif /* _IPXE_DHCPV6_H */