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