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 /**   Internet Protocol (IP)                                              */
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_ip.h"
29 
30 /* Bring in externs for caller checking code */
31 NX_CALLER_CHECKING_EXTERNS
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _nxe_ip_interface_info_get                          PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    Yuxin Zhou, Microsoft Corporation                                   */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function performs error checking for nx_ip_interface_info_get  */
46 /*    service call.                                                       */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    ip_ptr                                IP control block pointer      */
51 /*    interface_index                       Index to the interface        */
52 /*    interface_name                        Name of the interface         */
53 /*    ip_address                            Pointer to IP address         */
54 /*                                            destination in host byte    */
55 /*                                            order                       */
56 /*    network_mask                          Pointer to network mask       */
57 /*                                            destination, in host byte   */
58 /*                                            order                       */
59 /*    mtu_size                              Pointer to storage space for  */
60 /*                                            MTU                         */
61 /*    physical_address_msw                  Pointer to storage space for  */
62 /*                                            device phsyical address, MSW*/
63 /*    physical_address_lsw                  Pointer to storage space for  */
64 /*                                            device phsyical address, LSW*/
65 /*                                                                        */
66 /*  OUTPUT                                                                */
67 /*                                                                        */
68 /*    status                                Completion status             */
69 /*                                                                        */
70 /*  CALLS                                                                 */
71 /*                                                                        */
72 /*    _nx_ip_interface_info_get             Actual IP interface info get  */
73 /*                                            service call.               */
74 /*                                                                        */
75 /*  CALLED BY                                                             */
76 /*                                                                        */
77 /*    Application Code                                                    */
78 /*                                                                        */
79 /*  RELEASE HISTORY                                                       */
80 /*                                                                        */
81 /*    DATE              NAME                      DESCRIPTION             */
82 /*                                                                        */
83 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
84 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
85 /*                                            resulting in version 6.1    */
86 /*                                                                        */
87 /**************************************************************************/
88 
_nxe_ip_interface_info_get(NX_IP * ip_ptr,UINT interface_index,CHAR ** interface_name,ULONG * ip_address,ULONG * network_mask,ULONG * mtu_size,ULONG * physical_address_msw,ULONG * physical_address_lsw)89 UINT _nxe_ip_interface_info_get(NX_IP *ip_ptr, UINT interface_index, CHAR **interface_name,
90                                 ULONG *ip_address, ULONG *network_mask, ULONG *mtu_size,
91                                 ULONG *physical_address_msw, ULONG *physical_address_lsw)
92 {
93 UINT status;
94 
95     if (ip_ptr == NX_NULL)
96     {
97         return(NX_PTR_ERROR);
98     }
99 
100     if (ip_ptr -> nx_ip_id != NX_IP_ID)
101     {
102         return(NX_PTR_ERROR);
103     }
104 
105     if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
106     {
107         return(NX_INVALID_INTERFACE);
108     }
109 
110     NX_INIT_AND_THREADS_CALLER_CHECKING
111 
112     status = _nx_ip_interface_info_get(ip_ptr, interface_index, interface_name, ip_address, network_mask,
113                                        mtu_size, physical_address_msw, physical_address_lsw);
114 
115     return(status);
116 }
117 
118