]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
Add VLAN support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4Config.h
1 /** @file
2 Header file for IP4Config driver.
3
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
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
27 #include <Guid/MdeModuleHii.h>
28
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>
41
42 #include "NicIp4Variable.h"
43
44 typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;
45
46 //
47 // Global variables
48 //
49 extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding;
50 extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName;
51 extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2;
52
53 extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
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
80 typedef struct {
81 UINTN DeviceNum;
82 BOOLEAN Enabled;
83 EFI_IPv4_ADDRESS LocalIp;
84 EFI_IPv4_ADDRESS SubnetMask;
85 EFI_IPv4_ADDRESS Gateway;
86 } IP4_CONFIG_SESSION_DATA;
87
88 typedef struct _IP4_CONFIG_FORM_ENTRY {
89 LIST_ENTRY Link;
90 IP4_CONFIG_INSTANCE *Ip4ConfigInstance;
91 EFI_HANDLE Controller;
92 CHAR16 *MacString;
93 EFI_STRING_ID PortTitleToken;
94 EFI_STRING_ID PortTitleHelpToken;
95 IP4_CONFIG_SESSION_DATA SessionConfigData;
96 } IP4CONFIG_FORM_ENTRY;
97
98 #define IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C')
99
100 typedef struct _IP4_FORM_CALLBACK_INFO_INSTANCE {
101 UINTN Signature;
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;
109
110 #define IP4CONFIG_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK(Callback) \
111 CR ( \
112 Callback, \
113 IP4_FORM_CALLBACK_INFO, \
114 ConfigAccess, \
115 IP4CONFIG_FORM_CALLBACK_INFO_SIGNATURE \
116 )
117
118 struct _IP4_CONFIG_INSTANCE {
119 UINT32 Signature;
120 EFI_HANDLE Controller;
121 EFI_HANDLE Image;
122
123 EFI_IP4_CONFIG_PROTOCOL Ip4ConfigProtocol;
124
125 IP4_FORM_CALLBACK_INFO Ip4FormCallbackInfo;
126
127 //
128 // NicConfig's state, such as IP4_CONFIG_STATE_IDLE
129 //
130 INTN State;
131
132 //
133 // Mnp child to keep the connection with MNP.
134 //
135 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
136 EFI_HANDLE MnpHandle;
137
138 //
139 // User's requests data
140 //
141 EFI_EVENT DoneEvent;
142 EFI_EVENT ReconfigEvent;
143 EFI_STATUS Result;
144
145 //
146 // Identity of this interface and some configuration info.
147 //
148 NIC_ADDR NicAddr;
149 UINT16 NicName[IP4_NIC_NAME_LENGTH];
150 UINT32 NicIndex;
151 NIC_IP4_CONFIG_INFO *NicConfig;
152
153 //
154 // DHCP handles to access DHCP
155 //
156 EFI_DHCP4_PROTOCOL *Dhcp4;
157 EFI_HANDLE Dhcp4Handle;
158 EFI_EVENT Dhcp4Event;
159 };
160
161 #define IP4_CONFIG_INSTANCE_FROM_IP4CONFIG(this) \
162 CR (this, IP4_CONFIG_INSTANCE, Ip4ConfigProtocol, IP4_CONFIG_INSTANCE_SIGNATURE)
163
164 #define IP4_CONFIG_INSTANCE_FROM_IP4FORM_CALLBACK_INFO(this) \
165 CR (this, IP4_CONFIG_INSTANCE, Ip4FormCallbackInfo, IP4_CONFIG_INSTANCE_SIGNATURE)
166
167
168 /**
169 Set the IP configure parameters for this NIC.
170
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.
177
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
181 configuration
182
183 @retval EFI_SUCCESS The configure parameter for this NIC was
184 set successfully .
185 @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is
186 invalid.
187 @retval EFI_ALREADY_STARTED There is a pending auto configuration.
188 @retval EFI_NOT_FOUND No auto configure parameter is found
189
190 **/
191 EFI_STATUS
192 EFIAPI
193 EfiNicIp4ConfigSetInfo (
194 IN IP4_CONFIG_INSTANCE *Instance,
195 IN NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL,
196 IN BOOLEAN Reconfig
197 );
198
199 /**
200 Get the configure parameter for this NIC.
201
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
205 parameter.
206
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
211 NVRam.
212 @retval EFI_BUFFER_TOO_SMALL The ConfigLen is too small or the NicConfig is
213 NULL.
214
215 **/
216 EFI_STATUS
217 EFIAPI
218 EfiNicIp4ConfigGetInfo (
219 IN IP4_CONFIG_INSTANCE *Instance,
220 IN OUT UINTN *ConfigLen,
221 OUT NIC_IP4_CONFIG_INFO *NicConfig
222 );
223
224 /**
225 Release all the DHCP related resources.
226
227 @param This The IP4 configure instance
228
229 @return None
230
231 **/
232 VOID
233 Ip4ConfigCleanDhcp4 (
234 IN IP4_CONFIG_INSTANCE *This
235 );
236
237 /**
238 Clean up all the configuration parameters.
239
240 @param Instance The IP4 configure instance
241
242 @return None
243
244 **/
245 VOID
246 Ip4ConfigCleanConfig (
247 IN IP4_CONFIG_INSTANCE *Instance
248 );
249
250 //
251 // EFI Component Name Functions
252 //
253
254 /**
255 Retrieves a Unicode string that is the user readable name of the driver.
256
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.
263
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.
278
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.
286
287 **/
288 EFI_STATUS
289 EFIAPI
290 Ip4ConfigComponentNameGetDriverName (
291 IN EFI_COMPONENT_NAME_PROTOCOL *This,
292 IN CHAR8 *Language,
293 OUT CHAR16 **DriverName
294 );
295
296 /**
297 Retrieves a Unicode string that is the user readable name of the controller
298 that is being managed by a driver.
299
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.
308
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
314 returned.
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
322 child controller.
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
336 specified by This.
337
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
341 DriverName.
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
344 EFI_HANDLE.
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.
352
353 **/
354 EFI_STATUS
355 EFIAPI
356 Ip4ConfigComponentNameGetControllerName (
357 IN EFI_COMPONENT_NAME_PROTOCOL *This,
358 IN EFI_HANDLE ControllerHandle,
359 IN EFI_HANDLE ChildHandle OPTIONAL,
360 IN CHAR8 *Language,
361 OUT CHAR16 **ControllerName
362 );
363
364 /**
365 Test to see if this driver supports ControllerHandle.
366
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
370 device to start.
371
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
375
376 **/
377 EFI_STATUS
378 EFIAPI
379 Ip4ConfigDriverBindingSupported (
380 IN EFI_DRIVER_BINDING_PROTOCOL *This,
381 IN EFI_HANDLE ControllerHandle,
382 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
383 );
384
385 /**
386 Start this driver on ControllerHandle.
387
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
391 device to start.
392
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
396
397 **/
398 EFI_STATUS
399 EFIAPI
400 Ip4ConfigDriverBindingStart (
401 IN EFI_DRIVER_BINDING_PROTOCOL *This,
402 IN EFI_HANDLE ControllerHandle,
403 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
404 );
405
406 /**
407 Stop this driver on ControllerHandle.
408
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.
414
415 @retval EFI_SUCCES This driver is removed ControllerHandle
416 @retval other This driver was not removed from this device
417
418 **/
419 EFI_STATUS
420 EFIAPI
421 Ip4ConfigDriverBindingStop (
422 IN EFI_DRIVER_BINDING_PROTOCOL *This,
423 IN EFI_HANDLE ControllerHandle,
424 IN UINTN NumberOfChildren,
425 IN EFI_HANDLE *ChildHandleBuffer
426 );
427
428 #endif