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