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_nd_cache.h"
29 #endif /* FEATURE_NX_IPV6 */
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nxd_ipv6_default_router_get                         PORTABLE C     */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function gets a router from the default IPv6 routing table.    */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    ip_ptr                                IP instance pointer           */
49 /*    interface_index                       Index to the interface        */
50 /*    router_addr                           Router IPv6 Address           */
51 /*    router_lifetime                       Pointer to router life time   */
52 /*    prefix_length                         Pointer to prefix length      */
53 /*                                                                        */
54 /*  OUTPUT                                                                */
55 /*                                                                        */
56 /*    status                                Completion status             */
57 /*                                                                        */
58 /*  CALLS                                                                 */
59 /*                                                                        */
60 /*    _nxd_ipv6_default_router_entry_get    Get IPv6 router               */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Application code                                                    */
65 /*                                                                        */
66 /*  NOTE                                                                  */
67 /*                                                                        */
68 /*                                                                        */
69 /*    This function cannot be called from ISR.                            */
70 /*                                                                        */
71 /*  RELEASE HISTORY                                                       */
72 /*                                                                        */
73 /*    DATE              NAME                      DESCRIPTION             */
74 /*                                                                        */
75 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
76 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
77 /*                                            resulting in version 6.1    */
78 /*                                                                        */
79 /**************************************************************************/
_nxd_ipv6_default_router_get(NX_IP * ip_ptr,UINT interface_index,NXD_ADDRESS * router_addr,ULONG * router_lifetime,ULONG * prefix_length)80 UINT  _nxd_ipv6_default_router_get(NX_IP *ip_ptr, UINT interface_index, NXD_ADDRESS *router_addr,
81                                    ULONG *router_lifetime, ULONG *prefix_length)
82 {
83 #ifdef FEATURE_NX_IPV6
84 UINT status;
85 
86     /* Get the first router. */
87     status = _nxd_ipv6_default_router_entry_get(ip_ptr, interface_index, 0,
88                                                 router_addr, router_lifetime, prefix_length, NX_NULL);
89 
90     return(status);
91 
92 #else /* !FEATURE_NX_IPV6 */
93     NX_PARAMETER_NOT_USED(ip_ptr);
94     NX_PARAMETER_NOT_USED(interface_index);
95     NX_PARAMETER_NOT_USED(router_addr);
96     NX_PARAMETER_NOT_USED(router_lifetime);
97     NX_PARAMETER_NOT_USED(prefix_length);
98 
99     return(NX_NOT_SUPPORTED);
100 
101 #endif /* FEATURE_NX_IPV6 */
102 }
103 
104