]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
9bcee9f2cb370334f7c8097b0696e8ccdcfcec85
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4Config.h
1 /** @file
2 Header file for IP4Config driver.
3
4 Copyright (c) 2006 - 2010, 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 #include <Protocol/HiiConfigAccess.h>
24 #include <Protocol/HiiDatabase.h>
25 #include <Protocol/HiiConfigRouting.h>
26 #include <Protocol/ServiceBinding.h>
27
28 #include <Guid/MdeModuleHii.h>
29
30 #include <Library/DevicePathLib.h>
31 #include <Library/DebugLib.h>
32 #include <Library/UefiRuntimeServicesTableLib.h>
33 #include <Library/UefiDriverEntryPoint.h>
34 #include <Library/UefiBootServicesTableLib.h>
35 #include <Library/UefiLib.h>
36 #include <Library/NetLib.h>
37 #include <Library/BaseMemoryLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/HiiLib.h>
40 #include <Library/PrintLib.h>
41 #include <Library/DpcLib.h>
42 #include <Library/UefiHiiServicesLib.h>
43
44 #include "NicIp4Variable.h"
45
46 typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;
47
48 //
49 // Global variables
50 //
51 extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding;
52 extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName;
53 extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2;
54
55 extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
56 extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate;
57
58 #define IP4_PROTO_ICMP 0x01
59 #define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
60
61 #define IP4_CONFIG_STATE_IDLE 0
62 #define IP4_CONFIG_STATE_STARTED 1
63 #define IP4_CONFIG_STATE_CONFIGURED 2
64
65 #define DHCP_TAG_PARA_LIST 55
66 #define DHCP_TAG_NETMASK 1
67 #define DHCP_TAG_ROUTER 3
68
69
70 //
71 // Configure the DHCP to request the routers and netmask
72 // from server. The DHCP_TAG_NETMASK is included in Head.
73 //
74 #pragma pack(1)
75 typedef struct {
76 EFI_DHCP4_PACKET_OPTION Head;
77 UINT8 Route;
78 } IP4_CONFIG_DHCP4_OPTION;
79 #pragma pack()
80
81 typedef struct _IP4CONFIG_CALLBACK_INFO {
82 BOOLEAN Configured;
83 BOOLEAN DhcpEnabled;
84 EFI_IPv4_ADDRESS LocalIp;
85 EFI_IPv4_ADDRESS SubnetMask;
86 EFI_IPv4_ADDRESS Gateway;
87 } IP4_SETTING_INFO;
88
89 struct _IP4_CONFIG_INSTANCE {
90 UINT32 Signature;
91 EFI_HANDLE Controller;
92 EFI_HANDLE Image;
93 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
94
95 EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol;
96
97 EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccessProtocol;
98 EFI_HANDLE ChildHandle;
99 EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;
100 EFI_HII_HANDLE RegisteredHandle;
101 IP4_SETTING_INFO Ip4ConfigCallbackInfo;
102
103 //
104 // NicConfig's state, such as IP4_CONFIG_STATE_IDLE
105 //
106 INTN State;
107
108 //
109 // Mnp child to keep the connection with MNP.
110 //
111 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
112 EFI_HANDLE MnpHandle;
113
114 //
115 // User's requests data
116 //
117 EFI_EVENT DoneEvent;
118 EFI_EVENT ReconfigEvent;
119 EFI_STATUS Result;
120
121 //
122 // Identity of this interface and some configuration info.
123 //
124 NIC_ADDR NicAddr;
125 UINT16 NicName[IP4_NIC_NAME_LENGTH];
126 UINT32 NicIndex;
127 NIC_IP4_CONFIG_INFO *NicConfig;
128
129 //
130 // DHCP handles to access DHCP
131 //
132 EFI_DHCP4_PROTOCOL *Dhcp4;
133 EFI_HANDLE Dhcp4Handle;
134 EFI_EVENT Dhcp4Event;
135 };
136
137 #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \
138 CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)
139
140 #define IP4_CONFIG_INSTANCE_FROM_CONFIG_ACCESS(this) \
141 CR (this, IP4_CONFIG_INSTANCE, HiiConfigAccessProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)
142
143
144 /**
145 Set the IP configure parameters for this NIC.
146
147 If Reconfig is TRUE, the IP driver will be informed to discard current
148 auto configure parameter and restart the auto configuration process.
149 If current there is a pending auto configuration, EFI_ALREADY_STARTED is
150 returned. You can only change the configure setting when either
151 the configure has finished or not started yet. If NicConfig, the
152 NIC's configure parameter is removed from the variable.
153
154 @param Instance The IP4 CONFIG instance.
155 @param NicConfig The new NIC IP4 configure parameter.
156 @param Reconfig Inform the IP4 driver to restart the auto
157 configuration.
158
159 @retval EFI_SUCCESS The configure parameter for this NIC was
160 set successfully.
161 @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is
162 invalid.
163 @retval EFI_ALREADY_STARTED There is a pending auto configuration.
164 @retval EFI_NOT_FOUND No auto configure parameter is found.
165
166 **/
167 EFI_STATUS
168 EFIAPI
169 EfiNicIp4ConfigSetInfo (
170 IN IP4_CONFIG_INSTANCE *Instance,
171 IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL,
172 IN BOOLEAN Reconfig
173 );
174
175 /**
176 Get the configure parameter for this NIC.
177
178 @param Instance The IP4 CONFIG Instance.
179 @param ConfigLen The length of the NicConfig buffer.
180 @param NicConfig The buffer to receive the NIC's configure
181 parameter.
182
183 @retval EFI_SUCCESS The configure parameter for this NIC was
184 obtained successfully .
185 @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL.
186 @retval EFI_NOT_FOUND There is no configure parameter for the NIC in
187 NVRam.
188 @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is
189 NULL.
190
191 **/
192 EFI_STATUS
193 EFIAPI
194 EfiNicIp4ConfigGetInfo (
195 IN IP4_CONFIG_INSTANCE *Instance,
196 IN OUT UINTN *ConfigLen,
197 OUT NIC_IP4_CONFIG_INFO *NicConfig
198 );
199
200 /**
201 Release all the DHCP related resources.
202
203 @param This The IP4 configure instance
204
205 @return None
206
207 **/
208 VOID
209 Ip4ConfigCleanDhcp4 (
210 IN IP4_CONFIG_INSTANCE *This
211 );
212
213 /**
214 Clean up all the configuration parameters.
215
216 @param Instance The IP4 configure instance
217
218 @return None
219
220 **/
221 VOID
222 Ip4ConfigCleanConfig (
223 IN IP4_CONFIG_INSTANCE *Instance
224 );
225
226 //
227 // EFI Component Name Functions
228 //
229
230 /**
231 Retrieves a Unicode string that is the user readable name of the driver.
232
233 This function retrieves the user readable name of a driver in the form of a
234 Unicode string. If the driver specified by This has a user readable name in
235 the language specified by Language, then a pointer to the driver name is
236 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
237 by This does not support the language specified by Language,
238 then EFI_UNSUPPORTED is returned.
239
240 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
241 EFI_COMPONENT_NAME_PROTOCOL instance.
242 @param Language[in] A pointer to a Null-terminated ASCII string
243 array indicating the language. This is the
244 language of the driver name that the caller is
245 requesting, and it must match one of the
246 languages specified in SupportedLanguages. The
247 number of languages supported by a driver is up
248 to the driver writer. Language is specified
249 in RFC 3066 or ISO 639-2 language code format.
250 @param DriverName[out] A pointer to the Unicode string to return.
251 This Unicode string is the name of the
252 driver specified by This in the language
253 specified by Language.
254
255 @retval EFI_SUCCESS The Unicode string for the Driver specified by
256 This and the language specified by Language was
257 returned in DriverName.
258 @retval EFI_INVALID_PARAMETER Language is NULL.
259 @retval EFI_INVALID_PARAMETER DriverName is NULL.
260 @retval EFI_UNSUPPORTED The driver specified by This does not support
261 the language specified by Language.
262
263 **/
264 EFI_STATUS
265 EFIAPI
266 Ip4ConfigComponentNameGetDriverName (
267 IN EFI_COMPONENT_NAME_PROTOCOL *This,
268 IN CHAR8 *Language,
269 OUT CHAR16 **DriverName
270 );
271
272 /**
273 Retrieves a Unicode string that is the user readable name of the controller
274 that is being managed by a driver.
275
276 This function retrieves the user readable name of the controller specified by
277 ControllerHandle and ChildHandle in the form of a Unicode string. If the
278 driver specified by This has a user readable name in the language specified by
279 Language, then a pointer to the controller name is returned in ControllerName,
280 and EFI_SUCCESS is returned. If the driver specified by This is not currently
281 managing the controller specified by ControllerHandle and ChildHandle,
282 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
283 support the language specified by Language, then EFI_UNSUPPORTED is returned.
284
285 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
286 EFI_COMPONENT_NAME_PROTOCOL instance.
287 @param ControllerHandle[in] The handle of a controller that the driver
288 specified by This is managing. This handle
289 specifies the controller whose name is to be
290 returned.
291 @param ChildHandle[in] The handle of the child controller to retrieve
292 the name of. This is an optional parameter that
293 may be NULL. It will be NULL for device
294 drivers. It will also be NULL for a bus drivers
295 that wish to retrieve the name of the bus
296 controller. It will not be NULL for a bus
297 driver that wishes to retrieve the name of a
298 child controller.
299 @param Language[in] A pointer to a Null-terminated ASCII string
300 array indicating the language. This is the
301 language of the driver name that the caller is
302 requesting, and it must match one of the
303 languages specified in SupportedLanguages. The
304 number of languages supported by a driver is up
305 to the driver writer. Language is specified in
306 RFC 3066 or ISO 639-2 language code format.
307 @param ControllerName[out] A pointer to the Unicode string to return.
308 This Unicode string is the name of the
309 controller specified by ControllerHandle and
310 ChildHandle in the language specified by
311 Language from the point of view of the driver
312 specified by This.
313
314 @retval EFI_SUCCESS The Unicode string for the user readable name in
315 the language specified by Language for the
316 driver specified by This was returned in
317 DriverName.
318 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
319 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
320 EFI_HANDLE.
321 @retval EFI_INVALID_PARAMETER Language is NULL.
322 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
323 @retval EFI_UNSUPPORTED The driver specified by This is not currently
324 managing the controller specified by
325 ControllerHandle and ChildHandle.
326 @retval EFI_UNSUPPORTED The driver specified by This does not support
327 the language specified by Language.
328
329 **/
330 EFI_STATUS
331 EFIAPI
332 Ip4ConfigComponentNameGetControllerName (
333 IN EFI_COMPONENT_NAME_PROTOCOL *This,
334 IN EFI_HANDLE ControllerHandle,
335 IN EFI_HANDLE ChildHandle OPTIONAL,
336 IN CHAR8 *Language,
337 OUT CHAR16 **ControllerName
338 );
339
340 /**
341 Test to see if this driver supports ControllerHandle.
342
343 @param This Protocol instance pointer.
344 @param ControllerHandle Handle of device to test
345 @param RemainingDevicePath Optional parameter use to pick a specific child
346 device to start.
347
348 @retval EFI_SUCCES This driver supports this device
349 @retval EFI_ALREADY_STARTED This driver is already running on this device
350 @retval other This driver does not support this device
351
352 **/
353 EFI_STATUS
354 EFIAPI
355 Ip4ConfigDriverBindingSupported (
356 IN EFI_DRIVER_BINDING_PROTOCOL *This,
357 IN EFI_HANDLE ControllerHandle,
358 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
359 );
360
361 /**
362 Start this driver on ControllerHandle.
363
364 @param This Protocol instance pointer.
365 @param ControllerHandle Handle of device to bind driver to
366 @param RemainingDevicePath Optional parameter use to pick a specific child
367 device to start.
368
369 @retval EFI_SUCCES This driver is added to ControllerHandle
370 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
371 @retval other This driver does not support this device
372
373 **/
374 EFI_STATUS
375 EFIAPI
376 Ip4ConfigDriverBindingStart (
377 IN EFI_DRIVER_BINDING_PROTOCOL *This,
378 IN EFI_HANDLE ControllerHandle,
379 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
380 );
381
382 /**
383 Stop this driver on ControllerHandle.
384
385 @param This Protocol instance pointer.
386 @param ControllerHandle Handle of device to stop driver on
387 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
388 children is zero stop the entire bus driver.
389 @param ChildHandleBuffer List of Child Handles to Stop.
390
391 @retval EFI_SUCCES This driver is removed ControllerHandle
392 @retval other This driver was not removed from this device
393
394 **/
395 EFI_STATUS
396 EFIAPI
397 Ip4ConfigDriverBindingStop (
398 IN EFI_DRIVER_BINDING_PROTOCOL *This,
399 IN EFI_HANDLE ControllerHandle,
400 IN UINTN NumberOfChildren,
401 IN EFI_HANDLE *ChildHandleBuffer
402 );
403
404 #endif