TianoCore EDK2 master
Loading...
Searching...
No Matches
Udp4Impl.c
Go to the documentation of this file.
1
9#include "Udp4Impl.h"
10
11UINT16 mUdp4RandomPort;
12
22VOID
23EFIAPI
25 IN EFI_EVENT Event,
26 IN VOID *Context
27 );
28
41BOOLEAN
43 IN LIST_ENTRY *InstanceList,
44 IN EFI_IPv4_ADDRESS *Address,
45 IN UINT16 Port
46 );
47
59VOID
60EFIAPI
62 IN EFI_STATUS Status,
63 IN VOID *Context,
64 IN IP_IO_IP_PROTOCOL Sender,
65 IN VOID *NotifyData
66 );
67
80VOID
81EFIAPI
83 IN EFI_STATUS Status,
84 IN UINT8 IcmpError,
85 IN EFI_NET_SESSION_DATA *NetSession,
86 IN NET_BUF *Packet,
87 IN VOID *Context
88 );
89
107EFIAPI
109 IN NET_MAP *Map,
110 IN NET_MAP_ITEM *Item,
111 IN VOID *Arg OPTIONAL
112 );
113
126BOOLEAN
128 IN UDP4_INSTANCE_DATA *Instance,
129 IN EFI_UDP4_SESSION_DATA *Udp4Session
130 );
131
139VOID
140EFIAPI
142 IN EFI_EVENT Event,
143 IN VOID *Context
144 );
145
160 IN UDP4_INSTANCE_DATA *Instance,
161 IN NET_BUF *Packet,
163 );
164
177UINTN
179 IN UDP4_SERVICE_DATA *Udp4Service,
180 IN NET_BUF *Packet,
182 );
183
190VOID
192 IN UDP4_SERVICE_DATA *Udp4Service
193 );
194
205VOID
207 IN UDP4_SERVICE_DATA *Udp4Service,
208 IN EFI_NET_SESSION_DATA *NetSession,
209 IN NET_BUF *Packet
210 );
211
223VOID
225 IN UDP4_SERVICE_DATA *Udp4Service,
226 IN UINT8 IcmpError,
227 IN EFI_NET_SESSION_DATA *NetSession,
228 IN NET_BUF *Packet
229 );
230
241VOID
243 IN IP_IO *IpIo,
244 IN EFI_NET_SESSION_DATA *NetSession,
245 IN VOID *Udp4Header
246 );
247
263 IN OUT UDP4_SERVICE_DATA *Udp4Service,
264 IN EFI_HANDLE ImageHandle,
265 IN EFI_HANDLE ControllerHandle
266 )
267{
268 EFI_STATUS Status;
269 IP_IO_OPEN_DATA OpenData;
270 EFI_IP4_CONFIG_DATA *Ip4ConfigData;
271
272 ZeroMem (Udp4Service, sizeof (UDP4_SERVICE_DATA));
273
274 Udp4Service->Signature = UDP4_SERVICE_DATA_SIGNATURE;
275 Udp4Service->ServiceBinding = mUdp4ServiceBinding;
276 Udp4Service->ImageHandle = ImageHandle;
277 Udp4Service->ControllerHandle = ControllerHandle;
278 Udp4Service->ChildrenNumber = 0;
279
280 InitializeListHead (&Udp4Service->ChildrenList);
281
282 //
283 // Create the IpIo for this service context.
284 //
285 Udp4Service->IpIo = IpIoCreate (ImageHandle, ControllerHandle, IP_VERSION_4);
286 if (Udp4Service->IpIo == NULL) {
287 return EFI_OUT_OF_RESOURCES;
288 }
289
290 //
291 // Set the OpenData used to open the IpIo.
292 //
293 Ip4ConfigData = &OpenData.IpConfigData.Ip4CfgData;
294 CopyMem (Ip4ConfigData, &mIp4IoDefaultIpConfigData, sizeof (EFI_IP4_CONFIG_DATA));
295 Ip4ConfigData->AcceptBroadcast = TRUE;
296 OpenData.RcvdContext = (VOID *)Udp4Service;
297 OpenData.SndContext = NULL;
298 OpenData.PktRcvdNotify = Udp4DgramRcvd;
299 OpenData.PktSentNotify = Udp4DgramSent;
300
301 //
302 // Configure and start the IpIo.
303 //
304 Status = IpIoOpen (Udp4Service->IpIo, &OpenData);
305 if (EFI_ERROR (Status)) {
306 goto ON_ERROR;
307 }
308
309 //
310 // Create the event for Udp timeout checking.
311 //
312 Status = gBS->CreateEvent (
313 EVT_TIMER | EVT_NOTIFY_SIGNAL,
314 TPL_CALLBACK,
316 Udp4Service,
317 &Udp4Service->TimeoutEvent
318 );
319 if (EFI_ERROR (Status)) {
320 goto ON_ERROR;
321 }
322
323 //
324 // Start the timeout timer event.
325 //
326 Status = gBS->SetTimer (
327 Udp4Service->TimeoutEvent,
329 UDP4_TIMEOUT_INTERVAL
330 );
331 if (EFI_ERROR (Status)) {
332 goto ON_ERROR;
333 }
334
335 return EFI_SUCCESS;
336
337ON_ERROR:
338
339 if (Udp4Service->TimeoutEvent != NULL) {
340 gBS->CloseEvent (Udp4Service->TimeoutEvent);
341 }
342
343 IpIoDestroy (Udp4Service->IpIo);
344
345 return Status;
346}
347
354VOID
356 IN UDP4_SERVICE_DATA *Udp4Service
357 )
358{
359 //
360 // Cancel the TimeoutEvent timer.
361 //
362 gBS->SetTimer (Udp4Service->TimeoutEvent, TimerCancel, 0);
363
364 //
365 // Close the TimeoutEvent timer.
366 //
367 gBS->CloseEvent (Udp4Service->TimeoutEvent);
368
369 //
370 // Destroy the IpIo.
371 //
372 IpIoDestroy (Udp4Service->IpIo);
373}
374
384VOID
385EFIAPI
387 IN EFI_EVENT Event,
388 IN VOID *Context
389 )
390{
391 UDP4_SERVICE_DATA *Udp4Service;
392 LIST_ENTRY *Entry;
393 UDP4_INSTANCE_DATA *Instance;
394 LIST_ENTRY *WrapEntry;
395 LIST_ENTRY *NextEntry;
396 UDP4_RXDATA_WRAP *Wrap;
397
398 Udp4Service = (UDP4_SERVICE_DATA *)Context;
399 NET_CHECK_SIGNATURE (Udp4Service, UDP4_SERVICE_DATA_SIGNATURE);
400
401 NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {
402 //
403 // Iterate all the instances belonging to this service context.
404 //
405 Instance = NET_LIST_USER_STRUCT (Entry, UDP4_INSTANCE_DATA, Link);
406 NET_CHECK_SIGNATURE (Instance, UDP4_INSTANCE_DATA_SIGNATURE);
407
408 if (!Instance->Configured || (Instance->ConfigData.ReceiveTimeout == 0)) {
409 //
410 // Skip this instance if it's not configured or no receive timeout.
411 //
412 continue;
413 }
414
415 NET_LIST_FOR_EACH_SAFE (WrapEntry, NextEntry, &Instance->RcvdDgramQue) {
416 //
417 // Iterate all the rxdatas belonging to this udp instance.
418 //
419 Wrap = NET_LIST_USER_STRUCT (WrapEntry, UDP4_RXDATA_WRAP, Link);
420
421 //
422 // TimeoutTick unit is microsecond, MNP_TIMEOUT_CHECK_INTERVAL unit is 100ns.
423 //
424 if (Wrap->TimeoutTick < (UDP4_TIMEOUT_INTERVAL / 10)) {
425 //
426 // Remove this RxData if it timeouts.
427 //
428 Udp4RecycleRxDataWrap (NULL, (VOID *)Wrap);
429 } else {
430 Wrap->TimeoutTick -= (UDP4_TIMEOUT_INTERVAL / 10);
431 }
432 }
433 }
434}
435
443VOID
445 IN UDP4_SERVICE_DATA *Udp4Service,
446 IN OUT UDP4_INSTANCE_DATA *Instance
447 )
448{
449 //
450 // Set the signature.
451 //
452 Instance->Signature = UDP4_INSTANCE_DATA_SIGNATURE;
453
454 //
455 // Init the lists.
456 //
457 InitializeListHead (&Instance->Link);
458 InitializeListHead (&Instance->RcvdDgramQue);
459 InitializeListHead (&Instance->DeliveredDgramQue);
460
461 //
462 // Init the NET_MAPs.
463 //
464 NetMapInit (&Instance->TxTokens);
465 NetMapInit (&Instance->RxTokens);
466 NetMapInit (&Instance->McastIps);
467
468 //
469 // Save the pointer to the UDP4_SERVICE_DATA, and initialize other members.
470 //
471 Instance->Udp4Service = Udp4Service;
472 CopyMem (&Instance->Udp4Proto, &mUdp4Protocol, sizeof (Instance->Udp4Proto));
473 Instance->IcmpError = EFI_SUCCESS;
474 Instance->Configured = FALSE;
475 Instance->IsNoMapping = FALSE;
476 Instance->InDestroy = FALSE;
477}
478
485VOID
487 IN UDP4_INSTANCE_DATA *Instance
488 )
489{
490 NetMapClean (&Instance->McastIps);
491 NetMapClean (&Instance->RxTokens);
492 NetMapClean (&Instance->TxTokens);
493}
494
507BOOLEAN
509 IN LIST_ENTRY *InstanceList,
510 IN EFI_IPv4_ADDRESS *Address,
511 IN UINT16 Port
512 )
513{
514 LIST_ENTRY *Entry;
515 UDP4_INSTANCE_DATA *Instance;
516 EFI_UDP4_CONFIG_DATA *ConfigData;
517
518 NET_LIST_FOR_EACH (Entry, InstanceList) {
519 //
520 // Iterate all the udp instances.
521 //
522 Instance = NET_LIST_USER_STRUCT (Entry, UDP4_INSTANCE_DATA, Link);
523 ConfigData = &Instance->ConfigData;
524
525 if (!Instance->Configured || ConfigData->AcceptAnyPort) {
526 //
527 // If the instance is not configured or the configdata of the instance indicates
528 // this instance accepts any port, skip it.
529 //
530 continue;
531 }
532
533 if (EFI_IP4_EQUAL (&ConfigData->StationAddress, Address) &&
534 (ConfigData->StationPort == Port))
535 {
536 //
537 // if both the address and the port are the same, return TRUE.
538 //
539 return TRUE;
540 }
541 }
542
543 //
544 // return FALSE when matching fails.
545 //
546 return FALSE;
547}
548
567 IN LIST_ENTRY *InstanceList,
568 IN OUT EFI_UDP4_CONFIG_DATA *ConfigData
569 )
570{
571 EFI_IPv4_ADDRESS *StationAddress;
572 UINT16 StartPort;
573
574 if (ConfigData->AcceptAnyPort) {
575 return EFI_SUCCESS;
576 }
577
578 StationAddress = &ConfigData->StationAddress;
579
580 if (ConfigData->StationPort != 0) {
581 if (!ConfigData->AllowDuplicatePort &&
582 Udp4FindInstanceByPort (InstanceList, StationAddress, ConfigData->StationPort))
583 {
584 //
585 // Do not allow duplicate port and the port is already used by other instance.
586 //
587 return EFI_ACCESS_DENIED;
588 }
589 } else {
590 //
591 // select a random port for this instance;
592 //
593
594 if (ConfigData->AllowDuplicatePort) {
595 //
596 // Just pick up the random port if the instance allows duplicate port.
597 //
598 ConfigData->StationPort = mUdp4RandomPort;
599 } else {
600 StartPort = mUdp4RandomPort;
601
602 while (Udp4FindInstanceByPort (InstanceList, StationAddress, mUdp4RandomPort)) {
603 mUdp4RandomPort++;
604 if (mUdp4RandomPort == 0) {
605 mUdp4RandomPort = UDP4_PORT_KNOWN;
606 }
607
608 if (mUdp4RandomPort == StartPort) {
609 //
610 // No available port.
611 //
612 return EFI_OUT_OF_RESOURCES;
613 }
614 }
615
616 ConfigData->StationPort = mUdp4RandomPort;
617 }
618
619 mUdp4RandomPort++;
620 if (mUdp4RandomPort == 0) {
621 mUdp4RandomPort = UDP4_PORT_KNOWN;
622 }
623 }
624
625 return EFI_SUCCESS;
626}
627
640BOOLEAN
642 IN EFI_UDP4_CONFIG_DATA *OldConfigData,
643 IN EFI_UDP4_CONFIG_DATA *NewConfigData
644 )
645{
646 if ((NewConfigData->AcceptAnyPort != OldConfigData->AcceptAnyPort) ||
647 (NewConfigData->AcceptBroadcast != OldConfigData->AcceptBroadcast) ||
648 (NewConfigData->AcceptPromiscuous != OldConfigData->AcceptPromiscuous) ||
649 (NewConfigData->AllowDuplicatePort != OldConfigData->AllowDuplicatePort)
650 )
651 {
652 //
653 // The receiving filter parameters cannot be changed.
654 //
655 return FALSE;
656 }
657
658 if ((!NewConfigData->AcceptAnyPort) &&
659 (NewConfigData->StationPort != OldConfigData->StationPort)
660 )
661 {
662 //
663 // The port is not changeable.
664 //
665 return FALSE;
666 }
667
668 if (!NewConfigData->AcceptPromiscuous) {
669 if (NewConfigData->UseDefaultAddress != OldConfigData->UseDefaultAddress) {
670 //
671 // The NewConfigData differs to the old one on the UseDefaultAddress.
672 //
673 return FALSE;
674 }
675
676 if (!NewConfigData->UseDefaultAddress &&
677 (!EFI_IP4_EQUAL (&NewConfigData->StationAddress, &OldConfigData->StationAddress) ||
678 !EFI_IP4_EQUAL (&NewConfigData->SubnetMask, &OldConfigData->SubnetMask))
679 )
680 {
681 //
682 // If the instance doesn't use the default address, and the new address or
683 // new subnet mask is different from the old values.
684 //
685 return FALSE;
686 }
687 }
688
689 if (!EFI_IP4_EQUAL (&NewConfigData->RemoteAddress, &OldConfigData->RemoteAddress)) {
690 //
691 // The remoteaddress is not the same.
692 //
693 return FALSE;
694 }
695
696 if (!EFI_IP4_EQUAL (&NewConfigData->RemoteAddress, &mZeroIp4Addr) &&
697 (NewConfigData->RemotePort != OldConfigData->RemotePort)
698 )
699 {
700 //
701 // The RemotePort differs if it's designated in the configdata.
702 //
703 return FALSE;
704 }
705
706 //
707 // All checks pass, return TRUE.
708 //
709 return TRUE;
710}
711
719VOID
721 IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData,
722 IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData
723 )
724{
725 CopyMem (Ip4ConfigData, &mIp4IoDefaultIpConfigData, sizeof (*Ip4ConfigData));
726
727 Ip4ConfigData->DefaultProtocol = EFI_IP_PROTO_UDP;
728 Ip4ConfigData->AcceptBroadcast = Udp4ConfigData->AcceptBroadcast;
729 Ip4ConfigData->AcceptPromiscuous = Udp4ConfigData->AcceptPromiscuous;
730 Ip4ConfigData->UseDefaultAddress = Udp4ConfigData->UseDefaultAddress;
731 CopyMem (&Ip4ConfigData->StationAddress, &Udp4ConfigData->StationAddress, sizeof (EFI_IPv4_ADDRESS));
732 CopyMem (&Ip4ConfigData->SubnetMask, &Udp4ConfigData->SubnetMask, sizeof (EFI_IPv4_ADDRESS));
733
734 //
735 // use the -1 magic number to disable the receiving process of the ip instance.
736 //
737 Ip4ConfigData->ReceiveTimeout = (UINT32)(-1);
738}
739
768 IN UDP4_INSTANCE_DATA *Instance,
770 )
771{
773 UINT32 Index;
774 UINT32 TotalLen;
775 EFI_UDP4_CONFIG_DATA *ConfigData;
776 EFI_UDP4_SESSION_DATA *UdpSessionData;
777 IP4_ADDR SourceAddress;
778 IP4_ADDR GatewayAddress;
779
780 if (TxToken->Event == NULL) {
781 return EFI_INVALID_PARAMETER;
782 }
783
784 TxData = TxToken->Packet.TxData;
785
786 if ((TxData == NULL) || (TxData->FragmentCount == 0)) {
787 return EFI_INVALID_PARAMETER;
788 }
789
790 TotalLen = 0;
791 for (Index = 0; Index < TxData->FragmentCount; Index++) {
792 if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) ||
793 (TxData->FragmentTable[Index].FragmentLength == 0))
794 {
795 //
796 // if the FragmentBuffer is NULL or the FragmentLeng is zero.
797 //
798 return EFI_INVALID_PARAMETER;
799 }
800
801 TotalLen += TxData->FragmentTable[Index].FragmentLength;
802 }
803
804 if (TotalLen != TxData->DataLength) {
805 //
806 // The TotalLen calculated by adding all the FragmentLeng doesn't equal to the
807 // DataLength.
808 //
809 return EFI_INVALID_PARAMETER;
810 }
811
812 if (TxData->GatewayAddress != NULL) {
813 CopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR));
814
815 if (!Instance->ConfigData.UseDefaultAddress &&
816 (EFI_NTOHL (Instance->ConfigData.SubnetMask) != 0) &&
817 !NetIp4IsUnicast (NTOHL (GatewayAddress), EFI_NTOHL (Instance->ConfigData.SubnetMask)))
818 {
819 //
820 // The specified GatewayAddress is not a unicast IPv4 address while it's not 0.
821 //
822 return EFI_INVALID_PARAMETER;
823 }
824 }
825
826 ConfigData = &Instance->ConfigData;
827 UdpSessionData = TxData->UdpSessionData;
828
829 if (UdpSessionData != NULL) {
830 CopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR));
831
832 if ((SourceAddress != 0) &&
833 !Instance->ConfigData.UseDefaultAddress &&
834 (EFI_NTOHL (Instance->ConfigData.SubnetMask) != 0) &&
835 !NetIp4IsUnicast (HTONL (SourceAddress), EFI_NTOHL (Instance->ConfigData.SubnetMask)))
836 {
837 //
838 // Check whether SourceAddress is a valid IPv4 address in case it's not zero.
839 // The configured station address is used if SourceAddress is zero.
840 //
841 return EFI_INVALID_PARAMETER;
842 }
843
844 if ((UdpSessionData->DestinationPort == 0) && (ConfigData->RemotePort == 0)) {
845 //
846 // Ambiguous, no available DestinationPort for this token.
847 //
848 return EFI_INVALID_PARAMETER;
849 }
850
851 if (EFI_IP4_EQUAL (&UdpSessionData->DestinationAddress, &mZeroIp4Addr)) {
852 //
853 // The DestinationAddress specified in the UdpSessionData is 0.
854 //
855 return EFI_INVALID_PARAMETER;
856 }
857 } else if (EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &mZeroIp4Addr)) {
858 //
859 // the configured RemoteAddress is all zero, and the user doesn't override the
860 // destination address.
861 //
862 return EFI_INVALID_PARAMETER;
863 }
864
865 if (TxData->DataLength > UDP4_MAX_DATA_SIZE) {
866 return EFI_BAD_BUFFER_SIZE;
867 }
868
869 return EFI_SUCCESS;
870}
871
886EFIAPI
888 IN NET_MAP *Map,
889 IN NET_MAP_ITEM *Item,
890 IN VOID *Context
891 )
892{
894 EFI_UDP4_COMPLETION_TOKEN *TokenInItem;
895
896 Token = (EFI_UDP4_COMPLETION_TOKEN *)Context;
897 TokenInItem = (EFI_UDP4_COMPLETION_TOKEN *)Item->Key;
898
899 if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
900 //
901 // The Token duplicates with the TokenInItem in case either the two pointers are the
902 // same or the Events of these two tokens are the same.
903 //
904 return EFI_ACCESS_DENIED;
905 }
906
907 return EFI_SUCCESS;
908}
909
921UINT16
923 IN NET_BUF *Packet,
924 IN UINT16 HeadSum
925 )
926{
927 UINT16 Checksum;
928
929 Checksum = NetbufChecksum (Packet);
930 Checksum = NetAddChecksum (Checksum, HeadSum);
931
932 Checksum = NetAddChecksum (Checksum, HTONS ((UINT16)Packet->TotalSize));
933
934 return (UINT16) ~Checksum;
935}
936
949 IN OUT NET_MAP *TokenMap,
951 )
952{
953 NET_MAP_ITEM *Item;
954
955 //
956 // Find the Token first.
957 //
958 Item = NetMapFindKey (TokenMap, (VOID *)Token);
959
960 if (Item != NULL) {
961 //
962 // Remove the token if it's found in the map.
963 //
964 NetMapRemoveItem (TokenMap, Item, NULL);
965
966 return EFI_SUCCESS;
967 }
968
969 return EFI_NOT_FOUND;
970}
971
983VOID
984EFIAPI
986 IN EFI_STATUS Status,
987 IN VOID *Context,
988 IN IP_IO_IP_PROTOCOL Sender,
989 IN VOID *NotifyData
990 )
991{
992 UDP4_INSTANCE_DATA *Instance;
994
995 Instance = (UDP4_INSTANCE_DATA *)Context;
996 Token = (EFI_UDP4_COMPLETION_TOKEN *)NotifyData;
997
998 if (Udp4RemoveToken (&Instance->TxTokens, Token) == EFI_SUCCESS) {
999 //
1000 // The token may be cancelled. Only signal it if the remove operation succeeds.
1001 //
1002 Token->Status = Status;
1003 gBS->SignalEvent (Token->Event);
1004 DispatchDpc ();
1005 }
1006}
1007
1020VOID
1021EFIAPI
1023 IN EFI_STATUS Status,
1024 IN UINT8 IcmpError,
1025 IN EFI_NET_SESSION_DATA *NetSession,
1026 IN NET_BUF *Packet,
1027 IN VOID *Context
1028 )
1029{
1030 NET_CHECK_SIGNATURE (Packet, NET_BUF_SIGNATURE);
1031
1032 //
1033 // IpIo only passes received packets with Status EFI_SUCCESS or EFI_ICMP_ERROR.
1034 //
1035 if (Status == EFI_SUCCESS) {
1036 //
1037 // Demultiplex the received datagram.
1038 //
1039 Udp4Demultiplex ((UDP4_SERVICE_DATA *)Context, NetSession, Packet);
1040 } else {
1041 //
1042 // Handle the ICMP_ERROR packet.
1043 //
1044 Udp4IcmpHandler ((UDP4_SERVICE_DATA *)Context, IcmpError, NetSession, Packet);
1045 }
1046
1047 //
1048 // Dispatch the DPC queued by the NotifyFunction of the rx token's events
1049 // which are signaled with received data.
1050 //
1051 DispatchDpc ();
1052}
1053
1068EFIAPI
1070 IN OUT NET_MAP *Map,
1071 IN NET_MAP_ITEM *Item,
1072 IN VOID *Arg OPTIONAL
1073 )
1074{
1075 EFI_IPv4_ADDRESS *McastIp;
1076
1077 McastIp = Arg;
1078
1079 if ((McastIp != NULL) && (!EFI_IP4_EQUAL (McastIp, &(Item->Key)))) {
1080 //
1081 // McastIp is not NULL and the multicast address contained in the Item
1082 // is not the same as McastIp.
1083 //
1084 return EFI_SUCCESS;
1085 }
1086
1087 //
1088 // Remove this Item.
1089 //
1090 NetMapRemoveItem (Map, Item, NULL);
1091
1092 if (McastIp != NULL) {
1093 //
1094 // Return EFI_ABORTED in case McastIp is not NULL to terminate the iteration.
1095 //
1096 return EFI_ABORTED;
1097 }
1098
1099 return EFI_SUCCESS;
1100}
1101
1119EFIAPI
1121 IN NET_MAP *Map,
1122 IN NET_MAP_ITEM *Item,
1123 IN VOID *Arg OPTIONAL
1124 )
1125{
1126 EFI_UDP4_COMPLETION_TOKEN *TokenToCancel;
1127 NET_BUF *Packet;
1128 IP_IO *IpIo;
1129
1130 if ((Arg != NULL) && (Item->Key != Arg)) {
1131 return EFI_SUCCESS;
1132 }
1133
1134 if (Item->Value != NULL) {
1135 //
1136 // If the token is a transmit token, the corresponding Packet is recorded in
1137 // Item->Value, invoke IpIo to cancel this packet first. The IpIoCancelTxToken
1138 // will invoke Udp4DgramSent, the token will be signaled and this Item will
1139 // be removed from the Map there.
1140 //
1141 Packet = (NET_BUF *)(Item->Value);
1142 IpIo = (IP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
1143
1144 IpIoCancelTxToken (IpIo, Packet);
1145 } else {
1146 //
1147 // The token is a receive token. Abort it and remove it from the Map.
1148 //
1149 TokenToCancel = (EFI_UDP4_COMPLETION_TOKEN *)Item->Key;
1150 NetMapRemoveItem (Map, Item, NULL);
1151
1152 TokenToCancel->Status = EFI_ABORTED;
1153 gBS->SignalEvent (TokenToCancel->Event);
1154 }
1155
1156 if (Arg != NULL) {
1157 return EFI_ABORTED;
1158 }
1159
1160 return EFI_SUCCESS;
1161}
1162
1169VOID
1171 IN UDP4_INSTANCE_DATA *Instance
1172 )
1173{
1174 UDP4_RXDATA_WRAP *Wrap;
1175
1176 while (!IsListEmpty (&Instance->RcvdDgramQue)) {
1177 //
1178 // Iterate all the Wraps in the RcvdDgramQue.
1179 //
1180 Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link);
1181
1182 //
1183 // The Wrap will be removed from the RcvdDgramQue by this function call.
1184 //
1185 Udp4RecycleRxDataWrap (NULL, (VOID *)Wrap);
1186 }
1187}
1188
1202 IN UDP4_INSTANCE_DATA *Instance,
1203 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL
1204 )
1205{
1206 EFI_STATUS Status;
1207
1208 //
1209 // Cancel this token from the TxTokens map.
1210 //
1211 Status = NetMapIterate (&Instance->TxTokens, Udp4CancelTokens, Token);
1212
1213 if ((Token != NULL) && (Status == EFI_ABORTED)) {
1214 //
1215 // If Token isn't NULL and Status is EFI_ABORTED, the token is cancelled from
1216 // the TxTokens, just return success.
1217 //
1218 return EFI_SUCCESS;
1219 }
1220
1221 //
1222 // Try to cancel this token from the RxTokens map in condition either the Token
1223 // is NULL or the specified Token is not in TxTokens.
1224 //
1225 Status = NetMapIterate (&Instance->RxTokens, Udp4CancelTokens, Token);
1226
1227 if ((Token != NULL) && (Status == EFI_SUCCESS)) {
1228 //
1229 // If Token isn't NULL and Status is EFI_SUCCESS, the token is neither in the
1230 // TxTokens nor the RxTokens, or say, it's not found.
1231 //
1232 return EFI_NOT_FOUND;
1233 }
1234
1235 ASSERT (
1236 (Token != NULL) || ( (0 == NetMapGetCount (&Instance->TxTokens))
1237 && (0 == NetMapGetCount (&Instance->RxTokens)))
1238 );
1239
1240 return EFI_SUCCESS;
1241}
1242
1255BOOLEAN
1257 IN UDP4_INSTANCE_DATA *Instance,
1258 IN EFI_UDP4_SESSION_DATA *Udp4Session
1259 )
1260{
1261 EFI_UDP4_CONFIG_DATA *ConfigData;
1262 IP4_ADDR Destination;
1263
1264 ConfigData = &Instance->ConfigData;
1265
1266 if (ConfigData->AcceptPromiscuous) {
1267 //
1268 // Always matches if this instance is in the promiscuous state.
1269 //
1270 return TRUE;
1271 }
1272
1273 if ((!ConfigData->AcceptAnyPort && (Udp4Session->DestinationPort != ConfigData->StationPort)) ||
1274 ((ConfigData->RemotePort != 0) && (Udp4Session->SourcePort != ConfigData->RemotePort))
1275 )
1276 {
1277 //
1278 // The local port or the remote port doesn't match.
1279 //
1280 return FALSE;
1281 }
1282
1283 if (!EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &mZeroIp4Addr) &&
1284 !EFI_IP4_EQUAL (&ConfigData->RemoteAddress, &Udp4Session->SourceAddress)
1285 )
1286 {
1287 //
1288 // This datagram doesn't come from the instance's specified sender.
1289 //
1290 return FALSE;
1291 }
1292
1293 if (EFI_IP4_EQUAL (&ConfigData->StationAddress, &mZeroIp4Addr) ||
1294 EFI_IP4_EQUAL (&Udp4Session->DestinationAddress, &ConfigData->StationAddress)
1295 )
1296 {
1297 //
1298 // The instance is configured to receive datagrams destined to any station IP or
1299 // the destination address of this datagram matches the configured station IP.
1300 //
1301 return TRUE;
1302 }
1303
1304 CopyMem (&Destination, &Udp4Session->DestinationAddress, sizeof (IP4_ADDR));
1305
1306 if (IP4_IS_LOCAL_BROADCAST (Destination) && ConfigData->AcceptBroadcast) {
1307 //
1308 // The instance is configured to receive broadcast and this is a broadcast packet.
1309 //
1310 return TRUE;
1311 }
1312
1313 if (IP4_IS_MULTICAST (NTOHL (Destination)) &&
1314 (NetMapFindKey (&Instance->McastIps, (VOID *)(UINTN)Destination) != NULL)
1315 )
1316 {
1317 //
1318 // It's a multicast packet and the multicast address is accepted by this instance.
1319 //
1320 return TRUE;
1321 }
1322
1323 return FALSE;
1324}
1325
1333VOID
1334EFIAPI
1336 IN EFI_EVENT Event,
1337 IN VOID *Context
1338 )
1339{
1340 UDP4_RXDATA_WRAP *Wrap;
1341
1342 Wrap = (UDP4_RXDATA_WRAP *)Context;
1343
1344 //
1345 // Remove the Wrap from the list it belongs to.
1346 //
1347 RemoveEntryList (&Wrap->Link);
1348
1349 //
1350 // Free the Packet associated with this Wrap.
1351 //
1352 NetbufFree (Wrap->Packet);
1353
1354 //
1355 // Close the event.
1356 //
1357 gBS->CloseEvent (Wrap->RxData.RecycleSignal);
1358
1359 FreePool (Wrap);
1360}
1361
1376 IN UDP4_INSTANCE_DATA *Instance,
1377 IN NET_BUF *Packet,
1379 )
1380{
1381 EFI_STATUS Status;
1382 UDP4_RXDATA_WRAP *Wrap;
1383
1384 //
1385 // Allocate buffer for the Wrap.
1386 //
1387 Wrap = AllocatePool (
1388 sizeof (UDP4_RXDATA_WRAP) +
1389 (Packet->BlockOpNum - 1) * sizeof (EFI_UDP4_FRAGMENT_DATA)
1390 );
1391 if (Wrap == NULL) {
1392 return NULL;
1393 }
1394
1395 InitializeListHead (&Wrap->Link);
1396
1397 CopyMem (&Wrap->RxData, RxData, sizeof (Wrap->RxData));
1398
1399 //
1400 // Create the Recycle event.
1401 //
1402 Status = gBS->CreateEvent (
1403 EVT_NOTIFY_SIGNAL,
1404 TPL_NOTIFY,
1406 Wrap,
1407 &Wrap->RxData.RecycleSignal
1408 );
1409 if (EFI_ERROR (Status)) {
1410 FreePool (Wrap);
1411 return NULL;
1412 }
1413
1414 Wrap->Packet = Packet;
1415 Wrap->TimeoutTick = Instance->ConfigData.ReceiveTimeout;
1416
1417 return Wrap;
1418}
1419
1432UINTN
1434 IN UDP4_SERVICE_DATA *Udp4Service,
1435 IN NET_BUF *Packet,
1437 )
1438{
1439 LIST_ENTRY *Entry;
1440 UDP4_INSTANCE_DATA *Instance;
1441 UDP4_RXDATA_WRAP *Wrap;
1442 UINTN Enqueued;
1443
1444 Enqueued = 0;
1445
1446 NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {
1447 //
1448 // Iterate the instances.
1449 //
1450 Instance = NET_LIST_USER_STRUCT (Entry, UDP4_INSTANCE_DATA, Link);
1451
1452 if (!Instance->Configured) {
1453 continue;
1454 }
1455
1456 if (Udp4MatchDgram (Instance, &RxData->UdpSession)) {
1457 //
1458 // Wrap the RxData and put this Wrap into the instances RcvdDgramQue.
1459 //
1460 Wrap = Udp4WrapRxData (Instance, Packet, RxData);
1461 if (Wrap == NULL) {
1462 continue;
1463 }
1464
1465 NET_GET_REF (Packet);
1466
1467 InsertTailList (&Instance->RcvdDgramQue, &Wrap->Link);
1468
1469 Enqueued++;
1470 }
1471 }
1472
1473 return Enqueued;
1474}
1475
1482VOID
1484 IN UDP4_INSTANCE_DATA *Instance
1485 )
1486{
1487 UDP4_RXDATA_WRAP *Wrap;
1489 NET_BUF *Dup;
1490 EFI_UDP4_RECEIVE_DATA *RxData;
1491 EFI_TPL OldTpl;
1492
1493 if (!IsListEmpty (&Instance->RcvdDgramQue) &&
1494 !NetMapIsEmpty (&Instance->RxTokens))
1495 {
1496 Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP4_RXDATA_WRAP, Link);
1497
1498 if (NET_BUF_SHARED (Wrap->Packet)) {
1499 //
1500 // Duplicate the Packet if it is shared between instances.
1501 //
1502 Dup = NetbufDuplicate (Wrap->Packet, NULL, 0);
1503 if (Dup == NULL) {
1504 return;
1505 }
1506
1507 NetbufFree (Wrap->Packet);
1508
1509 Wrap->Packet = Dup;
1510 }
1511
1512 NetListRemoveHead (&Instance->RcvdDgramQue);
1513
1514 Token = (EFI_UDP4_COMPLETION_TOKEN *)NetMapRemoveHead (&Instance->RxTokens, NULL);
1515
1516 //
1517 // Build the FragmentTable and set the FragmentCount in RxData.
1518 //
1519 RxData = &Wrap->RxData;
1520 RxData->FragmentCount = Wrap->Packet->BlockOpNum;
1521
1523 Wrap->Packet,
1524 (NET_FRAGMENT *)RxData->FragmentTable,
1525 &RxData->FragmentCount
1526 );
1527
1528 Token->Status = EFI_SUCCESS;
1529 Token->Packet.RxData = &Wrap->RxData;
1530
1531 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1532 InsertTailList (&Instance->DeliveredDgramQue, &Wrap->Link);
1533 gBS->RestoreTPL (OldTpl);
1534
1535 gBS->SignalEvent (Token->Event);
1536 }
1537}
1538
1545VOID
1547 IN UDP4_SERVICE_DATA *Udp4Service
1548 )
1549{
1550 LIST_ENTRY *Entry;
1551 UDP4_INSTANCE_DATA *Instance;
1552
1553 NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {
1554 //
1555 // Iterate the instances.
1556 //
1557 Instance = NET_LIST_USER_STRUCT (Entry, UDP4_INSTANCE_DATA, Link);
1558
1559 if (!Instance->Configured) {
1560 continue;
1561 }
1562
1563 //
1564 // Deliver the datagrams of this instance.
1565 //
1566 Udp4InstanceDeliverDgram (Instance);
1567 }
1568}
1569
1580VOID
1582 IN UDP4_SERVICE_DATA *Udp4Service,
1583 IN EFI_NET_SESSION_DATA *NetSession,
1584 IN NET_BUF *Packet
1585 )
1586{
1587 EFI_UDP_HEADER *Udp4Header;
1588 UINT16 HeadSum;
1589 EFI_UDP4_RECEIVE_DATA RxData;
1590 EFI_UDP4_SESSION_DATA *Udp4Session;
1591 UINTN Enqueued;
1592
1593 if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) {
1594 NetbufFree (Packet);
1595 return;
1596 }
1597
1598 //
1599 // Get the datagram header from the packet buffer.
1600 //
1601 Udp4Header = (EFI_UDP_HEADER *)NetbufGetByte (Packet, 0, NULL);
1602 ASSERT (Udp4Header != NULL);
1603
1604 if (Udp4Header->Checksum != 0) {
1605 //
1606 // check the checksum.
1607 //
1608 HeadSum = NetPseudoHeadChecksum (
1609 NetSession->Source.Addr[0],
1610 NetSession->Dest.Addr[0],
1611 EFI_IP_PROTO_UDP,
1612 0
1613 );
1614
1615 if (Udp4Checksum (Packet, HeadSum) != 0) {
1616 //
1617 // Wrong checksum.
1618 //
1619 NetbufFree (Packet);
1620 return;
1621 }
1622 }
1623
1624 Udp4Session = &RxData.UdpSession;
1625 Udp4Session->SourcePort = NTOHS (Udp4Header->SrcPort);
1626 Udp4Session->DestinationPort = NTOHS (Udp4Header->DstPort);
1627
1628 CopyMem (&Udp4Session->SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));
1629 CopyMem (&Udp4Session->DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));
1630
1631 //
1632 // Trim the UDP header.
1633 //
1634 NetbufTrim (Packet, UDP4_HEADER_SIZE, TRUE);
1635
1636 RxData.DataLength = (UINT32)Packet->TotalSize;
1637
1638 //
1639 // Try to enqueue this datagram into the instances.
1640 //
1641 Enqueued = Udp4EnqueueDgram (Udp4Service, Packet, &RxData);
1642
1643 if (Enqueued == 0) {
1644 //
1645 // Send the port unreachable ICMP packet before we free this NET_BUF
1646 //
1647 Udp4SendPortUnreach (Udp4Service->IpIo, NetSession, Udp4Header);
1648 }
1649
1650 //
1651 // Try to free the packet before deliver it.
1652 //
1653 NetbufFree (Packet);
1654
1655 if (Enqueued > 0) {
1656 //
1657 // Deliver the datagram.
1658 //
1659 Udp4DeliverDgram (Udp4Service);
1660 }
1661}
1662
1673VOID
1675 IN IP_IO *IpIo,
1676 IN EFI_NET_SESSION_DATA *NetSession,
1677 IN VOID *Udp4Header
1678 )
1679{
1680 NET_BUF *Packet;
1681 UINT32 Len;
1682 IP4_ICMP_ERROR_HEAD *IcmpErrHdr;
1683 EFI_IP4_HEADER *IpHdr;
1684 UINT8 *Ptr;
1685 IP_IO_OVERRIDE Override;
1686 IP_IO_IP_INFO *IpSender;
1687
1688 IpSender = IpIoFindSender (&IpIo, NetSession->IpVersion, &NetSession->Dest);
1689 if (IpSender == NULL) {
1690 //
1691 // No appropriate sender, since we cannot send out the ICMP message through
1692 // the default zero station address IP instance, abort.
1693 //
1694 return;
1695 }
1696
1697 IpHdr = NetSession->IpHdr.Ip4Hdr;
1698
1699 //
1700 // Calculate the required length of the icmp error message.
1701 //
1702 Len = sizeof (IP4_ICMP_ERROR_HEAD) + (EFI_IP4_HEADER_LEN (IpHdr) -
1703 sizeof (IP4_HEAD)) + ICMP_ERROR_PACKET_LENGTH;
1704
1705 //
1706 // Allocate buffer for the icmp error message.
1707 //
1708 Packet = NetbufAlloc (Len);
1709 if (Packet == NULL) {
1710 return;
1711 }
1712
1713 //
1714 // Allocate space for the IP4_ICMP_ERROR_HEAD.
1715 //
1716 IcmpErrHdr = (IP4_ICMP_ERROR_HEAD *)NetbufAllocSpace (Packet, Len, FALSE);
1717 ASSERT (IcmpErrHdr != NULL);
1718
1719 //
1720 // Set the required fields for the icmp port unreachable message.
1721 //
1722 IcmpErrHdr->Head.Type = ICMP_TYPE_UNREACH;
1723 IcmpErrHdr->Head.Code = ICMP_CODE_UNREACH_PORT;
1724 IcmpErrHdr->Head.Checksum = 0;
1725 IcmpErrHdr->Fourth = 0;
1726
1727 //
1728 // Copy the IP header of the datagram tragged the error.
1729 //
1730 CopyMem (&IcmpErrHdr->IpHead, IpHdr, EFI_IP4_HEADER_LEN (IpHdr));
1731
1732 //
1733 // Copy the UDP header.
1734 //
1735 Ptr = (UINT8 *)&IcmpErrHdr->IpHead + EFI_IP4_HEADER_LEN (IpHdr);
1736 CopyMem (Ptr, Udp4Header, ICMP_ERROR_PACKET_LENGTH);
1737
1738 //
1739 // Calculate the checksum.
1740 //
1741 IcmpErrHdr->Head.Checksum = (UINT16) ~(NetbufChecksum (Packet));
1742
1743 //
1744 // Fill the override data.
1745 //
1746 Override.Ip4OverrideData.DoNotFragment = FALSE;
1747 Override.Ip4OverrideData.TypeOfService = 0;
1748 Override.Ip4OverrideData.TimeToLive = 255;
1749 Override.Ip4OverrideData.Protocol = EFI_IP_PROTO_ICMP;
1750
1751 CopyMem (&Override.Ip4OverrideData.SourceAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));
1752 ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
1753
1754 //
1755 // Send out this icmp packet.
1756 //
1757 IpIoSend (IpIo, Packet, IpSender, NULL, NULL, &NetSession->Source, &Override);
1758
1759 NetbufFree (Packet);
1760}
1761
1773VOID
1775 IN UDP4_SERVICE_DATA *Udp4Service,
1776 IN UINT8 IcmpError,
1777 IN EFI_NET_SESSION_DATA *NetSession,
1778 IN NET_BUF *Packet
1779 )
1780{
1781 EFI_UDP_HEADER *Udp4Header;
1782 EFI_UDP4_SESSION_DATA Udp4Session;
1783 LIST_ENTRY *Entry;
1784 UDP4_INSTANCE_DATA *Instance;
1785
1786 if (Packet->TotalSize < sizeof (EFI_UDP_HEADER)) {
1787 NetbufFree (Packet);
1788 return;
1789 }
1790
1791 Udp4Header = (EFI_UDP_HEADER *)NetbufGetByte (Packet, 0, NULL);
1792 ASSERT (Udp4Header != NULL);
1793
1794 CopyMem (&Udp4Session.SourceAddress, &NetSession->Source, sizeof (EFI_IPv4_ADDRESS));
1795 CopyMem (&Udp4Session.DestinationAddress, &NetSession->Dest, sizeof (EFI_IPv4_ADDRESS));
1796
1797 Udp4Session.SourcePort = NTOHS (Udp4Header->DstPort);
1798 Udp4Session.DestinationPort = NTOHS (Udp4Header->SrcPort);
1799
1800 NET_LIST_FOR_EACH (Entry, &Udp4Service->ChildrenList) {
1801 //
1802 // Iterate all the instances.
1803 //
1804 Instance = NET_LIST_USER_STRUCT (Entry, UDP4_INSTANCE_DATA, Link);
1805
1806 if (!Instance->Configured) {
1807 continue;
1808 }
1809
1810 if (Udp4MatchDgram (Instance, &Udp4Session)) {
1811 //
1812 // Translate the Icmp Error code according to the udp spec.
1813 //
1814 Instance->IcmpError = IpIoGetIcmpErrStatus (IcmpError, IP_VERSION_4, NULL, NULL);
1815
1816 if (IcmpError > ICMP_ERR_UNREACH_PORT) {
1817 Instance->IcmpError = EFI_ICMP_ERROR;
1818 }
1819
1820 //
1821 // Notify the instance with the received Icmp Error.
1822 //
1823 Udp4ReportIcmpError (Instance);
1824
1825 break;
1826 }
1827 }
1828
1829 NetbufFree (Packet);
1830}
1831
1838VOID
1840 IN UDP4_INSTANCE_DATA *Instance
1841 )
1842{
1844
1845 if (NetMapIsEmpty (&Instance->RxTokens)) {
1846 //
1847 // There are no receive tokens to deliver the ICMP error.
1848 //
1849 return;
1850 }
1851
1852 if (EFI_ERROR (Instance->IcmpError)) {
1853 //
1854 // Try to get a RxToken from the RxTokens map.
1855 //
1856 Token = (EFI_UDP4_COMPLETION_TOKEN *)NetMapRemoveHead (&Instance->RxTokens, NULL);
1857
1858 if (Token != NULL) {
1859 //
1860 // Report the error through the Token.
1861 //
1862 Token->Status = Instance->IcmpError;
1863 gBS->SignalEvent (Token->Event);
1864
1865 //
1866 // Clear the IcmpError.
1867 //
1868 Instance->IcmpError = EFI_SUCCESS;
1869 }
1870 }
1871}
1872
1880VOID
1881EFIAPI
1883 VOID *Context
1884 )
1885{
1886}
UINT64 UINTN
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
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)
Definition: DpcLib.c:86
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI IpIoDestroy(IN OUT IP_IO *IpIo)
Definition: DxeIpIoLib.c:1518
IP_IO *EFIAPI IpIoCreate(IN EFI_HANDLE Image, IN EFI_HANDLE Controller, IN UINT8 IpVersion)
Definition: DxeIpIoLib.c:1217
#define EFI_IP4_HEADER_LEN(HdrPtr)
Definition: IpIoLib.h:50
EFI_STATUS EFIAPI IpIoOpen(IN OUT IP_IO *IpIo, IN IP_IO_OPEN_DATA *OpenData)
Definition: DxeIpIoLib.c:1310
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)
Definition: DxeIpIoLib.c:1578
VOID EFIAPI IpIoCancelTxToken(IN IP_IO *IpIo, IN VOID *Packet)
Definition: DxeIpIoLib.c:1648
IP_IO_IP_INFO *EFIAPI IpIoFindSender(IN OUT IP_IO **IpIo, IN UINT8 IpVersion, IN EFI_IP_ADDRESS *Src)
Definition: DxeIpIoLib.c:2043
EFI_STATUS EFIAPI IpIoGetIcmpErrStatus(IN UINT8 IcmpError, IN UINT8 IpVersion, OUT BOOLEAN *IsHard OPTIONAL, OUT BOOLEAN *Notify OPTIONAL)
Definition: DxeIpIoLib.c:2109
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
VOID EFIAPI NetbufFree(IN NET_BUF *Nbuf)
Definition: NetBuffer.c:195
LIST_ENTRY *EFIAPI NetListRemoveHead(IN OUT LIST_ENTRY *Head)
Definition: DxeNetLib.c:1090
UINT32 EFIAPI NetbufTrim(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
Definition: NetBuffer.c:1134
UINT16 EFIAPI NetbufChecksum(IN NET_BUF *Nbuf)
Definition: NetBuffer.c:1687
EFI_STATUS EFIAPI NetbufBuildExt(IN NET_BUF *Nbuf, IN OUT NET_FRAGMENT *ExtFragment, IN OUT UINT32 *ExtNum)
Definition: NetBuffer.c:866
BOOLEAN EFIAPI NetIp4IsUnicast(IN IP4_ADDR Ip, IN IP4_ADDR NetMask)
Definition: DxeNetLib.c:683
VOID EFIAPI NetMapClean(IN OUT NET_MAP *Map)
Definition: DxeNetLib.c:1368
NET_MAP_ITEM *EFIAPI NetMapFindKey(IN NET_MAP *Map, IN VOID *Key)
Definition: DxeNetLib.c:1629
UINT16 EFIAPI NetAddChecksum(IN UINT16 Checksum1, IN UINT16 Checksum2)
Definition: NetBuffer.c:1658
NET_BUF *EFIAPI NetbufAlloc(IN UINT32 Len)
Definition: NetBuffer.c:89
VOID EFIAPI NetMapInit(IN OUT NET_MAP *Map)
Definition: DxeNetLib.c:1343
UINT8 *EFIAPI NetbufAllocSpace(IN OUT NET_BUF *Nbuf, IN UINT32 Len, IN BOOLEAN FromHead)
Definition: NetBuffer.c:1015
NET_BUF *EFIAPI NetbufDuplicate(IN NET_BUF *Nbuf, IN OUT NET_BUF *Duplicate OPTIONAL, IN UINT32 HeadSpace)
Definition: NetBuffer.c:280
BOOLEAN EFIAPI NetMapIsEmpty(IN NET_MAP *Map)
Definition: DxeNetLib.c:1413
UINT16 EFIAPI NetPseudoHeadChecksum(IN IP4_ADDR Src, IN IP4_ADDR Dst, IN UINT8 Proto, IN UINT16 Len)
Definition: NetBuffer.c:1740
UINT8 *EFIAPI NetbufGetByte(IN NET_BUF *Nbuf, IN UINT32 Offset, OUT UINT32 *Index OPTIONAL)
Definition: NetBuffer.c:359
VOID *EFIAPI NetMapRemoveItem(IN OUT NET_MAP *Map, IN OUT NET_MAP_ITEM *Item, OUT VOID **Value OPTIONAL)
Definition: DxeNetLib.c:1671
VOID *EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
Definition: DxeNetLib.c:1710
EFI_STATUS EFIAPI NetMapIterate(IN NET_MAP *Map, IN NET_MAP_CALLBACK CallBack, IN VOID *Arg OPTIONAL)
Definition: DxeNetLib.c:1800
UINTN EFIAPI NetMapGetCount(IN NET_MAP *Map)
Definition: DxeNetLib.c:1433
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID Udp4Demultiplex(IN UDP4_SERVICE_DATA *Udp4Service, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet)
Definition: Udp4Impl.c:1581
EFI_STATUS Udp4ValidateTxToken(IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *TxToken)
Definition: Udp4Impl.c:767
EFI_STATUS EFIAPI Udp4CancelTokens(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
Definition: Udp4Impl.c:1120
EFI_STATUS Udp4CreateService(IN OUT UDP4_SERVICE_DATA *Udp4Service, IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ControllerHandle)
Definition: Udp4Impl.c:262
EFI_STATUS Udp4RemoveToken(IN OUT NET_MAP *TokenMap, IN EFI_UDP4_COMPLETION_TOKEN *Token)
Definition: Udp4Impl.c:948
VOID Udp4IcmpHandler(IN UDP4_SERVICE_DATA *Udp4Service, IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet)
Definition: Udp4Impl.c:1774
EFI_STATUS EFIAPI Udp4LeaveGroup(IN OUT NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
Definition: Udp4Impl.c:1069
BOOLEAN Udp4FindInstanceByPort(IN LIST_ENTRY *InstanceList, IN EFI_IPv4_ADDRESS *Address, IN UINT16 Port)
Definition: Udp4Impl.c:508
VOID EFIAPI Udp4DgramSent(IN EFI_STATUS Status, IN VOID *Context, IN IP_IO_IP_PROTOCOL Sender, IN VOID *NotifyData)
Definition: Udp4Impl.c:985
BOOLEAN Udp4IsReconfigurable(IN EFI_UDP4_CONFIG_DATA *OldConfigData, IN EFI_UDP4_CONFIG_DATA *NewConfigData)
Definition: Udp4Impl.c:641
VOID Udp4InstanceDeliverDgram(IN UDP4_INSTANCE_DATA *Instance)
Definition: Udp4Impl.c:1483
VOID Udp4DeliverDgram(IN UDP4_SERVICE_DATA *Udp4Service)
Definition: Udp4Impl.c:1546
VOID EFIAPI Udp4CheckTimeout(IN EFI_EVENT Event, IN VOID *Context)
Definition: Udp4Impl.c:386
EFI_STATUS Udp4Bind(IN LIST_ENTRY *InstanceList, IN OUT EFI_UDP4_CONFIG_DATA *ConfigData)
Definition: Udp4Impl.c:566
VOID Udp4InitInstance(IN UDP4_SERVICE_DATA *Udp4Service, IN OUT UDP4_INSTANCE_DATA *Instance)
Definition: Udp4Impl.c:444
VOID EFIAPI Udp4NetVectorExtFree(VOID *Context)
Definition: Udp4Impl.c:1882
UINTN Udp4EnqueueDgram(IN UDP4_SERVICE_DATA *Udp4Service, IN NET_BUF *Packet, IN EFI_UDP4_RECEIVE_DATA *RxData)
Definition: Udp4Impl.c:1433
VOID Udp4BuildIp4ConfigData(IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData, IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData)
Definition: Udp4Impl.c:720
BOOLEAN Udp4MatchDgram(IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_SESSION_DATA *Udp4Session)
Definition: Udp4Impl.c:1256
VOID Udp4SendPortUnreach(IN IP_IO *IpIo, IN EFI_NET_SESSION_DATA *NetSession, IN VOID *Udp4Header)
Definition: Udp4Impl.c:1674
EFI_STATUS Udp4InstanceCancelToken(IN UDP4_INSTANCE_DATA *Instance, IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL)
Definition: Udp4Impl.c:1201
UINT16 Udp4Checksum(IN NET_BUF *Packet, IN UINT16 HeadSum)
Definition: Udp4Impl.c:922
EFI_STATUS EFIAPI Udp4TokenExist(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
Definition: Udp4Impl.c:887
VOID Udp4ReportIcmpError(IN UDP4_INSTANCE_DATA *Instance)
Definition: Udp4Impl.c:1839
UDP4_RXDATA_WRAP * Udp4WrapRxData(IN UDP4_INSTANCE_DATA *Instance, IN NET_BUF *Packet, IN EFI_UDP4_RECEIVE_DATA *RxData)
Definition: Udp4Impl.c:1375
VOID EFIAPI Udp4DgramRcvd(IN EFI_STATUS Status, IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet, IN VOID *Context)
Definition: Udp4Impl.c:1022
VOID Udp4FlushRcvdDgram(IN UDP4_INSTANCE_DATA *Instance)
Definition: Udp4Impl.c:1170
VOID Udp4CleanService(IN UDP4_SERVICE_DATA *Udp4Service)
Definition: Udp4Impl.c:355
VOID EFIAPI Udp4RecycleRxDataWrap(IN EFI_EVENT Event, IN VOID *Context)
Definition: Udp4Impl.c:1335
VOID Udp4CleanInstance(IN UDP4_INSTANCE_DATA *Instance)
Definition: Udp4Impl.c:486
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
UINTN EFI_TPL
Definition: UefiBaseType.h:41
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
@ TimerCancel
Definition: UefiSpec.h:531
@ TimerPeriodic
Definition: UefiSpec.h:535
PKT_RCVD_NOTIFY PktRcvdNotify
Receive callback.
Definition: IpIoLib.h:268
VOID * SndContext
Context data used by send callback.
Definition: IpIoLib.h:267
IP_IO_IP_CONFIG_DATA IpConfigData
Configuration of the IP instance.
Definition: IpIoLib.h:265
VOID * RcvdContext
Context data used by receive callback.
Definition: IpIoLib.h:266
PKT_SENT_NOTIFY PktSentNotify
Send callback.
Definition: IpIoLib.h:269
BOOLEAN AcceptBroadcast
Definition: Ip4.h:80