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