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 /* Bring in externs for caller checking code.  */
31 NX_CALLER_CHECKING_EXTERNS
32 
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _nxde_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                       Index to the interface        */
62 /*                                                                        */
63 /*  OUTPUT                                                                */
64 /*                                                                        */
65 /*    status                                Completion status             */
66 /*                                                                        */
67 /*  CALLS                                                                 */
68 /*                                                                        */
69 /*    _nxd_udp_packet_info_extract          The actual service routine.   */
70 /*                                                                        */
71 /*  CALLED BY                                                             */
72 /*                                                                        */
73 /*    Application Code                                                    */
74 /*                                                                        */
75 /*  RELEASE HISTORY                                                       */
76 /*                                                                        */
77 /*    DATE              NAME                      DESCRIPTION             */
78 /*                                                                        */
79 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
80 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
81 /*                                            resulting in version 6.1    */
82 /*                                                                        */
83 /**************************************************************************/
_nxde_udp_packet_info_extract(NX_PACKET * packet_ptr,NXD_ADDRESS * ip_address,UINT * protocol,UINT * port,UINT * interface_index)84 UINT  _nxde_udp_packet_info_extract(NX_PACKET *packet_ptr, NXD_ADDRESS *ip_address,
85                                     UINT *protocol, UINT *port, UINT *interface_index)
86 {
87 UINT status;
88 
89     if (packet_ptr == NX_NULL)
90     {
91         return(NX_PTR_ERROR);
92     }
93 
94     /* Check for appropriate caller.  */
95     NX_THREADS_ONLY_CALLER_CHECKING
96 
97     status = _nxd_udp_packet_info_extract(packet_ptr, ip_address, protocol, port, interface_index);
98 
99 
100     return(status);
101 }
102 
103