58 return EFI_INVALID_PARAMETER;
61 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
63 if (!Instance->Configured && (Udp4ConfigData !=
NULL)) {
64 return EFI_NOT_STARTED;
67 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
69 if (Udp4ConfigData !=
NULL) {
73 CopyMem (Udp4ConfigData, &Instance->ConfigData, sizeof (*Udp4ConfigData));
76 Ip = Instance->IpInfo->Ip.Ip4;
81 Status = Ip->GetModeData (Ip, Ip4ModeData, MnpConfigData, SnpModeData);
83 gBS->RestoreTPL (OldTpl);
132 IP4_ADDR StationAddress;
134 IP4_ADDR RemoteAddress;
140 return EFI_INVALID_PARAMETER;
143 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
145 if (!Instance->Configured && (UdpConfigData ==
NULL)) {
149 Udp4Service = Instance->Udp4Service;
152 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
154 if (UdpConfigData !=
NULL) {
155 CopyMem (&StationAddress, &UdpConfigData->StationAddress, sizeof (IP4_ADDR));
156 CopyMem (&SubnetMask, &UdpConfigData->SubnetMask, sizeof (IP4_ADDR));
157 CopyMem (&RemoteAddress, &UdpConfigData->RemoteAddress, sizeof (IP4_ADDR));
159 StationAddress = NTOHL (StationAddress);
160 SubnetMask = NTOHL (SubnetMask);
161 RemoteAddress = NTOHL (RemoteAddress);
163 if (!UdpConfigData->UseDefaultAddress &&
164 (!IP4_IS_VALID_NETMASK (SubnetMask) ||
165 !((StationAddress == 0) || ((SubnetMask != 0) &&
NetIp4IsUnicast (StationAddress, SubnetMask))) ||
166 IP4_IS_LOCAL_BROADCAST (RemoteAddress)))
173 Status = EFI_INVALID_PARAMETER;
177 if (Instance->Configured) {
186 Status = EFI_ALREADY_STARTED;
193 Instance->ConfigData.TypeOfService = UdpConfigData->TypeOfService;
194 Instance->ConfigData.TimeToLive = UdpConfigData->TimeToLive;
195 Instance->ConfigData.DoNotFragment = UdpConfigData->DoNotFragment;
196 Instance->ConfigData.ReceiveTimeout = UdpConfigData->ReceiveTimeout;
197 Instance->ConfigData.TransmitTimeout = UdpConfigData->TransmitTimeout;
207 Status =
IpIoConfigIp (Instance->IpInfo, &Ip4ConfigData);
208 if (EFI_ERROR (Status)) {
209 if (Status == EFI_NO_MAPPING) {
210 Instance->IsNoMapping =
TRUE;
216 Instance->IsNoMapping =
FALSE;
221 CopyMem (&Instance->ConfigData, UdpConfigData, sizeof (Instance->ConfigData));
222 IP4_COPY_ADDRESS (&Instance->ConfigData.StationAddress, &Ip4ConfigData.
StationAddress);
223 IP4_COPY_ADDRESS (&Instance->ConfigData.SubnetMask, &Ip4ConfigData.
SubnetMask);
228 Status =
Udp4Bind (&Udp4Service->ChildrenList, &Instance->ConfigData);
229 if (EFI_ERROR (Status)) {
240 CopyMem (&LocalAddr, &Instance->ConfigData.StationAddress, sizeof (IP4_ADDR));
241 CopyMem (&RemoteAddr, &Instance->ConfigData.RemoteAddress, sizeof (IP4_ADDR));
249 Instance->Configured =
TRUE;
255 Instance->Configured =
FALSE;
256 Instance->IsNoMapping =
FALSE;
266 Instance->Udp4Proto.Cancel (&Instance->Udp4Proto,
NULL);
273 ASSERT (
IsListEmpty (&Instance->DeliveredDgramQue));
278 gBS->RestoreTPL (OldTpl);
326 if ((This ==
NULL) || (JoinFlag && (MulticastAddress ==
NULL))) {
327 return EFI_INVALID_PARAMETER;
332 CopyMem (&McastIp, MulticastAddress,
sizeof (IP4_ADDR));
334 if (!IP4_IS_MULTICAST (NTOHL (McastIp))) {
335 return EFI_INVALID_PARAMETER;
339 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
341 if (Instance->IsNoMapping) {
342 return EFI_NO_MAPPING;
345 if (!Instance->Configured) {
346 return EFI_NOT_STARTED;
349 Ip = Instance->IpInfo->Ip.Ip4;
351 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
356 Status = Ip->Groups (Ip, JoinFlag, MulticastAddress);
358 if (EFI_ERROR (Status)) {
376 gBS->RestoreTPL (OldTpl);
423 IN BOOLEAN DeleteRoute,
433 return EFI_INVALID_PARAMETER;
436 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
438 if (Instance->IsNoMapping) {
439 return EFI_NO_MAPPING;
442 if (!Instance->Configured) {
443 return EFI_NOT_STARTED;
446 Ip = Instance->IpInfo->Ip.Ip4;
451 return Ip->Routes (Ip, DeleteRoute, SubnetAddress, SubnetMask, GatewayAddress);
498 IP4_ADDR Destination;
506 if ((This ==
NULL) || (Token ==
NULL)) {
507 return EFI_INVALID_PARAMETER;
510 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
512 if (Instance->IsNoMapping) {
513 return EFI_NO_MAPPING;
516 if (!Instance->Configured) {
517 return EFI_NOT_STARTED;
520 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
526 if (EFI_ERROR (Status)) {
537 Status = EFI_ACCESS_DENIED;
541 TxData = Token->Packet.TxData;
548 TxData->FragmentCount,
554 if (Packet ==
NULL) {
555 Status = EFI_OUT_OF_RESOURCES;
562 Udp4Service = Instance->Udp4Service;
563 *((
UINTN *)&Packet->ProtoData[0]) = (
UINTN)(Udp4Service->IpIo);
566 ASSERT (Udp4Header !=
NULL);
568 ConfigData = &Instance->ConfigData;
573 Udp4Header->SrcPort = HTONS (ConfigData->StationPort);
574 Udp4Header->DstPort = HTONS (ConfigData->RemotePort);
575 Udp4Header->Length = HTONS ((UINT16)Packet->TotalSize);
576 Udp4Header->Checksum = 0;
578 UdpSessionData = TxData->UdpSessionData;
579 IP4_COPY_ADDRESS (&Override.Ip4OverrideData.SourceAddress, &ConfigData->StationAddress);
581 if (UdpSessionData !=
NULL) {
586 if (!EFI_IP4_EQUAL (&UdpSessionData->SourceAddress, &mZeroIp4Addr)) {
587 IP4_COPY_ADDRESS (&Override.Ip4OverrideData.SourceAddress, &UdpSessionData->SourceAddress);
590 if (UdpSessionData->SourcePort != 0) {
591 Udp4Header->SrcPort = HTONS (UdpSessionData->SourcePort);
594 if (UdpSessionData->DestinationPort != 0) {
595 Udp4Header->DstPort = HTONS (UdpSessionData->DestinationPort);
598 CopyMem (&Source, &Override.Ip4OverrideData.SourceAddress, sizeof (IP4_ADDR));
599 CopyMem (&Destination, &UdpSessionData->DestinationAddress, sizeof (IP4_ADDR));
614 CopyMem (&Destination, &ConfigData->RemoteAddress, sizeof (IP4_ADDR));
616 HeadSum = Instance->HeadSum;
623 if (Udp4Header->Checksum == 0) {
627 Udp4Header->Checksum = 0xffff;
633 if (TxData->GatewayAddress !=
NULL) {
634 IP4_COPY_ADDRESS (&Override.Ip4OverrideData.GatewayAddress, TxData->GatewayAddress);
639 Override.Ip4OverrideData.Protocol = EFI_IP_PROTO_UDP;
640 Override.Ip4OverrideData.TypeOfService = ConfigData->TypeOfService;
641 Override.Ip4OverrideData.TimeToLive = ConfigData->TimeToLive;
642 Override.Ip4OverrideData.DoNotFragment = ConfigData->DoNotFragment;
648 if (EFI_ERROR (Status)) {
655 IpDestAddr.Addr[0] = Destination;
665 if (EFI_ERROR (Status)) {
678 gBS->RestoreTPL (OldTpl);
723 if ((This ==
NULL) || (Token ==
NULL) || (Token->Event ==
NULL)) {
724 return EFI_INVALID_PARAMETER;
727 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
729 if (Instance->IsNoMapping) {
730 return EFI_NO_MAPPING;
733 if (!Instance->Configured) {
734 return EFI_NOT_STARTED;
737 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
746 Status = EFI_ACCESS_DENIED;
750 Token->Packet.RxData =
NULL;
756 if (EFI_ERROR (Status)) {
757 Status = EFI_NOT_READY;
778 gBS->RestoreTPL (OldTpl);
823 return EFI_INVALID_PARAMETER;
826 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
828 if (Instance->IsNoMapping) {
829 return EFI_NO_MAPPING;
832 if (!Instance->Configured) {
833 return EFI_NOT_STARTED;
836 OldTpl =
gBS->RaiseTPL (TPL_CALLBACK);
848 gBS->RestoreTPL (OldTpl);
883 return EFI_INVALID_PARAMETER;
886 Instance = UDP4_INSTANCE_DATA_FROM_THIS (This);
887 Ip = Instance->IpInfo->Ip.Ip4;
892 return Ip->Poll (Ip);
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EFI_STATUS EFIAPI DispatchDpc(VOID)
EFI_STATUS EFIAPI IpIoSend(IN OUT IP_IO *IpIo, IN OUT NET_BUF *Pkt, IN IP_IO_IP_INFO *Sender OPTIONAL, IN VOID *Context OPTIONAL, IN VOID *NotifyData OPTIONAL, IN EFI_IP_ADDRESS *Dest OPTIONAL, IN IP_IO_OVERRIDE *OverrideData OPTIONAL)
EFI_STATUS EFIAPI IpIoConfigIp(IN OUT IP_IO_IP_INFO *IpInfo, IN OUT VOID *IpConfigData OPTIONAL)
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
BOOLEAN EFIAPI NetIp4IsUnicast(IN IP4_ADDR Ip, IN IP4_ADDR NetMask)
NET_BUF *EFIAPI NetbufFromExt(IN NET_FRAGMENT *ExtFragment, IN UINT32 ExtNum, IN UINT32 HeadSpace, IN UINT32 HeadLen, IN NET_VECTOR_EXT_FREE ExtFree, IN VOID *Arg OPTIONAL)
UINT8 *EFIAPI NetbufAllocSpace(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
UINT16 EFIAPI NetPseudoHeadChecksum(IN IP4_ADDR Src, IN IP4_ADDR Dst, IN UINT8 Proto, IN UINT16 Len)
EFI_STATUS EFIAPI NetMapInsertTail(IN OUT NET_MAP *Map, IN VOID *Key, IN VOID *Value OPTIONAL)
EFI_STATUS EFIAPI NetMapIterate(IN NET_MAP *Map, IN NET_MAP_CALLBACK CallBack, IN VOID *Arg OPTIONAL)
EFI_STATUS Udp4ValidateTxToken(IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *TxToken)
EFI_STATUS Udp4RemoveToken(IN OUT NET_MAP *TokenMap, IN EFI_UDP4_COMPLETION_TOKEN *Token)
EFI_STATUS EFIAPI Udp4LeaveGroup(IN OUT NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
BOOLEAN Udp4IsReconfigurable(IN EFI_UDP4_CONFIG_DATA *OldConfigData, IN EFI_UDP4_CONFIG_DATA *NewConfigData)
VOID Udp4InstanceDeliverDgram(IN UDP4_INSTANCE_DATA *Instance)
EFI_STATUS Udp4Bind(IN LIST_ENTRY *InstanceList, IN OUT EFI_UDP4_CONFIG_DATA *ConfigData)
VOID EFIAPI Udp4NetVectorExtFree(VOID *Context)
VOID Udp4BuildIp4ConfigData(IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData)
EFI_STATUS Udp4InstanceCancelToken(IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL)
UINT16 Udp4Checksum(IN NET_BUF *Packet, IN UINT16 HeadSum)
EFI_STATUS EFIAPI Udp4TokenExist(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
VOID Udp4ReportIcmpError(IN UDP4_INSTANCE_DATA *Instance)
VOID Udp4FlushRcvdDgram(IN UDP4_INSTANCE_DATA *Instance)
EFI_STATUS EFIAPI Udp4Configure(IN EFI_UDP4_PROTOCOL *This, IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL)
EFI_STATUS EFIAPI Udp4GetModeData(IN EFI_UDP4_PROTOCOL *This, OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL, OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL)
EFI_STATUS EFIAPI Udp4Routes(IN EFI_UDP4_PROTOCOL *This, IN BOOLEAN DeleteRoute, IN EFI_IPv4_ADDRESS *SubnetAddress, IN EFI_IPv4_ADDRESS *SubnetMask, IN EFI_IPv4_ADDRESS *GatewayAddress)
EFI_STATUS EFIAPI Udp4Groups(IN EFI_UDP4_PROTOCOL *This, IN BOOLEAN JoinFlag, IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL)
EFI_STATUS EFIAPI Udp4Transmit(IN EFI_UDP4_PROTOCOL *This, IN EFI_UDP4_COMPLETION_TOKEN *Token)
EFI_STATUS EFIAPI Udp4Poll(IN EFI_UDP4_PROTOCOL *This)
EFI_STATUS EFIAPI Udp4Cancel(IN EFI_UDP4_PROTOCOL *This, IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL)
EFI_STATUS EFIAPI Udp4Receive(IN EFI_UDP4_PROTOCOL *This, IN EFI_UDP4_COMPLETION_TOKEN *Token)
EFI_IPv4_ADDRESS SubnetMask
EFI_IPv4_ADDRESS StationAddress