Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/ArpDxe/ArpImpl.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (22 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/ArpDxe/ArpImpl.c
r85718 r99404 22 22 }; 23 23 24 25 24 /** 26 25 Initialize the instance context data. … … 52 51 } 53 52 54 55 53 /** 56 54 Process the Arp packets received from Mnp, the procedure conforms to RFC826. … … 65 63 EFIAPI 66 64 ArpOnFrameRcvdDpc ( 67 IN VOID 65 IN VOID *Context 68 66 ) 69 67 { … … 120 118 // Convert the byte order of the multi-byte fields. 121 119 // 122 Head = (ARP_HEAD *)RxData->PacketData;120 Head = (ARP_HEAD *)RxData->PacketData; 123 121 Head->HwType = NTOHS (Head->HwType); 124 122 Head->ProtoType = NTOHS (Head->ProtoType); … … 130 128 131 129 if ((Head->HwType != ArpService->SnpMode.IfType) || 132 (Head->HwAddrLen != ArpService->SnpMode.HwAddressSize) || 133 (RxData->ProtocolType != ARP_ETHER_PROTO_TYPE)) { 130 (Head->HwAddrLen != ArpService->SnpMode.HwAddressSize) || 131 (RxData->ProtocolType != ARP_ETHER_PROTO_TYPE)) 132 { 134 133 // 135 134 // The hardware type or the hardware address length doesn't match. … … 183 182 184 183 if ((Instance->Configured) && 185 (Head->ProtoType == ConfigData->SwAddressType) && 186 (Head->ProtoAddrLen == ConfigData->SwAddressLength)) { 184 (Head->ProtoType == ConfigData->SwAddressType) && 185 (Head->ProtoAddrLen == ConfigData->SwAddressLength)) 186 { 187 187 // 188 188 // The protocol type is matched for the received arp packet. … … 193 193 ConfigData->StationAddress, 194 194 ConfigData->SwAddressLength 195 )) { 195 )) 196 { 196 197 // 197 198 // The arp driver has the target address required by the received arp packet. … … 227 228 ArpFillAddressInCacheEntry (CacheEntry, &SenderAddress[Hardware], NULL); 228 229 CacheEntry->DecayTime = CacheEntry->DefaultDecayTime; 229 MergeFlag = TRUE;230 MergeFlag = TRUE; 230 231 } 231 232 … … 305 306 Status = ArpService->Mnp->Receive (ArpService->Mnp, RxToken); 306 307 307 DEBUG_CODE ( 308 if (EFI_ERROR (Status)) { 309 DEBUG ((EFI_D_ERROR, "ArpOnFrameRcvd: ArpService->Mnp->Receive " 310 "failed, %r\n.", Status)); 311 } 312 ); 308 DEBUG_CODE_BEGIN (); 309 if (EFI_ERROR (Status)) { 310 DEBUG (( 311 DEBUG_ERROR, 312 "ArpOnFrameRcvd: ArpService->Mnp->Receive " 313 "failed, %r\n.", 314 Status 315 )); 316 } 317 318 DEBUG_CODE_END (); 313 319 } 314 320 … … 348 354 EFIAPI 349 355 ArpOnFrameSentDpc ( 350 IN VOID 356 IN VOID *Context 351 357 ) 352 358 { … … 359 365 TxData = TxToken->Packet.TxData; 360 366 361 DEBUG_CODE ( 362 if (EFI_ERROR (TxToken->Status)) { 363 DEBUG ((EFI_D_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status)); 364 } 365 ); 367 DEBUG_CODE_BEGIN (); 368 if (EFI_ERROR (TxToken->Status)) { 369 DEBUG ((DEBUG_ERROR, "ArpOnFrameSent: TxToken->Status, %r.\n", TxToken->Status)); 370 } 371 372 DEBUG_CODE_END (); 366 373 367 374 // … … 396 403 QueueDpc (TPL_CALLBACK, ArpOnFrameSentDpc, Context); 397 404 } 398 399 405 400 406 /** … … 450 456 // resend the ARP request. 451 457 // 452 ASSERT (!IsListEmpty (&CacheEntry->UserRequestList));458 ASSERT (!IsListEmpty (&CacheEntry->UserRequestList)); 453 459 454 460 ContextEntry = CacheEntry->UserRequestList.ForwardLink; … … 525 531 } 526 532 527 528 533 /** 529 534 Match the two NET_ARP_ADDRESSes. … … 544 549 545 550 if ((AddressOne->Type != AddressTwo->Type) || 546 (AddressOne->Length != AddressTwo->Length)) { 551 (AddressOne->Length != AddressTwo->Length)) 552 { 547 553 // 548 554 // Either Type or Length doesn't match. … … 552 558 553 559 if ((AddressOne->AddressPtr != NULL) && 554 (CompareMem ( 555 AddressOne->AddressPtr, 556 AddressTwo->AddressPtr, 557 AddressOne->Length 558 ) != 0)) { 560 (CompareMem ( 561 AddressOne->AddressPtr, 562 AddressTwo->AddressPtr, 563 AddressOne->Length 564 ) != 0)) 565 { 559 566 // 560 567 // The address is not the same. … … 565 572 return TRUE; 566 573 } 567 568 574 569 575 /** … … 582 588 ARP_CACHE_ENTRY * 583 589 ArpFindNextCacheEntryInTable ( 584 IN LIST_ENTRY 585 IN LIST_ENTRY 586 IN FIND_OPTYPE 587 IN NET_ARP_ADDRESS 588 IN NET_ARP_ADDRESS 590 IN LIST_ENTRY *CacheTable, 591 IN LIST_ENTRY *StartEntry, 592 IN FIND_OPTYPE FindOpType, 593 IN NET_ARP_ADDRESS *ProtocolAddress OPTIONAL, 594 IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL 589 595 ) 590 596 { … … 637 643 return NULL; 638 644 } 639 640 645 641 646 /** … … 699 704 } 700 705 701 702 706 /** 703 707 Allocate a cache entry and initialize it. … … 735 739 // Init the address pointers to point to the concrete buffer. 736 740 // 737 Address = &CacheEntry->Addresses[Index];741 Address = &CacheEntry->Addresses[Index]; 738 742 Address->AddressPtr = Address->Buffer.ProtoAddress; 739 743 } … … 766 770 } 767 771 768 769 772 /** 770 773 Turn the CacheEntry into the resolved status. … … 798 801 799 802 if (((Instance == NULL) || (Context->Instance == Instance)) && 800 ((UserEvent == NULL) || (Context->UserRequestEvent == UserEvent))) { 803 ((UserEvent == NULL) || (Context->UserRequestEvent == UserEvent))) 804 { 801 805 // 802 806 // Copy the address to the user-provided buffer and notify the user. … … 827 831 } 828 832 829 830 833 /** 831 834 Fill the addresses in the CacheEntry using the information passed in by … … 881 884 } 882 885 } 883 884 886 885 887 /** … … 913 915 914 916 if (ConfigData != NULL) { 915 916 917 if (Instance->Configured) { 917 918 // … … 919 920 // 920 921 if ((OldConfigData->SwAddressType != ConfigData->SwAddressType) || 921 (OldConfigData->SwAddressLength != ConfigData->SwAddressLength) || 922 (CompareMem ( 923 OldConfigData->StationAddress, 924 ConfigData->StationAddress, 925 OldConfigData->SwAddressLength 926 ) != 0)) { 922 (OldConfigData->SwAddressLength != ConfigData->SwAddressLength) || 923 (CompareMem ( 924 OldConfigData->StationAddress, 925 ConfigData->StationAddress, 926 OldConfigData->SwAddressLength 927 ) != 0)) 928 { 927 929 // 928 930 // Deny the unallowed changes. … … 953 955 OldConfigData->StationAddress = AllocatePool (OldConfigData->SwAddressLength); 954 956 if (OldConfigData->StationAddress == NULL) { 955 DEBUG ((EFI_D_ERROR, "ArpConfigInstance: AllocatePool for the StationAddress " 956 "failed.\n")); 957 DEBUG (( 958 DEBUG_ERROR, 959 "ArpConfigInstance: AllocatePool for the StationAddress " 960 "failed.\n" 961 )); 957 962 return EFI_OUT_OF_RESOURCES; 958 963 } … … 977 982 // 978 983 OldConfigData->EntryTimeOut = (ConfigData->EntryTimeOut == 0) ? 979 ARP_DEFAULT_TIMEOUT_VALUE : ConfigData->EntryTimeOut;980 981 OldConfigData->RetryCount 982 ARP_DEFAULT_RETRY_COUNT : ConfigData->RetryCount;984 ARP_DEFAULT_TIMEOUT_VALUE : ConfigData->EntryTimeOut; 985 986 OldConfigData->RetryCount = (ConfigData->RetryCount == 0) ? 987 ARP_DEFAULT_RETRY_COUNT : ConfigData->RetryCount; 983 988 984 989 OldConfigData->RetryTimeOut = (ConfigData->RetryTimeOut == 0) ? 985 ARP_DEFAULT_RETRY_INTERVAL : ConfigData->RetryTimeOut;990 ARP_DEFAULT_RETRY_INTERVAL : ConfigData->RetryTimeOut; 986 991 } else { 987 992 // … … 1006 1011 return EFI_SUCCESS; 1007 1012 } 1008 1009 1013 1010 1014 /** … … 1043 1047 // Allocate memory for the TxToken. 1044 1048 // 1045 TxToken = AllocatePool (sizeof (EFI_MANAGED_NETWORK_COMPLETION_TOKEN));1049 TxToken = AllocatePool (sizeof (EFI_MANAGED_NETWORK_COMPLETION_TOKEN)); 1046 1050 if (TxToken == NULL) { 1047 DEBUG (( EFI_D_ERROR, "ArpSendFrame: Allocate memory for TxToken failed.\n"));1051 DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxToken failed.\n")); 1048 1052 return; 1049 1053 } … … 1064 1068 ); 1065 1069 if (EFI_ERROR (Status)) { 1066 DEBUG (( EFI_D_ERROR, "ArpSendFrame: CreateEvent failed for TxToken->Event.\n"));1070 DEBUG ((DEBUG_ERROR, "ArpSendFrame: CreateEvent failed for TxToken->Event.\n")); 1067 1071 goto CLEAN_EXIT; 1068 1072 } … … 1071 1075 // Allocate memory for the TxData used in the TxToken. 1072 1076 // 1073 TxData = AllocatePool (sizeof (EFI_MANAGED_NETWORK_TRANSMIT_DATA));1077 TxData = AllocatePool (sizeof (EFI_MANAGED_NETWORK_TRANSMIT_DATA)); 1074 1078 if (TxData == NULL) { 1075 DEBUG (( EFI_D_ERROR, "ArpSendFrame: Allocate memory for TxData failed.\n"));1079 DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for TxData failed.\n")); 1076 1080 goto CLEAN_EXIT; 1077 1081 } … … 1092 1096 Packet = AllocatePool (TotalLength); 1093 1097 if (Packet == NULL) { 1094 DEBUG (( EFI_D_ERROR, "ArpSendFrame: Allocate memory for Packet failed.\n"));1098 DEBUG ((DEBUG_ERROR, "ArpSendFrame: Allocate memory for Packet failed.\n")); 1095 1099 ASSERT (Packet != NULL); 1096 1100 } … … 1110 1114 ); 1111 1115 } 1116 1112 1117 TmpPtr += SnpMode->HwAddressSize; 1113 1118 … … 1122 1127 // 1123 1128 *(UINT16 *)TmpPtr = HTONS (ARP_ETHER_PROTO_TYPE); 1124 TmpPtr 1129 TmpPtr += 2; 1125 1130 1126 1131 // 1127 1132 // The ARP Head. 1128 1133 // 1129 ArpHead = (ARP_HEAD *) 1134 ArpHead = (ARP_HEAD *)TmpPtr; 1130 1135 ArpHead->HwType = HTONS ((UINT16)SnpMode->IfType); 1131 1136 ArpHead->ProtoType = HTONS (ConfigData->SwAddressType); … … 1133 1138 ArpHead->ProtoAddrLen = ConfigData->SwAddressLength; 1134 1139 ArpHead->OpCode = HTONS (ArpOpCode); 1135 TmpPtr 1140 TmpPtr += sizeof (ARP_HEAD); 1136 1141 1137 1142 // … … 1173 1178 TxData->ProtocolType = 0; 1174 1179 TxData->DataLength = TotalLength - SnpMode->MediaHeaderSize; 1175 TxData->HeaderLength = (UINT16) 1180 TxData->HeaderLength = (UINT16)SnpMode->MediaHeaderSize; 1176 1181 TxData->FragmentCount = 1; 1177 1182 … … 1190 1195 Status = ArpService->Mnp->Transmit (ArpService->Mnp, TxToken); 1191 1196 if (EFI_ERROR (Status)) { 1192 DEBUG (( EFI_D_ERROR, "Mnp->Transmit failed, %r.\n", Status));1197 DEBUG ((DEBUG_ERROR, "Mnp->Transmit failed, %r.\n", Status)); 1193 1198 goto CLEAN_EXIT; 1194 1199 } … … 1212 1217 FreePool (TxToken); 1213 1218 } 1214 1215 1219 1216 1220 /** … … 1232 1236 UINTN 1233 1237 ArpDeleteCacheEntryInTable ( 1234 IN LIST_ENTRY 1235 IN BOOLEAN 1236 IN UINT16 1237 IN UINT8 1238 IN BOOLEAN 1238 IN LIST_ENTRY *CacheTable, 1239 IN BOOLEAN BySwAddress, 1240 IN UINT16 SwAddressType, 1241 IN UINT8 *AddressBuffer OPTIONAL, 1242 IN BOOLEAN Force 1239 1243 ) 1240 1244 { … … 1262 1266 // 1263 1267 if ((AddressBuffer == NULL) || 1264 (CompareMem ( 1265 AddressBuffer, 1266 CacheEntry->Addresses[Protocol].AddressPtr, 1267 CacheEntry->Addresses[Protocol].Length 1268 ) == 0)) { 1268 (CompareMem ( 1269 AddressBuffer, 1270 CacheEntry->Addresses[Protocol].AddressPtr, 1271 CacheEntry->Addresses[Protocol].Length 1272 ) == 0)) 1273 { 1269 1274 // 1270 1275 // Address matched. … … 1275 1280 } else { 1276 1281 if ((AddressBuffer == NULL) || 1277 (CompareMem ( 1278 AddressBuffer, 1279 CacheEntry->Addresses[Hardware].AddressPtr, 1280 CacheEntry->Addresses[Hardware].Length 1281 ) == 0)) { 1282 (CompareMem ( 1283 AddressBuffer, 1284 CacheEntry->Addresses[Hardware].AddressPtr, 1285 CacheEntry->Addresses[Hardware].Length 1286 ) == 0)) 1287 { 1282 1288 // 1283 1289 // Address matched. … … 1303 1309 return Count; 1304 1310 } 1305 1306 1311 1307 1312 /** … … 1358 1363 } 1359 1364 1360 1361 1365 /** 1362 1366 Cancel the arp request. … … 1393 1397 1394 1398 if ((TargetSwAddress == NULL) || 1395 (CompareMem ( 1396 TargetSwAddress, 1397 CacheEntry->Addresses[Protocol].AddressPtr, 1398 CacheEntry->Addresses[Protocol].Length 1399 ) == 0)) { 1399 (CompareMem ( 1400 TargetSwAddress, 1401 CacheEntry->Addresses[Protocol].AddressPtr, 1402 CacheEntry->Addresses[Protocol].Length 1403 ) == 0)) 1404 { 1400 1405 // 1401 1406 // This request entry matches the TargetSwAddress or all requests are to be … … 1416 1421 return Count; 1417 1422 } 1418 1419 1423 1420 1424 /** … … 1573 1577 Status = EFI_SUCCESS; 1574 1578 1575 FoundCount = (UINT32) 1579 FoundCount = (UINT32)NetMapGetCount (&FoundEntries); 1576 1580 if (FoundCount == 0) { 1577 1581 Status = EFI_NOT_FOUND; … … 1583 1587 // 1584 1588 FoundEntryLength = (((sizeof (EFI_ARP_FIND_DATA) + Instance->ConfigData.SwAddressLength + 1585 ArpService->SnpMode.HwAddressSize) + 3) & ~(0x3));1589 ArpService->SnpMode.HwAddressSize) + 3) & ~(0x3)); 1586 1590 1587 1591 if (EntryLength != NULL) { … … 1605 1609 FindData = AllocatePool (FoundCount * FoundEntryLength); 1606 1610 if (FindData == NULL) { 1607 DEBUG (( EFI_D_ERROR, "ArpFindCacheEntry: Failed to allocate memory.\n"));1611 DEBUG ((DEBUG_ERROR, "ArpFindCacheEntry: Failed to allocate memory.\n")); 1608 1612 Status = EFI_OUT_OF_RESOURCES; 1609 1613 goto CLEAN_EXIT; … … 1665 1669 return Status; 1666 1670 } 1667
Note:
See TracChangeset
for help on using the changeset viewer.