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 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Component                                                        */
17 /**                                                                       */
18 /**   Internet Protocol (IP)                                              */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "nx_api.h"
29 #include "nx_ip.h"
30 
31 #if !defined(NX_DISABLE_IPV4) && defined(NX_ENABLE_IP_STATIC_ROUTING)
32 /* Bring in externs for caller checking code.  */
33 NX_CALLER_CHECKING_EXTERNS
34 #endif /* !NX_DISABLE_IPV4 && NX_ENABLE_IP_STATIC_ROUTING */
35 
36 /**************************************************************************/
37 /*                                                                        */
38 /*  FUNCTION                                               RELEASE        */
39 /*                                                                        */
40 /*    _nxe_ip_static_route_add                            PORTABLE C      */
41 /*                                                           6.1          */
42 /*  AUTHOR                                                                */
43 /*                                                                        */
44 /*    Yuxin Zhou, Microsoft Corporation                                   */
45 /*                                                                        */
46 /*  DESCRIPTION                                                           */
47 /*                                                                        */
48 /*    This function deltes static routing entry from the routing table.   */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    ip_ptr                                Pointer to IP instance        */
53 /*    network_address                       network address, in network   */
54 /*                                            byte order.                 */
55 /*    net_mask                              Network Mask, in network      */
56 /*                                            byte order.                 */
57 /*    next_hop                              Next Hop address, in network  */
58 /*                                            byte order.                 */
59 /*                                                                        */
60 /*                                                                        */
61 /*  OUTPUT                                                                */
62 /*                                                                        */
63 /*    status                                Completion status             */
64 /*                                                                        */
65 /*  CALLS                                                                 */
66 /*                                                                        */
67 /*    _nx_ip_staic_route_add                Actual IP static route        */
68 /*                                            add function.               */
69 /*  CALLED BY                                                             */
70 /*                                                                        */
71 /*    Application                                                         */
72 /*                                                                        */
73 /*  NOTE:                                                                 */
74 /*                                                                        */
75 /*    None                                                                */
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 /**************************************************************************/
_nxe_ip_static_route_add(NX_IP * ip_ptr,ULONG network_address,ULONG net_mask,ULONG next_hop)86 UINT  _nxe_ip_static_route_add(NX_IP *ip_ptr, ULONG network_address,
87                                ULONG net_mask, ULONG next_hop)
88 {
89 #if !defined(NX_DISABLE_IPV4) && defined(NX_ENABLE_IP_STATIC_ROUTING)
90 
91 UINT status;
92 
93     /* Check for invalid input pointers.  */
94     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID))
95     {
96         return(NX_PTR_ERROR);
97     }
98 
99     /* Check for appropriate caller.  */
100     NX_INIT_AND_THREADS_CALLER_CHECKING
101 
102     /* Call actual IP forwarding disable function.  */
103     status =  _nx_ip_static_route_add(ip_ptr, network_address, net_mask, next_hop);
104 
105     /* Return completion status.  */
106     return(status);
107 
108 #else /* !NX_DISABLE_IPV4 && NX_ENABLE_IP_STATIC_ROUTING */
109     NX_PARAMETER_NOT_USED(ip_ptr);
110     NX_PARAMETER_NOT_USED(network_address);
111     NX_PARAMETER_NOT_USED(net_mask);
112     NX_PARAMETER_NOT_USED(next_hop);
113 
114     return(NX_NOT_SUPPORTED);
115 
116 #endif /* !NX_DISABLE_IPV4 && NX_ENABLE_IP_STATIC_ROUTING */
117 }
118 
119