2 Header file for IP4Config driver.
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
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.
15 #ifndef _EFI_IP4CONFIG_H_
16 #define _EFI_IP4CONFIG_H_
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>
27 #include <Guid/MdeModuleHii.h>
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>
41 #include "NicIp4Variable.h"
43 typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE
;
48 extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding
;
49 extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName
;
50 extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2
;
52 extern IP4_CONFIG_INSTANCE
*mIp4ConfigNicList
[MAX_IP4_CONFIG_IN_VARIABLE
];
53 extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate
;
55 #define IP4_PROTO_ICMP 0x01
56 #define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
59 IP4_CONFIG_STATE_IDLE
= 0,
60 IP4_CONFIG_STATE_STARTED
,
61 IP4_CONFIG_STATE_CONFIGURED
65 DHCP_TAG_PARA_LIST
= 55,
71 // Configure the DHCP to request the routers and netmask
72 // from server. The DHCP_TAG_NETMASK is included in Head.
76 EFI_DHCP4_PACKET_OPTION Head
;
78 } IP4_CONFIG_DHCP4_OPTION
;
85 EFI_IPv4_ADDRESS LocalIp
;
86 EFI_IPv4_ADDRESS SubnetMask
;
87 EFI_IPv4_ADDRESS Gateway
;
88 } IP4_CONFIG_SESSION_DATA
;
90 typedef struct _IP4_CONFIG_FORM_ENTRY
{
92 IP4_CONFIG_INSTANCE
*Ip4ConfigInstance
;
93 EFI_HANDLE Controller
;
95 EFI_STRING_ID PortTitleToken
;
96 EFI_STRING_ID PortTitleHelpToken
;
97 IP4_CONFIG_SESSION_DATA SessionConfigData
;
98 } IP4CONFIG_FORM_ENTRY
;
100 #define IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
102 typedef struct _IP4_FORM_CALLBACK_INFO_INSTANCE
{
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
;
112 #define IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \
115 IP4_FORM_CALLBACK_INFO, \
117 IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE \
120 struct _IP4_CONFIG_INSTANCE
{
122 EFI_HANDLE Controller
;
125 EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol
;
127 IP4_FORM_CALLBACK_INFO Ip4FormCallbackInfo
;
130 // NicConfig's state, such as IP4_CONFIG_STATE_IDLE
135 // Mnp child to keep the connection with MNP.
137 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
138 EFI_HANDLE MnpHandle
;
141 // User's requests data
144 EFI_EVENT ReconfigEvent
;
148 // Identity of this interface and some configuration info.
151 UINT16 NicName
[IP4_NIC_NAME_LENGTH
];
153 NIC_IP4_CONFIG_INFO
*NicConfig
;
156 // DHCP handles to access DHCP
158 EFI_DHCP4_PROTOCOL
*Dhcp4
;
159 EFI_HANDLE Dhcp4Handle
;
160 EFI_EVENT Dhcp4Event
;
163 #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \
164 CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)
166 #define IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO(this) \
167 CR (this, IP4_CONFIG_INSTANCE, Ip4FormCallbackInfo, IP4_CONFIG_INSTANCE_SIGNATURE)
171 Set the IP configure parameters for this NIC.
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.
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
185 @retval EFI_SUCCESS The configure parameter for this NIC was
187 @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is
189 @retval EFI_ALREADY_STARTED There is a pending auto configuration.
190 @retval EFI_NOT_FOUND No auto configure parameter is found
195 EfiNicIp4ConfigSetInfo (
196 IN IP4_CONFIG_INSTANCE
*Instance
,
197 IN NIC_IP4_CONFIG_INFO
*NicConfig OPTIONAL
,
202 Get the configure parameter for this NIC.
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
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
214 @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is
220 EfiNicIp4ConfigGetInfo (
221 IN IP4_CONFIG_INSTANCE
*Instance
,
222 IN OUT UINTN
*ConfigLen
,
223 OUT NIC_IP4_CONFIG_INFO
*NicConfig
227 Release all the DHCP related resources.
229 @param This The IP4 configure instance
235 Ip4ConfigCleanDhcp4 (
236 IN IP4_CONFIG_INSTANCE
*This
240 Clean up all the configuration parameters.
242 @param Instance The IP4 configure instance
248 Ip4ConfigCleanConfig (
249 IN IP4_CONFIG_INSTANCE
*Instance
253 // EFI Component Name Functions
257 Retrieves a Unicode string that is the user readable name of the driver.
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.
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.
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.
292 Ip4ConfigComponentNameGetDriverName (
293 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
295 OUT CHAR16
**DriverName
299 Retrieves a Unicode string that is the user readable name of the controller
300 that is being managed by a driver.
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.
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
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
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
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
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
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.
358 Ip4ConfigComponentNameGetControllerName (
359 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
360 IN EFI_HANDLE ControllerHandle
,
361 IN EFI_HANDLE ChildHandle OPTIONAL
,
363 OUT CHAR16
**ControllerName
367 Test to see if this driver supports ControllerHandle.
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
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
381 Ip4ConfigDriverBindingSupported (
382 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
383 IN EFI_HANDLE ControllerHandle
,
384 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
388 Start this driver on ControllerHandle.
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
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
402 Ip4ConfigDriverBindingStart (
403 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
404 IN EFI_HANDLE ControllerHandle
,
405 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
409 Stop this driver on ControllerHandle.
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.
417 @retval EFI_SUCCES This driver is removed ControllerHandle
418 @retval other This driver was not removed from this device
423 Ip4ConfigDriverBindingStop (
424 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
425 IN EFI_HANDLE ControllerHandle
,
426 IN UINTN NumberOfChildren
,
427 IN EFI_HANDLE
*ChildHandleBuffer