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 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nx_ip_forwarding_enable                            PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function enables the IP forwarding by setting up the forward   */
45 /*    processing function pointer in the specified IP instance.           */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    ip_ptr                                Pointer to IP instance        */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    status                                Completion status             */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    None                                                                */
58 /*                                                                        */
59 /*  CALLED BY                                                             */
60 /*                                                                        */
61 /*    Application                                                         */
62 /*                                                                        */
63 /*  RELEASE HISTORY                                                       */
64 /*                                                                        */
65 /*    DATE              NAME                      DESCRIPTION             */
66 /*                                                                        */
67 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
68 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
69 /*                                            resulting in version 6.1    */
70 /*                                                                        */
71 /**************************************************************************/
_nx_ip_forwarding_enable(NX_IP * ip_ptr)72 UINT  _nx_ip_forwarding_enable(NX_IP *ip_ptr)
73 {
74 
75 #ifndef NX_DISABLE_IPV4
76 TX_INTERRUPT_SAVE_AREA
77 
78 
79     /* If trace is enabled, insert this event into the trace buffer.  */
80     NX_TRACE_IN_LINE_INSERT(NX_TRACE_IP_FORWARDING_ENABLE, ip_ptr, 0, 0, 0, NX_TRACE_IP_EVENTS, 0, 0);
81 
82     /* Disable interrupts temporarily.  */
83     TX_DISABLE
84     /* Setup the IP forwarding processing routine pointer.  */
85     ip_ptr -> nx_ip_forward_packet_process =  _nx_ip_forward_packet_process;
86 
87     /* Restore interrupts.  */
88     TX_RESTORE
89 
90     /* Return success to the caller.  */
91     return(NX_SUCCESS);
92 #else
93     NX_PARAMETER_NOT_USED(ip_ptr);
94 
95     return(NX_NOT_SUPPORTED);
96 #endif /* !NX_DISABLE_IPV4  */
97 }
98 
99