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 /**   Internet Protocol (IP)                                              */
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_ip.h"
30 
31 /* Bring in externs for caller checking code.  */
32 NX_CALLER_CHECKING_EXTERNS
33 
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _nxe_ip_interface_address_get                       PORTABLE C      */
40 /*                                                           6.1          */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    Yuxin Zhou, Microsoft Corporation                                   */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This function checks for errors in the IP address get function      */
48 /*    call.                                                               */
49 /*                                                                        */
50 /*  INPUT                                                                 */
51 /*                                                                        */
52 /*    ip_ptr                                IP control block pointer      */
53 /*    interface_index                       IP Interface Index            */
54 /*    ip_address                            Pointer to IP address         */
55 /*                                            destination                 */
56 /*    network_mask                          Pointer to network mask       */
57 /*                                            destination                 */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    status                                Completion status             */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _nx_ip_interface_address_get          Actual IP address get function*/
66 /*                                                                        */
67 /*  CALLED BY                                                             */
68 /*                                                                        */
69 /*    Application Code                                                    */
70 /*                                                                        */
71 /*  RELEASE HISTORY                                                       */
72 /*                                                                        */
73 /*    DATE              NAME                      DESCRIPTION             */
74 /*                                                                        */
75 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
76 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
77 /*                                            resulting in version 6.1    */
78 /*                                                                        */
79 /**************************************************************************/
_nxe_ip_interface_address_get(NX_IP * ip_ptr,UINT interface_index,ULONG * ip_address,ULONG * network_mask)80 UINT  _nxe_ip_interface_address_get(NX_IP *ip_ptr, UINT interface_index, ULONG *ip_address, ULONG *network_mask)
81 {
82 
83 #ifndef NX_DISABLE_IPV4
84 UINT status;
85 
86 
87     /* Check for invalid input pointers.  */
88     if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (ip_address == NX_NULL) || (network_mask == NX_NULL))
89     {
90         return(NX_PTR_ERROR);
91     }
92 
93     /* Check for valid interface ID */
94     if (interface_index >= NX_MAX_PHYSICAL_INTERFACES)
95     {
96         return(NX_INVALID_INTERFACE);
97     }
98 
99     /* Check for interface being valid. */
100     if (!ip_ptr -> nx_ip_interface[interface_index].nx_interface_valid)
101     {
102         return(NX_INVALID_INTERFACE);
103     }
104 
105     /* Check for appropriate caller.  */
106     NX_INIT_AND_THREADS_CALLER_CHECKING
107 
108     /* Call actual IP address get function.  */
109     status =  _nx_ip_interface_address_get(ip_ptr, interface_index, ip_address, network_mask);
110 
111     /* Return completion status.  */
112     return(status);
113 #else /* NX_DISABLE_IPV4  */
114     NX_PARAMETER_NOT_USED(ip_ptr);
115     NX_PARAMETER_NOT_USED(interface_index);
116     NX_PARAMETER_NOT_USED(ip_address);
117     NX_PARAMETER_NOT_USED(network_mask);
118 
119     return(NX_NOT_SUPPORTED);
120 #endif /* !NX_DISABLE_IPV4  */
121 }
122 
123