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>
40 #include <Library/DpcLib.h>
42 #include "NicIp4Variable.h"
44 typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE
;
49 extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding
;
50 extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName
;
51 extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2
;
53 extern IP4_CONFIG_INSTANCE
*mIp4ConfigNicList
[MAX_IP4_CONFIG_IN_VARIABLE
];
54 extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate
;
56 #define IP4_PROTO_ICMP 0x01
57 #define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
59 #define IP4_CONFIG_STATE_IDLE 0
60 #define IP4_CONFIG_STATE_STARTED 1
61 #define IP4_CONFIG_STATE_CONFIGURED 2
63 #define DHCP_TAG_PARA_LIST 55
64 #define DHCP_TAG_NETMASK 1
65 #define DHCP_TAG_ROUTER 3
69 // Configure the DHCP to request the routers and netmask
70 // from server. The DHCP_TAG_NETMASK is included in Head.
74 EFI_DHCP4_PACKET_OPTION Head
;
76 } IP4_CONFIG_DHCP4_OPTION
;
83 EFI_IPv4_ADDRESS LocalIp
;
84 EFI_IPv4_ADDRESS SubnetMask
;
85 EFI_IPv4_ADDRESS Gateway
;
86 } IP4_CONFIG_SESSION_DATA
;
88 typedef struct _IP4_CONFIG_FORM_ENTRY
{
90 IP4_CONFIG_INSTANCE
*Ip4ConfigInstance
;
91 EFI_HANDLE Controller
;
93 EFI_STRING_ID PortTitleToken
;
94 EFI_STRING_ID PortTitleHelpToken
;
95 IP4_CONFIG_SESSION_DATA SessionConfigData
;
96 } IP4CONFIG_FORM_ENTRY
;
98 #define IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
100 typedef struct _IP4_FORM_CALLBACK_INFO_INSTANCE
{
102 EFI_HANDLE DriverHandle
;
103 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess
;
104 EFI_HII_DATABASE_PROTOCOL
*HiiDatabase
;
105 EFI_HII_CONFIG_ROUTING_PROTOCOL
*ConfigRouting
;
106 EFI_HII_HANDLE RegisteredHandle
;
107 IP4CONFIG_FORM_ENTRY
*Current
;
108 } IP4_FORM_CALLBACK_INFO
;
110 #define IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \
113 IP4_FORM_CALLBACK_INFO, \
115 IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE \
118 struct _IP4_CONFIG_INSTANCE
{
120 EFI_HANDLE Controller
;
123 EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol
;
125 IP4_FORM_CALLBACK_INFO Ip4FormCallbackInfo
;
128 // NicConfig's state, such as IP4_CONFIG_STATE_IDLE
133 // Mnp child to keep the connection with MNP.
135 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
136 EFI_HANDLE MnpHandle
;
139 // User's requests data
142 EFI_EVENT ReconfigEvent
;
146 // Identity of this interface and some configuration info.
149 UINT16 NicName
[IP4_NIC_NAME_LENGTH
];
151 NIC_IP4_CONFIG_INFO
*NicConfig
;
154 // DHCP handles to access DHCP
156 EFI_DHCP4_PROTOCOL
*Dhcp4
;
157 EFI_HANDLE Dhcp4Handle
;
158 EFI_EVENT Dhcp4Event
;
161 #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \
162 CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)
164 #define IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO(this) \
165 CR (this, IP4_CONFIG_INSTANCE, Ip4FormCallbackInfo, IP4_CONFIG_INSTANCE_SIGNATURE)
169 Set the IP configure parameters for this NIC.
171 If Reconfig is TRUE, the IP driver will be informed to discard current
172 auto configure parameter and restart the auto configuration process.
173 If current there is a pending auto configuration, EFI_ALREADY_STARTED is
174 returned. You can only change the configure setting when either
175 the configure has finished or not started yet. If NicConfig, the
176 NIC's configure parameter is removed from the variable.
178 @param Instance The IP4 CONFIG instance.
179 @param NicConfig The new NIC IP4 configure parameter
180 @param Reconfig Inform the IP4 driver to restart the auto
183 @retval EFI_SUCCESS The configure parameter for this NIC was
185 @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is
187 @retval EFI_ALREADY_STARTED There is a pending auto configuration.
188 @retval EFI_NOT_FOUND No auto configure parameter is found
193 EfiNicIp4ConfigSetInfo (
194 IN IP4_CONFIG_INSTANCE
*Instance
,
195 IN NIC_IP4_CONFIG_INFO
*NicConfig OPTIONAL
,
200 Get the configure parameter for this NIC.
202 @param Instance The IP4 CONFIG Instance.
203 @param ConfigLen The length of the NicConfig buffer.
204 @param NicConfig The buffer to receive the NIC's configure
207 @retval EFI_SUCCESS The configure parameter for this NIC was
208 obtained successfully .
209 @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL.
210 @retval EFI_NOT_FOUND There is no configure parameter for the NIC in
212 @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is
218 EfiNicIp4ConfigGetInfo (
219 IN IP4_CONFIG_INSTANCE
*Instance
,
220 IN OUT UINTN
*ConfigLen
,
221 OUT NIC_IP4_CONFIG_INFO
*NicConfig
225 Release all the DHCP related resources.
227 @param This The IP4 configure instance
233 Ip4ConfigCleanDhcp4 (
234 IN IP4_CONFIG_INSTANCE
*This
238 Clean up all the configuration parameters.
240 @param Instance The IP4 configure instance
246 Ip4ConfigCleanConfig (
247 IN IP4_CONFIG_INSTANCE
*Instance
251 // EFI Component Name Functions
255 Retrieves a Unicode string that is the user readable name of the driver.
257 This function retrieves the user readable name of a driver in the form of a
258 Unicode string. If the driver specified by This has a user readable name in
259 the language specified by Language, then a pointer to the driver name is
260 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
261 by This does not support the language specified by Language,
262 then EFI_UNSUPPORTED is returned.
264 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
265 EFI_COMPONENT_NAME_PROTOCOL instance.
266 @param Language[in] A pointer to a Null-terminated ASCII string
267 array indicating the language. This is the
268 language of the driver name that the caller is
269 requesting, and it must match one of the
270 languages specified in SupportedLanguages. The
271 number of languages supported by a driver is up
272 to the driver writer. Language is specified
273 in RFC 3066 or ISO 639-2 language code format.
274 @param DriverName[out] A pointer to the Unicode string to return.
275 This Unicode string is the name of the
276 driver specified by This in the language
277 specified by Language.
279 @retval EFI_SUCCESS The Unicode string for the Driver specified by
280 This and the language specified by Language was
281 returned in DriverName.
282 @retval EFI_INVALID_PARAMETER Language is NULL.
283 @retval EFI_INVALID_PARAMETER DriverName is NULL.
284 @retval EFI_UNSUPPORTED The driver specified by This does not support
285 the language specified by Language.
290 Ip4ConfigComponentNameGetDriverName (
291 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
293 OUT CHAR16
**DriverName
297 Retrieves a Unicode string that is the user readable name of the controller
298 that is being managed by a driver.
300 This function retrieves the user readable name of the controller specified by
301 ControllerHandle and ChildHandle in the form of a Unicode string. If the
302 driver specified by This has a user readable name in the language specified by
303 Language, then a pointer to the controller name is returned in ControllerName,
304 and EFI_SUCCESS is returned. If the driver specified by This is not currently
305 managing the controller specified by ControllerHandle and ChildHandle,
306 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
307 support the language specified by Language, then EFI_UNSUPPORTED is returned.
309 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
310 EFI_COMPONENT_NAME_PROTOCOL instance.
311 @param ControllerHandle[in] The handle of a controller that the driver
312 specified by This is managing. This handle
313 specifies the controller whose name is to be
315 @param ChildHandle[in] The handle of the child controller to retrieve
316 the name of. This is an optional parameter that
317 may be NULL. It will be NULL for device
318 drivers. It will also be NULL for a bus drivers
319 that wish to retrieve the name of the bus
320 controller. It will not be NULL for a bus
321 driver that wishes to retrieve the name of a
323 @param Language[in] A pointer to a Null-terminated ASCII string
324 array indicating the language. This is the
325 language of the driver name that the caller is
326 requesting, and it must match one of the
327 languages specified in SupportedLanguages. The
328 number of languages supported by a driver is up
329 to the driver writer. Language is specified in
330 RFC 3066 or ISO 639-2 language code format.
331 @param ControllerName[out] A pointer to the Unicode string to return.
332 This Unicode string is the name of the
333 controller specified by ControllerHandle and
334 ChildHandle in the language specified by
335 Language from the point of view of the driver
338 @retval EFI_SUCCESS The Unicode string for the user readable name in
339 the language specified by Language for the
340 driver specified by This was returned in
342 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
343 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
345 @retval EFI_INVALID_PARAMETER Language is NULL.
346 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
347 @retval EFI_UNSUPPORTED The driver specified by This is not currently
348 managing the controller specified by
349 ControllerHandle and ChildHandle.
350 @retval EFI_UNSUPPORTED The driver specified by This does not support
351 the language specified by Language.
356 Ip4ConfigComponentNameGetControllerName (
357 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
358 IN EFI_HANDLE ControllerHandle
,
359 IN EFI_HANDLE ChildHandle OPTIONAL
,
361 OUT CHAR16
**ControllerName
365 Test to see if this driver supports ControllerHandle.
367 @param This Protocol instance pointer.
368 @param ControllerHandle Handle of device to test
369 @param RemainingDevicePath Optional parameter use to pick a specific child
372 @retval EFI_SUCCES This driver supports this device
373 @retval EFI_ALREADY_STARTED This driver is already running on this device
374 @retval other This driver does not support this device
379 Ip4ConfigDriverBindingSupported (
380 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
381 IN EFI_HANDLE ControllerHandle
,
382 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
386 Start this driver on ControllerHandle.
388 @param This Protocol instance pointer.
389 @param ControllerHandle Handle of device to bind driver to
390 @param RemainingDevicePath Optional parameter use to pick a specific child
393 @retval EFI_SUCCES This driver is added to ControllerHandle
394 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
395 @retval other This driver does not support this device
400 Ip4ConfigDriverBindingStart (
401 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
402 IN EFI_HANDLE ControllerHandle
,
403 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
407 Stop this driver on ControllerHandle.
409 @param This Protocol instance pointer.
410 @param ControllerHandle Handle of device to stop driver on
411 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
412 children is zero stop the entire bus driver.
413 @param ChildHandleBuffer List of Child Handles to Stop.
415 @retval EFI_SUCCES This driver is removed ControllerHandle
416 @retval other This driver was not removed from this device
421 Ip4ConfigDriverBindingStop (
422 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
423 IN EFI_HANDLE ControllerHandle
,
424 IN UINTN NumberOfChildren
,
425 IN EFI_HANDLE
*ChildHandleBuffer