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 
33 #endif /* FEATURE_NX_IPV6 */
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _nxde_ipv6_default_router_number_of_entries_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 entries*/
48 /*    get service.                                                        */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    ip_ptr                                IP instance pointer           */
53 /*    if_index                              Interface Index               */
54 /*    num_entries                           Destination for number of     */
55 /*                                            IPv6 routers on a specified */
56 /*                                            network interface           */
57 /*                                                                        */
58 /*  OUTPUT                                                                */
59 /*                                                                        */
60 /*    Status                                Completion status             */
61 /*                                                                        */
62 /*  CALLS                                                                 */
63 /*                                                                        */
64 /*    _nxd_ipv6_default_router_entries_get                                */
65 /*                                                                        */
66 /*  CALLED BY                                                             */
67 /*                                                                        */
68 /*    Application code                                                    */
69 /*                                                                        */
70 /*  NOTE                                                                  */
71 /*                                                                        */
72 /*                                                                        */
73 /*    This function cannot be called from ISR.                            */
74 /*                                                                        */
75 /*  RELEASE HISTORY                                                       */
76 /*                                                                        */
77 /*    DATE              NAME                      DESCRIPTION             */
78 /*                                                                        */
79 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
80 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
81 /*                                            resulting in version 6.1    */
82 /*                                                                        */
83 /**************************************************************************/
_nxde_ipv6_default_router_number_of_entries_get(NX_IP * ip_ptr,UINT if_index,UINT * num_entries)84 UINT  _nxde_ipv6_default_router_number_of_entries_get(NX_IP *ip_ptr, UINT if_index, UINT *num_entries)
85 {
86 #ifdef FEATURE_NX_IPV6
87 
88 UINT status;
89 
90 
91     /* Check for invalid input pointers. */
92     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (num_entries == NX_NULL))
93     {
94         return(NX_PTR_ERROR);
95     }
96 
97     /* Validate the interface. */
98     if (if_index >= NX_MAX_PHYSICAL_INTERFACES)
99     {
100         return(NX_INVALID_INTERFACE);
101     }
102 
103     /* Check for appropriate caller.  */
104     NX_INIT_AND_THREADS_CALLER_CHECKING
105 
106     /* Call actual IPv6 default router number get function.  */
107     status = _nxd_ipv6_default_router_number_of_entries_get(ip_ptr, if_index, num_entries);
108 
109     /* Return completion status.  */
110     return(status);
111 
112 #else /* !FEATURE_NX_IPV6 */
113     NX_PARAMETER_NOT_USED(ip_ptr);
114     NX_PARAMETER_NOT_USED(if_index);
115     NX_PARAMETER_NOT_USED(num_entries);
116 
117     return(NX_NOT_SUPPORTED);
118 
119 #endif /* FEATURE_NX_IPV6 */
120 }
121 
122