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