TianoCore EDK2 master
Loading...
Searching...
No Matches
Udp6Impl.c
Go to the documentation of this file.
1
10#include "Udp6Impl.h"
11
12UINT16 mUdp6RandomPort;
13
23VOID
24EFIAPI
26 IN EFI_EVENT Event,
27 IN VOID *Context
28 );
29
42BOOLEAN
44 IN LIST_ENTRY *InstanceList,
45 IN EFI_IPv6_ADDRESS *Address,
46 IN UINT16 Port
47 );
48
63VOID
64EFIAPI
66 IN EFI_STATUS Status,
67 IN VOID *Context,
68 IN IP_IO_IP_PROTOCOL Sender,
69 IN VOID *NotifyData
70 );
71
88VOID
89EFIAPI
91 IN EFI_STATUS Status,
92 IN UINT8 IcmpError,
93 IN EFI_NET_SESSION_DATA *NetSession,
94 IN NET_BUF *Packet,
95 IN VOID *Context
96 );
97
115EFIAPI
117 IN NET_MAP *Map,
118 IN NET_MAP_ITEM *Item,
119 IN VOID *Arg OPTIONAL
120 );
121
133BOOLEAN
135 IN UDP6_INSTANCE_DATA *Instance,
136 IN EFI_UDP6_SESSION_DATA *Udp6Session
137 );
138
146VOID
147EFIAPI
149 IN EFI_EVENT Event,
150 IN VOID *Context
151 );
152
168 IN UDP6_INSTANCE_DATA *Instance,
169 IN NET_BUF *Packet,
171 );
172
185UINTN
187 IN UDP6_SERVICE_DATA *Udp6Service,
188 IN NET_BUF *Packet,
190 );
191
198VOID
200 IN UDP6_SERVICE_DATA *Udp6Service
201 );
202
213VOID
215 IN UDP6_SERVICE_DATA *Udp6Service,
216 IN EFI_NET_SESSION_DATA *NetSession,
217 IN NET_BUF *Packet
218 );
219
231VOID
233 IN UDP6_SERVICE_DATA *Udp6Service,
234 IN UINT8 IcmpError,
235 IN EFI_NET_SESSION_DATA *NetSession,
236 IN OUT NET_BUF *Packet
237 );
238
249VOID
251 IN IP_IO *IpIo,
252 IN EFI_NET_SESSION_DATA *NetSession,
253 IN VOID *Udp6Header
254 );
255
267 IN NET_MAP *Map,
268 IN VOID *Key
269 );
270
286 IN UDP6_SERVICE_DATA *Udp6Service,
287 IN EFI_HANDLE ImageHandle,
288 IN EFI_HANDLE ControllerHandle
289 )
290{
291 EFI_STATUS Status;
292 IP_IO_OPEN_DATA OpenData;
293
294 ZeroMem (Udp6Service, sizeof (UDP6_SERVICE_DATA));
295
296 Udp6Service->Signature = UDP6_SERVICE_DATA_SIGNATURE;
297 Udp6Service->ServiceBinding = mUdp6ServiceBinding;
298 Udp6Service->ImageHandle = ImageHandle;
299 Udp6Service->ControllerHandle = ControllerHandle;
300 Udp6Service->ChildrenNumber = 0;
301
302 InitializeListHead (&Udp6Service->ChildrenList);
303
304 //
305 // Create the IpIo for this service context.
306 //
307 Udp6Service->IpIo = IpIoCreate (ImageHandle, ControllerHandle, IP_VERSION_6);
308 if (Udp6Service->IpIo == NULL) {
309 return EFI_OUT_OF_RESOURCES;
310 }
311
312 //
313 // Set the OpenData used to open the IpIo.
314 //
315 CopyMem (
316 &OpenData.IpConfigData.Ip6CfgData,
317 &mIp6IoDefaultIpConfigData,
318 sizeof (EFI_IP6_CONFIG_DATA)
319 );
320 OpenData.RcvdContext = (VOID *)Udp6Service;
321 OpenData.SndContext = NULL;
322 OpenData.PktRcvdNotify = Udp6DgramRcvd;
323 OpenData.PktSentNotify = Udp6DgramSent;
324
325 //
326 // Configure and start the IpIo.
327 //
328 Status = IpIoOpen (Udp6Service->IpIo, &OpenData);
329 if (EFI_ERROR (Status)) {
330 goto ON_ERROR;
331 }
332
333 //
334 // Create the event for Udp timeout checking.
335 //
336 Status = gBS->CreateEvent (
337 EVT_TIMER | EVT_NOTIFY_SIGNAL,
338 TPL_CALLBACK,
340 Udp6Service,
341 &Udp6Service->TimeoutEvent
342 );
343 if (EFI_ERROR (Status)) {
344 goto ON_ERROR;
345 }
346
347 //
348 // Start the timeout timer event.
349 //
350 Status = gBS->SetTimer (
351 Udp6Service->TimeoutEvent,
353 UDP6_TIMEOUT_INTERVAL
354 );
355 if (EFI_ERROR (Status)) {
356 goto ON_ERROR;
357 }
358
359 return EFI_SUCCESS;
360
361ON_ERROR:
362
363 if (Udp6Service->TimeoutEvent != NULL) {
364 gBS->CloseEvent (Udp6Service->TimeoutEvent);
365 }
366
367 IpIoDestroy (Udp6Service->IpIo);
368 Udp6Service->IpIo = NULL;
369
370 return Status;
371}
372
379VOID
381 IN OUT UDP6_SERVICE_DATA *Udp6Service
382 )
383{
384 //
385 // Close the TimeoutEvent timer.
386 //
387 gBS->CloseEvent (Udp6Service->TimeoutEvent);
388
389 //
390 // Destroy the IpIo.
391 //
392 IpIoDestroy (Udp6Service->IpIo);
393 Udp6Service->IpIo = NULL;
394
395 ZeroMem (Udp6Service, sizeof (UDP6_SERVICE_DATA));
396}
397
408VOID
409EFIAPI
411 IN EFI_EVENT Event,
412 IN VOID *Context
413 )
414{
415 UDP6_SERVICE_DATA *Udp6Service;
416 LIST_ENTRY *Entry;
417 UDP6_INSTANCE_DATA *Instance;
418 LIST_ENTRY *WrapEntry;
419 LIST_ENTRY *NextEntry;
420 UDP6_RXDATA_WRAP *Wrap;
421
422 Udp6Service = (UDP6_SERVICE_DATA *)Context;
423 NET_CHECK_SIGNATURE (Udp6Service, UDP6_SERVICE_DATA_SIGNATURE);
424
425 NET_LIST_FOR_EACH (Entry, &Udp6Service->ChildrenList) {
426 //
427 // Iterate all the instances belonging to this service context.
428 //
429 Instance = NET_LIST_USER_STRUCT (Entry, UDP6_INSTANCE_DATA, Link);
430 NET_CHECK_SIGNATURE (Instance, UDP6_INSTANCE_DATA_SIGNATURE);
431
432 if (!Instance->Configured || (Instance->ConfigData.ReceiveTimeout == 0)) {
433 //
434 // Skip this instance if it's not configured or no receive timeout.
435 //
436 continue;
437 }
438
439 NET_LIST_FOR_EACH_SAFE (WrapEntry, NextEntry, &Instance->RcvdDgramQue) {
440 //
441 // Iterate all the rxdatas belonging to this udp instance.
442 //
443 Wrap = NET_LIST_USER_STRUCT (WrapEntry, UDP6_RXDATA_WRAP, Link);
444
445 if (Wrap->TimeoutTick < UDP6_TIMEOUT_INTERVAL / 10) {
446 //
447 // Remove this RxData if it timeouts.
448 //
449 Udp6RecycleRxDataWrap (NULL, (VOID *)Wrap);
450 } else {
451 Wrap->TimeoutTick -= UDP6_TIMEOUT_INTERVAL / 10;
452 }
453 }
454 }
455}
456
464VOID
466 IN UDP6_SERVICE_DATA *Udp6Service,
467 IN OUT UDP6_INSTANCE_DATA *Instance
468 )
469{
470 //
471 // Set the signature.
472 //
473 Instance->Signature = UDP6_INSTANCE_DATA_SIGNATURE;
474
475 //
476 // Init the lists.
477 //
478 InitializeListHead (&Instance->Link);
479 InitializeListHead (&Instance->RcvdDgramQue);
480 InitializeListHead (&Instance->DeliveredDgramQue);
481
482 //
483 // Init the NET_MAPs.
484 //
485 NetMapInit (&Instance->TxTokens);
486 NetMapInit (&Instance->RxTokens);
487 NetMapInit (&Instance->McastIps);
488
489 //
490 // Save the pointer to the UDP6_SERVICE_DATA, and initialize other members.
491 //
492 Instance->Udp6Service = Udp6Service;
493 CopyMem (&Instance->Udp6Proto, &mUdp6Protocol, sizeof (EFI_UDP6_PROTOCOL));
494 Instance->IcmpError = EFI_SUCCESS;
495 Instance->Configured = FALSE;
496 Instance->IsNoMapping = FALSE;
497 Instance->InDestroy = FALSE;
498}
499
506VOID
508 IN OUT UDP6_INSTANCE_DATA *Instance
509 )
510{
511 NetMapClean (&Instance->McastIps);
512 NetMapClean (&Instance->RxTokens);
513 NetMapClean (&Instance->TxTokens);
514}
515
528BOOLEAN
530 IN LIST_ENTRY *InstanceList,
531 IN EFI_IPv6_ADDRESS *Address,
532 IN UINT16 Port
533 )
534{
535 LIST_ENTRY *Entry;
536 UDP6_INSTANCE_DATA *Instance;
537 EFI_UDP6_CONFIG_DATA *ConfigData;
538
539 NET_LIST_FOR_EACH (Entry, InstanceList) {
540 //
541 // Iterate all the udp instances.
542 //
543 Instance = NET_LIST_USER_STRUCT (Entry, UDP6_INSTANCE_DATA, Link);
544 ConfigData = &Instance->ConfigData;
545
546 if (!Instance->Configured || ConfigData->AcceptAnyPort) {
547 //
548 // If the instance is not configured, or the configdata of the instance indicates
549 // this instance accepts any port, skip it.
550 //
551 continue;
552 }
553
554 if (EFI_IP6_EQUAL (&ConfigData->StationAddress, Address) &&
555 (ConfigData->StationPort == Port)
556 )
557 {
558 //
559 // If both the address and the port are the same, return TRUE.
560 //
561 return TRUE;
562 }
563 }
564
565 //
566 // Return FALSE when matching fails.
567 //
568 return FALSE;
569}
570
588 IN LIST_ENTRY *InstanceList,
589 IN EFI_UDP6_CONFIG_DATA *ConfigData
590 )
591{
592 EFI_IPv6_ADDRESS *StationAddress;
593 UINT16 StartPort;
594
595 if (ConfigData->AcceptAnyPort) {
596 return EFI_SUCCESS;
597 }
598
599 StationAddress = &ConfigData->StationAddress;
600
601 if (ConfigData->StationPort != 0) {
602 if (!ConfigData->AllowDuplicatePort &&
603 Udp6FindInstanceByPort (InstanceList, StationAddress, ConfigData->StationPort)
604 )
605 {
606 //
607 // Do not allow duplicate ports and the port is already used by other instance.
608 //
609 return EFI_ACCESS_DENIED;
610 }
611 } else {
612 //
613 // Select a random port for this instance.
614 //
615 if (ConfigData->AllowDuplicatePort) {
616 //
617 // Just pick up the random port if the instance allows duplicate port.
618 //
619 ConfigData->StationPort = mUdp6RandomPort;
620 } else {
621 StartPort = mUdp6RandomPort;
622
623 while (Udp6FindInstanceByPort (InstanceList, StationAddress, mUdp6RandomPort)) {
624 mUdp6RandomPort++;
625 if (mUdp6RandomPort == 0) {
626 mUdp6RandomPort = UDP6_PORT_KNOWN;
627 }
628
629 if (mUdp6RandomPort == StartPort) {
630 //
631 // No available port.
632 //
633 return EFI_OUT_OF_RESOURCES;
634 }
635 }
636
637 ConfigData->StationPort = mUdp6RandomPort;
638 }
639
640 mUdp6RandomPort++;
641 if (mUdp6RandomPort == 0) {
642 mUdp6RandomPort = UDP6_PORT_KNOWN;
643 }
644 }
645
646 return EFI_SUCCESS;
647}
648
661BOOLEAN
663 IN EFI_UDP6_CONFIG_DATA *OldConfigData,
664 IN EFI_UDP6_CONFIG_DATA *NewConfigData
665 )
666{
667 if ((NewConfigData->AcceptAnyPort != OldConfigData->AcceptAnyPort) ||
668 (NewConfigData->AcceptPromiscuous != OldConfigData->AcceptPromiscuous) ||
669 (NewConfigData->AllowDuplicatePort != OldConfigData->AllowDuplicatePort)
670 )
671 {
672 //
673 // The receiving filter parameters cannot be changed.
674 //
675 return FALSE;
676 }
677
678 if ((!NewConfigData->AcceptAnyPort) &&
679 (NewConfigData->StationPort != OldConfigData->StationPort)
680 )
681 {
682 //
683 // The port is not changeable.
684 //
685 return FALSE;
686 }
687
688 if (!EFI_IP6_EQUAL (&NewConfigData->StationAddress, &OldConfigData->StationAddress)) {
689 //
690 // The StationAddress is not the same.
691 //
692 return FALSE;
693 }
694
695 if (!EFI_IP6_EQUAL (&NewConfigData->RemoteAddress, &OldConfigData->RemoteAddress)) {
696 //
697 // The remoteaddress is not the same.
698 //
699 return FALSE;
700 }
701
702 if (!NetIp6IsUnspecifiedAddr (&NewConfigData->RemoteAddress) &&
703 (NewConfigData->RemotePort != OldConfigData->RemotePort)
704 )
705 {
706 //
707 // The RemotePort differs if it's designated in the configdata.
708 //
709 return FALSE;
710 }
711
712 //
713 // All checks pass, return TRUE.
714 //
715 return TRUE;
716}
717
725VOID
727 IN EFI_UDP6_CONFIG_DATA *Udp6ConfigData,
728 IN OUT EFI_IP6_CONFIG_DATA *Ip6ConfigData
729 )
730{
731 CopyMem (
732 Ip6ConfigData,
733 &mIp6IoDefaultIpConfigData,
734 sizeof (EFI_IP6_CONFIG_DATA)
735 );
736 Ip6ConfigData->DefaultProtocol = EFI_IP_PROTO_UDP;
737 Ip6ConfigData->AcceptPromiscuous = Udp6ConfigData->AcceptPromiscuous;
738 IP6_COPY_ADDRESS (&Ip6ConfigData->StationAddress, &Udp6ConfigData->StationAddress);
739 IP6_COPY_ADDRESS (&Ip6ConfigData->DestinationAddress, &Udp6ConfigData->RemoteAddress);
740 //
741 // Use the -1 magic number to disable the receiving process of the ip instance.
742 //
743 Ip6ConfigData->ReceiveTimeout = (UINT32)(-1);
744}
745
777 IN UDP6_INSTANCE_DATA *Instance,
779 )
780{
782 UINT32 Index;
783 UINT32 TotalLen;
784 EFI_UDP6_CONFIG_DATA *ConfigData;
785 EFI_UDP6_SESSION_DATA *UdpSessionData;
786
787 if (TxToken->Event == NULL) {
788 return EFI_INVALID_PARAMETER;
789 }
790
791 TxData = TxToken->Packet.TxData;
792
793 if ((TxData == NULL) || (TxData->FragmentCount == 0)) {
794 return EFI_INVALID_PARAMETER;
795 }
796
797 TotalLen = 0;
798 for (Index = 0; Index < TxData->FragmentCount; Index++) {
799 if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) ||
800 (TxData->FragmentTable[Index].FragmentLength == 0)
801 )
802 {
803 //
804 // If the FragmentBuffer is NULL, or the FragmentLeng is zero.
805 //
806 return EFI_INVALID_PARAMETER;
807 }
808
809 TotalLen += TxData->FragmentTable[Index].FragmentLength;
810 }
811
812 if (TotalLen != TxData->DataLength) {
813 //
814 // The TotalLen calculated by adding all the FragmentLeng doesn't equal to the
815 // DataLength.
816 //
817 return EFI_INVALID_PARAMETER;
818 }
819
820 ConfigData = &Instance->ConfigData;
821 UdpSessionData = TxData->UdpSessionData;
822
823 if (UdpSessionData != NULL) {
824 if ((UdpSessionData->DestinationPort == 0) && (ConfigData->RemotePort == 0)) {
825 //
826 // Ambiguous; no available DestinationPort for this token.
827 //
828 return EFI_INVALID_PARAMETER;
829 }
830
831 if (NetIp6IsUnspecifiedAddr (&UdpSessionData->DestinationAddress) &&
833 )
834 {
835 //
836 // The DestinationAddress is not specified.
837 //
838 return EFI_INVALID_PARAMETER;
839 }
840
841 if (!NetIp6IsUnspecifiedAddr (&UdpSessionData->DestinationAddress) &&
843 )
844 {
845 //
846 // The ConfigData.RemoteAddress is not zero and the UdpSessionData.DestinationAddress
847 // is not zero too.
848 //
849 return EFI_INVALID_PARAMETER;
850 }
851 } else if (NetIp6IsUnspecifiedAddr (&ConfigData->RemoteAddress)) {
852 //
853 // The configured RemoteAddress is all zero, and the user doesn't override the
854 // destination address.
855 //
856 return EFI_INVALID_PARAMETER;
857 }
858
859 if (TxData->DataLength > UDP6_MAX_DATA_SIZE) {
860 return EFI_BAD_BUFFER_SIZE;
861 }
862
863 return EFI_SUCCESS;
864}
865
880EFIAPI
882 IN NET_MAP *Map,
883 IN NET_MAP_ITEM *Item,
884 IN VOID *Context
885 )
886{
888 EFI_UDP6_COMPLETION_TOKEN *TokenInItem;
889
890 Token = (EFI_UDP6_COMPLETION_TOKEN *)Context;
891 TokenInItem = (EFI_UDP6_COMPLETION_TOKEN *)Item->Key;
892
893 if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
894 //
895 // The Token duplicates with the TokenInItem in case either the two pointers are the
896 // same, or the Events of these two tokens are the same.
897 //
898 return EFI_ACCESS_DENIED;
899 }
900
901 return EFI_SUCCESS;
902}
903
915UINT16
917 IN NET_BUF *Packet,
918 IN UINT16 HeadSum
919 )
920{
921 UINT16 Checksum;
922
923 Checksum = NetbufChecksum (Packet);
924 Checksum = NetAddChecksum (Checksum, HeadSum);
925
926 Checksum = NetAddChecksum (Checksum, HTONS ((UINT16)Packet->TotalSize));
927 Checksum = (UINT16)(~Checksum);
928 return Checksum;
929}
930
943 IN NET_MAP *TokenMap,
945 )
946{
947 NET_MAP_ITEM *Item;
948
949 //
950 // Find the Token first.
951 //
952 Item = NetMapFindKey (TokenMap, (VOID *)Token);
953
954 if (Item != NULL) {
955 //
956 // Remove the token if it's found in the map.
957 //
958 NetMapRemoveItem (TokenMap, Item, NULL);
959
960 return EFI_SUCCESS;
961 }
962
963 return EFI_NOT_FOUND;
964}
965
980VOID
981EFIAPI
983 IN EFI_STATUS Status,
984 IN VOID *Context,
985 IN IP_IO_IP_PROTOCOL Sender,
986 IN VOID *NotifyData
987 )
988{
989 UDP6_INSTANCE_DATA *Instance;
991
992 ASSERT (Context != NULL && NotifyData != NULL);
993
994 Instance = (UDP6_INSTANCE_DATA *)Context;
995 Token = (EFI_UDP6_COMPLETION_TOKEN *)NotifyData;
996
997 if (Udp6RemoveToken (&Instance->TxTokens, Token) == EFI_SUCCESS) {
998 //
999 // The token may be cancelled. Only signal it if the remove operation succeeds.
1000 //
1001 Token->Status = Status;
1002 gBS->SignalEvent (Token->Event);
1003 DispatchDpc ();
1004 }
1005}
1006
1023VOID
1024EFIAPI
1026 IN EFI_STATUS Status,
1027 IN UINT8 IcmpError,
1028 IN EFI_NET_SESSION_DATA *NetSession,
1029 IN NET_BUF *Packet,
1030 IN VOID *Context
1031 )
1032{
1033 ASSERT (NetSession != NULL && Packet != NULL && Context != NULL);
1034 NET_CHECK_SIGNATURE (Packet, NET_BUF_SIGNATURE);
1035
1036 //
1037 // IpIo only passes received packets with Status EFI_SUCCESS or EFI_ICMP_ERROR.
1038 //
1039 if (Status == EFI_SUCCESS) {
1040 //
1041 // Demultiplex the received datagram.
1042 //
1043 Udp6Demultiplex ((UDP6_SERVICE_DATA *)Context, NetSession, Packet);
1044 } else {
1045 //
1046 // Handle the ICMP6 Error packet.
1047 //
1048 Udp6IcmpHandler ((UDP6_SERVICE_DATA *)Context, IcmpError, NetSession, Packet);
1049 }
1050
1051 //
1052 // Dispatch the DPC queued by the NotifyFunction of the rx token's events
1053 // that are signaled with received data.
1054 //
1055 DispatchDpc ();
1056}
1057
1073EFIAPI
1075 IN NET_MAP *Map,
1076 IN NET_MAP_ITEM *Item,
1077 IN VOID *Arg OPTIONAL
1078 )
1079{
1080 EFI_IPv6_ADDRESS *McastIp;
1081
1082 McastIp = Arg;
1083
1084 if ((McastIp != NULL) &&
1085 !EFI_IP6_EQUAL (McastIp, ((EFI_IPv6_ADDRESS *)Item->Key))
1086 )
1087 {
1088 //
1089 // McastIp is not NULL and the multicast address contained in the Item
1090 // is not the same as McastIp.
1091 //
1092 return EFI_SUCCESS;
1093 }
1094
1095 FreePool (Item->Key);
1096
1097 //
1098 // Remove this Item.
1099 //
1100 NetMapRemoveItem (Map, Item, NULL);
1101
1102 if (McastIp != NULL) {
1103 //
1104 // Return EFI_ABORTED in case McastIp is not NULL to terminate the iteration.
1105 //
1106 return EFI_ABORTED;
1107 }
1108
1109 return EFI_SUCCESS;
1110}
1111
1129EFIAPI
1131 IN NET_MAP *Map,
1132 IN NET_MAP_ITEM *Item,
1133 IN VOID *Arg OPTIONAL
1134 )
1135{
1136 EFI_UDP6_COMPLETION_TOKEN *TokenToCancel;
1137 NET_BUF *Packet;
1138 IP_IO *IpIo;
1139
1140 if ((Arg != NULL) && (Item->Key != Arg)) {
1141 return EFI_SUCCESS;
1142 }
1143
1144 if (Item->Value != NULL) {
1145 //
1146 // If the token is a transmit token, the corresponding Packet is recorded in
1147 // Item->Value, invoke IpIo to cancel this packet first. The IpIoCancelTxToken
1148 // will invoke Udp6DgramSent, the token will be signaled and this Item will
1149 // be removed from the Map there.
1150 //
1151 Packet = (NET_BUF *)(Item->Value);
1152 IpIo = (IP_IO *)(*((UINTN *)&Packet->ProtoData[0]));
1153
1154 IpIoCancelTxToken (IpIo, Packet);
1155 } else {
1156 //
1157 // The token is a receive token. Abort it and remove it from the Map.
1158 //
1159 TokenToCancel = (EFI_UDP6_COMPLETION_TOKEN *)Item->Key;
1160 NetMapRemoveItem (Map, Item, NULL);
1161
1162 TokenToCancel->Status = EFI_ABORTED;
1163 gBS->SignalEvent (TokenToCancel->Event);
1164 }
1165
1166 if (Arg != NULL) {
1167 return EFI_ABORTED;
1168 }
1169
1170 return EFI_SUCCESS;
1171}
1172
1179VOID
1181 IN UDP6_INSTANCE_DATA *Instance
1182 )
1183{
1184 UDP6_RXDATA_WRAP *Wrap;
1185
1186 while (!IsListEmpty (&Instance->RcvdDgramQue)) {
1187 //
1188 // Iterate all the Wraps in the RcvdDgramQue.
1189 //
1190 Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP6_RXDATA_WRAP, Link);
1191
1192 //
1193 // The Wrap will be removed from the RcvdDgramQue by this function call.
1194 //
1195 Udp6RecycleRxDataWrap (NULL, (VOID *)Wrap);
1196 }
1197}
1198
1213 IN UDP6_INSTANCE_DATA *Instance,
1214 IN EFI_UDP6_COMPLETION_TOKEN *Token OPTIONAL
1215 )
1216{
1217 EFI_STATUS Status;
1218
1219 //
1220 // Cancel this token from the TxTokens map.
1221 //
1222 Status = NetMapIterate (&Instance->TxTokens, Udp6CancelTokens, Token);
1223
1224 if ((Token != NULL) && (Status == EFI_ABORTED)) {
1225 //
1226 // If Token isn't NULL and Status is EFI_ABORTED, the token is cancelled from
1227 // the TxTokens and returns success.
1228 //
1229 return EFI_SUCCESS;
1230 }
1231
1232 //
1233 // Try to cancel this token from the RxTokens map in condition either the Token
1234 // is NULL or the specified Token is not in TxTokens.
1235 //
1236 Status = NetMapIterate (&Instance->RxTokens, Udp6CancelTokens, Token);
1237
1238 if ((Token != NULL) && (Status == EFI_SUCCESS)) {
1239 //
1240 // If Token isn't NULL and Status is EFI_SUCCESS, the token is neither in the
1241 // TxTokens nor the RxTokens, or say, it's not found.
1242 //
1243 return EFI_NOT_FOUND;
1244 }
1245
1246 ASSERT (
1247 (Token != NULL) ||
1248 ((0 == NetMapGetCount (&Instance->TxTokens)) &&
1249 (0 == NetMapGetCount (&Instance->RxTokens)))
1250 );
1251
1252 return EFI_SUCCESS;
1253}
1254
1266BOOLEAN
1268 IN UDP6_INSTANCE_DATA *Instance,
1269 IN EFI_UDP6_SESSION_DATA *Udp6Session
1270 )
1271{
1272 EFI_UDP6_CONFIG_DATA *ConfigData;
1273 EFI_IPv6_ADDRESS Destination;
1274
1275 ConfigData = &Instance->ConfigData;
1276
1277 if (ConfigData->AcceptPromiscuous) {
1278 //
1279 // Always matches if this instance is in the promiscuous state.
1280 //
1281 return TRUE;
1282 }
1283
1284 if ((!ConfigData->AcceptAnyPort && (Udp6Session->DestinationPort != ConfigData->StationPort)) ||
1285 ((ConfigData->RemotePort != 0) && (Udp6Session->SourcePort != ConfigData->RemotePort))
1286 )
1287 {
1288 //
1289 // The local port or the remote port doesn't match.
1290 //
1291 return FALSE;
1292 }
1293
1294 if (!NetIp6IsUnspecifiedAddr (&ConfigData->RemoteAddress) &&
1295 !EFI_IP6_EQUAL (&ConfigData->RemoteAddress, &Udp6Session->SourceAddress)
1296 )
1297 {
1298 //
1299 // This datagram doesn't come from the instance's specified sender.
1300 //
1301 return FALSE;
1302 }
1303
1304 if (NetIp6IsUnspecifiedAddr (&ConfigData->StationAddress) ||
1305 EFI_IP6_EQUAL (&Udp6Session->DestinationAddress, &ConfigData->StationAddress)
1306 )
1307 {
1308 //
1309 // The instance is configured to receive datagrams destinated to any station IP or
1310 // the destination address of this datagram matches the configured station IP.
1311 //
1312 return TRUE;
1313 }
1314
1315 IP6_COPY_ADDRESS (&Destination, &Udp6Session->DestinationAddress);
1316
1317 if (IP6_IS_MULTICAST (&Destination) &&
1318 (NULL != Udp6MapMultiCastAddr (&Instance->McastIps, &Destination))
1319 )
1320 {
1321 //
1322 // It's a multicast packet and the multicast address is accepted by this instance.
1323 //
1324 return TRUE;
1325 }
1326
1327 return FALSE;
1328}
1329
1337VOID
1338EFIAPI
1340 IN EFI_EVENT Event,
1341 IN VOID *Context
1342 )
1343{
1344 UDP6_RXDATA_WRAP *Wrap;
1345
1346 Wrap = (UDP6_RXDATA_WRAP *)Context;
1347
1348 //
1349 // Remove the Wrap from the list it belongs to.
1350 //
1351 RemoveEntryList (&Wrap->Link);
1352
1353 //
1354 // Free the Packet associated with this Wrap.
1355 //
1356 NetbufFree (Wrap->Packet);
1357
1358 //
1359 // Close the event.
1360 //
1361 gBS->CloseEvent (Wrap->RxData.RecycleSignal);
1362
1363 FreePool (Wrap);
1364}
1365
1381 IN UDP6_INSTANCE_DATA *Instance,
1382 IN NET_BUF *Packet,
1384 )
1385{
1386 EFI_STATUS Status;
1387 UDP6_RXDATA_WRAP *Wrap;
1388
1389 //
1390 // Allocate buffer for the Wrap.
1391 //
1392 Wrap = AllocateZeroPool (
1393 sizeof (UDP6_RXDATA_WRAP) +
1394 (Packet->BlockOpNum - 1) * sizeof (EFI_UDP6_FRAGMENT_DATA)
1395 );
1396 if (Wrap == NULL) {
1397 return NULL;
1398 }
1399
1400 InitializeListHead (&Wrap->Link);
1401
1402 CopyMem (&Wrap->RxData, RxData, sizeof (EFI_UDP6_RECEIVE_DATA));
1403 //
1404 // Create the Recycle event.
1405 //
1406 Status = gBS->CreateEvent (
1407 EVT_NOTIFY_SIGNAL,
1408 TPL_NOTIFY,
1410 Wrap,
1411 &Wrap->RxData.RecycleSignal
1412 );
1413 if (EFI_ERROR (Status)) {
1414 FreePool (Wrap);
1415 return NULL;
1416 }
1417
1418 Wrap->Packet = Packet;
1419 Wrap->TimeoutTick = Instance->ConfigData.ReceiveTimeout;
1420
1421 return Wrap;
1422}
1423
1436UINTN
1438 IN UDP6_SERVICE_DATA *Udp6Service,
1439 IN NET_BUF *Packet,
1441 )
1442{
1443 LIST_ENTRY *Entry;
1444 UDP6_INSTANCE_DATA *Instance;
1445 UDP6_RXDATA_WRAP *Wrap;
1446 UINTN Enqueued;
1447
1448 Enqueued = 0;
1449
1450 NET_LIST_FOR_EACH (Entry, &Udp6Service->ChildrenList) {
1451 //
1452 // Iterate the instances.
1453 //
1454 Instance = NET_LIST_USER_STRUCT (Entry, UDP6_INSTANCE_DATA, Link);
1455
1456 if (!Instance->Configured) {
1457 continue;
1458 }
1459
1460 if (Udp6MatchDgram (Instance, &RxData->UdpSession)) {
1461 //
1462 // Wrap the RxData and put this Wrap into the instances RcvdDgramQue.
1463 //
1464 Wrap = Udp6WrapRxData (Instance, Packet, RxData);
1465 if (Wrap == NULL) {
1466 continue;
1467 }
1468
1469 NET_GET_REF (Packet);
1470
1471 InsertTailList (&Instance->RcvdDgramQue, &Wrap->Link);
1472
1473 Enqueued++;
1474 }
1475 }
1476
1477 return Enqueued;
1478}
1479
1486VOID
1488 IN UDP6_INSTANCE_DATA *Instance
1489 )
1490{
1491 UDP6_RXDATA_WRAP *Wrap;
1493 NET_BUF *Dup;
1494 EFI_UDP6_RECEIVE_DATA *RxData;
1495 EFI_TPL OldTpl;
1496
1497 if (!IsListEmpty (&Instance->RcvdDgramQue) &&
1498 !NetMapIsEmpty (&Instance->RxTokens)
1499 )
1500 {
1501 Wrap = NET_LIST_HEAD (&Instance->RcvdDgramQue, UDP6_RXDATA_WRAP, Link);
1502
1503 if (NET_BUF_SHARED (Wrap->Packet)) {
1504 //
1505 // Duplicate the Packet if it is shared between instances.
1506 //
1507 Dup = NetbufDuplicate (Wrap->Packet, NULL, 0);
1508 if (Dup == NULL) {
1509 return;
1510 }
1511
1512 NetbufFree (Wrap->Packet);
1513
1514 Wrap->Packet = Dup;
1515 }
1516
1517 NetListRemoveHead (&Instance->RcvdDgramQue);
1518
1519 Token = (EFI_UDP6_COMPLETION_TOKEN *)NetMapRemoveHead (&Instance->RxTokens, NULL);
1520
1521 //
1522 // Build the FragmentTable and set the FragmentCount in RxData.
1523 //
1524 RxData = &Wrap->RxData;
1525 RxData->FragmentCount = Wrap->Packet->BlockOpNum;
1526
1528 Wrap->Packet,
1529 (NET_FRAGMENT *)RxData->FragmentTable,
1530 &RxData->FragmentCount
1531 );
1532
1533 Token->Status = EFI_SUCCESS;
1534 Token->Packet.RxData = &Wrap->RxData;
1535
1536 OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
1537 InsertTailList (&Instance->DeliveredDgramQue, &Wrap->Link);
1538 gBS->RestoreTPL (OldTpl);
1539
1540 gBS->SignalEvent (Token->Event);
1541 }
1542}
1543
1550VOID
1552 IN UDP6_SERVICE_DATA *Udp6Service
1553 )
1554{
1555 LIST_ENTRY *Entry;
1556 UDP6_INSTANCE_DATA *Instance;
1557
1558 NET_LIST_FOR_EACH (Entry, &Udp6Service->ChildrenList) {
1559 //
1560 // Iterate the instances.
1561 //
1562 Instance = NET_LIST_USER_STRUCT (Entry, UDP6_INSTANCE_DATA, Link);
1563
1564 if (!Instance->Configured) {
1565 continue;
1566 }
1567
1568 //
1569 // Deliver the datagrams of this instance.
1570 //
1571 Udp6InstanceDeliverDgram (Instance);
1572 }
1573}
1574
1585VOID
1587 IN UDP6_SERVICE_DATA *Udp6Service,
1588 IN EFI_NET_SESSION_DATA *NetSession,
1589 IN NET_BUF *Packet
1590 )
1591{
1592 EFI_UDP_HEADER *Udp6Header;
1593 UINT16 HeadSum;
1594 EFI_UDP6_RECEIVE_DATA RxData;
1595 EFI_UDP6_SESSION_DATA *Udp6Session;
1596 UINTN Enqueued;
1597
1598 if (Packet->TotalSize < UDP6_HEADER_SIZE) {
1599 NetbufFree (Packet);
1600 return;
1601 }
1602
1603 //
1604 // Get the datagram header from the packet buffer.
1605 //
1606 Udp6Header = (EFI_UDP_HEADER *)NetbufGetByte (Packet, 0, NULL);
1607 ASSERT (Udp6Header != NULL);
1608 if (Udp6Header == NULL) {
1609 NetbufFree (Packet);
1610 return;
1611 }
1612
1613 if (Udp6Header->Checksum != 0) {
1614 //
1615 // check the checksum.
1616 //
1617 HeadSum = NetIp6PseudoHeadChecksum (
1618 &NetSession->Source.v6,
1619 &NetSession->Dest.v6,
1620 EFI_IP_PROTO_UDP,
1621 0
1622 );
1623
1624 if (Udp6Checksum (Packet, HeadSum) != 0) {
1625 //
1626 // Wrong checksum.
1627 //
1628 NetbufFree (Packet);
1629 return;
1630 }
1631 }
1632
1633 Udp6Session = &RxData.UdpSession;
1634 Udp6Session->SourcePort = NTOHS (Udp6Header->SrcPort);
1635 Udp6Session->DestinationPort = NTOHS (Udp6Header->DstPort);
1636
1637 IP6_COPY_ADDRESS (&Udp6Session->SourceAddress, &NetSession->Source);
1638 IP6_COPY_ADDRESS (&Udp6Session->DestinationAddress, &NetSession->Dest);
1639
1640 //
1641 // Trim the UDP header.
1642 //
1643 NetbufTrim (Packet, UDP6_HEADER_SIZE, TRUE);
1644
1645 RxData.DataLength = (UINT32)Packet->TotalSize;
1646
1647 //
1648 // Try to enqueue this datagram into the instances.
1649 //
1650 Enqueued = Udp6EnqueueDgram (Udp6Service, Packet, &RxData);
1651
1652 if (Enqueued == 0) {
1653 //
1654 // Send the port unreachable ICMP packet before we free this NET_BUF
1655 //
1656 Udp6SendPortUnreach (Udp6Service->IpIo, NetSession, Udp6Header);
1657 }
1658
1659 //
1660 // Try to free the packet before deliver it.
1661 //
1662 NetbufFree (Packet);
1663
1664 if (Enqueued > 0) {
1665 //
1666 // Deliver the datagram.
1667 //
1668 Udp6DeliverDgram (Udp6Service);
1669 }
1670}
1671
1682VOID
1684 IN IP_IO *IpIo,
1685 IN EFI_NET_SESSION_DATA *NetSession,
1686 IN VOID *Udp6Header
1687 )
1688{
1689 NET_BUF *Packet;
1690 UINT32 Len;
1691 IP6_ICMP_ERROR_HEAD *IcmpErrHdr;
1692 UINT8 *Ptr;
1693 IP_IO_OVERRIDE Override;
1694 IP_IO_IP_INFO *IpSender;
1695 EFI_IP6_MODE_DATA *Ip6ModeData;
1696 EFI_STATUS Status;
1697 EFI_IP6_PROTOCOL *Ip6Protocol;
1698
1699 Ip6ModeData = NULL;
1700
1701 //
1702 // An ICMPv6 error message MUST NOT be originated as A packet destined to
1703 // 1) an IPv6 multicast address 2) The IPv6 Unspecified Address
1704 //
1705 if (NetSession->IpVersion == IP_VERSION_6) {
1706 if (NetIp6IsUnspecifiedAddr (&NetSession->Dest.v6) ||
1707 IP6_IS_MULTICAST (&NetSession->Dest.v6)
1708 )
1709 {
1710 goto EXIT;
1711 }
1712 }
1713
1714 IpSender = IpIoFindSender (&IpIo, NetSession->IpVersion, &NetSession->Dest);
1715
1716 //
1717 // Get the Ipv6 Mode Data.
1718 //
1719 Ip6ModeData = AllocateZeroPool (sizeof (EFI_IP6_MODE_DATA));
1720 ASSERT (Ip6ModeData != NULL);
1721 if (Ip6ModeData == NULL) {
1722 goto EXIT;
1723 }
1724
1725 //
1726 // If not finding the related IpSender use the default IpIo to send out
1727 // the port unreachable ICMP message.
1728 //
1729 if (IpSender == NULL) {
1730 Ip6Protocol = IpIo->Ip.Ip6;
1731 } else {
1732 Ip6Protocol = IpSender->Ip.Ip6;
1733 }
1734
1735 Status = Ip6Protocol->GetModeData (
1736 Ip6Protocol,
1737 Ip6ModeData,
1738 NULL,
1739 NULL
1740 );
1741
1742 if (EFI_ERROR (Status)) {
1743 goto EXIT;
1744 }
1745
1746 //
1747 // The ICMP6 packet length, includes whole invoking packet and ICMP6 error header.
1748 //
1749 Len = NetSession->IpHdrLen +
1750 NTOHS (((EFI_UDP_HEADER *)Udp6Header)->Length) +
1751 sizeof (IP6_ICMP_ERROR_HEAD);
1752
1753 //
1754 // If the ICMP6 packet length larger than IP MTU, adjust its length to MTU.
1755 //
1756 if (Ip6ModeData->MaxPacketSize < Len) {
1757 Len = Ip6ModeData->MaxPacketSize;
1758 }
1759
1760 //
1761 // Allocate buffer for the icmp error message.
1762 //
1763 Packet = NetbufAlloc (Len);
1764 if (Packet == NULL) {
1765 goto EXIT;
1766 }
1767
1768 //
1769 // Allocate space for the IP6_ICMP_ERROR_HEAD.
1770 //
1771 IcmpErrHdr = (IP6_ICMP_ERROR_HEAD *)NetbufAllocSpace (Packet, Len, FALSE);
1772 ASSERT (IcmpErrHdr != NULL);
1773 if (IcmpErrHdr == NULL) {
1774 goto EXIT;
1775 }
1776
1777 //
1778 // Set the required fields for the icmp port unreachable message.
1779 //
1780 IcmpErrHdr->Head.Type = ICMP_V6_DEST_UNREACHABLE;
1781 IcmpErrHdr->Head.Code = ICMP_V6_PORT_UNREACHABLE;
1782 IcmpErrHdr->Head.Checksum = 0;
1783 IcmpErrHdr->Fourth = 0;
1784
1785 //
1786 // Copy as much of invoking Packet as possible without the ICMPv6 packet
1787 // exceeding the minimum Ipv6 MTU. The length of IP6_ICMP_ERROR_HEAD contains
1788 // the length of EFI_IP6_HEADER, so when using the length of IP6_ICMP_ERROR_HEAD
1789 // for pointer movement that fact should be considered.
1790 //
1791 Ptr = (VOID *)&IcmpErrHdr->Head;
1792 Ptr = (UINT8 *)(UINTN)((UINTN)Ptr + sizeof (IP6_ICMP_ERROR_HEAD) - sizeof (EFI_IP6_HEADER));
1793 CopyMem (Ptr, NetSession->IpHdr.Ip6Hdr, NetSession->IpHdrLen);
1794 CopyMem (
1795 Ptr + NetSession->IpHdrLen,
1796 Udp6Header,
1797 Len - NetSession->IpHdrLen - sizeof (IP6_ICMP_ERROR_HEAD) + sizeof (EFI_IP6_HEADER)
1798 );
1799
1800 //
1801 // Set the checksum as zero, and IP6 driver will calculate it with pseudo header.
1802 //
1803 IcmpErrHdr->Head.Checksum = 0;
1804
1805 //
1806 // Fill the override data.
1807 //
1808 Override.Ip6OverrideData.FlowLabel = 0;
1809 Override.Ip6OverrideData.HopLimit = 255;
1810 Override.Ip6OverrideData.Protocol = IP6_ICMP;
1811
1812 //
1813 // Send out this icmp packet.
1814 //
1815 IpIoSend (IpIo, Packet, IpSender, NULL, NULL, &NetSession->Source, &Override);
1816
1817 NetbufFree (Packet);
1818
1819EXIT:
1820 if (Ip6ModeData != NULL) {
1821 FreePool (Ip6ModeData);
1822 }
1823}
1824
1836VOID
1838 IN UDP6_SERVICE_DATA *Udp6Service,
1839 IN UINT8 IcmpError,
1840 IN EFI_NET_SESSION_DATA *NetSession,
1841 IN OUT NET_BUF *Packet
1842 )
1843{
1844 EFI_UDP_HEADER *Udp6Header;
1845 EFI_UDP6_SESSION_DATA Udp6Session;
1846 LIST_ENTRY *Entry;
1847 UDP6_INSTANCE_DATA *Instance;
1848
1849 if (Packet->TotalSize < UDP6_HEADER_SIZE) {
1850 NetbufFree (Packet);
1851 return;
1852 }
1853
1854 Udp6Header = (EFI_UDP_HEADER *)NetbufGetByte (Packet, 0, NULL);
1855 ASSERT (Udp6Header != NULL);
1856 if (Udp6Header == NULL) {
1857 NetbufFree (Packet);
1858 return;
1859 }
1860
1861 IP6_COPY_ADDRESS (&Udp6Session.SourceAddress, &NetSession->Source);
1862 IP6_COPY_ADDRESS (&Udp6Session.DestinationAddress, &NetSession->Dest);
1863
1864 Udp6Session.SourcePort = NTOHS (Udp6Header->DstPort);
1865 Udp6Session.DestinationPort = NTOHS (Udp6Header->SrcPort);
1866
1867 NET_LIST_FOR_EACH (Entry, &Udp6Service->ChildrenList) {
1868 //
1869 // Iterate all the instances.
1870 //
1871 Instance = NET_LIST_USER_STRUCT (Entry, UDP6_INSTANCE_DATA, Link);
1872
1873 if (!Instance->Configured) {
1874 continue;
1875 }
1876
1877 if (Udp6MatchDgram (Instance, &Udp6Session)) {
1878 //
1879 // Translate the Icmp Error code according to the udp spec.
1880 //
1881 Instance->IcmpError = IpIoGetIcmpErrStatus (IcmpError, IP_VERSION_6, NULL, NULL);
1882
1883 if (IcmpError > ICMP_ERR_UNREACH_PORT) {
1884 Instance->IcmpError = EFI_ICMP_ERROR;
1885 }
1886
1887 //
1888 // Notify the instance with the received Icmp Error.
1889 //
1890 Udp6ReportIcmpError (Instance);
1891
1892 break;
1893 }
1894 }
1895
1896 NetbufFree (Packet);
1897}
1898
1905VOID
1907 IN UDP6_INSTANCE_DATA *Instance
1908 )
1909{
1911
1912 if (NetMapIsEmpty (&Instance->RxTokens)) {
1913 //
1914 // There are no receive tokens to deliver the ICMP error.
1915 //
1916 return;
1917 }
1918
1919 if (EFI_ERROR (Instance->IcmpError)) {
1920 //
1921 // Try to get a RxToken from the RxTokens map.
1922 //
1923 Token = (EFI_UDP6_COMPLETION_TOKEN *)NetMapRemoveHead (&Instance->RxTokens, NULL);
1924
1925 if (Token != NULL) {
1926 //
1927 // Report the error through the Token.
1928 //
1929 Token->Status = Instance->IcmpError;
1930 gBS->SignalEvent (Token->Event);
1931
1932 //
1933 // Clear the IcmpError.
1934 //
1935 Instance->IcmpError = EFI_SUCCESS;
1936 }
1937 }
1938}
1939
1947VOID
1948EFIAPI
1950 IN VOID *Context
1951 )
1952{
1953}
1954
1966 IN NET_MAP *Map,
1967 IN VOID *Key
1968 )
1969{
1970 LIST_ENTRY *Entry;
1971 NET_MAP_ITEM *Item;
1972 EFI_IPv6_ADDRESS *Addr;
1973
1974 ASSERT (Map != NULL);
1975 NET_LIST_FOR_EACH (Entry, &Map->Used) {
1976 Item = NET_LIST_USER_STRUCT (Entry, NET_MAP_ITEM, Link);
1977 Addr = (EFI_IPv6_ADDRESS *)Item->Key;
1978 if (EFI_IP6_EQUAL (Addr, Key)) {
1979 return Item;
1980 }
1981 }
1982 return NULL;
1983}
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 AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ICMP_V6_DEST_UNREACHABLE
Definition: Ip6.h:80
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
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
UINT16 EFIAPI NetIp6PseudoHeadChecksum(IN EFI_IPv6_ADDRESS *Src, IN EFI_IPv6_ADDRESS *Dst, IN UINT8 NextHeader, IN UINT32 Len)
Definition: NetBuffer.c:1777
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
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
BOOLEAN EFIAPI NetIp6IsUnspecifiedAddr(IN EFI_IPv6_ADDRESS *Ip6)
Definition: DxeNetLib.c:766
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
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
EFI_STATUS EFIAPI Udp6LeaveGroup(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
Definition: Udp6Impl.c:1074
EFI_STATUS Udp6CreateService(IN UDP6_SERVICE_DATA *Udp6Service, IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ControllerHandle)
Definition: Udp6Impl.c:285
EFI_STATUS Udp6RemoveToken(IN NET_MAP *TokenMap, IN EFI_UDP6_COMPLETION_TOKEN *Token)
Definition: Udp6Impl.c:942
UINTN Udp6EnqueueDgram(IN UDP6_SERVICE_DATA *Udp6Service, IN NET_BUF *Packet, IN EFI_UDP6_RECEIVE_DATA *RxData)
Definition: Udp6Impl.c:1437
VOID Udp6CleanInstance(IN OUT UDP6_INSTANCE_DATA *Instance)
Definition: Udp6Impl.c:507
VOID Udp6InstanceDeliverDgram(IN UDP6_INSTANCE_DATA *Instance)
Definition: Udp6Impl.c:1487
VOID Udp6InitInstance(IN UDP6_SERVICE_DATA *Udp6Service, IN OUT UDP6_INSTANCE_DATA *Instance)
Definition: Udp6Impl.c:465
UINT16 Udp6Checksum(IN NET_BUF *Packet, IN UINT16 HeadSum)
Definition: Udp6Impl.c:916
EFI_STATUS EFIAPI Udp6CancelTokens(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Arg OPTIONAL)
Definition: Udp6Impl.c:1130
VOID Udp6FlushRcvdDgram(IN UDP6_INSTANCE_DATA *Instance)
Definition: Udp6Impl.c:1180
EFI_STATUS Udp6InstanceCancelToken(IN UDP6_INSTANCE_DATA *Instance, IN EFI_UDP6_COMPLETION_TOKEN *Token OPTIONAL)
Definition: Udp6Impl.c:1212
EFI_STATUS Udp6ValidateTxToken(IN UDP6_INSTANCE_DATA *Instance, IN EFI_UDP6_COMPLETION_TOKEN *TxToken)
Definition: Udp6Impl.c:776
EFI_STATUS Udp6Bind(IN LIST_ENTRY *InstanceList, IN EFI_UDP6_CONFIG_DATA *ConfigData)
Definition: Udp6Impl.c:587
NET_MAP_ITEM * Udp6MapMultiCastAddr(IN NET_MAP *Map, IN VOID *Key)
Definition: Udp6Impl.c:1965
VOID Udp6CleanService(IN OUT UDP6_SERVICE_DATA *Udp6Service)
Definition: Udp6Impl.c:380
VOID Udp6SendPortUnreach(IN IP_IO *IpIo, IN EFI_NET_SESSION_DATA *NetSession, IN VOID *Udp6Header)
Definition: Udp6Impl.c:1683
VOID EFIAPI Udp6RecycleRxDataWrap(IN EFI_EVENT Event, IN VOID *Context)
Definition: Udp6Impl.c:1339
VOID EFIAPI Udp6NetVectorExtFree(IN VOID *Context)
Definition: Udp6Impl.c:1949
VOID Udp6ReportIcmpError(IN UDP6_INSTANCE_DATA *Instance)
Definition: Udp6Impl.c:1906
VOID EFIAPI Udp6DgramRcvd(IN EFI_STATUS Status, IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet, IN VOID *Context)
Definition: Udp6Impl.c:1025
VOID Udp6DeliverDgram(IN UDP6_SERVICE_DATA *Udp6Service)
Definition: Udp6Impl.c:1551
VOID EFIAPI Udp6CheckTimeout(IN EFI_EVENT Event, IN VOID *Context)
Definition: Udp6Impl.c:410
BOOLEAN Udp6MatchDgram(IN UDP6_INSTANCE_DATA *Instance, IN EFI_UDP6_SESSION_DATA *Udp6Session)
Definition: Udp6Impl.c:1267
VOID EFIAPI Udp6DgramSent(IN EFI_STATUS Status, IN VOID *Context, IN IP_IO_IP_PROTOCOL Sender, IN VOID *NotifyData)
Definition: Udp6Impl.c:982
BOOLEAN Udp6IsReconfigurable(IN EFI_UDP6_CONFIG_DATA *OldConfigData, IN EFI_UDP6_CONFIG_DATA *NewConfigData)
Definition: Udp6Impl.c:662
VOID Udp6IcmpHandler(IN UDP6_SERVICE_DATA *Udp6Service, IN UINT8 IcmpError, IN EFI_NET_SESSION_DATA *NetSession, IN OUT NET_BUF *Packet)
Definition: Udp6Impl.c:1837
UDP6_RXDATA_WRAP * Udp6WrapRxData(IN UDP6_INSTANCE_DATA *Instance, IN NET_BUF *Packet, IN EFI_UDP6_RECEIVE_DATA *RxData)
Definition: Udp6Impl.c:1380
VOID Udp6BuildIp6ConfigData(IN EFI_UDP6_CONFIG_DATA *Udp6ConfigData, IN OUT EFI_IP6_CONFIG_DATA *Ip6ConfigData)
Definition: Udp6Impl.c:726
BOOLEAN Udp6FindInstanceByPort(IN LIST_ENTRY *InstanceList, IN EFI_IPv6_ADDRESS *Address, IN UINT16 Port)
Definition: Udp6Impl.c:529
EFI_STATUS EFIAPI Udp6TokenExist(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
Definition: Udp6Impl.c:881
VOID Udp6Demultiplex(IN UDP6_SERVICE_DATA *Udp6Service, IN EFI_NET_SESSION_DATA *NetSession, IN NET_BUF *Packet)
Definition: Udp6Impl.c:1586
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
@ TimerPeriodic
Definition: UefiSpec.h:535
UINT8 HopLimit
Hop-Limit override.
Definition: Ip6.h:466
UINT32 FlowLabel
Flow-Label override.
Definition: Ip6.h:467
UINT8 Protocol
Protocol type override.
Definition: Ip6.h:465
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
UINT32 MaxPacketSize
Definition: Ip6.h:315
EFI_UDP6_RECEIVE_DATA * RxData
Definition: Udp6.h:288
EFI_STATUS Status
Definition: Udp6.h:283
UINT16 StationPort
Definition: Udp6.h:168
BOOLEAN AcceptAnyPort
Definition: Udp6.h:126
UINT16 RemotePort
Definition: Udp6.h:182
BOOLEAN AcceptPromiscuous
Definition: Udp6.h:122
EFI_IPv6_ADDRESS RemoteAddress
Definition: Udp6.h:175
UINT32 ReceiveTimeout
Definition: Udp6.h:144
EFI_IPv6_ADDRESS StationAddress
Definition: Udp6.h:161
UINT32 FragmentLength
Length of the fragment data buffer.
Definition: Udp6.h:86
VOID * FragmentBuffer
Pointer to the fragment data buffer.
Definition: Udp6.h:87
UINT32 DataLength
Definition: Udp6.h:237
EFI_UDP6_FRAGMENT_DATA FragmentTable[1]
Definition: Udp6.h:245
EFI_UDP6_SESSION_DATA UdpSession
Definition: Udp6.h:233
EFI_EVENT RecycleSignal
Definition: Udp6.h:228
UINT32 FragmentCount
Definition: Udp6.h:241
EFI_IPv6_ADDRESS DestinationAddress
Definition: Udp6.h:110
UINT16 SourcePort
Definition: Udp6.h:105
EFI_IPv6_ADDRESS SourceAddress
Definition: Udp6.h:100
UINT16 DestinationPort
Definition: Udp6.h:115
EFI_UDP6_FRAGMENT_DATA FragmentTable[1]
Definition: Udp6.h:207
UINT32 FragmentCount
Definition: Udp6.h:203
EFI_UDP6_SESSION_DATA * UdpSessionData
Definition: Udp6.h:195