1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** NetX Component                                                        */
16 /**                                                                       */
17 /**   Dynamic Host Configuration Protocol over IPv6 (DHCPv6)              */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  APPLICATION INTERFACE DEFINITION                       RELEASE        */
26 /*                                                                        */
27 /*    nxd_dhcpv6_server.h                                 PORTABLE C      */
28 /*                                                           6.1.9        */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Yuxin Zhou, Microsoft Corporation                                   */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the NetX Dynamic Host Configuration Protocol over */
36 /*    IPv6 (DHCPv6) component, including all data types and external      */
37 /*    references. It is assumed that nx_api.h and nx_port.h have already  */
38 /*    been included.                                                      */
39 /*                                                                        */
40 /*  RELEASE HISTORY                                                       */
41 /*                                                                        */
42 /*    DATE              NAME                      DESCRIPTION             */
43 /*                                                                        */
44 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
45 /*  09-30-2020     Yuxin Zhou               Modified comment(s), improved */
46 /*                                            packet length verification, */
47 /*                                            resulting in version 6.1    */
48 /*  10-15-2021     Yuxin Zhou               Modified comment(s), included */
49 /*                                            necessary header file,      */
50 /*                                            resulting in version 6.1.9  */
51 /*                                                                        */
52 /**************************************************************************/
53 
54 #ifndef NXD_DHCPV6_SERVER_H
55 #define NXD_DHCPV6_SERVER_H
56 
57 /* Determine if a C++ compiler is being used.  If so, ensure that standard
58    C is used to process the API information.  */
59 
60 #ifdef   __cplusplus
61 
62 /* Yes, C++ compiler is present.  Use standard C.  */
63 extern   "C" {
64 
65 #endif
66 
67 #include "nx_api.h"
68 
69 /* Define the DHCPv6 ID to mark the DHCPV6_CLIENT and DHCPV6_SERVER structures as created.  */
70 
71 #define NX_DHCPV6_CLIENT_ID               0x44484336UL
72 #define NX_DHCPV6_SERVER_ID               0x44484337UL
73 
74 
75 /* Define the conversion between timer ticks and seconds (processor dependent). */
76 
77 #define NX_DHCPV6_SERVER_TICKS_PER_SECOND                   NX_IP_PERIODIC_RATE
78 
79 
80 /* Set up interface defines for NetX Duo. */
81 
82 #define LINK_LOCAL_INTERFACE                                0
83 #define GLOBAL_IP_INTERFACE                                 1
84 
85 
86 /* Set the Client lease time. An infinate lease time is not recommended by the RFC
87    unless the Client requires a permanent IP address.  Most servers will likely not
88    grant an infinite IP address lease. */
89 
90 #define NX_DHCPV6_INFINITE_LEASE                            0xffffffffUL
91 #define NX_DHCPV6_MULTICAST_MASK                            0xff000000UL
92 
93 
94 /* Define RFC mandated (draft only) option codes. */
95 
96 #define NX_DHCPV6_RFC_DNS_SERVER_OPTION                     0x00000017UL    /* RFC Option code for requesting DNS server IP address  */
97 #define NX_DHCPV6_RFC_TIME_SERVER_OPTION                    0x0000001FUL    /* RFC Option code for requesting tme server IP address. */
98 #define NX_DHCPV6_RFC_TIME_ZONE_OPTION                      0x00000029UL    /* RFC Option code for requesting Time zone. */
99 #define NX_DHCPV6_RFC_DOMAIN_NAME                           0x00000018UL    /* RFC Option code for requesting domain name. */
100 
101 
102 /* Define the DHCPv6 DUID types supported by the NetX DHCPv6 Server. */
103 
104 typedef enum
105 {
106 NX_DHCPV6_SERVER_DUID_TYPE_LINK_TIME =                         1,
107 NX_DHCPV6_SERVER_DUID_TYPE_VENDOR_ASSIGNED,
108 NX_DHCPV6_SERVER_DUID_TYPE_LINK_ONLY
109 
110 } NX_DHCPV6_DUID_TYPE_SERVER;
111 
112 /* Define constants for denoting server vs client DUIDs. */
113 
114 #define NX_DHCPV6_SERVER_DUID_TYPE                          1
115 #define NX_DHCPV6_CLIENT_DUID_TYPE                          2
116 
117 /* Define approximate time since Jan 1, 2000 for computing DUID time. This will form the
118    basis for the DUID time ID field.  */
119 
120 #define SECONDS_SINCE_JAN_1_2000_MOD_32                     2563729999UL
121 
122 
123 /* Define the Hardware types.  */
124 #define NX_DHCPV6_SERVER_HARDWARE_TYPE_ETHERNET             1
125 #define NX_DHCPV6_SERVER_HARDWARE_TYPE_EUI_64               27
126 
127 /* NX_DHCPV6_HW_TYPE_IEEE_802 is defined as 1 to indicate Ethernet hardware type in old releases, for backward compatibility.
128 
129    Note: NX_DHCPV6_HW_TYPE_IEEE_802 will be deprecated by NX_DHCPV6_SERVER_HARDWARE_TYPE_ETHERNET
130          in future releases, should use above symbols to define hardware types.
131 */
132 #define NX_DHCPV6_HW_TYPE_IEEE_802                          1
133 
134 
135 /* Define the symbol for a static IP address lease, e.g. infinity. */
136 
137 #define NX_DHCPV6_INFINTY_LEASE                             0xFFFFFFFF
138 
139 
140 /* Define the DHCPv6 Message Types.  */
141 
142 #define NX_DHCPV6_MESSAGE_TYPE_DHCPSILENT               0
143 #define NX_DHCPV6_MESSAGE_TYPE_SOLICIT                  1
144 #define NX_DHCPV6_MESSAGE_TYPE_ADVERTISE                2
145 #define NX_DHCPV6_MESSAGE_TYPE_REQUEST                  3
146 #define NX_DHCPV6_MESSAGE_TYPE_CONFIRM                  4
147 #define NX_DHCPV6_MESSAGE_TYPE_RENEW                    5
148 #define NX_DHCPV6_MESSAGE_TYPE_REBIND                   6
149 #define NX_DHCPV6_MESSAGE_TYPE_REPLY                    7
150 #define NX_DHCPV6_MESSAGE_TYPE_RELEASE                  8
151 #define NX_DHCPV6_MESSAGE_TYPE_DECLINE                  9
152 #define NX_DHCPV6_MESSAGE_TYPE_RECONFIGURE              10
153 #define NX_DHCPV6_MESSAGE_TYPE_INFORM_REQUEST           11
154 
155 
156 /* Define the DHCPv6 Options.  */
157 
158 #define NX_DHCPV6_OP_DUID_CLIENT                        1         /* Client DUID (DHCP unique identifier) */
159 #define NX_DHCPV6_OP_DUID_SERVER                        2         /* Server DUID (DHCP unique identifier) */
160 #define NX_DHCPV6_OP_IA_NA                              3         /* Identity association for non temporary addresses */
161 #define NX_DHCPV6_OP_IA_TA                              4         /* Identity association for temporary addresses */
162 #define NX_DHCPV6_OP_IA_ADDRESS                         5         /* Address associated with IA_NA or IA_TA */
163 #define NX_DHCPV6_OP_OPTION_REQUEST                     6         /* Identifies a list of options */
164 #define NX_DHCPV6_OP_PREFERENCE                         7         /* Server's means of affecting Client choice of servers. */
165 #define NX_DHCPV6_OP_ELAPSED_TIME                       8         /* Duration of Client exchange with DHCPv6 server  */
166 #define NX_DHCPV6_OP_RELAY_MESSAGE                      9         /* Not in use in NetX DHCPV6 */
167 #define NX_DHCPV6_OP_AUTHENTICATION                     11        /* Not in use in NetX DHCPV6 */
168 #define NX_DHCPV6_OP_SERVER_UNICAST                     12        /* Server ok's allowing the client to address it in Unicast */
169 #define NX_DHCPV6_OP_OPTION_STATUS                      13        /* Option request status.  */
170 #define NX_DHCPV6_OP_RAPID_COMMIT                       14        /* Option requesting exchange of two DHCPv6 packets to assign address  */
171 
172 
173 /* Define the DHCPv6 Client states */
174 
175 #define NX_DHCPV6_STATE_BOUND                            1          /* Client not known to be bound to an IP address.   */
176 #define NX_DHCPV6_STATE_UNBOUND                          2          /* Client is bound to an IP address (not necessarily by this server).  */
177 
178 
179 /* Define DHCPv6 event flags.  These events are processed by the Server DHCPv6 thread. */
180 
181 #define NX_DHCPV6_ALL_EVENTS                            0xFFFFFFFFUL    /* All Server DHCPv6 event flags */
182 #define NX_DHCPV6_SERVER_RECEIVE_EVENT                  0x00000001UL    /* Packet received on the DHCPv6 server queue. */
183 #define NX_DHCPV6_IP_LEASE_CHECK_PERIODIC_EVENT         0x00000008UL    /* Time keeper to check for expiration on leased IP addresses. */
184 #define NX_DHCPV6_CHECK_SESSION_PERIODIC_EVENT          0x00000004UL    /* Time keeper to check if each session with active client has timed out. */
185 
186 
187 /* Define DHCPv6 client and server ports.  */
188 
189 #define NX_DHCPV6_SERVER_UDP_PORT                       547
190 #define NX_DHCPV6_CLIENT_UDP_PORT                       546
191 
192 
193 /* Define error codes from DHCPv6 API.  */
194 
195 #define NX_DHCPV6_ALREADY_STARTED                       0xE91    /* DHCPv6 already started when API called to start it. */
196 #define NX_DHCPV6_NOT_STARTED                           0xE92    /* DHCPv6 was not started when API was called  */
197 #define NX_DHCPV6_PARAM_ERROR                           0xE93    /* Invalid non pointer input to API */
198 #define NX_DHCPV6_INVALID_DEVICE_MAC_ADDRESS            0xE94    /* DHCPv6 server device mac address unknown or undefined */
199 #define NX_DHCPV6_INVALID_INTERFACE_IP_ADDRESS          0xE95    /* DHCPv6 server interface global IP address unknown or undefined */
200 #define NX_DHCPV6_INVALID_INTERFACE_LL_ADDRESS          0xE96    /* DHCPv6 server interface link local address unknown or undefined */
201 #define NX_DHCPV6_INVALID_GLOBAL_INDEX                  0xE97    /* DHCPv6 global address index not set */
202 #define NX_DHCPV6_BAD_SERVER_DUID                       0xE98    /* Invalid or inappropriate server DUID (Should not be in some DHCPv6 message types).  */
203 #define NX_DHCPV6_MESSAGE_DUID_MISSING                  0xE99    /* Received a message type missing server or client DUID. */
204 #define NX_DHCPV6_INVALID_INTERFACE_INDEX               0xEBC    /* Specified interface does not exist for the DHCPv6 server instance  */
205 #define NX_DHCPV6_INVALID_IANA_TIME                     0xEA0    /* Client IA-NA option T1 vs T2 address lease time is invalid. */
206 #define NX_DHCPV6_IANA_OPTION_MISSING                   0xEA1    /* Received IA address option not belonging to an IA block */
207 #define NX_DHCPV6_NO_SERVER_DUID                        0xEA2    /* No server DUID detected; DHCPv6 server cannot start without one */
208 #define NX_DHCPV6_INVALID_IANA_DATA                     0xEA3    /* Client IA-NA option block has bad syntax or missing data */
209 #define NX_DHCPV6_INVALID_IA_DATA                       0xEA5    /* Server IA address option block has bad syntax or missing data */
210 #define NX_DHCPV6_INVALID_IA_TIME                       0xEA6    /* Server IA option preferred vs valid lease time is invalid. */
211 #define NX_DHCPV6_NO_ASSIGNABLE_ADDRESSES               0xEA7    /* Server created with no assignable addresses. */
212 #define NX_DHCPV6_ADDRESS_NOT_FOUND                     0xEA8    /* Client address not found in server lease table. */
213 #define NX_DHCPV6_OPTION_BLOCK_INCOMPLETE               0xEA9    /* Empty option block data; either zero length or zero option parsed. */
214 #define NX_DHCPV6_INVALID_OPTION_DATA                   0xEAA    /* Server received option data with missing data or bad syntax */
215 #define NX_DHCPV6_ILLEGAL_MESSAGE_TYPE                  0xEB1    /* Received invalid message request e.g. RENEW (server should discard),  */
216 #define NX_DHCPV6_PROCESSING_ERROR                      0xEB5    /* Invalid Client packet with DHCPv6 format or packet size  */
217 #define NX_DHCPV6_INSUFFICIENT_PACKET_PAYLOAD           0xEB6    /* Server DHCPv6 reply will not fit in packet pool packet buffer. */
218 #define NX_DHCPV6_INVALID_DATA_SIZE                     0xEB7    /* Attempting to parse too large a data object from DHCPv6 request. */
219 #define NX_DHCPV6_TABLE_FULL                            0xEC4    /* Server table (e.g. Client records or IP address leases) is full. */
220 #define NX_DHCPV6_INVALID_IP_ADDRESS                    0xECB    /* Invalid IP address e.g. null address received or obtained from client record. */
221 #define NX_DHCPV6_INVALID_DUID                          0xECC    /* Invalid DUID received from client or retrieved from memory. */
222 #define NX_DHCPV6_CLIENT_RECORD_NOT_FOUND               0xECF    /* Unable to find client in Client records table. */
223 #define NX_DHCPV6_TIMER_INTERNAL_ERROR                  0xED4    /* Problem setting or accessing real time clock server for DUID time field. */
224 #define NX_DHCPV6_INVALID_VENDOR_DATA                   0xED5    /* Vendor data invalid (ID is too long, null data etc). */
225 
226 
227 /* Define the DHCPv6 status codes.  */
228 
229 #define NX_DHCPV6_STATUS_SUCCESS               0        /* Client request granted. */
230 #define NX_DHCPV6_STATUS_UNSPECIFIED           1        /* Failure, reason unspecified; */
231 #define NX_DHCPV6_STATUS_NO_ADDRS_AVAILABLE    2        /* Server has no addresses available to assign to  the IA(s) */
232 #define NX_DHCPV6_STATUS_NO_BINDING            3        /* Client record (binding) unavailable or not possible */
233 #define NX_DHCPV6_STATUS_NOT_ON_LINK           4        /* Address prefix not appropriate for client domain */
234 #define NX_DHCPV6_STATUS_USE_MULTICAST         5        /* Server informs client to use the All_DHCP_Relay_Agents_and_Servers address. */
235 
236 
237 /* Define the server messages for IANA status codes.  Note that these
238    messages must be shorter than the NX_DHCPV6_STATUS_MESSAGE_MAX
239    option defined for the client IANA status option.
240 */
241 #ifndef NX_DHCPV6_STATUS_MESSAGE_SUCCESS
242 #define NX_DHCPV6_STATUS_MESSAGE_SUCCESS                "IA OPTION GRANTED"
243 #endif
244 
245 #ifndef NX_DHCPV6_STATUS_MESSAGE_UNSPECIFIED
246 #define NX_DHCPV6_STATUS_MESSAGE_UNSPECIFIED            "IA OPTION NOT GRANTED-FAILURE UNSPECIFIED"
247 #endif
248 
249 #ifndef NX_DHCPV6_STATUS_MESSAGE_NO_ADDRS_AVAILABLE
250 #define NX_DHCPV6_STATUS_MESSAGE_NO_ADDRS_AVAILABLE     "IA OPTION NOT GRANTED-NO ADDRESSES AVAILABLE"
251 #endif
252 
253 
254 #ifndef NX_DHCPV6_STATUS_MESSAGE_NO_BINDING
255 #define NX_DHCPV6_STATUS_MESSAGE_NO_BINDING             "IA OPTION NOT GRANTED-INVALID CLIENT REQUEST"
256 #endif
257 
258 
259 #ifndef NX_DHCPV6_STATUS_MESSAGE_NOT_ON_LINK
260 #define NX_DHCPV6_STATUS_MESSAGE_NOT_ON_LINK            "IA OPTION NOT GRANTED-CLIENT NOT ON LINK"
261 #endif
262 
263 
264 #ifndef NX_DHCPV6_STATUS_MESSAGE_USE_MULTICAST
265 #define NX_DHCPV6_STATUS_MESSAGE_USE_MULTICAST          "IA OPTION NOT GRANTED-CLIENT MUST USE MULTICAST"
266 #endif
267 
268 
269 /* Define the wait option on receiving packets on the DHCPv6 server queue. This
270    is on a receive notify callback, so there need not be any wait involved.  */
271 
272 #ifndef NX_DHCPV6_PACKET_WAIT_OPTION
273 #define NX_DHCPV6_PACKET_WAIT_OPTION                   NX_IP_PERIODIC_RATE
274 #endif
275 
276 /* Note the DHCPv6 server only supports the DNS server option in the current release. */
277 
278 
279 
280 /* Define the DHCPv6 Server application stack size. This is more than enough
281    for most DHCPv6 Server applications. */
282 
283 #ifndef NX_DHCPV6_SERVER_THREAD_STACK_SIZE
284 #define NX_DHCPV6_SERVER_THREAD_STACK_SIZE             4096
285 #endif
286 
287 
288 /* Define the DHCPv6 Server thread priority.  */
289 
290 #ifndef NX_DHCPV6_SERVER_THREAD_PRIORITY
291 #define NX_DHCPV6_SERVER_THREAD_PRIORITY               2
292 #endif
293 
294 
295 /* Define the timer interval in seconds for checking Client lease time expirations.  */
296 
297 #ifndef NX_DHCPV6_IP_LEASE_TIMER_INTERVAL
298 #define NX_DHCPV6_IP_LEASE_TIMER_INTERVAL       (60)
299 #endif
300 
301 
302 /* Define the timer interval in seconds for the session duration timer.  */
303 
304 #ifndef NX_DHCPV6_SESSION_TIMER_INTERVAL
305 #define NX_DHCPV6_SESSION_TIMER_INTERVAL         (3)
306 #endif
307 
308 
309 /* Define the session time out in seconds. This is the timer for how long the server has not
310    received a client response. */
311 
312 #ifndef NX_DHCPV6_SESSION_TIMEOUT
313 #define NX_DHCPV6_SESSION_TIMEOUT                (20)
314 #endif
315 
316 /* Define the private ID of the vendor DUID tuple. This is a 32 bit word. */
317 
318 #ifndef NX_DHCPV6_SERVER_DUID_VENDOR_PRIVATE_ID
319 #define NX_DHCPV6_SERVER_DUID_VENDOR_PRIVATE_ID   0x12345678
320 #endif
321 
322 
323 /* Define the size limit on the Vendor ID buffer. */
324 
325 #ifndef NX_DHCPV6_SERVER_DUID_VENDOR_ASSIGNED_LENGTH
326 #define NX_DHCPV6_SERVER_DUID_VENDOR_ASSIGNED_LENGTH               48
327 #endif
328 
329 
330 /* Define the vendor ID. The server must have this data to create its DUID required for sending
331    responses to the DHCPv6 client. */
332 
333 #ifndef NX_DHCPV6_SERVER_DUID_VENDOR_ASSIGNED_ID
334 #define NX_DHCPV6_SERVER_DUID_VENDOR_ASSIGNED_ID                  "abcdeffghijklmnopqrstuvwxyz"
335 #endif
336 
337 
338 /* Define parameters for the server DUID */
339 
340 /* Define the server DUID type.  The most common are link layer, based on mac address,
341    and link layer-time which is based on mac address and current time.  */
342 
343 #ifndef NX_DHCPV6_SERVER_DUID_TYPE
344 #define NX_DHCPV6_SERVER_DUID_TYPE                          NX_DHCPV6_DUID_TYPE_LINK_TIME
345 #endif
346 
347 
348 /* Default DUID hardware type to Ethernet */
349 
350 #ifndef NX_DHCPV6_SERVER_HW_TYPE
351 #define NX_DHCPV6_SERVER_HW_TYPE                            NX_DHCPV6_SERVER_HARDWARE_TYPE_ETHERNET
352 #endif
353 
354 
355 /* Define the preference option pref-value. When multiple DHCPv6 servers exist, this
356    enables a server to tell the client which preference to place on this server. The higher
357    the value the greater the preference. A value of 255 received by a DHCPv6
358    client will instruct the client to choose this DHPCv6 server immediately, rather
359    than wait for the full round trip time out option specified in RFC 3315. RFC 3315
360    sect 17.2.2 requires the server set this value to zero by default*/
361 
362 #ifndef NX_DHCPV6_PREFERENCE_VALUE
363 #define NX_DHCPV6_PREFERENCE_VALUE              0
364 #endif
365 
366 
367 /* Define the maximum options to extract from a client message. This makes
368    no assumptions about the packet size limitations which the host application
369    must ensure can handle both the client request and the server reply. */
370 
371 #ifndef NX_DHCPV6_MAX_OPTION_REQUEST_OPTIONS
372 #define NX_DHCPV6_MAX_OPTION_REQUEST_OPTIONS    6
373 #endif
374 
375 
376 /* Set the default T1 time, which is when the Client should begin renewing its IP address,
377    for leased IP addresses in seconds. RFC 3315 recommends
378    T1 is 0.5 the value of the preferred lifetime. */
379 
380 #ifndef  NX_DHCPV6_DEFAULT_T1_TIME
381 #define  NX_DHCPV6_DEFAULT_T1_TIME              (2000)
382 #endif
383 
384 
385 /* Set the default T2 time, which is when the Client should begin renewing its IP address,
386    assuming renewal attempts failed, for leased IP addresses in seconds.
387    T2 must be greater than T2 and less than the value of the preferred lifetime. */
388 
389 #ifndef  NX_DHCPV6_DEFAULT_T2_TIME
390 #define  NX_DHCPV6_DEFAULT_T2_TIME              (3000)
391 #endif
392 
393 
394 /* Set the default preferred lifetime for leased IP addresses in seconds, which is
395     when the Client IP address becomes deprecated. A value of zero in
396     this field indicates that the server leaves it to the
397    client discretion to renew its IP address lease. */
398 
399 #ifndef  NX_DHCPV6_DEFAULT_PREFERRED_TIME
400 #define  NX_DHCPV6_DEFAULT_PREFERRED_TIME        (2 * NX_DHCPV6_DEFAULT_T1_TIME)
401 #endif
402 
403 
404 /* Set the default valid lifetime in seconds for leased IP addresses in secs, which is when
405    the Client IP address becomes obsolete. A value of zero in this field indicates
406    that the server leaves it to the client discretion to renew its IP address lease.
407    The valid time must be greater than the preferred time. */
408 
409 #ifndef  NX_DHCPV6_DEFAULT_VALID_TIME
410 #define  NX_DHCPV6_DEFAULT_VALID_TIME             (2 * NX_DHCPV6_DEFAULT_PREFERRED_TIME)
411 #endif
412 
413 
414 
415 /* Define maximum size for server messages in status option. */
416 
417 #ifndef NX_DHCPV6_STATUS_MESSAGE_MAX
418 #define NX_DHCPV6_STATUS_MESSAGE_MAX           100
419 #endif
420 
421 
422 /* Define the max number of IPv6 address leases available to lease.  */
423 
424 #ifndef NX_DHCPV6_MAX_LEASES
425 #define NX_DHCPV6_MAX_LEASES                   100
426 #endif
427 
428 
429 /* Define the max number of clients the server can assign leases to at any given time.
430    These are clients either already leasing an IPv6 address or currently requesting one.
431    Note: there are more addresses than clients in the event the client declines an address
432    or one assigned is already in use. The NetX DHCPv6 server currently only supports
433    one IP address leased to each client. */
434 
435 #ifndef NX_DHCPV6_MAX_CLIENTS
436 #define NX_DHCPV6_MAX_CLIENTS                   120
437 #endif
438 
439 /* Define the wait option in timer ticks for DHCPv6 server packet allocations.  */
440 
441 #ifndef NX_DHCPV6_PACKET_TIME_OUT
442 #define NX_DHCPV6_PACKET_TIME_OUT               (3 * NX_DHCPV6_SERVER_TICKS_PER_SECOND)
443 #endif
444 
445 
446 /* Define the DHCPv6 packet size. Should be large enough to hold IP and UDP headers,
447    plus DHCPv6 data runs about 200 - 300 bytes for a typical exchange. */
448 
449 #ifndef NX_DHCPV6_PACKET_SIZE
450 #define NX_DHCPV6_PACKET_SIZE                    500
451 #endif
452 
453 
454 /* Define the DHCPv6 packet memory area. Packet pool size depends on client traffic and
455    available network bandwidth. */
456 
457 #ifndef NX_DHCPV6_PACKET_POOL_SIZE
458 #define NX_DHCPV6_PACKET_POOL_SIZE               (10 * NX_DHCPV6_PACKET_SIZE)
459 #endif
460 
461 
462 /* Define UDP socket type of service.  */
463 
464 #ifndef NX_DHCPV6_TYPE_OF_SERVICE
465 #define NX_DHCPV6_TYPE_OF_SERVICE                NX_IP_NORMAL
466 #endif
467 
468 
469 /* Define the UDP socket fragment option. */
470 
471 #ifndef NX_DHCPV6_FRAGMENT_OPTION
472 #define NX_DHCPV6_FRAGMENT_OPTION                NX_DONT_FRAGMENT
473 #endif
474 
475 /* Define the number of routers a UDP packet passes before it is discarded. */
476 
477 #ifndef NX_DHCPV6_TIME_TO_LIVE
478 #define NX_DHCPV6_TIME_TO_LIVE                   0x80
479 #endif
480 
481 /* Define the stored packets in the UDP server socket queue. */
482 
483 #ifndef NX_DHCPV6_QUEUE_DEPTH
484 #define NX_DHCPV6_QUEUE_DEPTH                    5
485 #endif
486 
487 
488 /* Define the Identity Association Internet Address option structure  */
489 typedef struct NX_DHCPV6_SERVER_IA_ADDRESS_STRUCT
490 {
491 
492     USHORT          nx_op_code;                    /* IA internet address option code is 5 */
493     USHORT          nx_option_length;              /* Length of the IA address option data = 24 not including length and op code field*/
494     NXD_ADDRESS     nx_global_address;             /* Assigned Host IPv6 address */
495     ULONG           nx_preferred_lifetime;         /* Server's preference for IPv6 address T1 life time for itself */
496     ULONG           nx_valid_lifetime;             /* Server's assigned valid time for T2 for any server  */
497 
498 } NX_DHCPV6_SERVER_IA_ADDRESS;
499 
500 /* Define the Option status structure  */
501 typedef struct NX_DHCPV6_SERVER_IANA_STATUS_STRUCT
502 {
503 
504     USHORT          nx_op_code;                    /* IA address option code is 5 */
505     USHORT          nx_option_length;              /* Length of the IA address option data = 24 not including length and op code field*/
506     USHORT          nx_status_code;                /* Server status (reply) to client request */
507     CHAR            nx_status_message[NX_DHCPV6_STATUS_MESSAGE_MAX];
508                                                    /* Buffer containing server status messages */
509 } NX_DHCPV6_SERVER_IANA_STATUS;
510 
511 
512 /* Define the Preference Option structure  */
513 typedef struct NX_DHCPV6_SERVER_PREFERENCE_STRUCT
514 {
515 
516     USHORT          nx_op_code;                    /* IA address option code is 5 */
517     USHORT          nx_option_length;              /* Length of the IA address option data = 24 not including length and op code field*/
518     USHORT          nx_pref_value;                  /* Assigned Host IPv6 address */
519 
520 } NX_DHCPV6_SERVER_PREFERENCE;
521 
522 
523 /* Define the Identity Association for Permanent ("Non Temporary" in RFC) address */
524 
525 typedef struct NX_DHCPV6_SERVER_IA_NA_STRUCT
526 {
527 
528     USHORT              nx_op_code;             /* IA NA address option code is 3 */
529     USHORT              nx_option_length;       /* 12 + length of variable length fields in IA_NA option . */
530     ULONG               nx_IA_NA_id;            /* IANA identifier; must be unique among all client IANA's. Must be the same on restart per IANA */
531     ULONG               nx_T1;                  /* Time client can extend time before address lifetime expires from the server it got it from; applies to all addresses in IA_NA. */
532     ULONG               nx_T2;                  /* Same as T1 except this is when the client will request REBIND from another server. */
533 
534 } NX_DHCPV6_SERVER_IA_NA;
535 
536 
537 /* Define DHCPv6 Unique Identifier (DUID); both Client and Server must send messages with their own DUID. */
538 
539 typedef struct NX_DHCPV6_SVR_DUID_STRUCT
540 {
541 
542     USHORT            nx_op_code;                 /* Client DUID option code is 1; Server DUID code is 2  */
543     USHORT            nx_option_length;           /* Option length = 14 not including length and op code field; */
544     USHORT            nx_duid_type;               /* 3 main types: hw; hw + time; vendor assigned ID (not supported here); requires DUID be stored in non volatile storage */
545     USHORT            nx_hardware_type;           /* Only if LL/LLT type. Hardware type specified by IANA/RFC 826 e.g. IEEE 802; network byte order */
546     ULONG             nx_duid_time;               /* Only if LLT type. Time based on when DUID generated; network byte order. */
547     ULONG             nx_duid_enterprise_number;  /* Only if vendor assigned (enterprise) DUID */
548     UCHAR             nx_duid_private_identifier[NX_DHCPV6_SERVER_DUID_VENDOR_ASSIGNED_LENGTH];
549     USHORT            nx_link_layer_address_msw;  /* Only if LL/LLT type. Pointer to Unique link layer address - most significant word (2 bytes)*/
550     ULONG             nx_link_layer_address_lsw;  /* Only if LL/LLT type. Pointer to Unique link layer address - least significant word (4 bytes) */
551 
552 } NX_DHCPV6_SVR_DUID;
553 
554 
555 /* Define the elapsed time option structure.  This contains the length of the Client Server session. */
556 
557 typedef struct NX_DHCPV6_SERVER_ELAPSED_TIME_STRUCT
558 {
559 
560     USHORT            nx_op_code;                /* Elapsed time option code = 8 not including length and op code field. */
561     USHORT            nx_option_length;              /* Length of time data = 2. */
562     USHORT            nx_session_time;           /* Time of DHCP session e.g. first msg elapsed time is zero. */
563 
564 } NX_DHCPV6_SERVER_ELAPSED_TIME;
565 
566 
567 /* Define the option request structure. This is how the Client requests information other than global IP address.
568    It can ask for domain name, DNS server, time zone, time server and other options. */
569 
570 typedef struct NX_DHCPV6_SERVER_OPTIONREQUEST_STRUCT
571 {
572     USHORT             nx_op_code;                /* Option Request code  = 6*/
573     USHORT             nx_option_length;          /* Length in bytes of option data = 2 * number of requests */
574     USHORT             nx_op_request[NX_DHCPV6_MAX_OPTION_REQUEST_OPTIONS];
575                                                   /* List of option request options e.g. DNS server */
576 
577 } NX_DHCPV6_SERVER_OPTIONREQUEST;
578 
579 /* Define the Client DHCPv6 structure containing the DHCPv6 Client record (DHCPv6 status, server DUID etc).  */
580 
581 typedef struct NX_DHCPV6_CLIENT_STRUCT
582 {
583 
584     ULONG                   nx_dhcpv6_id;                               /* DHCPv6 Structure ID  */
585     ULONG                   nx_dhcpv6_message_xid;                      /* Message transaction ID (3 bytes)*/
586     UCHAR                   nx_dhcpv6_state;                            /* The current state of the DHCPv6 Client */
587     UINT                    nx_dhcpv6_message_type;                     /* DHCPv6 message type most recently received from client. */
588     UINT                    nx_dhcpv6_response_back_from_server;        /* Response server will send back to client based on previous client message */
589     NX_DHCPV6_SVR_DUID      nx_dhcpv6_client_duid;                      /* Client DUID parsed from client DHCPv6 requests */
590     NX_DHCPV6_SVR_DUID      nx_dhcpv6_server_duid;                      /* Server DUID parsed from client DHCPv6 requests */
591     ULONG                   nx_dhcpv6_client_session_time;              /* Duration of client server session. Used to determine if client quit on the session. */
592     UINT                    nx_dhcpv6_rapid_commit_status;              /* Client status on rapid commit (set to true if requests and server approves). */
593     NX_DHCPV6_SERVER_ELAPSED_TIME
594                             nx_dhcpv6_elapsed_time;                     /* Time duration of the current DHCP msg exchange between Client and Server. */
595     NX_DHCPV6_SERVER_IA_NA  nx_dhcpv6_iana;                             /* Identity Association for non temp address - must be stored in non volatile memory */
596     NX_DHCPV6_SERVER_IA_ADDRESS
597                             nx_dhcpv6_ia;                               /* Client internet address option */
598     NX_DHCPV6_SERVER_OPTIONREQUEST
599                             nx_dhcpv6_option_request;                   /* Set of request options in Solicit, Renew, Confirm or Rebind message types. */
600     NX_DHCPV6_SERVER_IANA_STATUS
601                             nx_dhcpv6_iana_status;                      /* Status option set by the server for client IANA */
602     NX_DHCPV6_SERVER_PREFERENCE
603                             nx_dhcpv6_preference;                       /* Preference option set by the server */
604     ULONG                   nx_dhcpv6_IP_lease_time_accrued ;           /* Time remaining on the Client IP address lease. */
605     NXD_ADDRESS             nx_dhcp_source_ip_address;                  /* Source IP of the client DHCP message. */
606     NXD_ADDRESS             nx_dhcp_destination_ip_address;             /* Destination IP of the client DHCP message. */
607 
608 } NX_DHCPV6_CLIENT;
609 
610 /* Define the DHCPv6 server interface IP address table. */
611 
612 typedef struct NX_DHCPV6_ADDRESS_LEASE_STRUCT
613 {
614 
615     NXD_ADDRESS             nx_dhcpv6_lease_IP_address;                       /* Address to assign */
616     ULONG                   nx_dhcpv6_lease_T1_lifetime;                      /* T1 value set if assigned to client */
617     ULONG                   nx_dhcpv6_lease_T2_lifetime;                      /* T2 value set if assigned to client */
618     ULONG                   nx_dhcpv6_lease_valid_lifetime;                   /* valid lifetime set if assigned to client */
619     ULONG                   nx_dhcpv6_lease_preferred_lifetime;               /* preferred lifetime set if assigned to client */
620     NX_DHCPV6_CLIENT        *nx_dhcpv6_lease_assigned_to;                      /* Client DUID assigned the address */
621 
622 }NX_DHCPV6_ADDRESS_LEASE;
623 
624 
625 /* Define the Server DHCPv6 structure containing the Client tables and assignable IP address tables.  */
626 
627 typedef struct NX_DHCPV6_SERVER_STRUCT
628 {
629     ULONG                   nx_dhcpv6_id;                                   /* DHCPv6 Structure ID  */
630     CHAR                    *nx_dhcpv6_server_name;                         /* DHCPv6 name supplied at create */
631     NX_IP                   *nx_dhcpv6_ip_ptr;                              /* The associated IP pointer for this DHCPV6 instance */
632     UINT                    nx_dhcpv6_server_interface_index;               /* Index indicating interface DHCPv6 requests accepted */
633     UINT                    nx_dhcpv6_server_ga_address_index;              /* Global address index of the DHCPv6 server*/
634     NX_DHCPV6_SVR_DUID       nx_dhcpv6_server_duid;                          /* DUID by which server identifies itself to clients */
635     NX_DHCPV6_CLIENT        nx_dhcpv6_clients[NX_DHCPV6_MAX_CLIENTS];       /* list of clients leased an IPv6 address */
636     NX_DHCPV6_ADDRESS_LEASE nx_dhcpv6_lease_list[NX_DHCPV6_MAX_LEASES];     /* List of IP addresses available for DHCPv6 Clients */
637     UINT                    nx_dhcpv6_assignable_addresses;                 /* Number of assignable addresses the server starts with. */
638     UINT                    nx_dhcpv6_server_multicast_only;                /* Indicate if the client should send requests using all servers multicast address */
639     NX_UDP_SOCKET           nx_dhcpv6_server_socket;                        /* UDP socket for communicating with DHCPv6 clients */
640     TX_MUTEX                nx_dhcpv6_server_mutex;                         /* Mutex protection of server control block */
641     TX_TIMER                nx_dhcpv6_lease_timer;                          /* Timer for tracking IP lease expiration   */
642     TX_TIMER                nx_dhcpv6_session_timer;                        /* Server session duration timer */
643     TX_THREAD               nx_dhcpv6_server_thread;                        /* DHCPv6 Server processing thread */
644     NX_PACKET_POOL          *nx_dhcpv6_packet_pool_ptr;                     /* Pointer to packet pool for sending DHCPV6 messages */
645     TX_EVENT_FLAGS_GROUP    nx_dhcpv6_server_timer_events;                  /* Message queue for IP lease and session timer events. */
646     UINT                    nx_dhcpv6_server_running;                       /* Status of dhcpv6 server; idle (NX_FALSE) or running (NX_TRUE) */
647     NXD_ADDRESS             nx_dhcpv6_dns_ip_address;                     /* DHCP server DNS Server Address in message to DHCP Client  */
648 
649     /* Define a handler for receiving a DECLINE or RELEASE message. */
650     VOID (*nx_dhcpv6_IP_address_declined_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UINT message_type);
651     /* Define a handler for Option Request options. */
652     VOID (*nx_dhcpv6_server_option_request_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request, UCHAR *buffer_ptr, UINT *index);
653 
654     /* Define a extended handler for Option Request options. */
655     VOID (*nx_dhcpv6_server_option_request_handler_extended)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request, UCHAR *buffer_ptr, UINT *index, UINT available_payload);
656 
657 } NX_DHCPV6_SERVER;
658 
659 #ifndef NX_DHCPV6_SOURCE_CODE
660 
661 /* Application caller is present, perform API mapping.  */
662 
663 /* Determine if error checking is desired.  If so, map DHCP API functions
664    to the appropriate error checking front-ends.  Otherwise, map API
665    functions to the core functions that actually perform the work.
666    Note: error checking is enabled by default.  */
667 
668 
669 #ifdef NX_DISABLE_ERROR_CHECKING
670 
671 /* Services without error checking.  */
672 
673 
674 #define nx_dhcpv6_set_server_duid               _nx_dhcpv6_set_server_duid
675 #define nx_dhcpv6_create_dns_address            _nx_dhcpv6_create_dns_address
676 #define nx_dhcpv6_create_ip_address_range       _nx_dhcpv6_create_ip_address_range
677 #define nx_dhcpv6_add_ip_address_lease          _nx_dhcpv6_add_ip_address_lease
678 #define nx_dhcpv6_add_client_record             _nx_dhcpv6_add_client_record
679 #define nx_dhcpv6_retrieve_client_record        _nx_dhcpv6_retrieve_client_record
680 #define nx_dhcpv6_retrieve_ip_address_lease     _nx_dhcpv6_retrieve_ip_address_lease
681 #define nx_dhcpv6_reserve_ip_address_range      _nx_dhcpv6_reserve_ip_address_range
682 #define nx_dhcpv6_server_create                 _nx_dhcpv6_server_create
683 #define nx_dhcpv6_server_delete                 _nx_dhcpv6_server_delete
684 #define nx_dhcpv6_server_resume                 _nx_dhcpv6_server_resume
685 #define nx_dhcpv6_server_suspend                _nx_dhcpv6_server_suspend
686 #define nx_dhcpv6_server_start                  _nx_dhcpv6_server_start
687 #define nx_dhcpv6_server_interface_set          _nx_dhcpv6_server_interface_set
688 #define nx_dhcpv6_server_option_request_handler_set _nx_dhcpv6_server_option_request_handler_set
689 
690 #else
691 
692 /* Services with error checking.  */
693 
694 #define nx_dhcpv6_set_server_duid               _nxe_dhcpv6_set_server_duid
695 #define nx_dhcpv6_create_dns_address            _nxe_dhcpv6_create_dns_address
696 #define nx_dhcpv6_create_ip_address_range       _nxe_dhcpv6_create_ip_address_range
697 #define nx_dhcpv6_add_ip_address_lease          _nxe_dhcpv6_add_ip_address_lease
698 #define nx_dhcpv6_add_client_record             _nxe_dhcpv6_add_client_record
699 #define nx_dhcpv6_retrieve_client_record        _nxe_dhcpv6_retrieve_client_record
700 #define nx_dhcpv6_retrieve_ip_address_lease     _nxe_dhcpv6_retrieve_ip_address_lease
701 #define nx_dhcpv6_reserve_ip_address_range      _nxe_dhcpv6_reserve_ip_address_range
702 #define nx_dhcpv6_server_create                 _nxe_dhcpv6_server_create
703 #define nx_dhcpv6_server_delete                 _nxe_dhcpv6_server_delete
704 #define nx_dhcpv6_server_resume                 _nxe_dhcpv6_server_resume
705 #define nx_dhcpv6_server_suspend                _nxe_dhcpv6_server_suspend
706 #define nx_dhcpv6_server_start                  _nxe_dhcpv6_server_start
707 #define nx_dhcpv6_server_interface_set          _nxe_dhcpv6_server_interface_set
708 #define nx_dhcpv6_server_option_request_handler_set _nxe_dhcpv6_server_option_request_handler_set
709 #endif   /* NX_DISABLE_ERROR_CHECKING */
710 
711 
712 /* Define the prototypes accessible to the application software.  */
713 UINT        nx_dhcpv6_set_server_duid(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT duid_type, UINT hardware_type, ULONG mac_address_msw, ULONG mac_address_lsw, ULONG time);
714 UINT        nx_dhcpv6_create_dns_address(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *dns_ipv6_address);
715 UINT        nx_dhcpv6_create_ip_address_range(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *start_ipv6_address, NXD_ADDRESS *end_ipv6_address, UINT *addresses_added);
716 UINT        nx_dhcpv6_add_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, ULONG T1, ULONG T2, ULONG valid_lifetime, ULONG preferred_lifetimeo);
717 UINT        nx_dhcpv6_add_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG message_xid, NXD_ADDRESS *client_address, UINT client_state,
718                                   ULONG IP_lease_time_accrued    , ULONG valid_lifetime, UINT duid_type,  UINT duid_hardware, ULONG physical_address_msw,
719                                   ULONG physical_address_lsw, ULONG duid_time, ULONG duid_vendor_number, UCHAR *duid_vendor_private, UINT duid_private_length);
720 UINT        nx_dhcpv6_retrieve_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG *message_xid, NXD_ADDRESS *client_address, UINT *client_state,
721                                   ULONG *IP_lease_time_accrued    , ULONG *valid_lifetime, UINT *duid_type,  UINT *duid_hardware, ULONG *physical_address_msw,
722                                   ULONG *physical_address_lsw, ULONG *duid_time, ULONG *duid_vendor_number, UCHAR *duid_vendor_private, UINT *duid_private_length);
723 UINT        nx_dhcpv6_retrieve_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, ULONG *T1, ULONG *T2, ULONG *valid_lifetime, ULONG *preferred_lifetime);
724 UINT        nx_dhcpv6_reserve_ip_address_range(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *start_ipv6_address, NXD_ADDRESS *end_ipv6_address, UINT *addresses_reserved);
725 UINT        nx_dhcpv6_server_create(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_IP *ip_ptr, CHAR *name_ptr, NX_PACKET_POOL *packet_pool_ptr, VOID *stack_ptr, ULONG stack_size,
726                               VOID (*dhcpv6_address_declined_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UINT message),
727                               VOID (*dhcpv6_option_request_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request, UCHAR *buffer_ptr, UINT *index));
728 UINT        nx_dhcpv6_server_delete(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
729 UINT        nx_dhcpv6_server_resume(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
730 UINT        nx_dhcpv6_server_start(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
731 UINT        nx_dhcpv6_server_suspend(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
732 UINT        nx_dhcpv6_server_interface_set(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT iface_index, UINT ga_address_index);
733 UINT        nx_dhcpv6_server_option_request_handler_set(NX_DHCPV6_SERVER *dhcpv6_server_ptr,
734                                                         VOID (*dhcpv6_option_request_handler_extended)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request,
735                                                                                                        UCHAR *buffer_ptr, UINT *index, UINT available_payload));
736 
737 #else
738 
739 /* DHCP source code is being compiled, do not perform any API mapping.  */
740 
741 UINT        _nxe_dhcpv6_set_server_duid(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT duid_type, UINT hardware_type, ULONG mac_address_msw, ULONG mac_address_lsw, ULONG time);
742 UINT        _nx_dhcpv6_set_server_duid(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT duid_type, UINT hardware_type, ULONG mac_address_msw, ULONG mac_address_lsw, ULONG time);
743 UINT        _nxe_dhcpv6_create_dns_address(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *dns_ipv6_address);
744 UINT        _nx_dhcpv6_create_dns_address(NX_DHCPV6_SERVER *dhcpv6_server_ptr,  NXD_ADDRESS *dns_ipv6_address);
745 UINT        _nxe_dhcpv6_create_ip_address_range(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *start_ipv6_address, NXD_ADDRESS *end_ipv6_address, UINT *addresses_added);
746 UINT        _nx_dhcpv6_create_ip_address_range(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *start_ipv6_address, NXD_ADDRESS *end_ipv6_address, UINT *addresses_added);
747 UINT        _nxe_dhcpv6_reserve_ip_address_range(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *start_ipv6_address, NXD_ADDRESS *end_ipv6_address, UINT *addresses_reserved);
748 UINT        _nx_dhcpv6_reserve_ip_address_range(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NXD_ADDRESS *start_ipv6_address, NXD_ADDRESS *end_ipv6_address, UINT *addresses_reserved);
749 UINT        _nxe_dhcpv6_add_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, ULONG T1, ULONG T2, ULONG valid_lifetime, ULONG preferred_lifetime);
750 UINT        _nx_dhcpv6_add_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, ULONG T1, ULONG T2, ULONG valid_lifetime, ULONG preferred_lifetime);
751 UINT        _nxe_dhcpv6_add_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG message_xid, NXD_ADDRESS *client_address, UINT client_state,
752                                   ULONG IP_lease_time_accrued    , ULONG valid_lifetime, UINT duid_type,  UINT duid_hardware, ULONG physical_address_msw,
753                                   ULONG physical_address_lsw, ULONG duid_time, ULONG duid_vendor_number, UCHAR *duid_vendor_private, UINT duid_private_length);
754 UINT        _nx_dhcpv6_add_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG message_xid, NXD_ADDRESS *client_address, UINT client_state,
755                                   ULONG IP_lease_time_accrued    , ULONG valid_lifetime, UINT duid_type,  UINT duid_hardware, ULONG physical_address_msw,
756                                   ULONG physical_address_lsw, ULONG duid_time, ULONG duid_vendor_number, UCHAR *duid_vendor_private, UINT duid_private_length);
757 UINT        _nxe_dhcpv6_retrieve_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG *message_xid, NXD_ADDRESS *client_address, UINT *client_state,
758                                   ULONG *IP_lease_time_accrued    , ULONG *valid_lifetime, UINT *duid_type,  UINT *duid_hardware, ULONG *physical_address_msw,
759                                   ULONG *physical_address_lsw, ULONG *duid_time, ULONG *duid_vendor_number, UCHAR *duid_vendor_private, UINT *duid_private_length);
760 UINT        _nx_dhcpv6_retrieve_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, ULONG *message_xid, NXD_ADDRESS *client_address, UINT *client_state,
761                                   ULONG *IP_lease_time_accrued    , ULONG *valid_lifetime, UINT *duid_type,  UINT *duid_hardware, ULONG *physical_address_msw,
762                                   ULONG *physical_address_lsw, ULONG *duid_time, ULONG *duid_vendor_number, UCHAR *duid_vendor_private, UINT *duid_private_length);
763 UINT        _nxe_dhcpv6_retrieve_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, ULONG *T1, ULONG *T2, ULONG *valid_lifetime, ULONG *preferred_lifetime);
764 UINT        _nx_dhcpv6_retrieve_ip_address_lease(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT table_index, NXD_ADDRESS *lease_IP_address, ULONG *T1, ULONG *T2, ULONG *valid_lifetime, ULONG *preferred_lifetime);
765 UINT        _nxe_dhcpv6_server_create(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_IP *ip_ptr, CHAR *name_ptr, NX_PACKET_POOL *packet_pool_ptr, VOID *stack_ptr,  ULONG stack_size,
766                              VOID (*dhcpv6_address_declined_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UINT message),
767                              VOID (*dhcpv6_option_request_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request, UCHAR *buffer_ptr, UINT *index));
768 UINT        _nx_dhcpv6_server_create(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_IP *ip_ptr, CHAR *name_ptr, NX_PACKET_POOL *packet_pool_ptr, VOID *stack_ptr,   ULONG stack_size,
769                              VOID (*dhcpv6_address_declined_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UINT message),
770                              VOID (*dhcpv6_option_request_handler)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request, UCHAR *buffer_ptr, UINT *index));
771 UINT        _nxe_dhcpv6_server_delete(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
772 UINT        _nx_dhcpv6_server_delete(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
773 UINT        _nxe_dhcpv6_server_resume(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
774 UINT        _nx_dhcpv6_server_resume(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
775 UINT        _nxe_dhcpv6_server_start(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
776 UINT        _nx_dhcpv6_server_start(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
777 UINT        _nxe_dhcpv6_server_suspend(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
778 UINT        _nx_dhcpv6_server_suspend(NX_DHCPV6_SERVER *dhcpv6_server_ptr);
779 UINT        _nxe_dhcpv6_server_interface_set(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT iface_index, UINT ga_address_index);
780 UINT        _nx_dhcpv6_server_interface_set(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT iface_index, UINT ga_address_index);
781 UINT        _nxe_dhcpv6_server_option_request_handler_set(NX_DHCPV6_SERVER *dhcpv6_server_ptr,
782                                                           VOID (*dhcpv6_option_request_handler_extended)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request,
783                                                                                                          UCHAR *buffer_ptr, UINT *index, UINT available_payload));
784 UINT        _nx_dhcpv6_server_option_request_handler_set(NX_DHCPV6_SERVER *dhcpv6_server_ptr,
785                                                          VOID (*dhcpv6_option_request_handler_extended)(struct NX_DHCPV6_SERVER_STRUCT *dhcpv6_server_ptr, UINT option_request,
786                                                                                                         UCHAR *buffer_ptr, UINT *index, UINT available_payload));
787 
788 
789 #endif  /* NX_DHCPV6_SOURCE_CODE */
790 
791 
792 UINT        _nx_dhcpv6_add_duid(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_SVR_DUID *dhcpv6_duid_ptr, UCHAR *buffer_ptr, UINT *index, UINT duid_type);
793 UINT        _nx_dhcpv6_add_ia(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_SERVER_IA_ADDRESS *dhcpv6_ia_ptr, UCHAR *buffer_ptr, UINT *index);
794 UINT        _nx_dhcpv6_server_add_iana(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr,  UCHAR *buffer_ptr, UINT *index);
795 UINT        _nx_dhcpv6_add_iana_status(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_SERVER_IANA_STATUS *iana_status_ptr, UCHAR *buffer_ptr, UINT *index);
796 UINT        _nx_dhcpv6_add_option_requests(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UCHAR *buffer_ptr, UINT *index);
797 UINT        _nx_dhcpv6_add_preference(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, UCHAR *buffer_ptr, UINT *index);
798 UINT        _nx_dhcpv6_assign_ip_address(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, NX_DHCPV6_ADDRESS_LEASE **interface_address_ptr);
799 UINT        _nx_dhcpv6_check_duids_same(NX_DHCPV6_SVR_DUID *dhcpv6_duid1_ptr, NX_DHCPV6_SVR_DUID *dhcpv6_duid2_ptr, UINT *matching);
800 UINT        _nx_dhcpv6_clear_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr);
801 UINT        _nx_dhcpv6_create_server_duid(NX_DHCPV6_SERVER *dhcpv6_server_ptr, UINT duid_type, UINT hardware_type, ULONG mac_address_msw, ULONG mac_address_lsw);
802 UINT        _nx_dhcpv6_find_client_record_by_duid(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_SVR_DUID *duid_ptr, UINT *record_index, UINT add_on, ULONG message_xid, UINT *matching);
803 UINT        _nx_dhcpv6_find_ip_address(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr, NX_DHCPV6_ADDRESS_LEASE **interface_address_ptr);
804 UINT        _nx_dhcpv6_server_extract_packet_information(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT **dhcpv6_client_ptr, NX_PACKET *packet_ptr,
805                                                          UINT iface_index, NXD_ADDRESS source_address, NXD_ADDRESS destination_address);
806 UINT        _nx_dhcpv6_listen_for_messages(NX_DHCPV6_SERVER *dhcpv6_ptr);
807 UINT        _nx_dhcpv6_prepare_iana_status(NX_DHCPV6_SERVER_IANA_STATUS *dhcpv6_status_ptr, UINT flag);
808 UINT        _nx_dhcpv6_process_duid(NX_DHCPV6_SVR_DUID *duid_ptr, ULONG option_code, UINT option_length, UCHAR *option_data);
809 UINT        _nx_dhcpv6_process_elapsed_time(NX_DHCPV6_CLIENT *dhcpv6_client_ptr, ULONG option_code, UINT option_length, UCHAR *option_data);
810 UINT        _nx_dhcpv6_server_process_ia(NX_DHCPV6_CLIENT *dhcpv6_client_ptr, ULONG option_code, UINT option_length, UCHAR *option_data, UINT process_ia);
811 UINT        _nx_dhcpv6_server_process_iana(NX_DHCPV6_CLIENT *dhcpv6_client_ptr, ULONG option_code, UINT option_length, UCHAR *option_data);
812 UINT        _nx_dhcpv6_process_option_request(NX_DHCPV6_CLIENT *client_ptr, ULONG option_code, UINT option_length, UCHAR *option_data);
813 UINT        _nx_dhcpv6_send_response_to_client(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr);
814 VOID        _nx_dhcpv6_server_lease_timeout_entry(ULONG dhcpv6_server_ptr_value);
815 VOID        _nx_dhcpv6_server_thread_entry(ULONG ip_instance);
816 VOID        _nx_dhcpv6_server_socket_receive_notify(NX_UDP_SOCKET *socket_ptr);
817 VOID        _nx_dhcpv6_server_session_timeout_entry(ULONG dhcpv6_server_ptr_value);
818 UINT        _nx_dhcpv6_update_client_record(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *from_client_ptr, NX_DHCPV6_CLIENT *to_client_ptr);
819 UINT        _nx_dhcpv6_validate_client_message(NX_DHCPV6_SERVER *dhcpv6_server_ptr, NX_DHCPV6_CLIENT *dhcpv6_client_ptr);
820 UINT        _nx_dhcpv6_server_utility_get_block_option_length(UCHAR *buffer_ptr, ULONG *option, ULONG *length);
821 UINT        _nx_dhcpv6_server_utility_get_data(UCHAR *data, UINT size, ULONG *value);
822 INT         _nx_dhcpv6_server_utility_time_randomize(void);
823 
824 /* Determine if a C++ compiler is being used.  If so, complete the standard
825    C conditional started above.  */
826 #ifdef   __cplusplus
827         }
828 #endif
829 
830 #endif /* NX_DHCPV6_SERVER_H */
831 
832 
833