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