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