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_fragment_enable                              PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function enables the IP fragment processing by setting up the  */
45 /*    function pointers responsible for fragmenting and unfragmenting IP  */
46 /*    packets.                                                            */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    ip_ptr                                Pointer to IP instance        */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    None                                                                */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    Application                                                         */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
69 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_nx_ip_fragment_enable(NX_IP * ip_ptr)73 UINT  _nx_ip_fragment_enable(NX_IP *ip_ptr)
74 {
75 #ifndef NX_DISABLE_FRAGMENTATION
76 TX_INTERRUPT_SAVE_AREA
77 
78     /* If trace is enabled, insert this event into the trace buffer.  */
79     NX_TRACE_IN_LINE_INSERT(NX_TRACE_IP_FRAGMENT_ENABLE, ip_ptr, 0, 0, 0, NX_TRACE_IP_EVENTS, 0, 0);
80 
81     /* Disable interrupts temporarily.  */
82     TX_DISABLE
83 
84     /* Setup the IP fragment processing routine pointer.  */
85     ip_ptr -> nx_ip_fragment_processing =  _nx_ip_fragment_packet;
86 
87     /* Setup the IP fragment assembly routine pointer.  */
88     ip_ptr -> nx_ip_fragment_assembly =  _nx_ip_fragment_assembly;
89 
90     /* Setup the IP fragment timeout routine pointer.  */
91     ip_ptr -> nx_ip_fragment_timeout_check =  _nx_ip_fragment_timeout_check;
92 
93     /* Restore interrupts.  */
94     TX_RESTORE
95 
96     /* Return success to the caller.  */
97     return(NX_SUCCESS);
98 
99 #else /* NX_DISABLE_FRAGMENTATION */
100     NX_PARAMETER_NOT_USED(ip_ptr);
101 
102     return(NX_NOT_ENABLED);
103 
104 #endif /* NX_DISABLE_FRAGMENTATION */
105 }
106 
107