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 /** NetX Component */
14 /** */
15 /** Internet Protocol version 6 Default Router Table (IPv6 router) */
16 /** */
17 /**************************************************************************/
18 /**************************************************************************/
19 #define NX_SOURCE_CODE
20
21
22 /* Include necessary system files. */
23
24 #include "nx_api.h"
25 #include "nx_ipv6.h"
26 #ifdef FEATURE_NX_IPV6
27 #include "nx_ip.h"
28 #include "nx_nd_cache.h"
29
30 /* Bring in externs for caller checking code. */
31 NX_CALLER_CHECKING_EXTERNS
32 #endif /* FEATURE_NX_IPV6 */
33
34
35 /**************************************************************************/
36 /* */
37 /* FUNCTION RELEASE */
38 /* */
39 /* _nxde_ipv6_default_router_entry_get PORTABLE C */
40 /* 6.1 */
41 /* AUTHOR */
42 /* */
43 /* Yuxin Zhou, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function performs error checking for the default router entry */
48 /* get service. */
49 /* */
50 /* INPUT */
51 /* */
52 /* ip_ptr IP instance pointer */
53 /* interface_index Index to the interface */
54 /* router_addr Router IPv6 Address */
55 /* router_lifetime Pointer to router life time */
56 /* prefix_length Pointer to prefix length */
57 /* configuration_method Pointer to the information */
58 /* on how the entry was */
59 /* configured */
60 /* */
61 /* OUTPUT */
62 /* */
63 /* status Completion status */
64 /* */
65 /* CALLS */
66 /* */
67 /* _nxd_ipv6_default_router_entry_get */
68 /* */
69 /* CALLED BY */
70 /* */
71 /* Application code */
72 /* */
73 /* NOTE */
74 /* */
75 /* */
76 /* This function cannot be called from ISR. */
77 /* */
78 /* RELEASE HISTORY */
79 /* */
80 /* DATE NAME DESCRIPTION */
81 /* */
82 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
83 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
84 /* resulting in version 6.1 */
85 /* */
86 /**************************************************************************/
_nxde_ipv6_default_router_entry_get(NX_IP * ip_ptr,UINT interface_index,UINT entry_index,NXD_ADDRESS * router_addr,ULONG * router_lifetime,ULONG * prefix_length,ULONG * configuration_method)87 UINT _nxde_ipv6_default_router_entry_get(NX_IP *ip_ptr, UINT interface_index, UINT entry_index,
88 NXD_ADDRESS *router_addr, ULONG *router_lifetime,
89 ULONG *prefix_length, ULONG *configuration_method)
90 {
91 #ifdef FEATURE_NX_IPV6
92
93 UINT status;
94
95
96 /* Check for invalid input pointers. */
97 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
98 {
99 return(NX_PTR_ERROR);
100 }
101
102 /* Validate the interface. */
103 if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
104 {
105 return(NX_INVALID_INTERFACE);
106 }
107
108 /* Validate the interface. */
109 if (entry_index >= NX_IPV6_DEFAULT_ROUTER_TABLE_SIZE)
110 {
111 return(NX_INVALID_INTERFACE);
112 }
113
114 /* Check for appropriate caller. */
115 NX_INIT_AND_THREADS_CALLER_CHECKING
116
117 /* Call actual IPv6 default router entry get function. */
118 status = _nxd_ipv6_default_router_entry_get(ip_ptr, interface_index, entry_index, router_addr,
119 router_lifetime, prefix_length, configuration_method);
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(interface_index);
127 NX_PARAMETER_NOT_USED(entry_index);
128 NX_PARAMETER_NOT_USED(router_addr);
129 NX_PARAMETER_NOT_USED(router_lifetime);
130 NX_PARAMETER_NOT_USED(prefix_length);
131 NX_PARAMETER_NOT_USED(configuration_method);
132
133 return(NX_NOT_SUPPORTED);
134
135 #endif /* FEATURE_NX_IPV6 */
136 }
137
138