]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
13ed77128231518e766015553816d55f6505eaa4
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / Ip4Config.c
1 /** @file
2
3 Copyright (c) 2006 - 2007, 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 NetCopyMem (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 NetFreePool (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 NetFreePool (NewVariable);
122 };
123
124 NetFreePool (Config);
125 Config = NULL;
126 }
127
128 NetFreePool (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 NetCopyMem (NicConfig, Config, Len);
183 }
184
185 *ConfigLen = Len;
186
187 NetFreePool (Config);
188 return Status;
189 }
190
191
192 /**
193 Set the IP configure parameters for this NIC. If Reconfig is TRUE,
194 the IP driver will be informed to discard current auto configure
195 parameter and restart the auto configuration process. If current
196 there is a pending auto configuration, EFI_ALREADY_STARTED is
197 returned. You can only change the configure setting when either
198 the configure has finished or not started yet. If NicConfig, the
199 NIC's configure parameter is removed from the variable.
200
201 @param This The NIC IP4 CONFIG protocol
202 @param NicConfig The new NIC IP4 configure parameter
203 @param Reconfig Inform the IP4 driver to restart the auto
204 configuration
205
206 @retval EFI_INVALID_PARAMETER This is NULL or the configure parameter is
207 invalid.
208 @retval EFI_ALREADY_STARTED There is a pending auto configuration.
209 @retval EFI_NOT_FOUND No auto configure parameter is found
210
211 **/
212 EFI_STATUS
213 EFIAPI
214 EfiNicIp4ConfigSetInfo (
215 IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
216 IN NIC_IP4_CONFIG_INFO *NicConfig, OPTIONAL
217 IN BOOLEAN Reconfig
218 )
219 {
220 IP4_CONFIG_INSTANCE *Instance;
221 IP4_CONFIG_VARIABLE *Variable;
222 IP4_CONFIG_VARIABLE *NewVariable;
223 EFI_STATUS Status;
224
225 //
226 // Validate the parameters
227 //
228 if (This == NULL) {
229 return EFI_INVALID_PARAMETER;
230 }
231
232 Instance = IP4_CONFIG_INSTANCE_FROM_NIC_IP4CONFIG (This);
233
234 if ((NicConfig != NULL) && (!Ip4ConfigIsValid (NicConfig) ||
235 !NIC_ADDR_EQUAL (&NicConfig->NicAddr, &Instance->NicAddr))) {
236 return EFI_INVALID_PARAMETER;
237 }
238
239 if (Instance->State == IP4_CONFIG_STATE_STARTED) {
240 return EFI_ALREADY_STARTED;
241 }
242
243 //
244 // Update the parameter in the configure variable
245 //
246 Variable = Ip4ConfigReadVariable ();
247
248 if ((Variable == NULL) && (NicConfig == NULL)) {
249 return EFI_NOT_FOUND;
250 }
251
252 NewVariable = Ip4ConfigModifyVariable (Variable, &Instance->NicAddr, NicConfig);
253 Status = Ip4ConfigWriteVariable (NewVariable);
254
255 if (NewVariable != NULL) {
256 NetFreePool (NewVariable);
257 }
258
259 //
260 // Variable is NULL when saving the first configure parameter
261 //
262 if (Variable != NULL) {
263 NetFreePool (Variable);
264 }
265
266 if (EFI_ERROR (Status)) {
267 return Status;
268 }
269
270 //
271 // Signal the IP4 to run the auto configuration again
272 //
273 if (Reconfig && (Instance->ReconfigEvent != NULL)) {
274 Status = gBS->SignalEvent (Instance->ReconfigEvent);
275 }
276
277 return Status;
278 }
279
280
281 /**
282 Start the auto configuration process.
283
284 @param This The IP4 configure protocol
285 @param DoneEvent The event to signal when auto configure is done
286 @param ReconfigEvent The event to signal when reconfigure is necessary.
287
288 @retval EFI_INVALID_PARAMETER One of the function parameters is NULL.
289 @retval EFI_ALREADY_STARTED The auto configuration has already started.
290 @retval EFI_SUCCESS The auto configure is successfully started.
291
292 **/
293 EFI_STATUS
294 EFIAPI
295 EfiIp4ConfigStart (
296 IN EFI_IP4_CONFIG_PROTOCOL *This,
297 IN EFI_EVENT DoneEvent,
298 IN EFI_EVENT ReconfigEvent
299 )
300 {
301 IP4_CONFIG_INSTANCE *Instance;
302 EFI_DHCP4_PROTOCOL *Dhcp4;
303 EFI_DHCP4_MODE_DATA Dhcp4Mode;
304 EFI_DHCP4_PACKET_OPTION *OptionList[1];
305 IP4_CONFIG_DHCP4_OPTION ParaList;
306 EFI_STATUS Status;
307 UINT32 Source;
308 EFI_TPL OldTpl;
309
310 if ((This == NULL) || (DoneEvent == NULL) || (ReconfigEvent == NULL)) {
311 return EFI_INVALID_PARAMETER;
312 }
313
314 Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This);
315
316 OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
317
318 if (Instance->State != IP4_CONFIG_STATE_IDLE) {
319 Status = EFI_ALREADY_STARTED;
320
321 goto ON_EXIT;
322 }
323
324 Instance->DoneEvent = DoneEvent;
325 Instance->ReconfigEvent = ReconfigEvent;
326
327 Instance->NicConfig = Ip4ConfigGetNicInfo (&Instance->NicAddr);
328
329 if (Instance->NicConfig == NULL) {
330 Source = IP4_CONFIG_SOURCE_DHCP;
331 } else {
332 Source = Instance->NicConfig->Source;
333 }
334
335 //
336 // If the source is static, the auto configuration is done.
337 // return now.
338 //
339 if (Source == IP4_CONFIG_SOURCE_STATIC) {
340 Instance->State = IP4_CONFIG_STATE_CONFIGURED;
341 Instance->Result = EFI_SUCCESS;
342
343 gBS->SignalEvent (Instance->DoneEvent);
344 Status = EFI_SUCCESS;
345 goto ON_EXIT;
346 }
347
348 //
349 // Start the dhcp process
350 //
351 ASSERT ((Source == IP4_CONFIG_SOURCE_DHCP) && (Instance->Dhcp4 == NULL));
352
353 Status = NetLibCreateServiceChild (
354 Instance->Controller,
355 Instance->Image,
356 &gEfiDhcp4ServiceBindingProtocolGuid,
357 &Instance->Dhcp4Handle
358 );
359
360 if (EFI_ERROR (Status)) {
361 goto ON_ERROR;
362 }
363
364 Status = gBS->OpenProtocol (
365 Instance->Dhcp4Handle,
366 &gEfiDhcp4ProtocolGuid,
367 (VOID **) &Instance->Dhcp4,
368 Instance->Image,
369 Instance->Controller,
370 EFI_OPEN_PROTOCOL_BY_DRIVER
371 );
372
373 if (EFI_ERROR (Status)) {
374 goto ON_ERROR;
375 }
376
377 //
378 // Check the current DHCP status, if the DHCP process has
379 // already finished, return now.
380 //
381 Dhcp4 = Instance->Dhcp4;
382 Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
383
384 if (EFI_ERROR (Status)) {
385 goto ON_ERROR;
386 }
387
388 if (Dhcp4Mode.State == Dhcp4Bound) {
389 Ip4ConfigOnDhcp4Complete (NULL, Instance);
390
391 goto ON_EXIT;
392 }
393
394 //
395 // Try to start the DHCP process. Use most of the current
396 // DHCP configuration to avoid problems if some DHCP client
397 // yields the control of this DHCP service to us.
398 //
399 ParaList.Head.OpCode = DHCP_TAG_PARA_LIST;
400 ParaList.Head.Length = 2;
401 ParaList.Head.Data[0] = DHCP_TAG_NETMASK;
402 ParaList.Route = DHCP_TAG_ROUTER;
403 OptionList[0] = &ParaList.Head;
404 Dhcp4Mode.ConfigData.OptionCount = 1;
405 Dhcp4Mode.ConfigData.OptionList = OptionList;
406
407 Status = Dhcp4->Configure (Dhcp4, &Dhcp4Mode.ConfigData);
408
409 if (EFI_ERROR (Status)) {
410 goto ON_ERROR;
411 }
412
413 //
414 // Start the DHCP process
415 //
416 Status = gBS->CreateEvent (
417 EVT_NOTIFY_SIGNAL,
418 NET_TPL_LOCK,
419 Ip4ConfigOnDhcp4Complete,
420 Instance,
421 &Instance->Dhcp4Event
422 );
423
424 if (EFI_ERROR (Status)) {
425 goto ON_ERROR;
426 }
427
428 Status = Dhcp4->Start (Dhcp4, Instance->Dhcp4Event);
429
430 if (EFI_ERROR (Status)) {
431 goto ON_ERROR;
432 }
433
434 Instance->State = IP4_CONFIG_STATE_STARTED;
435 Instance->Result = EFI_NOT_READY;
436
437 ON_ERROR:
438 if (EFI_ERROR (Status)) {
439 Ip4ConfigCleanConfig (Instance);
440 }
441
442 ON_EXIT:
443 NET_RESTORE_TPL (OldTpl);
444
445 return Status;
446 }
447
448
449 /**
450 Stop the current auto configuration
451
452 @param This The IP4 CONFIG protocol
453
454 @retval EFI_INVALID_PARAMETER This is NULL.
455 @retval EFI_NOT_STARTED The auto configuration hasn't been started.
456 @retval EFI_SUCCESS The auto configuration has been stopped.
457
458 **/
459 EFI_STATUS
460 EFIAPI
461 EfiIp4ConfigStop (
462 IN EFI_IP4_CONFIG_PROTOCOL *This
463 )
464 {
465 IP4_CONFIG_INSTANCE *Instance;
466 EFI_STATUS Status;
467 EFI_TPL OldTpl;
468
469 if (This == NULL) {
470 return EFI_INVALID_PARAMETER;
471 }
472
473 Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This);
474
475 Status = EFI_SUCCESS;
476 OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
477
478 if (Instance->State == IP4_CONFIG_STATE_IDLE) {
479 Status = EFI_NOT_STARTED;
480 goto ON_EXIT;
481 }
482
483 //
484 // Release all the configure parameters. Don't signal the user
485 // event. The user wants to abort the configuration, this isn't
486 // the configuration done or reconfiguration.
487 //
488 Ip4ConfigCleanConfig (Instance);
489
490 ON_EXIT:
491 NET_RESTORE_TPL (OldTpl);
492
493 return Status;
494 }
495
496
497 /**
498 Get the current outcome of the auto configuration process
499
500 @param This The IP4 CONFIG protocol
501 @param ConfigDataSize The size of the configure data
502 @param ConfigData The buffer to save the configure data
503
504 @retval EFI_INVALID_PARAMETER This or ConfigDataSize is NULL
505 @retval EFI_BUFFER_TOO_SMALL The buffer is too small. The needed size is
506 returned in the ConfigDataSize.
507 @retval EFI_SUCCESS The configure data is put in the buffer
508
509 **/
510 EFI_STATUS
511 EFIAPI
512 EfiIp4ConfigGetData (
513 IN EFI_IP4_CONFIG_PROTOCOL *This,
514 IN OUT UINTN *ConfigDataSize,
515 OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL
516 )
517 {
518 IP4_CONFIG_INSTANCE *Instance;
519 NIC_IP4_CONFIG_INFO *NicConfig;
520 EFI_STATUS Status;
521 EFI_TPL OldTpl;
522 UINTN Len;
523
524 if ((This == NULL) || (ConfigDataSize == NULL)) {
525 return EFI_INVALID_PARAMETER;
526 }
527
528 Instance = IP4_CONFIG_INSTANCE_FROM_IP4CONFIG (This);
529
530 Status = EFI_SUCCESS;
531 OldTpl = NET_RAISE_TPL (NET_TPL_LOCK);
532
533 if (Instance->State == IP4_CONFIG_STATE_IDLE) {
534 Status = EFI_NOT_STARTED;
535 } else if (Instance->State == IP4_CONFIG_STATE_STARTED) {
536 Status = EFI_NOT_READY;
537 }
538
539 if (EFI_ERROR (Status)) {
540 goto ON_EXIT;
541 }
542
543 //
544 // Copy the configure data if auto configuration succeeds.
545 //
546 Status = Instance->Result;
547
548 if (Status == EFI_SUCCESS) {
549 ASSERT (Instance->NicConfig != NULL);
550
551 NicConfig = Instance->NicConfig;
552 Len = SIZEOF_IP4_CONFIG_INFO (&NicConfig->Ip4Info);
553
554 if ((*ConfigDataSize < Len) || (ConfigData == NULL)) {
555 Status = EFI_BUFFER_TOO_SMALL;
556 } else {
557 NetCopyMem (ConfigData, &NicConfig->Ip4Info, Len);
558 }
559
560 *ConfigDataSize = Len;
561 }
562
563 ON_EXIT:
564 NET_RESTORE_TPL (OldTpl);
565
566 return Status;
567 }
568
569
570 /**
571 Callback function when DHCP process finished. It will save the
572 retrieved IP configure parameter from DHCP to the NVRam.
573
574 @param Event The callback event
575 @param Context Opaque context to the callback
576
577 @return None
578
579 **/
580 VOID
581 EFIAPI
582 Ip4ConfigOnDhcp4Complete (
583 IN EFI_EVENT Event,
584 IN VOID *Context
585 )
586 {
587 IP4_CONFIG_INSTANCE *Instance;
588 EFI_DHCP4_MODE_DATA Dhcp4Mode;
589 EFI_IP4_IPCONFIG_DATA *Ip4Config;
590 EFI_STATUS Status;
591 BOOLEAN Perment;
592 IP4_ADDR Subnet;
593 IP4_ADDR Ip1;
594 IP4_ADDR Ip2;
595
596 Instance = (IP4_CONFIG_INSTANCE *) Context;
597 ASSERT (Instance->Dhcp4 != NULL);
598
599 Instance->State = IP4_CONFIG_STATE_CONFIGURED;
600 Instance->Result = EFI_TIMEOUT;
601
602 //
603 // Get the DHCP retrieved parameters
604 //
605 Status = Instance->Dhcp4->GetModeData (Instance->Dhcp4, &Dhcp4Mode);
606
607 if (EFI_ERROR (Status)) {
608 goto ON_EXIT;
609 }
610
611 if (Dhcp4Mode.State == Dhcp4Bound) {
612 //
613 // Save the new configuration retrieved by DHCP both in
614 // the instance and to NVRam. So, both the IP4 driver and
615 // other user can get that address.
616 //
617 Perment = FALSE;
618
619 if (Instance->NicConfig != NULL) {
620 ASSERT (Instance->NicConfig->Source == IP4_CONFIG_SOURCE_DHCP);
621 Perment = Instance->NicConfig->Perment;
622 NetFreePool (Instance->NicConfig);
623 }
624
625 Instance->NicConfig = NetAllocatePool (sizeof (NIC_IP4_CONFIG_INFO) + 2* sizeof (EFI_IP4_ROUTE_TABLE));
626
627 if (Instance->NicConfig == NULL) {
628 Instance->Result = EFI_OUT_OF_RESOURCES;
629 goto ON_EXIT;
630 }
631
632 Instance->NicConfig->Ip4Info.RouteTable = (EFI_IP4_ROUTE_TABLE *) (Instance->NicConfig + 1);
633
634 CopyMem (&Instance->NicConfig->NicAddr, &Instance->NicAddr, sizeof (Instance->NicConfig->NicAddr));
635 Instance->NicConfig->Source = IP4_CONFIG_SOURCE_DHCP;
636 Instance->NicConfig->Perment = Perment;
637
638 Ip4Config = &Instance->NicConfig->Ip4Info;
639 Ip4Config->StationAddress = Dhcp4Mode.ClientAddress;
640 Ip4Config->SubnetMask = Dhcp4Mode.SubnetMask;
641
642 //
643 // Create a route for the connected network
644 //
645 Ip4Config->RouteTableSize = 1;
646
647 NetCopyMem (&Ip1, &Dhcp4Mode.ClientAddress, sizeof (IP4_ADDR));
648 NetCopyMem (&Ip2, &Dhcp4Mode.SubnetMask, sizeof (IP4_ADDR));
649
650 Subnet = Ip1 & Ip2;
651
652 NetCopyMem (&Ip4Config->RouteTable[0].SubnetAddress, &Subnet, sizeof (EFI_IPv4_ADDRESS));
653 NetCopyMem (&Ip4Config->RouteTable[0].SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
654 NetZeroMem (&Ip4Config->RouteTable[0].GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
655
656 //
657 // Create a route if there is a default router.
658 //
659 if (!EFI_IP4_EQUAL (&Dhcp4Mode.RouterAddress, &mZeroIp4Addr)) {
660 Ip4Config->RouteTableSize = 2;
661
662 NetZeroMem (&Ip4Config->RouteTable[1].SubnetAddress, sizeof (EFI_IPv4_ADDRESS));
663 NetZeroMem (&Ip4Config->RouteTable[1].SubnetMask, sizeof (EFI_IPv4_ADDRESS));
664 NetCopyMem (&Ip4Config->RouteTable[1].GatewayAddress, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS));
665 }
666
667 Instance->Result = EFI_SUCCESS;
668
669 //
670 // ignore the return status of EfiNicIp4ConfigSetInfo. Network
671 // stack can operate even that failed.
672 //
673 EfiNicIp4ConfigSetInfo (&Instance->NicIp4Protocol, Instance->NicConfig, FALSE);
674 }
675
676 ON_EXIT:
677 gBS->SignalEvent (Instance->DoneEvent);
678 Ip4ConfigCleanDhcp4 (Instance);
679 return ;
680 }
681
682
683 /**
684 Release all the DHCP related resources.
685
686 @param This The IP4 configure instance
687
688 @return None
689
690 **/
691 VOID
692 Ip4ConfigCleanDhcp4 (
693 IN IP4_CONFIG_INSTANCE *This
694 )
695 {
696 if (This->Dhcp4 != NULL) {
697 This->Dhcp4->Stop (This->Dhcp4);
698
699 gBS->CloseProtocol (
700 This->Dhcp4Handle,
701 &gEfiDhcp4ProtocolGuid,
702 This->Image,
703 This->Controller
704 );
705
706 This->Dhcp4 = NULL;
707 }
708
709 if (This->Dhcp4Handle != NULL) {
710 NetLibDestroyServiceChild (
711 This->Controller,
712 This->Image,
713 &gEfiDhcp4ServiceBindingProtocolGuid,
714 This->Dhcp4Handle
715 );
716
717 This->Dhcp4Handle = NULL;
718 }
719
720 if (This->Dhcp4Event == NULL) {
721 gBS->CloseEvent (This->Dhcp4Event);
722 This->Dhcp4Event = NULL;
723 }
724 }
725
726
727 /**
728 Clean up all the configuration parameters
729
730 @param Instance The IP4 configure instance
731
732 @return None
733
734 **/
735 VOID
736 Ip4ConfigCleanConfig (
737 IN IP4_CONFIG_INSTANCE *Instance
738 )
739 {
740 if (Instance->NicConfig != NULL) {
741 NetFreePool (Instance->NicConfig);
742 Instance->NicConfig = NULL;
743 }
744
745 Instance->State = IP4_CONFIG_STATE_IDLE;
746 Instance->DoneEvent = NULL;
747 Instance->ReconfigEvent = NULL;
748
749 Ip4ConfigCleanDhcp4 (Instance);
750 }
751
752 EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate = {
753 EfiIp4ConfigStart,
754 EfiIp4ConfigStop,
755 EfiIp4ConfigGetData
756 };
757
758 EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate = {
759 EfiNicIp4ConfigGetName,
760 EfiNicIp4ConfigGetInfo,
761 EfiNicIp4ConfigSetInfo
762 };