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 /**************************************************************************/
38 /* */
39 /* FUNCTION RELEASE */
40 /* */
41 /* _nxd_ipv6_default_router_add PORTABLE C */
42 /* 6.1 */
43 /* AUTHOR */
44 /* */
45 /* Yuxin Zhou, Microsoft Corporation */
46 /* */
47 /* DESCRIPTION */
48 /* */
49 /* This function performs error checking for the default router add */
50 /* service. */
51 /* */
52 /* INPUT */
53 /* */
54 /* ip_ptr IP instance pointer */
55 /* router_addr Destination Network addr */
56 /* router_lifetime Life time information */
57 /* interface_index Index to the interface */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* status Actual completion status */
62 /* NX_INVALID_PARAMETERS Invalid IP version */
63 /* NX_PTR_ERROR Invalid pointer input */
64 /* NX_INVALID_INTERFACE Invalid Interface Index */
65 /* */
66 /* CALLS */
67 /* */
68 /* _nxd_ipv6_default_router_add */
69 /* Actual function that adds */
70 /* an entry to the router table */
71 /* */
72 /* CALLED BY */
73 /* */
74 /* Application code */
75 /* */
76 /* */
77 /* RELEASE HISTORY */
78 /* */
79 /* DATE NAME DESCRIPTION */
80 /* */
81 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
82 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
83 /* resulting in version 6.1 */
84 /* */
85 /**************************************************************************/
_nxde_ipv6_default_router_add(NX_IP * ip_ptr,NXD_ADDRESS * router_addr,ULONG router_lifetime,UINT interface_index)86 UINT _nxde_ipv6_default_router_add(NX_IP *ip_ptr, NXD_ADDRESS *router_addr,
87 ULONG router_lifetime, UINT interface_index)
88
89
90 {
91 #ifdef FEATURE_NX_IPV6
92 /* Check for invalid input pointers. */
93 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (router_addr == NX_NULL))
94 {
95 return(NX_PTR_ERROR);
96 }
97
98 /* Check for valid IP version. */
99 if (router_addr -> nxd_ip_version != NX_IP_VERSION_V6)
100 {
101 return(NX_INVALID_PARAMETERS);
102 }
103
104 if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
105 {
106 return(NX_INVALID_INTERFACE);
107 }
108
109 /* Make sure the interface is valid. */
110 if (ip_ptr -> nx_ip_interface[interface_index].nx_interface_valid != NX_TRUE)
111 {
112 return(NX_INVALID_INTERFACE);
113 }
114
115 /* Check for appropriate caller. */
116 NX_INIT_AND_THREADS_CALLER_CHECKING
117
118 /* Call the actual service and return completion status. */
119 return(_nxd_ipv6_default_router_add(ip_ptr, router_addr, router_lifetime, interface_index));
120
121 #else /* !FEATURE_NX_IPV6 */
122 NX_PARAMETER_NOT_USED(ip_ptr);
123 NX_PARAMETER_NOT_USED(router_addr);
124 NX_PARAMETER_NOT_USED(router_lifetime);
125 NX_PARAMETER_NOT_USED(interface_index);
126
127 return(NX_NOT_SUPPORTED);
128
129 #endif /* FEATURE_NX_IPV6 */
130 }
131
132