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 /**   User Datagram Protocol (UDP)                                        */
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_udp.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _nx_udp_socket_checksum_disable                     PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Yuxin Zhou, Microsoft Corporation                                   */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function disables the UDP checksum logic for the specified     */
45 /*    socket.  Note this function has no effect on UDP packets over IPv6  */
46 /*    network, since the UDP packet checksum must be computed for UDP     */
47 /*    over IPv6 network.                                                  */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    socket_ptr                            Pointer to UDP socket         */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Completion status             */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    None                                                                */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
70 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_nx_udp_socket_checksum_disable(NX_UDP_SOCKET * socket_ptr)74 UINT  _nx_udp_socket_checksum_disable(NX_UDP_SOCKET *socket_ptr)
75 {
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_UDP_SOCKET_CHECKSUM_DISABLE, socket_ptr -> nx_udp_socket_ip_ptr, socket_ptr, 0, 0, NX_TRACE_UDP_EVENTS, 0, 0);
81 
82     /* Lockout interrupts.  */
83     TX_DISABLE
84 
85     /* Determine if the socket is currently bound.  */
86     if (!socket_ptr ->  nx_udp_socket_bound_next)
87     {
88 
89         /* Restore interrupts.  */
90         TX_RESTORE
91 
92         /* Socket is not bound, return an error message.  */
93         return(NX_NOT_BOUND);
94     }
95 
96     /* Set the checksum disable flag.  */
97     socket_ptr -> nx_udp_socket_disable_checksum =  NX_TRUE;
98 
99     /* Restore interrupts.  */
100     TX_RESTORE
101 
102     /* Return a successful status.  */
103     return(NX_SUCCESS);
104 }
105 
106