]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
code scrub for Ip4ConfigDxe
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4Config.h
1 /** @file
2 Header file for IP4Config driver.
3
4 Copyright (c) 2006 - 2008, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at<BR>
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _EFI_IP4CONFIG_H_
16 #define _EFI_IP4CONFIG_H_
17
18 #include <Uefi.h>
19
20 #include <Protocol/Dhcp4.h>
21 #include <Protocol/Ip4Config.h>
22 #include <Protocol/ManagedNetwork.h>
23
24 #include <Library/DebugLib.h>
25 #include <Library/UefiRuntimeServicesTableLib.h>
26 #include <Library/UefiDriverEntryPoint.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/UefiLib.h>
29 #include <Library/NetLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/MemoryAllocationLib.h>
32
33 #include "NicIp4Variable.h"
34
35 typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;
36
37 //
38 // Global variables
39 //
40 extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding;
41 extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName;
42 extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2;
43
44 extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
45 extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate;
46 extern EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate;
47
48 #define IP4_PROTO_ICMP 0x01
49 #define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
50
51 typedef enum {
52 IP4_CONFIG_STATE_IDLE = 0,
53 IP4_CONFIG_STATE_STARTED,
54 IP4_CONFIG_STATE_CONFIGURED
55 } IP4_CONFIG_STATE;
56
57 typedef enum {
58 DHCP_TAG_PARA_LIST = 55,
59 DHCP_TAG_NETMASK = 1,
60 DHCP_TAG_ROUTER = 3
61 } DHCP_TAGS;
62
63 //
64 // Configure the DHCP to request the routers and netmask
65 // from server. The DHCP_TAG_NETMASK is included in Head.
66 //
67 #pragma pack(1)
68 typedef struct {
69 EFI_DHCP4_PACKET_OPTION Head;
70 UINT8 Route;
71 } IP4_CONFIG_DHCP4_OPTION;
72 #pragma pack()
73
74 struct _IP4_CONFIG_INSTANCE {
75 UINT32 Signature;
76 EFI_HANDLE Controller;
77 EFI_HANDLE Image;
78
79 EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol;
80 EFI_NIC_IP4_CONFIG_PROTOCOL NicIp4Protocol;
81
82 //
83 // NicConfig's state, such as IP4_CONFIG_STATE_IDLE
84 //
85 INTN State;
86
87 //
88 // Mnp child to keep the connection with MNP.
89 //
90 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
91 EFI_HANDLE MnpHandle;
92
93 //
94 // User's requests data
95 //
96 EFI_EVENT DoneEvent;
97 EFI_EVENT ReconfigEvent;
98 EFI_STATUS Result;
99
100 //
101 // Identity of this interface and some configuration info.
102 //
103 NIC_ADDR NicAddr;
104 UINT16 NicName[IP4_NIC_NAME_LENGTH];
105 UINT32 NicIndex;
106 NIC_IP4_CONFIG_INFO *NicConfig;
107
108 //
109 // DHCP handles to access DHCP
110 //
111 EFI_DHCP4_PROTOCOL *Dhcp4;
112 EFI_HANDLE Dhcp4Handle;
113 EFI_EVENT Dhcp4Event;
114 };
115
116 #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \
117 CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)
118
119 #define IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG(this) \
120 CR (this, IP4_CONFIG_INSTANCE, NicIp4Protocol, IP4_CONFIG_INSTANCE_SIGNATURE)
121
122 /**
123 Release all the DHCP related resources.
124
125 @param This The IP4 configure instance
126
127 @return None
128
129 **/
130 VOID
131 Ip4ConfigCleanDhcp4 (
132 IN IP4_CONFIG_INSTANCE *This
133 );
134
135 /**
136 Clean up all the configuration parameters.
137
138 @param Instance The IP4 configure instance
139
140 @return None
141
142 **/
143 VOID
144 Ip4ConfigCleanConfig (
145 IN IP4_CONFIG_INSTANCE *Instance
146 );
147
148 //
149 // EFI Component Name Functions
150 //
151
152 /**
153 Retrieves a Unicode string that is the user readable name of the driver.
154
155 This function retrieves the user readable name of a driver in the form of a
156 Unicode string. If the driver specified by This has a user readable name in
157 the language specified by Language, then a pointer to the driver name is
158 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
159 by This does not support the language specified by Language,
160 then EFI_UNSUPPORTED is returned.
161
162 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
163 EFI_COMPONENT_NAME_PROTOCOL instance.
164 @param Language[in] A pointer to a Null-terminated ASCII string
165 array indicating the language. This is the
166 language of the driver name that the caller is
167 requesting, and it must match one of the
168 languages specified in SupportedLanguages. The
169 number of languages supported by a driver is up
170 to the driver writer. Language is specified
171 in RFC 3066 or ISO 639-2 language code format.
172 @param DriverName[out] A pointer to the Unicode string to return.
173 This Unicode string is the name of the
174 driver specified by This in the language
175 specified by Language.
176
177 @retval EFI_SUCCESS The Unicode string for the Driver specified by
178 This and the language specified by Language was
179 returned in DriverName.
180 @retval EFI_INVALID_PARAMETER Language is NULL.
181 @retval EFI_INVALID_PARAMETER DriverName is NULL.
182 @retval EFI_UNSUPPORTED The driver specified by This does not support
183 the language specified by Language.
184
185 **/
186 EFI_STATUS
187 EFIAPI
188 Ip4ConfigComponentNameGetDriverName (
189 IN EFI_COMPONENT_NAME_PROTOCOL *This,
190 IN CHAR8 *Language,
191 OUT CHAR16 **DriverName
192 );
193
194 /**
195 Retrieves a Unicode string that is the user readable name of the controller
196 that is being managed by a driver.
197
198 This function retrieves the user readable name of the controller specified by
199 ControllerHandle and ChildHandle in the form of a Unicode string. If the
200 driver specified by This has a user readable name in the language specified by
201 Language, then a pointer to the controller name is returned in ControllerName,
202 and EFI_SUCCESS is returned. If the driver specified by This is not currently
203 managing the controller specified by ControllerHandle and ChildHandle,
204 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
205 support the language specified by Language, then EFI_UNSUPPORTED is returned.
206
207 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
208 EFI_COMPONENT_NAME_PROTOCOL instance.
209 @param ControllerHandle[in] The handle of a controller that the driver
210 specified by This is managing. This handle
211 specifies the controller whose name is to be
212 returned.
213 @param ChildHandle[in] The handle of the child controller to retrieve
214 the name of. This is an optional parameter that
215 may be NULL. It will be NULL for device
216 drivers. It will also be NULL for a bus drivers
217 that wish to retrieve the name of the bus
218 controller. It will not be NULL for a bus
219 driver that wishes to retrieve the name of a
220 child controller.
221 @param Language[in] A pointer to a Null-terminated ASCII string
222 array indicating the language. This is the
223 language of the driver name that the caller is
224 requesting, and it must match one of the
225 languages specified in SupportedLanguages. The
226 number of languages supported by a driver is up
227 to the driver writer. Language is specified in
228 RFC 3066 or ISO 639-2 language code format.
229 @param ControllerName[out] A pointer to the Unicode string to return.
230 This Unicode string is the name of the
231 controller specified by ControllerHandle and
232 ChildHandle in the language specified by
233 Language from the point of view of the driver
234 specified by This.
235
236 @retval EFI_SUCCESS The Unicode string for the user readable name in
237 the language specified by Language for the
238 driver specified by This was returned in
239 DriverName.
240 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
241 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
242 EFI_HANDLE.
243 @retval EFI_INVALID_PARAMETER Language is NULL.
244 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
245 @retval EFI_UNSUPPORTED The driver specified by This is not currently
246 managing the controller specified by
247 ControllerHandle and ChildHandle.
248 @retval EFI_UNSUPPORTED The driver specified by This does not support
249 the language specified by Language.
250
251 **/
252 EFI_STATUS
253 EFIAPI
254 Ip4ConfigComponentNameGetControllerName (
255 IN EFI_COMPONENT_NAME_PROTOCOL *This,
256 IN EFI_HANDLE ControllerHandle,
257 IN EFI_HANDLE ChildHandle OPTIONAL,
258 IN CHAR8 *Language,
259 OUT CHAR16 **ControllerName
260 );
261
262 /**
263 Test to see if this driver supports ControllerHandle.
264
265 @param This Protocol instance pointer.
266 @param ControllerHandle Handle of device to test
267 @param RemainingDevicePath Optional parameter use to pick a specific child
268 device to start.
269
270 @retval EFI_SUCCES This driver supports this device
271 @retval EFI_ALREADY_STARTED This driver is already running on this device
272 @retval other This driver does not support this device
273
274 **/
275 EFI_STATUS
276 EFIAPI
277 Ip4ConfigDriverBindingSupported (
278 IN EFI_DRIVER_BINDING_PROTOCOL *This,
279 IN EFI_HANDLE ControllerHandle,
280 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
281 );
282
283 /**
284 Start this driver on ControllerHandle.
285
286 @param This Protocol instance pointer.
287 @param ControllerHandle Handle of device to bind driver to
288 @param RemainingDevicePath Optional parameter use to pick a specific child
289 device to start.
290
291 @retval EFI_SUCCES This driver is added to ControllerHandle
292 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
293 @retval other This driver does not support this device
294
295 **/
296 EFI_STATUS
297 EFIAPI
298 Ip4ConfigDriverBindingStart (
299 IN EFI_DRIVER_BINDING_PROTOCOL *This,
300 IN EFI_HANDLE ControllerHandle,
301 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
302 );
303
304 /**
305 Stop this driver on ControllerHandle.
306
307 @param This Protocol instance pointer.
308 @param ControllerHandle Handle of device to stop driver on
309 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
310 children is zero stop the entire bus driver.
311 @param ChildHandleBuffer List of Child Handles to Stop.
312
313 @retval EFI_SUCCES This driver is removed ControllerHandle
314 @retval other This driver was not removed from this device
315
316 **/
317 EFI_STATUS
318 EFIAPI
319 Ip4ConfigDriverBindingStop (
320 IN EFI_DRIVER_BINDING_PROTOCOL *This,
321 IN EFI_HANDLE ControllerHandle,
322 IN UINTN NumberOfChildren,
323 IN EFI_HANDLE *ChildHandleBuffer
324 );
325
326 #endif