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