37#define NIC_ITEM_CONFIG_SIZE (sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE)
38#define DEFAULT_ZERO_START ((UINTN) ~0)
148 &gEfiRngAlgorithmSp80090Ctr256Guid,
149 &gEfiRngAlgorithmSp80090Hmac256Guid,
150 &gEfiRngAlgorithmSp80090Hash256Guid,
151 &gEfiRngAlgorithmArmRndr,
152 &gEfiRngAlgorithmRaw,
155#define SECURE_HASH_ALGORITHMS_SIZE (sizeof (mSecureHashAlgorithms) / sizeof (EFI_GUID *))
180 Status =
gBS->LocateHandleBuffer (
182 &gEfiSimpleNetworkProtocolGuid,
188 if (EFI_ERROR (Status) || (HandleCount == 0)) {
197 for (Index = 0; Index < HandleCount; Index++) {
198 Status =
gBS->HandleProtocol (
200 &gEfiSimpleNetworkProtocolGuid,
205 (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) &&
206 (Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN))
246 ASSERT (Packet !=
NULL);
251 return EFI_DEVICE_ERROR;
260 Status =
gBS->CreateEvent (
268 if (EFI_ERROR (Status)) {
272 Status =
gBS->SetTimer (TimeoutEvent,
TimerRelative, NET_SYSLOG_TX_TIMEOUT);
274 if (EFI_ERROR (Status)) {
282 Status = Snp->Transmit (Snp, 0, Length, Packet,
NULL,
NULL,
NULL);
284 if ((Status !=
EFI_SUCCESS) && (Status != EFI_NOT_READY)) {
285 Status = EFI_DEVICE_ERROR;
300 Snp->GetStatus (Snp,
NULL, (VOID **)&TxBuf);
302 if (!EFI_ERROR (
gBS->CheckEvent (TimeoutEvent))) {
303 Status = EFI_TIMEOUT;
306 }
while (TxBuf ==
NULL);
308 if ((Status ==
EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {
322 gBS->CloseEvent (TimeoutEvent);
365 CopyMem (Ether->DstMac, mSyslogDstMac, NET_ETHER_ADDR_LEN);
366 ZeroMem (Ether->SrcMac, NET_ETHER_ADDR_LEN);
368 Ether->EtherType = HTONS (0x0800);
381 Ip4->Id = (UINT16)mSyslogPacketSeq;
384 Ip4->Protocol = 0x11;
386 Ip4->Src = mSyslogSrcIp;
387 Ip4->Dst = mSyslogDstIp;
396 Udp4->SrcPort = HTONS (514);
397 Udp4->DstPort = HTONS (514);
407 Pri = ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7);
408 Status =
gRT->GetTime (&Time,
NULL);
409 if (EFI_ERROR (Status)) {
420 "<%d> %a %d %d:%d:%d ",
422 mMonthName[Time.Month-1],
432 "Tiano %a: %a (Line: %d File: %a)",
444 Udp4->Length = HTONS ((UINT16)Len);
447 Ip4->TotalLen = HTONS ((UINT16)Len);
489 ASSERT (Format !=
NULL);
539 if ((Message ==
NULL) || (File ==
NULL) || (Module ==
NULL)) {
540 return EFI_INVALID_PARAMETER;
543 if (Level > mNetDebugLevelMax) {
555 if (Packet ==
NULL) {
556 Status = EFI_OUT_OF_RESOURCES;
569 NET_SYSLOG_PACKET_LEN,
573 Status = EFI_DEVICE_ERROR;
606 for (Index = 0; Index <= IP4_MASK_MAX; Index++) {
607 if (NetMask == gIp4AllMasks[Index]) {
649 ByteOne = (UINT8)(Addr >> 24);
651 if ((ByteOne & 0x80) == 0) {
652 return IP4_ADDR_CLASSA;
653 }
else if ((ByteOne & 0xC0) == 0x80) {
654 return IP4_ADDR_CLASSB;
655 }
else if ((ByteOne & 0xE0) == 0xC0) {
656 return IP4_ADDR_CLASSC;
657 }
else if ((ByteOne & 0xF0) == 0xE0) {
658 return IP4_ADDR_CLASSD;
660 return IP4_ADDR_CLASSE;
690 ASSERT (NetMask != 0);
692 if ((Ip == 0) || IP4_IS_LOCAL_BROADCAST (Ip)) {
697 ASSERT ((MaskLength >= 0) && (MaskLength <= IP4_MASK_NUM));
698 if (MaskLength < 31) {
699 if (((Ip &~NetMask) == ~NetMask) || ((Ip &~NetMask) == 0)) {
732 ASSERT (Ip6 !=
NULL);
734 if (Ip6->Addr[0] == 0xFF) {
738 for (Index = 0; Index < 15; Index++) {
739 if (Ip6->Addr[Index] != 0) {
744 Byte = Ip6->Addr[Index];
746 if ((Byte == 0x0) || (Byte == 0x1)) {
772 ASSERT (Ip6 !=
NULL);
774 for (Index = 0; Index < 16; Index++) {
775 if (Ip6->Addr[Index] != 0) {
802 ASSERT (Ip6 !=
NULL);
804 if (Ip6->Addr[0] != 0xFE) {
808 if (Ip6->Addr[1] != 0x80) {
812 for (Index = 2; Index < 8; Index++) {
813 if (Ip6->Addr[Index] != 0) {
847 ASSERT ((Ip1 !=
NULL) && (Ip2 !=
NULL) && (PrefixLength < IP6_PREFIX_MAX));
849 if (PrefixLength == 0) {
853 Byte = (UINT8)(PrefixLength / 8);
854 Bit = (UINT8)(PrefixLength % 8);
861 Mask = (UINT8)(0xFF << (8 - Bit));
868 if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
899 ASSERT (Ip6 !=
NULL);
901 CopyMem (&High, Ip6,
sizeof (UINT64));
902 CopyMem (&Low, &Ip6->Addr[8], sizeof (UINT64));
907 CopyMem (Ip6, &Low,
sizeof (UINT64));
908 CopyMem (&Ip6->Addr[8], &High, sizeof (UINT64));
935 UINTN AlgorithmIndex;
937 if ((Output ==
NULL) || (OutputLength == 0)) {
938 return EFI_INVALID_PARAMETER;
941 Status =
gBS->LocateProtocol (&gEfiRngProtocolGuid,
NULL, (VOID **)&RngProtocol);
942 if (EFI_ERROR (Status)) {
943 DEBUG ((DEBUG_ERROR,
"Failed to locate EFI_RNG_PROTOCOL: %r\n", Status));
948 if (
PcdGetBool (PcdEnforceSecureRngAlgorithms)) {
949 for (AlgorithmIndex = 0; AlgorithmIndex < SECURE_HASH_ALGORITHMS_SIZE; AlgorithmIndex++) {
950 Status = RngProtocol->GetRNG (RngProtocol, mSecureHashAlgorithms[AlgorithmIndex], OutputLength, (UINT8 *)Output);
951 if (!EFI_ERROR (Status)) {
956 }
else if (Status == EFI_UNSUPPORTED) {
960 DEBUG ((DEBUG_VERBOSE,
"Failed to generate random data using secure algorithm %d: %r\n", AlgorithmIndex, Status));
970 DEBUG ((DEBUG_ERROR,
"Failed to generate random data using secure algorithm %d: %r\n", AlgorithmIndex, Status));
980 DEBUG ((DEBUG_ERROR,
"Failed to generate random data, no supported secure algorithm found\n"));
988 Status = RngProtocol->GetRNG (RngProtocol,
NULL, OutputLength, (UINT8 *)Output);
989 if (EFI_ERROR (Status)) {
990 DEBUG ((DEBUG_ERROR,
"%a failed to generate random data: %r\n", __func__, Status));
1039 ASSERT (Buf !=
NULL);
1041 CopyMem (&Value, Buf,
sizeof (UINT32));
1042 return NTOHL (Value);
1064 ASSERT (Buf !=
NULL);
1066 Data = HTONL (Data);
1067 CopyMem (Buf, &Data,
sizeof (UINT32));
1096 ASSERT (Head !=
NULL);
1102 First = Head->ForwardLink;
1103 Head->ForwardLink = First->ForwardLink;
1104 First->ForwardLink->BackLink = Head;
1140 ASSERT (Head !=
NULL);
1146 Last = Head->BackLink;
1147 Head->BackLink = Last->BackLink;
1148 Last->BackLink->ForwardLink = Head;
1177 ASSERT (PrevEntry !=
NULL && NewEntry !=
NULL);
1179 NewEntry->BackLink = PrevEntry;
1180 NewEntry->ForwardLink = PrevEntry->ForwardLink;
1181 PrevEntry->ForwardLink->BackLink = NewEntry;
1182 PrevEntry->ForwardLink = NewEntry;
1204 ASSERT (PostEntry !=
NULL && NewEntry !=
NULL);
1206 NewEntry->ForwardLink = PostEntry;
1207 NewEntry->BackLink = PostEntry->BackLink;
1208 PostEntry->BackLink->ForwardLink = NewEntry;
1209 PostEntry->BackLink = NewEntry;
1239 IN VOID *Context OPTIONAL,
1243 UINTN PreviousLength;
1249 if ((List ==
NULL) || (CallBack ==
NULL)) {
1250 return EFI_INVALID_PARAMETER;
1255 PreviousLength = Length;
1257 while (!
IsNull (List, Entry)) {
1258 Status = CallBack (Entry, Context);
1259 if (EFI_ERROR (Status)) {
1268 for (Ptr = List->ForwardLink; Ptr != List; Ptr = Ptr->ForwardLink) {
1281 for (Length = 0, Ptr = List->ForwardLink; Ptr != List; Length++, Ptr = Ptr->ForwardLink) {
1283 }
while (Length != PreviousLength);
1285 if (ListLength !=
NULL) {
1286 *ListLength = Length;
1314 if ((NumberOfChildren == 0) || (ChildHandleBuffer ==
NULL)) {
1318 for (Index = 0; Index < NumberOfChildren; Index++) {
1319 if (Handle == ChildHandleBuffer[Index]) {
1347 ASSERT (Map !=
NULL);
1376 ASSERT (Map !=
NULL);
1378 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Map->Used) {
1379 Item = NET_LIST_USER_STRUCT (Entry,
NET_MAP_ITEM, Link);
1384 gBS->FreePool (Item);
1387 ASSERT ((Map->Count == 0) &&
IsListEmpty (&Map->Used));
1389 NET_LIST_FOR_EACH_SAFE (Entry, Next, &Map->Recycled) {
1390 Item = NET_LIST_USER_STRUCT (Entry,
NET_MAP_ITEM, Link);
1393 gBS->FreePool (Item);
1417 ASSERT (Map !=
NULL);
1418 return (BOOLEAN)(Map->Count == 0);
1437 ASSERT (Map !=
NULL);
1466 ASSERT (Map !=
NULL);
1468 Head = &Map->Recycled;
1471 for (Index = 0; Index < NET_MAP_INCREAMENT; Index++) {
1515 IN VOID *Value OPTIONAL
1520 ASSERT (Map !=
NULL && Key !=
NULL);
1525 return EFI_OUT_OF_RESOURCES;
1529 Item->Value = Value;
1559 IN VOID *Value OPTIONAL
1564 ASSERT (Map !=
NULL && Key !=
NULL);
1569 return EFI_OUT_OF_RESOURCES;
1573 Item->Value = Value;
1601 ASSERT (Map !=
NULL && Item !=
NULL);
1603 NET_LIST_FOR_EACH (ListEntry, &Map->Used) {
1604 if (ListEntry == &Item->Link) {
1637 ASSERT (Map !=
NULL && Key !=
NULL);
1639 NET_LIST_FOR_EACH (Entry, &Map->Used) {
1640 Item = NET_LIST_USER_STRUCT (Entry,
NET_MAP_ITEM, Link);
1642 if (Item->Key == Key) {
1674 OUT VOID **Value OPTIONAL
1677 ASSERT ((Map !=
NULL) && (Item !=
NULL));
1684 if (Value !=
NULL) {
1685 *Value = Item->Value;
1712 OUT VOID **Value OPTIONAL
1728 if (Value !=
NULL) {
1729 *Value = Item->Value;
1756 OUT VOID **Value OPTIONAL
1772 if (Value !=
NULL) {
1773 *Value = Item->Value;
1802 IN NET_MAP_CALLBACK CallBack,
1803 IN VOID *Arg OPTIONAL
1812 ASSERT ((Map !=
NULL) && (CallBack !=
NULL));
1820 NET_LIST_FOR_EACH_SAFE (Entry, Next, Head) {
1821 Item = NET_LIST_USER_STRUCT (Entry,
NET_MAP_ITEM, Link);
1822 Result = CallBack (Map, Item, Arg);
1824 if (EFI_ERROR (Result)) {
1852 UINTN DeviceHandleCount;
1864 Status =
gBS->LocateHandleBuffer (
1872 if (EFI_ERROR (Status)) {
1876 for (Index = 0; Index < DeviceHandleCount; Index++) {
1877 Status =
gBS->HandleProtocol (
1878 DeviceHandleBuffer[Index],
1879 &gEfiDriverBindingProtocolGuid,
1880 (VOID **)&DriverBinding
1882 if (EFI_ERROR (Status)) {
1886 if (DriverBinding->ImageHandle != ImageHandle) {
1894 for (Index2 = 0; Index2 < DeviceHandleCount; Index2++) {
1895 Status =
gBS->DisconnectController (
1896 DeviceHandleBuffer[Index2],
1897 DriverBinding->DriverBindingHandle,
1905 gBS->UninstallProtocolInterface (
1906 DriverBinding->DriverBindingHandle,
1907 &gEfiDriverBindingProtocolGuid,
1911 Status =
gBS->HandleProtocol (
1912 DeviceHandleBuffer[Index],
1913 &gEfiComponentNameProtocolGuid,
1914 (VOID **)&ComponentName
1916 if (!EFI_ERROR (Status)) {
1917 gBS->UninstallProtocolInterface (
1918 DriverBinding->DriverBindingHandle,
1919 &gEfiComponentNameProtocolGuid,
1924 Status =
gBS->HandleProtocol (
1925 DeviceHandleBuffer[Index],
1926 &gEfiComponentName2ProtocolGuid,
1927 (VOID **)&ComponentName2
1929 if (!EFI_ERROR (Status)) {
1930 gBS->UninstallProtocolInterface (
1931 DriverBinding->DriverBindingHandle,
1932 &gEfiComponentName2ProtocolGuid,
1941 if (DeviceHandleBuffer !=
NULL) {
1942 gBS->FreePool (DeviceHandleBuffer);
1977 ASSERT ((ServiceBindingGuid !=
NULL) && (ChildHandle !=
NULL));
1982 Status =
gBS->OpenProtocol (
1988 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1991 if (EFI_ERROR (Status)) {
1998 Status = Service->CreateChild (Service, ChildHandle);
2030 ASSERT (ServiceBindingGuid !=
NULL);
2035 Status =
gBS->OpenProtocol (
2041 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2044 if (EFI_ERROR (Status)) {
2051 Status = Service->DestroyChild (Service, ChildHandle);
2087 Status =
gBS->HandleProtocol (ServiceHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&SnpInstance);
2088 if (!EFI_ERROR (Status)) {
2093 return ServiceHandle;
2100 if (DevicePath ==
NULL) {
2105 Status =
gBS->LocateDevicePath (&gEfiSimpleNetworkProtocolGuid, &DevicePath, &SnpHandle);
2106 if (EFI_ERROR (Status)) {
2113 Status =
gBS->HandleProtocol (SnpHandle, &gEfiSimpleNetworkProtocolGuid, (VOID **)&SnpInstance);
2114 if (!EFI_ERROR (Status)) {
2148 if (DevicePath ==
NULL) {
2192 if (ParentDevicePath ==
NULL) {
2200 VlanNode.
VlanId = VlanId;
2205 if (VlanDevicePath ==
NULL) {
2213 DevicePath = VlanDevicePath;
2214 gBS->LocateDevicePath (
2215 &gEfiDevicePathProtocolGuid,
2266 ASSERT (MacAddress !=
NULL);
2267 ASSERT (AddressSize !=
NULL);
2274 if (SnpHandle !=
NULL) {
2278 SnpMode = Snp->
Mode;
2283 MnpChildHandle =
NULL;
2284 Status =
gBS->HandleProtocol (
2286 &gEfiManagedNetworkServiceBindingProtocolGuid,
2289 if (EFI_ERROR (Status)) {
2296 Status = MnpSb->CreateChild (MnpSb, &MnpChildHandle);
2297 if (EFI_ERROR (Status)) {
2304 Status =
gBS->HandleProtocol (
2306 &gEfiManagedNetworkProtocolGuid,
2309 if (EFI_ERROR (Status)) {
2310 MnpSb->DestroyChild (MnpSb, MnpChildHandle);
2317 Status = Mnp->GetModeData (Mnp,
NULL, &SnpModeData);
2318 if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
2319 MnpSb->DestroyChild (MnpSb, MnpChildHandle);
2323 SnpMode = &SnpModeData;
2328 MnpSb->DestroyChild (MnpSb, MnpChildHandle);
2366 OUT CHAR16 **MacString
2372 UINTN HwAddressSize;
2378 ASSERT (MacString !=
NULL);
2384 if (EFI_ERROR (Status)) {
2393 BufferSize = (2 * HwAddressSize + 5 + 1) *
sizeof (CHAR16);
2395 if (String ==
NULL) {
2396 return EFI_OUT_OF_RESOURCES;
2399 *MacString = String;
2404 HwAddress = &MacAddress.Addr[0];
2405 for (Index = 0; Index < HwAddressSize; Index++) {
2408 BufferSize - ((
UINTN)String - (
UINTN)*MacString),
2409 PREFIX_ZERO | RADIX_HEX,
2413 String +=
StrnLenS (String, (BufferSize - ((
UINTN)String - (
UINTN)*MacString)) /
sizeof (CHAR16));
2424 BufferSize - ((
UINTN)String - (
UINTN)*MacString),
2425 PREFIX_ZERO | RADIX_HEX,
2429 String +=
StrnLenS (String, (BufferSize - ((
UINTN)String - (
UINTN)*MacString)) /
sizeof (CHAR16));
2474 OUT BOOLEAN *MediaPresent
2480 UINT32 InterruptStatus;
2483 UINT32 MCastFilterCount;
2484 UINT32 EnableFilterBits;
2485 UINT32 DisableFilterBits;
2486 BOOLEAN ResetMCastFilters;
2488 ASSERT (MediaPresent !=
NULL);
2495 if (SnpHandle ==
NULL) {
2496 return EFI_INVALID_PARAMETER;
2503 return EFI_UNSUPPORTED;
2509 Status = Snp->GetStatus (Snp, &InterruptStatus,
NULL);
2510 if (EFI_ERROR (Status)) {
2518 *MediaPresent =
TRUE;
2528 if (OldState >= EfiSimpleNetworkMaxState) {
2529 return EFI_DEVICE_ERROR;
2534 if (OldState == EfiSimpleNetworkInitialized) {
2545 ResetMCastFilters =
TRUE;
2547 if (MCastFilterCount != 0) {
2552 ASSERT (MCastFilter !=
NULL);
2553 if (MCastFilter ==
NULL) {
2554 Status = EFI_OUT_OF_RESOURCES;
2558 ResetMCastFilters =
FALSE;
2564 Status = Snp->Shutdown (Snp);
2565 if (!EFI_ERROR (Status)) {
2566 Status = Snp->Stop (Snp);
2569 if (EFI_ERROR (Status)) {
2576 Status = Snp->Start (Snp);
2577 if (!EFI_ERROR (Status)) {
2578 Status = Snp->Initialize (Snp, 0, 0);
2581 if (EFI_ERROR (Status)) {
2593 Status = Snp->ReceiveFilters (
2602 if (MCastFilter !=
NULL) {
2612 if (OldState == EfiSimpleNetworkStopped) {
2616 Status = Snp->Start (Snp);
2617 if (EFI_ERROR (Status)) {
2625 Status = Snp->Initialize (Snp, 0, 0);
2626 if (EFI_ERROR (Status)) {
2627 Status = EFI_DEVICE_ERROR;
2639 Snp->Shutdown (Snp);
2642 if (OldState == EfiSimpleNetworkStopped) {
2649 if (MCastFilter !=
NULL) {
2694 BOOLEAN MediaPresent;
2698 UINT64 TimeRemained;
2700 if (MediaState ==
NULL) {
2701 return EFI_INVALID_PARAMETER;
2712 if (SnpHandle ==
NULL) {
2713 return EFI_INVALID_PARAMETER;
2716 Status =
gBS->HandleProtocol (
2718 &gEfiAdapterInformationProtocolGuid,
2721 if (EFI_ERROR (Status)) {
2722 MediaPresent =
TRUE;
2724 if (!EFI_ERROR (Status)) {
2728 *MediaState = EFI_NO_MEDIA;
2738 Status = Aip->GetInformation (
2740 &gEfiAdapterInfoMediaStateGuid,
2741 (VOID **)&MediaInfo,
2744 if (!EFI_ERROR (Status)) {
2747 if ((*MediaState != EFI_NOT_READY) || (Timeout < MEDIA_STATE_DETECT_TIME_INTERVAL)) {
2751 if (MediaInfo !=
NULL) {
2755 if (Status == EFI_UNSUPPORTED) {
2759 MediaPresent =
TRUE;
2761 if (!EFI_ERROR (Status)) {
2765 *MediaState = EFI_NO_MEDIA;
2780 TimeRemained = Timeout;
2781 Status =
gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK,
NULL,
NULL, &Timer);
2782 if (EFI_ERROR (Status)) {
2783 return EFI_DEVICE_ERROR;
2787 Status =
gBS->SetTimer (
2790 MEDIA_STATE_DETECT_TIME_INTERVAL
2792 if (EFI_ERROR (Status)) {
2793 gBS->CloseEvent (Timer);
2794 return EFI_DEVICE_ERROR;
2798 TimerStatus =
gBS->CheckEvent (Timer);
2799 if (!EFI_ERROR (TimerStatus)) {
2800 TimeRemained -= MEDIA_STATE_DETECT_TIME_INTERVAL;
2801 Status = Aip->GetInformation (
2803 &gEfiAdapterInfoMediaStateGuid,
2804 (VOID **)&MediaInfo,
2807 if (!EFI_ERROR (Status)) {
2808 *MediaState = MediaInfo->MediaState;
2811 if (MediaInfo !=
NULL) {
2815 gBS->CloseEvent (Timer);
2819 }
while (TimerStatus == EFI_NOT_READY);
2820 }
while (*MediaState == EFI_NOT_READY && TimeRemained >= MEDIA_STATE_DETECT_TIME_INTERVAL);
2822 gBS->CloseEvent (Timer);
2823 if ((*MediaState == EFI_NOT_READY) && (TimeRemained < MEDIA_STATE_DETECT_TIME_INTERVAL)) {
2865 Status =
gBS->HandleProtocol (Controller, &gEfiIp4Config2ProtocolGuid, (VOID **)&Ip4Config2);
2866 if (EFI_ERROR (Status)) {
2871 if (EFI_ERROR (Status)) {
2906 IN IP4_ADDR LocalIp,
2907 IN UINT16 LocalPort,
2908 IN IP4_ADDR RemoteIp,
2909 IN UINT16 RemotePort,
2911 IN BOOLEAN UseDefaultAddress
2914 ASSERT (Node !=
NULL);
2923 Node->LocalPort = LocalPort;
2924 Node->RemotePort = RemotePort;
2926 Node->Protocol = Protocol;
2928 if (!UseDefaultAddress) {
2929 Node->StaticIpAddress =
TRUE;
2940 Node->SubnetMask.Addr[3] = 0;
2969 IN UINT16 LocalPort,
2971 IN UINT16 RemotePort,
2975 ASSERT (Node !=
NULL && LocalIp !=
NULL && RemoteIp !=
NULL);
2984 Node->LocalPort = LocalPort;
2985 Node->RemotePort = RemotePort;
2987 Node->Protocol = Protocol;
2993 Node->IpAddressOrigin = 0;
2994 Node->PrefixLength = IP6_PREFIX_LENGTH;
3030 ASSERT (ProtocolGuid !=
NULL);
3032 Status =
gBS->OpenProtocolInformation (
3039 if (EFI_ERROR (Status)) {
3045 for (Index = 0; Index < OpenCount; Index++) {
3046 if ((OpenBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
3047 Handle = OpenBuffer[Index].ControllerHandle;
3052 gBS->FreePool (OpenBuffer);
3073 RETURN_STATUS Status;
3078 return EFI_INVALID_PARAMETER;
3102 RETURN_STATUS Status;
3107 return EFI_INVALID_PARAMETER;
3130 RETURN_STATUS Status;
3135 return EFI_INVALID_PARAMETER;
3159 RETURN_STATUS Status;
3164 return EFI_INVALID_PARAMETER;
3188 OUT UINT8 *PrefixLength
3191 RETURN_STATUS Status;
3196 return EFI_INVALID_PARAMETER;
3226 UINTN LongestZerosStart;
3227 UINTN LongestZerosLength;
3228 UINTN CurrentZerosStart;
3229 UINTN CurrentZerosLength;
3230 CHAR16 Buffer[
sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
3233 if ((Ip6Address ==
NULL) || (String ==
NULL) || (StringSize == 0)) {
3234 return EFI_INVALID_PARAMETER;
3240 ZeroMem (Ip6Addr,
sizeof (Ip6Addr));
3241 for (Index = 0; Index < 16; Index++) {
3242 Ip6Addr[Index / 2] |= (Ip6Address->Addr[Index] << ((1 - (Index % 2)) << 3));
3248 CurrentZerosStart = DEFAULT_ZERO_START;
3249 CurrentZerosLength = 0;
3250 LongestZerosStart = DEFAULT_ZERO_START;
3251 LongestZerosLength = 0;
3252 for (Index = 0; Index < 8; Index++) {
3253 if (Ip6Addr[Index] == 0) {
3254 if (CurrentZerosStart == DEFAULT_ZERO_START) {
3255 CurrentZerosStart = Index;
3256 CurrentZerosLength = 1;
3258 CurrentZerosLength++;
3261 if (CurrentZerosStart != DEFAULT_ZERO_START) {
3262 if ((CurrentZerosLength > 2) && ((LongestZerosStart == (DEFAULT_ZERO_START)) || (CurrentZerosLength > LongestZerosLength))) {
3263 LongestZerosStart = CurrentZerosStart;
3264 LongestZerosLength = CurrentZerosLength;
3267 CurrentZerosStart = DEFAULT_ZERO_START;
3268 CurrentZerosLength = 0;
3273 if ((CurrentZerosStart != DEFAULT_ZERO_START) && (CurrentZerosLength > 2)) {
3274 if ((LongestZerosStart == DEFAULT_ZERO_START) || (LongestZerosLength < CurrentZerosLength)) {
3275 LongestZerosStart = CurrentZerosStart;
3276 LongestZerosLength = CurrentZerosLength;
3281 for (Index = 0; Index < 8; Index++) {
3282 if ((LongestZerosStart != DEFAULT_ZERO_START) && (Index >= LongestZerosStart) && (Index < LongestZerosStart + LongestZerosLength)) {
3283 if (Index == LongestZerosStart) {
3297 if ((LongestZerosStart != DEFAULT_ZERO_START) && (LongestZerosStart + LongestZerosLength == 8)) {
3303 if ((
UINTN)Ptr - (
UINTN)Buffer > StringSize) {
3304 return EFI_BUFFER_TOO_SMALL;
3307 StrCpyS (String, StringSize /
sizeof (CHAR16), Buffer);
3336 ASSERT (SystemGuid !=
NULL);
3340 if (!(EFI_ERROR (Status) || (Smbios30Table ==
NULL))) {
3342 SmbiosEnd.Raw = (UINT8 *)(
UINTN)(Smbios30Table->TableAddress + Smbios30Table->TableMaximumSize);
3345 if (EFI_ERROR (Status) || (SmbiosTable ==
NULL)) {
3346 return EFI_NOT_FOUND;
3350 SmbiosEnd.Raw = (UINT8 *)((
UINTN)SmbiosTable->TableAddress + SmbiosTable->TableLength);
3354 if (Smbios.Hdr->Type == 1) {
3355 if (Smbios.Hdr->Length < 0x19) {
3359 return EFI_NOT_FOUND;
3379 String = (CHAR8 *)(Smbios.Raw + Smbios.Hdr->Length);
3389 for ( ; *String != 0; String++) {
3392 if (*(UINT8 *)++String == 0) {
3396 Smbios.Raw = (UINT8 *)++String;
3400 }
while (Smbios.Raw < SmbiosEnd.Raw);
3402 return EFI_NOT_FOUND;
3425 IN CHAR16 *DomainName
3429 UINTN QueryNameSize;
3435 ASSERT (DomainName !=
NULL);
3445 QueryNameSize =
StrLen (DomainName) + 2;
3447 if (QueryNameSize > DNS_MAX_NAME_SIZE) {
3452 if (QueryName ==
NULL) {
3459 for (Index = 0; DomainName[Index] != 0; Index++) {
3460 *Tail = (CHAR8)DomainName[Index];
3462 *Header = (CHAR8)Len;
3472 *Header = (CHAR8)Len;
BOOLEAN EFIAPI IsNull(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
LIST_ENTRY *EFIAPI InsertHeadList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
UINTN EFIAPI StrnLenS(IN CONST CHAR16 *String, IN UINTN MaxSize)
RETURN_STATUS EFIAPI StrToIpv6Address(IN CONST CHAR16 *String, OUT CHAR16 **EndPointer OPTIONAL, OUT IPv6_ADDRESS *Address, OUT UINT8 *PrefixLength OPTIONAL)
RETURN_STATUS EFIAPI StrToIpv4Address(IN CONST CHAR16 *String, OUT CHAR16 **EndPointer OPTIONAL, OUT IPv4_ADDRESS *Address, OUT UINT8 *PrefixLength OPTIONAL)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
RETURN_STATUS EFIAPI AsciiStrToIpv4Address(IN CONST CHAR8 *String, OUT CHAR8 **EndPointer OPTIONAL, OUT IPv4_ADDRESS *Address, OUT UINT8 *PrefixLength OPTIONAL)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI AsciiStrToIpv6Address(IN CONST CHAR8 *String, OUT CHAR8 **EndPointer OPTIONAL, OUT IPv6_ADDRESS *Address, OUT UINT8 *PrefixLength OPTIONAL)
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define MESSAGING_DEVICE_PATH
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
VOID *EFIAPI NetMapRemoveTail(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
LIST_ENTRY *EFIAPI NetListRemoveHead(IN OUT LIST_ENTRY *Head)
LIST_ENTRY *EFIAPI NetListRemoveTail(IN OUT LIST_ENTRY *Head)
EFI_STATUS EFIAPI NetLibGetMacAddress(IN EFI_HANDLE ServiceHandle, OUT EFI_MAC_ADDRESS *MacAddress, OUT UINTN *AddressSize)
EFI_STATUS EFIAPI NetLibGetMacString(IN EFI_HANDLE ServiceHandle, IN EFI_HANDLE ImageHandle OPTIONAL, OUT CHAR16 **MacString)
BOOLEAN EFIAPI NetIp4IsUnicast(IN IP4_ADDR Ip, IN IP4_ADDR NetMask)
BOOLEAN EFIAPI NetIp6IsValidUnicast(IN EFI_IPv6_ADDRESS *Ip6)
VOID EFIAPI NetMapClean(IN OUT NET_MAP *Map)
EFI_HANDLE EFIAPI NetLibGetVlanHandle(IN EFI_HANDLE ControllerHandle, IN UINT16 VlanId)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
NET_MAP_ITEM * NetMapAllocItem(IN OUT NET_MAP *Map)
BOOLEAN NetItemInMap(IN NET_MAP *Map, IN NET_MAP_ITEM *Item)
VOID EFIAPI NetLibCreateIPv6DPathNode(IN OUT IPv6_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN EFI_IPv6_ADDRESS *LocalIp, IN UINT16 LocalPort, IN EFI_IPv6_ADDRESS *RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol)
EFI_STATUS EFIAPI NetLibAsciiStrToIp4(IN CONST CHAR8 *String, OUT EFI_IPv4_ADDRESS *Ip4Address)
CHAR8 *EFIAPI NetLibCreateDnsQName(IN CHAR16 *DomainName)
BOOLEAN EFIAPI NetIp6IsNetEqual(EFI_IPv6_ADDRESS *Ip1, EFI_IPv6_ADDRESS *Ip2, UINT8 PrefixLength)
NET_MAP_ITEM *EFIAPI NetMapFindKey(IN NET_MAP *Map, IN VOID *Key)
EFI_STATUS EFIAPI NetMapInsertHead(IN OUT NET_MAP *Map, IN VOID *Key, IN VOID *Value OPTIONAL)
BOOLEAN EFIAPI NetIp6IsLinkLocalAddr(IN EFI_IPv6_ADDRESS *Ip6)
EFI_IPv6_ADDRESS *EFIAPI Ip6Swap128(EFI_IPv6_ADDRESS *Ip6)
VOID EFIAPI NetListInsertAfter(IN OUT LIST_ENTRY *PrevEntry, IN OUT LIST_ENTRY *NewEntry)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
VOID EFIAPI NetMapInit(IN OUT NET_MAP *Map)
EFI_STATUS EFIAPI NetLibDetectMedia(IN EFI_HANDLE ServiceHandle, OUT BOOLEAN *MediaPresent)
UINT32 EFIAPI NetGetUint32(IN UINT8 *Buf)
CHAR8 *EFIAPI NetDebugASPrint(IN CHAR8 *Format,...)
VOID EFIAPI NetLibCreateIPv4DPathNode(IN OUT IPv4_DEVICE_PATH *Node, IN EFI_HANDLE Controller, IN IP4_ADDR LocalIp, IN UINT16 LocalPort, IN IP4_ADDR RemoteIp, IN UINT16 RemotePort, IN UINT16 Protocol, IN BOOLEAN UseDefaultAddress)
EFI_STATUS EFIAPI NetLibDefaultUnload(IN EFI_HANDLE ImageHandle)
BOOLEAN EFIAPI NetIsInHandleBuffer(IN EFI_HANDLE Handle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer OPTIONAL)
BOOLEAN EFIAPI NetIp6IsUnspecifiedAddr(IN EFI_IPv6_ADDRESS *Ip6)
VOID EFIAPI NetPutUint32(IN OUT UINT8 *Buf, IN UINT32 Data)
EFI_STATUS EFIAPI NetLibDetectMediaWaitTimeout(IN EFI_HANDLE ServiceHandle, IN UINT64 Timeout, OUT EFI_STATUS *MediaState)
EFI_STATUS EFIAPI NetLibGetSystemGuid(OUT EFI_GUID *SystemGuid)
EFI_STATUS EFIAPI NetLibStrToIp4(IN CONST CHAR16 *String, OUT EFI_IPv4_ADDRESS *Ip4Address)
INTN EFIAPI NetGetIpClass(IN IP4_ADDR Addr)
EFI_HANDLE EFIAPI NetLibGetSnpHandle(IN EFI_HANDLE ServiceHandle, OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL)
EFI_STATUS EFIAPI NetLibStrToIp6andPrefix(IN CONST CHAR16 *String, OUT EFI_IPv6_ADDRESS *Ip6Address, OUT UINT8 *PrefixLength)
BOOLEAN EFIAPI NetMapIsEmpty(IN NET_MAP *Map)
EFI_STATUS EFIAPI NetLibAsciiStrToIp6(IN CONST CHAR8 *String, OUT EFI_IPv6_ADDRESS *Ip6Address)
INTN EFIAPI NetGetMaskLength(IN IP4_ADDR NetMask)
EFI_STATUS EFIAPI NetLibStrToIp6(IN CONST CHAR16 *String, OUT EFI_IPv6_ADDRESS *Ip6Address)
EFI_STATUS EFIAPI PseudoRandomU32(OUT UINT32 *Output)
EFI_SIMPLE_NETWORK_PROTOCOL * SyslogLocateSnp(VOID)
EFI_STATUS EFIAPI NetLibIp6ToStr(IN EFI_IPv6_ADDRESS *Ip6Address, OUT CHAR16 *String, IN UINTN StringSize)
VOID *EFIAPI NetMapRemoveItem(IN OUT NET_MAP *Map, IN OUT NET_MAP_ITEM *Item, OUT VOID **Value OPTIONAL)
VOID *EFIAPI NetMapRemoveHead(IN OUT NET_MAP *Map, OUT VOID **Value OPTIONAL)
BOOLEAN NetLibDefaultAddressIsStatic(IN EFI_HANDLE Controller)
EFI_HANDLE EFIAPI NetLibGetNicHandle(IN EFI_HANDLE Controller, IN EFI_GUID *ProtocolGuid)
EFI_STATUS EFIAPI NetMapInsertTail(IN OUT NET_MAP *Map, IN VOID *Key, IN VOID *Value OPTIONAL)
EFI_STATUS SyslogSendPacket(IN CHAR8 *Packet, IN UINT32 Length)
EFI_STATUS EFIAPI NetDestroyLinkList(IN LIST_ENTRY *List, IN NET_DESTROY_LINK_LIST_CALLBACK CallBack, IN VOID *Context OPTIONAL, OUT UINTN *ListLength OPTIONAL)
UINT32 SyslogBuildPacket(IN UINT32 Level, IN UINT8 *Module, IN UINT8 *File, IN UINT32 Line, IN UINT8 *Message, IN UINT32 BufLen, OUT CHAR8 *Buf)
EFI_STATUS EFIAPI NetMapIterate(IN NET_MAP *Map, IN NET_MAP_CALLBACK CallBack, IN VOID *Arg OPTIONAL)
VOID EFIAPI NetListInsertBefore(IN OUT LIST_ENTRY *PostEntry, IN OUT LIST_ENTRY *NewEntry)
EFI_STATUS EFIAPI PseudoRandom(OUT VOID *Output, IN UINTN OutputLength)
UINT16 EFIAPI NetLibGetVlanId(IN EFI_HANDLE ServiceHandle)
EFI_STATUS EFIAPI NetDebugOutput(IN UINT32 Level, IN UINT8 *Module, IN UINT8 *File, IN UINT32 Line, IN UINT8 *Message)
UINTN EFIAPI NetMapGetCount(IN NET_MAP *Map)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
@ Ip4Config2DataTypePolicy
RETURN_STATUS EFIAPI UnicodeValueToStringS(IN OUT CHAR16 *Buffer, IN UINTN BufferSize, IN UINTN Flags, IN INT64 Value, IN UINTN Width)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
UINTN EFIAPI AsciiVSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define RETURN_ERROR(StatusCode)
#define VA_START(Marker, Parameter)
#define GLOBAL_REMOVE_IF_UNREFERENCED
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define DEBUG_CODE(Expression)
UINT16 EFIAPI NetblockChecksum(IN UINT8 *Bulk, IN UINT32 Len)
EFI_STATUS(EFIAPI * NET_DESTROY_LINK_LIST_CALLBACK)(IN LIST_ENTRY *Entry, IN VOID *Context OPTIONAL)
#define PcdGetBool(TokenName)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
VOID EFIAPI Exit(IN EFI_STATUS Status)
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
EFI_SIMPLE_NETWORK_MODE * Mode
EFI_MAC_ADDRESS CurrentAddress
EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT]
BOOLEAN MediaPresentSupported
UINT32 ReceiveFilterSetting