Add qemu 2.4.0
[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 int32_t dhcpv6 ( char *ret_buffer, void *fn_ip);
81 uint32_t handle_dhcpv6(uint8_t * , int32_t);
82
83 struct dhcp6_gen_option {
84         uint16_t code;
85         uint16_t length;
86 };
87
88 struct client_identifier {
89         uint16_t code;
90         uint16_t length;
91         uint16_t duid_type;
92         uint16_t hardware_type;
93         uint8_t mac[6];
94 };
95
96 struct server_identifier {
97         uint16_t code;
98         uint16_t length;
99         uint16_t duid_type;
100         uint16_t hardware_type;
101         uint32_t time;
102         uint8_t mac[6];
103 };
104
105 struct dhcp_info_request {
106         struct client_identifier client_id;
107         struct elapsed_time {
108                 uint16_t code;
109                 uint16_t length;
110                 uint16_t time;
111         } el_time;
112         struct option_request {
113                 uint16_t code;
114                 uint16_t length;
115                 uint16_t option_code[5];
116         } option_request_option;
117 };
118
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;
123 };
124
125 struct dhcp_dns {
126         uint16_t code;
127         uint16_t length;
128         uint8_t p_ip6[16];
129         uint8_t s_ip6[16];
130 }__attribute((packed));
131
132 struct dhcp_dns_list {
133         uint16_t code;
134         uint16_t length;
135         uint8_t domain[256];
136 }__attribute((packed));
137
138 struct dhcp_boot_url {
139         uint16_t type;
140         uint16_t length;
141         uint8_t url[256];
142 };
143
144 struct dhcp6_received_options {
145         uint8_t filename;
146         uint8_t ip;
147         uint8_t client_id;
148         uint8_t server_id;
149 };
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;
155 };
156
157 #endif