44 UINTN NumberOfChildren;
47 if ((Entry ==
NULL) || (Context ==
NULL)) {
48 return EFI_INVALID_PARAMETER;
51 Instance = NET_LIST_USER_STRUCT_S (Entry,
UDP4_INSTANCE_DATA, Link, UDP4_INSTANCE_DATA_SIGNATURE);
60 return ServiceBinding->DestroyChild (ServiceBinding, Instance->ChildHandle);
94 Status =
gBS->OpenProtocol (
96 &gEfiUdp4ServiceBindingProtocolGuid,
98 This->DriverBindingHandle,
100 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
102 if (!EFI_ERROR (Status)) {
103 return EFI_ALREADY_STARTED;
109 Status =
gBS->OpenProtocol (
111 &gEfiIp4ServiceBindingProtocolGuid,
113 This->DriverBindingHandle,
115 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
154 if (Udp4Service ==
NULL) {
155 return EFI_OUT_OF_RESOURCES;
158 Status =
Udp4CreateService (Udp4Service, This->DriverBindingHandle, ControllerHandle);
159 if (EFI_ERROR (Status)) {
167 Status =
gBS->InstallMultipleProtocolInterfaces (
169 &gEfiUdp4ServiceBindingProtocolGuid,
170 &Udp4Service->ServiceBinding,
173 if (EFI_ERROR (Status)) {
219 if (NicHandle ==
NULL) {
226 Status =
gBS->OpenProtocol (
228 &gEfiUdp4ServiceBindingProtocolGuid,
229 (VOID **)&ServiceBinding,
230 This->DriverBindingHandle,
232 EFI_OPEN_PROTOCOL_GET_PROTOCOL
234 if (EFI_ERROR (Status)) {
235 return EFI_DEVICE_ERROR;
238 Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (ServiceBinding);
239 if (NumberOfChildren != 0) {
243 List = &Udp4Service->ChildrenList;
244 Context.ServiceBinding = ServiceBinding;
245 Context.NumberOfChildren = NumberOfChildren;
246 Context.ChildHandleBuffer = ChildHandleBuffer;
254 gBS->UninstallMultipleProtocolInterfaces (
256 &gEfiUdp4ServiceBindingProtocolGuid,
257 &Udp4Service->ServiceBinding,
263 if (gUdpControllerNameTable !=
NULL) {
265 gUdpControllerNameTable =
NULL;
306 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
307 return EFI_INVALID_PARAMETER;
310 Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (This);
316 if (Instance ==
NULL) {
317 return EFI_OUT_OF_RESOURCES;
325 Instance->IpInfo =
IpIoAddIp (Udp4Service->IpIo);
326 if (Instance->IpInfo ==
NULL) {
327 Status = EFI_OUT_OF_RESOURCES;
334 Status =
gBS->InstallMultipleProtocolInterfaces (
336 &gEfiUdp4ProtocolGuid,
337 &Instance->Udp4Proto,
340 if (EFI_ERROR (Status)) {
344 Instance->ChildHandle = *ChildHandle;
349 Status =
gBS->OpenProtocol (
350 Udp4Service->IpIo->ChildHandle,
351 &gEfiIp4ProtocolGuid,
354 Instance->ChildHandle,
355 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
357 if (EFI_ERROR (Status)) {
364 Status =
gBS->OpenProtocol (
365 Instance->IpInfo->ChildHandle,
366 &gEfiIp4ProtocolGuid,
369 Instance->ChildHandle,
370 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
372 if (EFI_ERROR (Status)) {
376 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
382 Udp4Service->ChildrenNumber++;
384 gBS->RestoreTPL (OldTpl);
390 if (Instance->ChildHandle !=
NULL) {
391 gBS->UninstallMultipleProtocolInterfaces (
392 Instance->ChildHandle,
393 &gEfiUdp4ProtocolGuid,
394 &Instance->Udp4Proto,
399 if (Instance->IpInfo !=
NULL) {
441 if ((This ==
NULL) || (ChildHandle ==
NULL)) {
442 return EFI_INVALID_PARAMETER;
445 Udp4Service = UDP4_SERVICE_DATA_FROM_THIS (This);
450 Status =
gBS->OpenProtocol (
452 &gEfiUdp4ProtocolGuid,
456 EFI_OPEN_PROTOCOL_GET_PROTOCOL
458 if (EFI_ERROR (Status)) {
459 return EFI_UNSUPPORTED;
462 Instance = UDP4_INSTANCE_DATA_FROM_THIS (Udp4Proto);
464 if (Instance->InDestroy) {
471 Instance->InDestroy =
TRUE;
477 Udp4Service->IpIo->ChildHandle,
478 &gEfiIp4ProtocolGuid,
480 Instance->ChildHandle
486 Instance->IpInfo->ChildHandle,
487 &gEfiIp4ProtocolGuid,
489 Instance->ChildHandle
495 Status =
gBS->UninstallMultipleProtocolInterfaces (
497 &gEfiUdp4ProtocolGuid,
498 (VOID *)&Instance->Udp4Proto,
501 if (EFI_ERROR (Status)) {
502 Instance->InDestroy =
FALSE;
509 Udp4Proto->Configure (Udp4Proto,
NULL);
516 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
522 Udp4Service->ChildrenNumber--;
529 gBS->RestoreTPL (OldTpl);
562 if (EFI_ERROR (Status)) {
563 DEBUG ((DEBUG_ERROR,
"%a failed to generate random number: %r\n", __func__, Status));
578 if (!EFI_ERROR (Status)) {
582 mUdp4RandomPort = (UINT16)(((UINT16)Random) % UDP4_PORT_KNOWN + UDP4_PORT_KNOWN);
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI IpIoRemoveIp(IN IP_IO *IpIo, IN IP_IO_IP_INFO *IpInfo)
IP_IO_IP_INFO *EFIAPI IpIoAddIp(IN OUT IP_IO *IpIo)
#define DEBUG(Expression)
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)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI Udp4DriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI Udp4DriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI Udp4ServiceBindingDestroyChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE ChildHandle)
EFI_STATUS EFIAPI Udp4DriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI Udp4DriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL)
EFI_STATUS EFIAPI Udp4ServiceBindingCreateChild(IN EFI_SERVICE_BINDING_PROTOCOL *This, IN EFI_HANDLE *ChildHandle)
EFI_STATUS EFIAPI Udp4DestroyChildEntryInHandleBuffer(IN LIST_ENTRY *Entry, IN VOID *Context)
EFI_STATUS Udp4CreateService(IN OUT UDP4_SERVICE_DATA *Udp4Service, IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ControllerHandle)
VOID Udp4InitInstance(IN UDP4_SERVICE_DATA *Udp4Service, IN OUT UDP4_INSTANCE_DATA *Instance)
VOID Udp4CleanService(IN UDP4_SERVICE_DATA *Udp4Service)
VOID Udp4CleanInstance(IN UDP4_INSTANCE_DATA *Instance)
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