Update version
[l2tpns.git] / dhcp6.h
1 /*
2 * Fernando ALVES 2014
3 * Add functionality DHCPv6 to l2tpns.
4 * GPL licenced
5 */
6
7 #ifndef __DHCP6_H__
8 #define __DHCP6_H__
9
10 #define DHCP6_SOLICIT 1
11 #define DHCP6_ADVERTISE 2
12 #define DHCP6_REQUEST 3
13 #define DHCP6_CONFIRM 4
14 #define DHCP6_RENEW 5
15 #define DHCP6_REBIND 6
16 #define DHCP6_REPLY 7
17 #define DHCP6_RELEASE 8
18 #define DHCP6_DECLINE 9
19 #define DHCP6_RECONFIGURE 10
20 #define DHCP6_INFORMATION_REQUEST 11
21 #define DHCP6_RELAY_FORM 12
22 #define DHCP6_RELAY_REPL 13
23
24 #define D6_OPT_CLIENTID 1
25 #define D6_OPT_SERVERID 2
26 #define D6_OPT_IA_NA 3
27 #define D6_OPT_IA_TA 4
28 #define D6_OPT_IAADDR 5
29 #define D6_OPT_ORO 6
30 #define D6_OPT_PREFERENCE 7
31 #define D6_OPT_ELAPSED_TIME 8
32 #define D6_OPT_RELAY_MSG 9
33 #define D6_OPT_AUTH 11
34 #define D6_OPT_UNICAST 12
35 #define D6_OPT_STATUS_CODE 13
36 #define D6_OPT_RAPID_COMMIT 14
37 #define D6_OPT_USER_CLASS 15
38 #define D6_OPT_VENDOR_CLASS 16
39 #define D6_OPT_VENDOR_SPECIFIC 17
40 #define D6_OPT_INTERFACE_ID 18
41 #define D6_OPT_RECONF_MSG 19
42 #define D6_OPT_RECONF_ACCEPT 20
43 #define D6_OPT_DNS_SERVERS 23
44 #define D6_OPT_DOMAIN_LIST 24
45 #define D6_OPT_IA_PD 25
46 #define D6_OPT_IAPREFIX 26
47
48 #define D6_STATUS_Success 0
49 #define D6_STATUS_UnspecFail 1
50 #define D6_STATUS_NoAddrsAvail 2
51 #define D6_STATUS_NoBinding 3
52 #define D6_STATUS_NotOnLink 4
53 #define D6_STATUS_UseMulticast 5
54 #define D6_STATUS_NoPrefixAvail 6
55
56 #define DUID_LLT 1
57 #define DUID_EN 2
58 #define DUID_LL 3
59
60 //~ 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
61 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 //~ | D6_OPT_IA_PD | Longueur d’option |
63 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 //~ | IAID (4 octets) |
65 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 //~ | T1 (4 octets) |
67 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 //~ | T2 (4 octets) |
69 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 //~ | Options-IA_PD |
71 //~ . .
72 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
73
74 // Prefix for IA_PD
75 //~ 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
76 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 //~ | OPTION_IAPREFIX | option-length |
78 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 //~ | preferred-lifetime |
80 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 //~ | valid-lifetime |
82 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
83 //~ | prefix-length | |
84 //~ +-+-+-+-+-+-+-+-+ IPv6 prefix |
85 //~ | (16 octets) |
86 //~ | |
87 //~ | |
88 //~ | |
89 //~ | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 //~ | | .
91 //~ +-+-+-+-+-+-+-+-+ .
92 //~ . IAprefix-options .
93 //~ . .
94 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95
96 //~ 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
97 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
98 //~ | D6_OPT_IA_NA | Longueur d’option |
99 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
100 //~ | IAID (4 octets) |
101 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
102 //~ | T1 (4 octets) |
103 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
104 //~ | T2 (4 octets) |
105 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
106 //~ | Options-IA_NA |
107 //~ . .
108 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
109
110 //~ 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F
111 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
112 //~ | OPTION_IA_TA | Longueur d’option |
113 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
114 //~ | IAID (4 octets) |
115 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116 //~ | Options-IA_TA |
117 //~ . .
118 //~ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
119
120 struct dhcp6_mess_hdr
121 {
122 uint32_t type:8;
123 uint32_t trans_id:24;
124 } __attribute__((packed));
125
126 struct dhcp6_opt_h
127 {
128 uint16_t code;
129 uint16_t len;
130 } __attribute__((packed));
131
132 struct dhcp6_duid
133 {
134 uint16_t type;
135 union {
136 struct {
137 uint16_t htype;
138 uint32_t time;
139 uint8_t addr[0];
140 } __attribute__((packed)) llt;
141 struct {
142 uint32_t enterprise;
143 uint8_t id[0];
144 } __attribute__((packed)) en;
145 struct {
146 uint16_t htype;
147 uint8_t addr[0];
148 } __attribute__((packed)) ll;
149 uint8_t raw[128];
150 } u;
151 } __attribute__((packed));
152
153 struct dhcp6_opt_serverid
154 {
155 struct dhcp6_opt_h opt_hdr;
156 struct dhcp6_duid duid;
157 } __attribute__((packed));
158
159 struct dhcp6_opt_clientid
160 {
161 struct dhcp6_opt_h opt_hdr;
162 struct dhcp6_duid duid;
163 } __attribute__((packed));
164
165 struct dhcp6_opt_ia_na {
166 struct dhcp6_opt_h hdr;
167 uint32_t iaid;
168 uint32_t T1;
169 uint32_t T2;
170 } __attribute__((packed));
171
172 struct dhcp6_opt_ia_ta {
173 struct dhcp6_opt_h hdr;
174 uint32_t iaid;
175 } __attribute__((packed));
176
177 struct dhcp6_opt_ia_pd {
178 struct dhcp6_opt_h hdr;
179 uint32_t iaid;
180 uint32_t T1;
181 uint32_t T2;
182 } __attribute__((packed));
183
184 struct dhcp6_opt_ia_addr {
185 struct dhcp6_opt_h hdr;
186 struct in6_addr addr;
187 uint32_t pref_lifetime;
188 uint32_t valid_lifetime;
189 } __attribute__((packed));
190
191 struct dhcp6_opt_oro {
192 struct dhcp6_opt_h hdr;
193 uint16_t opt_demand[0];
194 } __attribute__((packed));
195
196 struct dhcp6_opt_status {
197 struct dhcp6_opt_h hdr;
198 uint16_t code;
199 } __attribute__((packed));
200
201 struct dhcp6_opt_preference {
202 struct dhcp6_opt_h hdr;
203 uint8_t pref;
204 } __attribute__((packed));
205
206 struct dhcp6_opt_ia_prefix {
207 struct dhcp6_opt_h hdr;
208 uint32_t pref_lifetime;
209 uint32_t valid_lifetime;
210 uint8_t prefix_len;
211 struct in6_addr prefix;
212 } __attribute__((packed));
213
214 // dhcp6.c
215 void dhcpv6_process(uint16_t s, uint16_t t, uint8_t *p, uint16_t l);
216 void dhcpv6_init(void);
217
218 #endif /* __DHCP6_H__ */