]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
[Description]:
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4Config.c
1 /** @file
2
3 Copyright (c) 2006 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Ip4Config.c
15
16 Abstract:
17
18 This code implements the IP4Config and NicIp4Config protocols.
19
20
21 **/
22
23 #include "Ip4Config.h"
24
25 IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
26
27 VOID
28 EFIAPI
29 Ip4ConfigOnDhcp4Complete (
30 IN EFI_EVENT Event,
31 IN VOID *Context
32 );
33
34
35 /**
36 Return the name and MAC address for the NIC. The Name, if not NULL,
37 has at least IP4_NIC_NAME_LENGTH bytes.
38
39 @param This The NIC IP4 CONFIG protocol
40 @param Name The buffer to return the name
41 @param NicAddr The buffer to return the MAC addr
42
43 @retval EFI_INVALID_PARAMETER This is NULL
44 @retval EFI_SUCCESS The name or address of the NIC are returned.
45
46 **/
47 STATIC
48 EFI_STATUS
49 EFIAPI
50 EfiNicIp4ConfigGetName (
51 IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
52 IN UINT16 *Name, OPTIONAL
53 IN NIC_ADDR *NicAddr OPTIONAL
54 )
55 {
56 IP4_CONFIG_INSTANCE *Instance;
57
58 if (This == NULL) {
59 return EFI_INVALID_PARAMETER;
60 }
61
62 Instance = IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG (This);
63
64 if (Name != NULL) {
65 CopyMem (Name, Instance->NicName, IP4_NIC_NAME_LENGTH);
66 }
67
68 if (NicAddr != NULL) {
69 CopyMem (NicAddr, &Instance->NicAddr, sizeof (*NicAddr));
70 }
71
72 return EFI_SUCCESS;
73 }
74
75
76 /**
77 Get the NIC's configure information from the IP4 configure variable.
78 It will remove the invalid variable.
79
80 @param NicAddr The NIC to check
81
82 @return NULL if no configure for the NIC in the variable, or it is invalid.
83 @return Otherwise the NIC's IP configure parameter.
84
85 **/
86 NIC_IP4_CONFIG_INFO *
87 Ip4ConfigGetNicInfo (
88 IN NIC_ADDR *NicAddr
89 )
90 {
91 IP4_CONFIG_VARIABLE *Variable;
92 IP4_CONFIG_VARIABLE *NewVariable;
93 NIC_IP4_CONFIG_INFO *Config;
94
95 //
96 // Read the configuration parameter for this NicAddr from
97 // the EFI variable
98 //
99 Variable = Ip4ConfigReadVariable ();
100
101 if (Variable == NULL) {
102 return NULL;
103 }
104
105 Config = Ip4ConfigFindNicVariable (Variable, NicAddr);
106
107 if (Config == NULL) {
108 gBS->FreePool (Variable);
109 return NULL;
110 }
111
112 //
113 // Validate the configuration, if the configuration is invalid,
114 // remove it from the variable.
115 //
116 if (!Ip4ConfigIsValid (Config)) {
117 NewVariable = Ip4ConfigModifyVariable (Variable, &Config->NicAddr, NULL);
118 Ip4ConfigWriteVariable (NewVariable);
119
120 if (NewVariable != NULL) {
121 gBS->FreePool (NewVariable);
122 };
123
124 gBS->FreePool (Config);
125 Config = NULL;
126 }
127
128 gBS->FreePool (Variable);
129 return Config;
130 }
131
132
133 /**
134 Get the configure parameter for this NIC.
135
136 @param This The NIC IP4 CONFIG protocol
137 @param ConfigLen The length of the NicConfig buffer.
138 @param NicConfig The buffer to receive the NIC's configure
139 parameter.
140
141 @retval EFI_INVALID_PARAMETER This or ConfigLen is NULL
142 @retval EFI_NOT_FOUND There is no configure parameter for the NIC in
143 NVRam.
144
145 **/
146 EFI_STATUS
147 EFIAPI
148 EfiNicIp4ConfigGetInfo (
149 IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
150 IN OUT UINTN *ConfigLen,
151 OUT NIC_IP4_CONFIG_INFO *NicConfig
152 )
153 {
154 IP4_CONFIG_INSTANCE *Instance;
155 NIC_IP4_CONFIG_INFO *Config;
156 EFI_STATUS Status;
157 UINTN Len;
158
159 if ((This == NULL) || (ConfigLen == NULL)) {
160 return EFI_INVALID_PARAMETER;
161 }
162
163 //
164 // Read the Nic's configuration parameter from variable
165 //
166 Instance = IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG (This);
167 Config = Ip4ConfigGetNicInfo (&Instance->NicAddr);
168
169 if (Config == NULL) {
170 return EFI_NOT_FOUND;
171 }
172
173 //
174 // Copy the data to user's buffer
175 //
176 Len = SIZEOF_NIC_IP4_CONFIG_INFO (Config);
177
178 if ((*ConfigLen < Len) || (NicConfig == NULL)) {
179 Status = EFI_BUFFER_TOO_SMALL;
180 } else {
181 Status = EFI_SUCCESS;
182 CopyMem (NicConfig, Config, Len);
183 Ip4ConfigFixRouteTablePointer (&NicConfig->Ip4Info);
184 }
185
186 *ConfigLen = Len;
187
188 gBS->FreePool (Config);
189 return Status;
190 }
191
192
193 /**
194 Set the IP configure parameters for this NIC. If Reconfig is TRUE,
195 the IP driver will be informed to discard current auto configure
196 parameter and restart the auto configuration process. If current
197 there is a pending auto configuration, EFI_ALREADY_STARTED is
198 returned. You can only change the configure setting when either
199 the configure has finished or not started yet. If NicConfig, the
200 NIC's configure parameter is removed from the variable.
201
202 @param This The NIC IP4 CONFIG protocol
203 @param NicConfig The new NIC IP4 configure parameter
204 @param Reconfig Inform the IP4 driver to restart the auto
205 configuration
206
207 @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is
208 invalid.
209 @retval EFI_ALREADY_STARTED There is a pending auto configuration.
210 @retval EFI_NOT_FOUND No auto configure parameter is found
211
212 **/
213 EFI_STATUS
214 EFIAPI
215 EfiNicIp4ConfigSetInfo (
216 IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
217 IN NIC_IP4_CONFIG_INFO *NicConfig, OPTIONAL
218 IN BOOLEAN Reconfig
219 )
220 {
221 IP4_CONFIG_INSTANCE *Instance;
222 IP4_CONFIG_VARIABLE *Variable;
223 IP4_CONFIG_VARIABLE *NewVariable;
224 EFI_STATUS Status;
225
226 //
227 // Validate the parameters
228 //
229 if (This == NULL) {
230 return EFI_INVALID_PARAMETER;
231 }
232
233 Instance = IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG (This);
234
235 if ((NicConfig != NULL) && (!Ip4ConfigIsValid (NicConfig) ||
236 !NIC_ADDR_EQUAL (&NicConfig->NicAddr, &Instance->NicAddr))) {
237 return EFI_INVALID_PARAMETER;
238 }
239
240 if (Instance->State == IP4_CONFIG_STATE_STARTED) {
241 return EFI_ALREADY_STARTED;
242 }
243
244 //
245 // Update the parameter in the configure variable
246 //
247 Variable = Ip4ConfigReadVariable ();
248
249 if ((Variable == NULL) && (NicConfig == NULL)) {
250 return EFI_NOT_FOUND;
251 }
252
253 NewVariable = Ip4ConfigModifyVariable (Variable, &Instance->NicAddr, NicConfig);
254 Status = Ip4ConfigWriteVariable (NewVariable);
255
256 if (NewVariable != NULL) {
257 gBS->FreePool (NewVariable);
258 }
259
260 //
261 // Variable is NULL when saving the first configure parameter
262 //
263 if (Variable != NULL) {
264 gBS->FreePool (Variable);
265 }
266
267 if (EFI_ERROR (Status)) {
268 return Status;
269 }
270
271 //
272 // Signal the IP4 to run the auto configuration again
273 //
274 if (Reconfig && (Instance->ReconfigEvent != NULL)) {
275 Status = gBS->SignalEvent (Instance->ReconfigEvent);
276 NetLibDispatchDpc ();
277 }
278
279 return Status;
280 }
281
282
283 /**
284 Start the auto configuration process.
285
286 @param This The IP4 configure protocol
287 @param DoneEvent The event to signal when auto configure is done
288 @param ReconfigEvent The event to signal when reconfigure is necessary.
289
290 @retval EFI_INVALID_PARAMETER One of the function parameters is NULL.
291 @retval EFI_ALREADY_STARTED The auto configuration has already started.
292 @retval EFI_SUCCESS The auto configure is successfully started.
293
294 **/
295 EFI_STATUS
296 EFIAPI
297 EfiIp4ConfigStart (
298 IN EFI_IP4_CONFIG_PROTOCOL *This,
299 IN EFI_EVENT DoneEvent,
300 IN EFI_EVENT ReconfigEvent
301 )
302 {
303 IP4_CONFIG_INSTANCE *Instance;
304 EFI_DHCP4_PROTOCOL *Dhcp4;
305 EFI_DHCP4_MODE_DATA Dhcp4Mode;
306 EFI_DHCP4_PACKET_OPTION *OptionList[1];
307 IP4_CONFIG_DHCP4_OPTION ParaList;
308 EFI_STATUS Status;
309 UINT32 Source;
310 EFI_TPL OldTpl;
311
312 if ((This == NULL) || (DoneEvent == NULL) || (ReconfigEvent == NULL)) {
313 return EFI_INVALID_PARAMETER;
314 }
315
316 Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This);
317
318 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
319
320 if (Instance->State != IP4_CONFIG_STATE_IDLE) {
321 Status = EFI_ALREADY_STARTED;
322
323 goto ON_EXIT;
324 }
325
326 Instance->DoneEvent = DoneEvent;
327 Instance->ReconfigEvent = ReconfigEvent;
328
329 Instance->NicConfig = Ip4ConfigGetNicInfo (&Instance->NicAddr);
330
331 if (Instance->NicConfig == NULL) {
332 Source = IP4_CONFIG_SOURCE_DHCP;
333 } else {
334 Source = Instance->NicConfig->Source;
335 }
336
337 //
338 // If the source is static, the auto configuration is done.
339 // return now.
340 //
341 if (Source == IP4_CONFIG_SOURCE_STATIC) {
342 Instance->State = IP4_CONFIG_STATE_CONFIGURED;
343 Instance->Result = EFI_SUCCESS;
344
345 gBS->SignalEvent (Instance->DoneEvent);
346 Status = EFI_SUCCESS;
347 goto ON_EXIT;
348 }
349
350 //
351 // Start the dhcp process
352 //
353 ASSERT ((Source == IP4_CONFIG_SOURCE_DHCP) && (Instance->Dhcp4 == NULL));
354
355 Status = NetLibCreateServiceChild (
356 Instance->Controller,
357 Instance->Image,
358 &gEfiDhcp4ServiceBindingProtocolGuid,
359 &Instance->Dhcp4Handle
360 );
361
362 if (EFI_ERROR (Status)) {
363 goto ON_ERROR;
364 }
365
366 Status = gBS->OpenProtocol (
367 Instance->Dhcp4Handle,
368 &gEfiDhcp4ProtocolGuid,
369 (VOID **) &Instance->Dhcp4,
370 Instance->Image,
371 Instance->Controller,
372 EFI_OPEN_PROTOCOL_BY_DRIVER
373 );
374
375 if (EFI_ERROR (Status)) {
376 goto ON_ERROR;
377 }
378
379 //
380 // Check the current DHCP status, if the DHCP process has
381 // already finished, return now.
382 //
383 Dhcp4 = Instance->Dhcp4;
384 Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
385
386 if (EFI_ERROR (Status)) {
387 goto ON_ERROR;
388 }
389
390 if (Dhcp4Mode.State == Dhcp4Bound) {
391 Ip4ConfigOnDhcp4Complete (NULL, Instance);
392
393 goto ON_EXIT;
394 }
395
396 //
397 // Try to start the DHCP process. Use most of the current
398 // DHCP configuration to avoid problems if some DHCP client
399 // yields the control of this DHCP service to us.
400 //
401 ParaList.Head.OpCode = DHCP_TAG_PARA_LIST;
402 ParaList.Head.Length = 2;
403 ParaList.Head.Data[0] = DHCP_TAG_NETMASK;
404 ParaList.Route = DHCP_TAG_ROUTER;
405 OptionList[0] = &ParaList.Head;
406 Dhcp4Mode.ConfigData.OptionCount = 1;
407 Dhcp4Mode.ConfigData.OptionList = OptionList;
408
409 Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData);
410
411 if (EFI_ERROR (Status)) {
412 goto ON_ERROR;
413 }
414
415 //
416 // Start the DHCP process
417 //
418 Status = gBS->CreateEvent (
419 EVT_NOTIFY_SIGNAL,
420 TPL_CALLBACK,
421 Ip4ConfigOnDhcp4Complete,
422 Instance,
423 &Instance->Dhcp4Event
424 );
425
426 if (EFI_ERROR (Status)) {
427 goto ON_ERROR;
428 }
429
430 Status = Dhcp4->Start (Dhcp4, Instance->Dhcp4Event);
431
432 if (EFI_ERROR (Status)) {
433 goto ON_ERROR;
434 }
435
436 Instance->State = IP4_CONFIG_STATE_STARTED;
437 Instance->Result = EFI_NOT_READY;
438
439 ON_ERROR:
440 if (EFI_ERROR (Status)) {
441 Ip4ConfigCleanConfig (Instance);
442 }
443
444 ON_EXIT:
445 gBS->RestoreTPL (OldTpl);
446
447 NetLibDispatchDpc ();
448
449 return Status;
450 }
451
452
453 /**
454 Stop the current auto configuration
455
456 @param This The IP4 CONFIG protocol
457
458 @retval EFI_INVALID_PARAMETER This is NULL.
459 @retval EFI_NOT_STARTED The auto configuration hasn't been started.
460 @retval EFI_SUCCESS The auto configuration has been stopped.
461
462 **/
463 EFI_STATUS
464 EFIAPI
465 EfiIp4ConfigStop (
466 IN EFI_IP4_CONFIG_PROTOCOL *This
467 )
468 {
469 IP4_CONFIG_INSTANCE *Instance;
470 EFI_STATUS Status;
471 EFI_TPL OldTpl;
472
473 if (This == NULL) {
474 return EFI_INVALID_PARAMETER;
475 }
476
477 Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This);
478
479 Status = EFI_SUCCESS;
480 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
481
482 if (Instance->State == IP4_CONFIG_STATE_IDLE) {
483 Status = EFI_NOT_STARTED;
484 goto ON_EXIT;
485 }
486
487 //
488 // Release all the configure parameters. Don't signal the user
489 // event. The user wants to abort the configuration, this isn't
490 // the configuration done or reconfiguration.
491 //
492 Ip4ConfigCleanConfig (Instance);
493
494 ON_EXIT:
495 gBS->RestoreTPL (OldTpl);
496
497 return Status;
498 }
499
500
501 /**
502 Get the current outcome of the auto configuration process
503
504 @param This The IP4 CONFIG protocol
505 @param ConfigDataSize The size of the configure data
506 @param ConfigData The buffer to save the configure data
507
508 @retval EFI_INVALID_PARAMETER This or ConfigDataSize is NULL
509 @retval EFI_BUFFER_TOO_SMALL The buffer is too small. The needed size is
510 returned in the ConfigDataSize.
511 @retval EFI_SUCCESS The configure data is put in the buffer
512
513 **/
514 EFI_STATUS
515 EFIAPI
516 EfiIp4ConfigGetData (
517 IN EFI_IP4_CONFIG_PROTOCOL *This,
518 IN OUT UINTN *ConfigDataSize,
519 OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL
520 )
521 {
522 IP4_CONFIG_INSTANCE *Instance;
523 NIC_IP4_CONFIG_INFO *NicConfig;
524 EFI_STATUS Status;
525 EFI_TPL OldTpl;
526 UINTN Len;
527
528 if ((This == NULL) || (ConfigDataSize == NULL)) {
529 return EFI_INVALID_PARAMETER;
530 }
531
532 Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This);
533
534 Status = EFI_SUCCESS;
535 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
536
537 if (Instance->State == IP4_CONFIG_STATE_IDLE) {
538 Status = EFI_NOT_STARTED;
539 } else if (Instance->State == IP4_CONFIG_STATE_STARTED) {
540 Status = EFI_NOT_READY;
541 }
542
543 if (EFI_ERROR (Status)) {
544 goto ON_EXIT;
545 }
546
547 //
548 // Copy the configure data if auto configuration succeeds.
549 //
550 Status = Instance->Result;
551
552 if (Status == EFI_SUCCESS) {
553 ASSERT (Instance->NicConfig != NULL);
554
555 NicConfig = Instance->NicConfig;
556 Len = SIZEOF_IP4_CONFIG_INFO (&NicConfig->Ip4Info);
557
558 if ((*ConfigDataSize < Len) || (ConfigData == NULL)) {
559 Status = EFI_BUFFER_TOO_SMALL;
560 } else {
561 CopyMem (ConfigData, &NicConfig->Ip4Info, Len);
562 Ip4ConfigFixRouteTablePointer (ConfigData);
563 }
564
565 *ConfigDataSize = Len;
566 }
567
568 ON_EXIT:
569 gBS->RestoreTPL (OldTpl);
570
571 return Status;
572 }
573
574
575 /**
576 Callback function when DHCP process finished. It will save the
577 retrieved IP configure parameter from DHCP to the NVRam.
578
579 @param Event The callback event
580 @param Context Opaque context to the callback
581
582 @return None
583
584 **/
585 VOID
586 EFIAPI
587 Ip4ConfigOnDhcp4Complete (
588 IN EFI_EVENT Event,
589 IN VOID *Context
590 )
591 {
592 IP4_CONFIG_INSTANCE *Instance;
593 EFI_DHCP4_MODE_DATA Dhcp4Mode;
594 EFI_IP4_IPCONFIG_DATA *Ip4Config;
595 EFI_STATUS Status;
596 BOOLEAN Perment;
597 IP4_ADDR Subnet;
598 IP4_ADDR Ip1;
599 IP4_ADDR Ip2;
600
601 Instance = (IP4_CONFIG_INSTANCE *) Context;
602 ASSERT (Instance->Dhcp4 != NULL);
603
604 Instance->State = IP4_CONFIG_STATE_CONFIGURED;
605 Instance->Result = EFI_TIMEOUT;
606
607 //
608 // Get the DHCP retrieved parameters
609 //
610 Status = Instance->Dhcp4->GetModeData (Instance->Dhcp4, &Dhcp4Mode);
611
612 if (EFI_ERROR (Status)) {
613 goto ON_EXIT;
614 }
615
616 if (Dhcp4Mode.State == Dhcp4Bound) {
617 //
618 // Save the new configuration retrieved by DHCP both in
619 // the instance and to NVRam. So, both the IP4 driver and
620 // other user can get that address.
621 //
622 Perment = FALSE;
623
624 if (Instance->NicConfig != NULL) {
625 ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
626 Perment = Instance->NicConfig->Perment;
627 gBS->FreePool (Instance->NicConfig);
628 }
629
630 Instance->NicConfig = AllocatePool (sizeof (NIC_IP4_CONFIG_INFO) + 2* sizeof (EFI_IP4_ROUTE_TABLE));
631
632 if (Instance->NicConfig == NULL) {
633 Instance->Result = EFI_OUT_OF_RESOURCES;
634 goto ON_EXIT;
635 }
636
637 Instance->NicConfig->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (Instance->NicConfig + 1);
638
639 CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr));
640 Instance->NicConfig->Source = IP4_CONFIG_SOURCE_DHCP;
641 Instance->NicConfig->Perment = Perment;
642
643 Ip4Config = &Instance->NicConfig->Ip4Info;
644 Ip4Config->StationAddress = Dhcp4Mode.ClientAddress;
645 Ip4Config->SubnetMask = Dhcp4Mode.SubnetMask;
646
647 //
648 // Create a route for the connected network
649 //
650 Ip4Config->RouteTableSize = 1;
651
652 CopyMem (&Ip1, &Dhcp4Mode.ClientAddress, sizeof (IP4_ADDR));
653 CopyMem (&Ip2, &Dhcp4Mode.SubnetMask, sizeof (IP4_ADDR));
654
655 Subnet = Ip1 & Ip2;
656
657 CopyMem (&Ip4Config->RouteTable[0].SubnetAddress, &Subnet, sizeof (EFI_IPv4_ADDRESS));
658 CopyMem (&Ip4Config->RouteTable[0].SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
659 ZeroMem (&Ip4Config->RouteTable[0].GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
660
661 //
662 // Create a route if there is a default router.
663 //
664 if (!EFI_IP4_EQUAL (&Dhcp4Mode.RouterAddress, &mZeroIp4Addr)) {
665 Ip4Config->RouteTableSize = 2;
666
667 ZeroMem (&Ip4Config->RouteTable[1].SubnetAddress, sizeof (EFI_IPv4_ADDRESS));
668 ZeroMem (&Ip4Config->RouteTable[1].SubnetMask, sizeof (EFI_IPv4_ADDRESS));
669 CopyMem (&Ip4Config->RouteTable[1].GatewayAddress, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS));
670 }
671
672 Instance->Result = EFI_SUCCESS;
673
674 //
675 // ignore the return status of EfiNicIp4ConfigSetInfo. Network
676 // stack can operate even that failed.
677 //
678 EfiNicIp4ConfigSetInfo (&Instance->NicIp4Protocol, Instance->NicConfig, FALSE);
679 }
680
681 ON_EXIT:
682 gBS->SignalEvent (Instance->DoneEvent);
683 Ip4ConfigCleanDhcp4 (Instance);
684
685 NetLibDispatchDpc ();
686
687 return ;
688 }
689
690
691 /**
692 Release all the DHCP related resources.
693
694 @param This The IP4 configure instance
695
696 @return None
697
698 **/
699 VOID
700 Ip4ConfigCleanDhcp4 (
701 IN IP4_CONFIG_INSTANCE *This
702 )
703 {
704 if (This->Dhcp4 != NULL) {
705 This->Dhcp4->Stop (This->Dhcp4);
706
707 gBS->CloseProtocol (
708 This->Dhcp4Handle,
709 &gEfiDhcp4ProtocolGuid,
710 This->Image,
711 This->Controller
712 );
713
714 This->Dhcp4 = NULL;
715 }
716
717 if (This->Dhcp4Handle != NULL) {
718 NetLibDestroyServiceChild (
719 This->Controller,
720 This->Image,
721 &gEfiDhcp4ServiceBindingProtocolGuid,
722 This->Dhcp4Handle
723 );
724
725 This->Dhcp4Handle = NULL;
726 }
727
728 if (This->Dhcp4Event == NULL) {
729 gBS->CloseEvent (This->Dhcp4Event);
730 This->Dhcp4Event = NULL;
731 }
732 }
733
734
735 /**
736 Clean up all the configuration parameters
737
738 @param Instance The IP4 configure instance
739
740 @return None
741
742 **/
743 VOID
744 Ip4ConfigCleanConfig (
745 IN IP4_CONFIG_INSTANCE *Instance
746 )
747 {
748 if (Instance->NicConfig != NULL) {
749 gBS->FreePool (Instance->NicConfig);
750 Instance->NicConfig = NULL;
751 }
752
753 Instance->State = IP4_CONFIG_STATE_IDLE;
754 Instance->DoneEvent = NULL;
755 Instance->ReconfigEvent = NULL;
756
757 Ip4ConfigCleanDhcp4 (Instance);
758 }
759
760 EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate = {
761 EfiIp4ConfigStart,
762 EfiIp4ConfigStop,
763 EfiIp4ConfigGetData
764 };
765
766 EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate = {
767 EfiNicIp4ConfigGetName,
768 EfiNicIp4ConfigGetInfo,
769 EfiNicIp4ConfigSetInfo
770 };