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 #endif /* FEATURE_NX_IPV6 */
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _nxde_ipv6_default_router_get                        PORTABLE C     */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Yuxin Zhou, Microsoft Corporation                                   */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function performs error checking for the default router get    */
46 /*    service.                                                            */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    ip_ptr                                IP instance pointer           */
51 /*    interface_index                       Index to the interface        */
52 /*    router_addr                           Router IPv6 Address           */
53 /*    router_lifetime                       Pointer to router life time   */
54 /*    prefix_length                         Pointer to prefix length      */
55 /*                                                                        */
56 /*  OUTPUT                                                                */
57 /*                                                                        */
58 /*    status                                Completion status             */
59 /*                                                                        */
60 /*  CALLS                                                                 */
61 /*                                                                        */
62 /*    None                                                                */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    Application code                                                    */
67 /*                                                                        */
68 /*  NOTE                                                                  */
69 /*                                                                        */
70 /*                                                                        */
71 /*    This function cannot be called from ISR.                            */
72 /*                                                                        */
73 /*  RELEASE HISTORY                                                       */
74 /*                                                                        */
75 /*    DATE              NAME                      DESCRIPTION             */
76 /*                                                                        */
77 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
78 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
79 /*                                            resulting in version 6.1    */
80 /*                                                                        */
81 /**************************************************************************/
_nxde_ipv6_default_router_get(NX_IP * ip_ptr,UINT interface_index,NXD_ADDRESS * router_addr,ULONG * router_lifetime,ULONG * prefix_length)82 UINT  _nxde_ipv6_default_router_get(NX_IP *ip_ptr, UINT interface_index, NXD_ADDRESS *router_addr, ULONG *router_lifetime, ULONG *prefix_length)
83 {
84 #ifdef FEATURE_NX_IPV6
85 
86 UINT status;
87 
88 
89     /* Check for invalid input pointers. */
90     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (router_addr == NX_NULL) || (router_lifetime == NX_NULL) || (prefix_length == NX_NULL))
91     {
92         return(NX_PTR_ERROR);
93     }
94 
95     /* Validate the interface. */
96     if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
97     {
98         return(NX_INVALID_INTERFACE);
99     }
100 
101     /* Call actual IPv6 default router get function.  */
102     status = _nxd_ipv6_default_router_get(ip_ptr, interface_index, router_addr, router_lifetime, prefix_length);
103 
104     /* Return completion status.  */
105     return(status);
106 
107 #else /* !FEATURE_NX_IPV6 */
108     NX_PARAMETER_NOT_USED(ip_ptr);
109     NX_PARAMETER_NOT_USED(interface_index);
110     NX_PARAMETER_NOT_USED(router_addr);
111     NX_PARAMETER_NOT_USED(router_lifetime);
112     NX_PARAMETER_NOT_USED(prefix_length);
113 
114     return(NX_NOT_SUPPORTED);
115 
116 #endif /* FEATURE_NX_IPV6 */
117 }
118 
119