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