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 /** Internet Protocol (IP) */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define NX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27
28 #include "nx_api.h"
29 #include "nx_ipv6.h"
30 #ifdef FEATURE_NX_IPV6
31 #include "nx_ip.h"
32
33 /* Bring in externs for caller checking code. */
34 NX_CALLER_CHECKING_EXTERNS
35
36 #endif /* FEATURE_NX_IPV6 */
37
38
39 /**************************************************************************/
40 /* */
41 /* FUNCTION RELEASE */
42 /* */
43 /* _nxde_ipv6_address_get PORTABLE C */
44 /* 6.1 */
45 /* AUTHOR */
46 /* */
47 /* Yuxin Zhou, Microsoft Corporation */
48 /* */
49 /* DESCRIPTION */
50 /* */
51 /* This function checks for errors in the IP address get function */
52 /* call. */
53 /* */
54 /* INPUT */
55 /* */
56 /* ip_ptr IP control block pointer */
57 /* address_index Index to the IPv6 address */
58 /* table */
59 /* ip_address Pointer to IP address */
60 /* structure to be filled */
61 /* prefix_length Pointer to prefix length */
62 /* to return */
63 /* interface_index The index to the physical */
64 /* interface this address */
65 /* belongs to */
66 /* */
67 /* OUTPUT */
68 /* */
69 /* status Completion status */
70 /* */
71 /* CALLS */
72 /* */
73 /* _nxd_ipv6_address_get Actual IPv6 address get */
74 /* function */
75 /* */
76 /* CALLED BY */
77 /* */
78 /* Application Code */
79 /* */
80 /* RELEASE HISTORY */
81 /* */
82 /* DATE NAME DESCRIPTION */
83 /* */
84 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
85 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
86 /* resulting in version 6.1 */
87 /* */
88 /**************************************************************************/
_nxde_ipv6_address_get(NX_IP * ip_ptr,UINT address_index,NXD_ADDRESS * ip_address,ULONG * prefix_length,UINT * interface_index)89 UINT _nxde_ipv6_address_get(NX_IP *ip_ptr, UINT address_index, NXD_ADDRESS *ip_address, ULONG *prefix_length, UINT *interface_index)
90 {
91 #ifdef FEATURE_NX_IPV6
92
93 UINT status;
94
95
96 /* Check for invalid IP pointer. */
97 if (ip_ptr == NX_NULL)
98 {
99 return(NX_PTR_ERROR);
100 }
101
102 /* Check for other invalid input. */
103 if ((ip_ptr -> nx_ip_id != NX_IP_ID) || (ip_address == NX_NULL) || (prefix_length == NX_NULL) || (interface_index == NX_NULL))
104 {
105 return(NX_PTR_ERROR);
106 }
107
108 /* Check the validity of the address index. */
109 if (address_index >= (NX_MAX_IPV6_ADDRESSES + NX_LOOPBACK_IPV6_ENABLED))
110 {
111 return(NX_NO_INTERFACE_ADDRESS);
112 }
113
114 /* Check for appropriate caller. */
115 NX_INIT_AND_THREADS_CALLER_CHECKING
116
117 /* Call actual IP address get function. */
118 status = _nxd_ipv6_address_get(ip_ptr, address_index, ip_address, prefix_length, interface_index);
119
120 /* Return completion status. */
121 return(status);
122
123 #else /* !FEATURE_NX_IPV6 */
124 NX_PARAMETER_NOT_USED(ip_ptr);
125 NX_PARAMETER_NOT_USED(address_index);
126 NX_PARAMETER_NOT_USED(ip_address);
127 NX_PARAMETER_NOT_USED(prefix_length);
128 NX_PARAMETER_NOT_USED(interface_index);
129
130 return(NX_NOT_SUPPORTED);
131
132 #endif /* FEATURE_NX_IPV6 */
133 }
134
135