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