1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** NetX Component */
16 /** */
17 /** User Datagram Protocol (UDP) */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define NX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "nx_api.h"
28 #include "nx_udp.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_udp_socket_checksum_enable PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function enables the UDP checksum logic for the specified */
44 /* socket. Note this function has no effect on UDP packets over IPv6 */
45 /* network, since the UDP packet checksum must be computed for UDP */
46 /* over IPv6 network. */
47 /* */
48 /* INPUT */
49 /* */
50 /* socket_ptr Pointer to UDP socket */
51 /* */
52 /* OUTPUT */
53 /* */
54 /* status Completion status */
55 /* */
56 /* CALLS */
57 /* */
58 /* None */
59 /* */
60 /* CALLED BY */
61 /* */
62 /* Application Code */
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_udp_socket_checksum_enable(NX_UDP_SOCKET * socket_ptr)73 UINT _nx_udp_socket_checksum_enable(NX_UDP_SOCKET *socket_ptr)
74 {
75 TX_INTERRUPT_SAVE_AREA
76
77
78 /* If trace is enabled, insert this event into the trace buffer. */
79 NX_TRACE_IN_LINE_INSERT(NX_TRACE_UDP_SOCKET_CHECKSUM_ENABLE, socket_ptr -> nx_udp_socket_ip_ptr, socket_ptr, 0, 0, NX_TRACE_UDP_EVENTS, 0, 0);
80
81 /* Lockout interrupts. */
82 TX_DISABLE
83
84 /* Determine if the socket is currently bound. */
85 if (!socket_ptr -> nx_udp_socket_bound_next)
86 {
87
88 /* Restore interrupts. */
89 TX_RESTORE
90
91 /* Socket is not bound, return an error message. */
92 return(NX_NOT_BOUND);
93 }
94
95 /* Clear the checksum disable flag. */
96 socket_ptr -> nx_udp_socket_disable_checksum = NX_FALSE;
97
98 /* Restore interrupts. */
99 TX_RESTORE
100
101 /* Return a successful status. */
102 return(NX_SUCCESS);
103 }
104
105