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 /* Bring in externs for caller checking code.  */
32 
33 NX_CALLER_CHECKING_EXTERNS
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _nxe_udp_pacekt_info_extract                        PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    Yuxin Zhou, Microsoft Corporation                                   */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function performs error checking for UDP packet info extract   */
47 /*    service.                                                            */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    packet_ptr                            Pointer to UDP packet pointer */
52 /*    ip_address                            Pointer to destination for IP */
53 /*                                            address, or NULL            */
54 /*    protocol                              Pointer to destination for    */
55 /*                                            protocol information, or    */
56 /*                                            NULL                        */
57 /*    port                                  Pointer to destination for    */
58 /*                                            source port.  This service  */
59 /*                                            always returns 17 (UDP), or */
60 /*                                            NULL                        */
61 /*    interface_index                       Pointer to destination for    */
62 /*                                            incoming interface ID, or   */
63 /*                                            NULL                        */
64 /*                                                                        */
65 /*  OUTPUT                                                                */
66 /*                                                                        */
67 /*    status                                Completion status             */
68 /*                                                                        */
69 /*  CALLS                                                                 */
70 /*                                                                        */
71 /*    _nx_udp_packet_info_extract           The actual service routine.   */
72 /*                                                                        */
73 /*  CALLED BY                                                             */
74 /*                                                                        */
75 /*    Application Code                                                    */
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_udp_packet_info_extract(NX_PACKET * packet_ptr,ULONG * ip_address,UINT * protocol,UINT * port,UINT * interface_index)86 UINT  _nxe_udp_packet_info_extract(NX_PACKET *packet_ptr, ULONG *ip_address,
87                                    UINT *protocol, UINT *port, UINT *interface_index)
88 {
89 #ifndef NX_DISABLE_IPV4
90 UINT status;
91 
92     if (packet_ptr == NX_NULL)
93     {
94         return(NX_PTR_ERROR);
95     }
96 
97 
98     /* Check for appropriate caller.  */
99     NX_THREADS_ONLY_CALLER_CHECKING
100 
101     status = _nx_udp_packet_info_extract(packet_ptr, ip_address, protocol, port, interface_index);
102 
103 
104     return(status);
105 #else
106     NX_PARAMETER_NOT_USED(packet_ptr);
107     NX_PARAMETER_NOT_USED(ip_address);
108     NX_PARAMETER_NOT_USED(protocol);
109     NX_PARAMETER_NOT_USED(port);
110     NX_PARAMETER_NOT_USED(interface_index);
111 
112     return(NX_NOT_SUPPORTED);
113 #endif /* NX_DISABLE_IPV4 */
114 }
115 
116