23BOOLEAN mIpSec2Installed =
FALSE;
45 Status =
gBS->LocateProtocol (&gEfiIpSec2ProtocolGuid,
NULL, (VOID **)&mIpSec);
50 gBS->CloseEvent (Event);
52 mIpSec2Installed =
TRUE;
81 &gEfiIpSec2ProtocolGuid,
129 Status =
gBS->OpenProtocol (
131 &gEfiManagedNetworkServiceBindingProtocolGuid,
133 This->DriverBindingHandle,
135 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
138 if (EFI_ERROR (Status)) {
145 Status =
gBS->OpenProtocol (
147 &gEfiArpServiceBindingProtocolGuid,
149 This->DriverBindingHandle,
151 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
199 ASSERT (Service !=
NULL);
211 return EFI_OUT_OF_RESOURCES;
214 IpSb->Signature = IP4_SERVICE_SIGNATURE;
217 IpSb->State = IP4_SERVICE_UNSTARTED;
219 IpSb->NumChildren = 0;
223 IpSb->DefaultInterface =
NULL;
224 IpSb->DefaultRouteTable =
NULL;
228 IpSb->IgmpCtrl.Igmpv1QuerySeen = 0;
231 IpSb->Image = ImageHandle;
232 IpSb->Controller = Controller;
234 IpSb->MnpChildHandle =
NULL;
251 IpSb->ReconfigCheckTimer =
NULL;
253 IpSb->ReconfigEvent =
NULL;
255 IpSb->Reconfig =
FALSE;
257 IpSb->MediaPresent =
TRUE;
266 if (IpSb->DefaultRouteTable ==
NULL) {
267 Status = EFI_OUT_OF_RESOURCES;
271 Status =
gBS->CreateEvent (
272 EVT_NOTIFY_SIGNAL | EVT_TIMER,
279 if (EFI_ERROR (Status)) {
283 Status =
gBS->CreateEvent (
284 EVT_NOTIFY_SIGNAL | EVT_TIMER,
288 &IpSb->ReconfigCheckTimer
291 if (EFI_ERROR (Status)) {
295 Status =
gBS->CreateEvent (
302 if (EFI_ERROR (Status)) {
309 &gEfiManagedNetworkServiceBindingProtocolGuid,
310 &IpSb->MnpChildHandle
313 if (EFI_ERROR (Status)) {
317 Status =
gBS->OpenProtocol (
318 IpSb->MnpChildHandle,
319 &gEfiManagedNetworkProtocolGuid,
323 EFI_OPEN_PROTOCOL_BY_DRIVER
326 if (EFI_ERROR (Status)) {
332 if (EFI_ERROR (Status)) {
336 Status = IpSb->Mnp->GetModeData (IpSb->Mnp,
NULL, &IpSb->SnpMode);
338 if (EFI_ERROR (Status)) {
344 if (EFI_ERROR (Status)) {
348 IpSb->MacString =
NULL;
351 if (EFI_ERROR (Status)) {
357 if (IpSb->DefaultInterface ==
NULL) {
358 Status = EFI_OUT_OF_RESOURCES;
362 InsertHeadList (&IpSb->Interfaces, &IpSb->DefaultInterface->Link);
368 if (EFI_ERROR (Status)) {
377 IpSb->MaxPacketSize -= NET_VLAN_TAG_LEN;
412 IpSb->State = IP4_SERVICE_DESTROY;
414 if (IpSb->Timer !=
NULL) {
416 gBS->CloseEvent (IpSb->Timer);
421 if (IpSb->ReconfigCheckTimer !=
NULL) {
423 gBS->CloseEvent (IpSb->ReconfigCheckTimer);
425 IpSb->ReconfigCheckTimer =
NULL;
428 if (IpSb->DefaultInterface !=
NULL) {
431 if (EFI_ERROR (Status)) {
435 IpSb->DefaultInterface =
NULL;
438 if (IpSb->DefaultRouteTable !=
NULL) {
440 IpSb->DefaultRouteTable =
NULL;
445 if (IpSb->MnpChildHandle !=
NULL) {
446 if (IpSb->Mnp !=
NULL) {
448 IpSb->MnpChildHandle,
449 &gEfiManagedNetworkProtocolGuid,
460 &gEfiManagedNetworkServiceBindingProtocolGuid,
464 IpSb->MnpChildHandle =
NULL;
467 if (IpSb->ReconfigEvent !=
NULL) {
468 gBS->CloseEvent (IpSb->ReconfigEvent);
470 IpSb->ReconfigEvent =
NULL;
473 IpSb->Reconfig =
FALSE;
475 if (IpSb->MacString !=
NULL) {
503 UINTN NumberOfChildren;
506 if ((Entry ==
NULL) || (Context ==
NULL)) {
507 return EFI_INVALID_PARAMETER;
510 IpInstance = NET_LIST_USER_STRUCT_S (Entry,
IP4_PROTOCOL, Link, IP4_PROTOCOL_SIGNATURE);
519 return ServiceBinding->DestroyChild (ServiceBinding, IpInstance->Handle);
560 if (EFI_ERROR (Status)) {
561 DEBUG ((DEBUG_ERROR,
"%a failed to generate random number: %r\n", __func__, Status));
568 Status =
gBS->OpenProtocol (
570 &gEfiIp4ServiceBindingProtocolGuid,
572 This->DriverBindingHandle,
574 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
578 return EFI_ALREADY_STARTED;
581 Status =
Ip4CreateService (ControllerHandle, This->DriverBindingHandle, &IpSb);
583 if (EFI_ERROR (Status)) {
587 ASSERT (IpSb !=
NULL);
589 Ip4Cfg2 = &IpSb->Ip4Config2Instance.Ip4Config2;
594 Status =
gBS->InstallMultipleProtocolInterfaces (
596 &gEfiIp4ServiceBindingProtocolGuid,
597 &IpSb->ServiceBinding,
598 &gEfiIp4Config2ProtocolGuid,
603 if (EFI_ERROR (Status)) {
612 if (EFI_ERROR (Status)) {
613 goto UNINSTALL_PROTOCOL;
620 DataItem = &IpSb->Ip4Config2Instance.DataItem[Index];
621 if (DataItem->Data.Ptr !=
NULL) {
622 Status = Ip4Cfg2->SetData (
628 if (EFI_ERROR (Status)) {
629 goto UNINSTALL_PROTOCOL;
645 if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
646 goto UNINSTALL_PROTOCOL;
651 if (EFI_ERROR (Status)) {
652 goto UNINSTALL_PROTOCOL;
655 Status =
gBS->SetTimer (IpSb->ReconfigCheckTimer,
TimerPeriodic, 500 * TICKS_PER_MS);
657 if (EFI_ERROR (Status)) {
658 goto UNINSTALL_PROTOCOL;
664 mIp4Id = (UINT16)Random;
669 gBS->UninstallMultipleProtocolInterfaces (
671 &gEfiIp4ServiceBindingProtocolGuid,
672 &IpSb->ServiceBinding,
673 &gEfiIp4Config2ProtocolGuid,
726 if (NicHandle ==
NULL) {
728 if (NicHandle ==
NULL) {
730 if (NicHandle !=
NULL) {
738 Status =
gBS->OpenProtocol (
740 &gEfiIp4ServiceBindingProtocolGuid,
741 (VOID **)&ServiceBinding,
742 This->DriverBindingHandle,
744 EFI_OPEN_PROTOCOL_GET_PROTOCOL
746 if (EFI_ERROR (Status)) {
747 return EFI_DEVICE_ERROR;
750 IpSb = IP4_SERVICE_FROM_PROTOCOL (ServiceBinding);
754 gBS->CloseEvent (IpSb->Ip4Config2Instance.Dhcp4Event);
755 IpSb->Ip4Config2Instance.Dhcp4Event =
NULL;
756 }
else if (NumberOfChildren != 0) {
757 List = &IpSb->Children;
758 Context.ServiceBinding = ServiceBinding;
759 Context.NumberOfChildren = NumberOfChildren;
760 Context.ChildHandleBuffer = ChildHandleBuffer;
767 }
else if (IpSb->DefaultInterface->ArpHandle == ControllerHandle) {
783 if (RouteTable ==
NULL) {
788 IpSb->DefaultInterface = IpIf;
790 IpSb->DefaultRouteTable = RouteTable;
793 IpSb->State = IP4_SERVICE_UNSTARTED;
800 if (EFI_ERROR (Status)) {
805 gBS->UninstallMultipleProtocolInterfaces (
807 &gEfiIp4ServiceBindingProtocolGuid,
809 &gEfiIp4Config2ProtocolGuid,
810 &IpSb->Ip4Config2Instance.Ip4Config2,
814 if (gIp4ControllerNameTable !=
NULL) {
816 gIp4ControllerNameTable =
NULL;
858 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
859 return EFI_INVALID_PARAMETER;
862 IpSb = IP4_SERVICE_FROM_PROTOCOL (This);
865 if (IpInstance ==
NULL) {
866 return EFI_OUT_OF_RESOURCES;
874 Status =
gBS->InstallMultipleProtocolInterfaces (
876 &gEfiIp4ProtocolGuid,
877 &IpInstance->Ip4Proto,
881 if (EFI_ERROR (Status)) {
885 IpInstance->Handle = *ChildHandle;
890 Status =
gBS->OpenProtocol (
891 IpSb->MnpChildHandle,
892 &gEfiManagedNetworkProtocolGuid,
896 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
898 if (EFI_ERROR (Status)) {
899 gBS->UninstallMultipleProtocolInterfaces (
901 &gEfiIp4ProtocolGuid,
902 &IpInstance->Ip4Proto,
912 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
917 gBS->RestoreTPL (OldTpl);
921 if (EFI_ERROR (Status)) {
961 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
962 return EFI_INVALID_PARAMETER;
968 IpSb = IP4_SERVICE_FROM_PROTOCOL (This);
970 Status =
gBS->OpenProtocol (
972 &gEfiIp4ProtocolGuid,
976 EFI_OPEN_PROTOCOL_GET_PROTOCOL
979 if (EFI_ERROR (Status)) {
980 return EFI_UNSUPPORTED;
983 IpInstance = IP4_INSTANCE_FROM_PROTOCOL (Ip4);
985 if (IpInstance->Service != IpSb) {
986 return EFI_INVALID_PARAMETER;
989 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
997 if (IpInstance->InDestroy) {
998 gBS->RestoreTPL (OldTpl);
1002 IpInstance->InDestroy =
TRUE;
1007 gBS->CloseProtocol (
1008 IpSb->MnpChildHandle,
1009 &gEfiManagedNetworkProtocolGuid,
1014 if ((IpInstance->Interface !=
NULL) && (IpInstance->Interface->Arp !=
NULL)) {
1015 gBS->CloseProtocol (
1016 IpInstance->Interface->ArpHandle,
1017 &gEfiArpProtocolGuid,
1037 gBS->RestoreTPL (OldTpl);
1038 Status =
gBS->UninstallProtocolInterface (
1040 &gEfiIp4ProtocolGuid,
1041 &IpInstance->Ip4Proto
1043 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
1044 if (EFI_ERROR (Status)) {
1045 IpInstance->InDestroy =
FALSE;
1050 if (EFI_ERROR (Status)) {
1051 gBS->InstallMultipleProtocolInterfaces (
1053 &gEfiIp4ProtocolGuid,
1062 IpSb->NumChildren--;
1064 gBS->RestoreTPL (OldTpl);
1070 gBS->RestoreTPL (OldTpl);
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertHeadList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
@ Ip4Config2DataTypePolicy
EFI_STATUS Ip4Config2ReadConfigData(IN CHAR16 *VarName, IN OUT IP4_CONFIG2_INSTANCE *Instance)
EFI_STATUS Ip4Config2InitInstance(OUT IP4_CONFIG2_INSTANCE *Instance)
EFI_STATUS Ip4Config2DestroyDhcp4(IN OUT IP4_CONFIG2_INSTANCE *Instance)
VOID Ip4Config2CleanInstance(IN OUT IP4_CONFIG2_INSTANCE *Instance)
VOID EFIAPI Ip4AutoReconfigCallBack(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI Ip4DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI Ip4DriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS Ip4CleanService(IN IP4_SERVICE *IpSb)
EFI_STATUS EFIAPI Ip4ServiceBindingDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
VOID EFIAPI IpSec2InstalledCallback(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI Ip4DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context)
EFI_STATUS Ip4CreateService(IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle, OUT IP4_SERVICE **Service)
EFI_STATUS EFIAPI Ip4ServiceBindingCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN OUT EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI Ip4DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI Ip4DriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS Ip4FreeInterface(IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance OPTIONAL)
EFI_STATUS Ip4ReceiveFrame(IN IP4_INTERFACE *Interface, IN IP4_PROTOCOL *IpInstance OPTIONAL, IN IP4_FRAME_CALLBACK CallBack, IN VOID *Context)
IP4_INTERFACE * Ip4CreateInterface(IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp, IN EFI_HANDLE Controller, IN EFI_HANDLE ImageHandle)
VOID Ip4CancelReceive(IN IP4_INTERFACE *Interface)
EFI_STATUS Ip4InitIgmp(IN OUT IP4_SERVICE *IpSb)
EFI_STATUS Ip4ServiceConfigMnp(IN IP4_SERVICE *IpSb, IN BOOLEAN Force)
VOID Ip4InitProtocol(IN IP4_SERVICE *IpSb, IN OUT IP4_PROTOCOL *IpInstance)
VOID EFIAPI Ip4TimerTicking(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI Ip4TimerReconfigChecking(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS Ip4CleanProtocol(IN IP4_PROTOCOL *IpInstance)
IP4_ROUTE_TABLE * Ip4CreateRouteTable(VOID)
VOID Ip4FreeRouteTable(IN IP4_ROUTE_TABLE *RtTable)
#define DEBUG(Expression)
EFI_STATUS EFIAPI NetLibGetMacString(IN EFI_HANDLE ServiceHandle, IN EFI_HANDLE ImageHandle OPTIONAL, OUT CHAR16 **MacString)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
BOOLEAN EFIAPI NetIsInHandleBuffer(IN EFI_HANDLE Handle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
EFI_STATUS EFIAPI PseudoRandomU32(OUT UINT32 *Output)
EFI_HANDLE EFIAPI NetLibGetNicHandle(IN EFI_HANDLE Controller, IN EFI_GUID *ProtocolGuid)
EFI_STATUS EFIAPI NetDestroyLinkList(IN LIST_ENTRY *List, IN NET_DESTROY_LINK_LIST_CALLBACK CallBack, IN VOID *Context OPTIONAL, OUT UINTN *ListLength OPTIONAL)
UINT16 EFIAPI NetLibGetVlanId(IN EFI_HANDLE ServiceHandle)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
EFI_HANDLE DriverBindingHandle
UINT32 OldMaxPacketSize
The MTU before IPsec enable.
BOOLEAN EnableBroadcastReceive
BOOLEAN EnableMulticastReceive
BOOLEAN FlushQueuesOnReset
UINT32 ReceivedQueueTimeoutValue
UINT16 ProtocolTypeFilter
UINT32 TransmitQueueTimeoutValue
BOOLEAN DisableBackgroundPolling
BOOLEAN EnableUnicastReceive
BOOLEAN EnablePromiscuousReceive
BOOLEAN EnableReceiveTimestamps