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