27 if ((Event ==
NULL) || (Context ==
NULL)) {
31 *((BOOLEAN *)Context) =
TRUE;
49 if (Context ==
NULL) {
54 HttpInstance = Wrap->HttpInstance;
56 if (!HttpInstance->LocalAddressIsIPv6) {
58 gBS->SignalEvent (Wrap->HttpToken->
Event);
63 if (Wrap->TcpWrap.Tx4Token.Packet.
TxData->FragmentTable[0].FragmentBuffer !=
NULL) {
64 FreePool (Wrap->TcpWrap.Tx4Token.Packet.
TxData->FragmentTable[0].FragmentBuffer);
72 gBS->SignalEvent (Wrap->HttpToken->
Event);
86 Wrap->TcpWrap.IsTxDone =
TRUE;
133 if (Context ==
NULL) {
138 HttpInstance = Wrap->HttpInstance;
139 UsingIpv6 = HttpInstance->LocalAddressIsIPv6;
148 gBS->SignalEvent (Wrap->HttpToken->
Event);
150 Item =
NetMapFindKey (&HttpInstance->RxTokens, Wrap->HttpToken);
165 DEBUG ((DEBUG_ERROR,
"HttpTcpReceiveNotifyDpc: %r!\n", Wrap->TcpWrap.Rx4Token.
CompletionToken.Status));
167 gBS->SignalEvent (Wrap->HttpToken->
Event);
169 Item =
NetMapFindKey (&HttpInstance->RxTokens, Wrap->HttpToken);
184 ASSERT (HttpInstance->MsgParser !=
NULL);
188 Length = (
UINTN)Wrap->TcpWrap.Rx4Data.FragmentTable[0].FragmentLength;
194 HttpInstance->CallbackData.Wrap = (VOID *)Wrap;
195 HttpInstance->CallbackData.ParseData = Wrap->HttpToken->
Message->
Body;
196 HttpInstance->CallbackData.ParseDataLength = Length;
202 HttpInstance->MsgParser,
206 if (EFI_ERROR (Status)) {
215 HttpInstance->MsgParser =
NULL;
219 ASSERT (HttpInstance->CacheBody ==
NULL);
223 if (HttpInstance->NextMsg !=
NULL) {
227 if (HttpInstance->CacheLen != 0) {
229 if (HttpInstance->CacheBody ==
NULL) {
233 CopyMem (HttpInstance->CacheBody, HttpInstance->NextMsg, HttpInstance->CacheLen);
234 HttpInstance->NextMsg = HttpInstance->CacheBody;
235 HttpInstance->CacheOffset = 0;
239 Item =
NetMapFindKey (&Wrap->HttpInstance->RxTokens, Wrap->HttpToken);
244 Wrap->TcpWrap.IsRxDone =
TRUE;
251 gBS->SignalEvent (Wrap->HttpToken->
Event);
298 if (!HttpInstance->LocalAddressIsIPv6) {
302 Status =
gBS->CreateEvent (
306 &HttpInstance->IsTcp4ConnDone,
307 &HttpInstance->Tcp4ConnToken.CompletionToken.Event
309 if (EFI_ERROR (Status)) {
316 Status =
gBS->CreateEvent (
320 &HttpInstance->IsTcp4CloseDone,
321 &HttpInstance->Tcp4CloseToken.CompletionToken.Event
323 if (EFI_ERROR (Status)) {
330 Status =
gBS->CreateEvent (
334 &HttpInstance->IsTcp6ConnDone,
335 &HttpInstance->Tcp6ConnToken.CompletionToken.Event
337 if (EFI_ERROR (Status)) {
344 Status =
gBS->CreateEvent (
348 &HttpInstance->IsTcp6CloseDone,
349 &HttpInstance->Tcp6CloseToken.CompletionToken.Event
351 if (EFI_ERROR (Status)) {
378 ASSERT (HttpInstance !=
NULL);
380 if (HttpInstance->LocalAddressIsIPv6) {
381 if (
NULL != HttpInstance->Tcp6ConnToken.CompletionToken.Event) {
382 gBS->CloseEvent (HttpInstance->Tcp6ConnToken.CompletionToken.Event);
383 HttpInstance->Tcp6ConnToken.CompletionToken.Event =
NULL;
386 if (
NULL != HttpInstance->Tcp6CloseToken.CompletionToken.Event) {
387 gBS->CloseEvent (HttpInstance->Tcp6CloseToken.CompletionToken.Event);
388 HttpInstance->Tcp6CloseToken.CompletionToken.Event =
NULL;
391 if (
NULL != HttpInstance->Tcp4ConnToken.CompletionToken.Event) {
392 gBS->CloseEvent (HttpInstance->Tcp4ConnToken.CompletionToken.Event);
393 HttpInstance->Tcp4ConnToken.CompletionToken.Event =
NULL;
396 if (
NULL != HttpInstance->Tcp4CloseToken.CompletionToken.Event) {
397 gBS->CloseEvent (HttpInstance->Tcp4CloseToken.CompletionToken.Event);
398 HttpInstance->Tcp4CloseToken.CompletionToken.Event =
NULL;
421 HttpInstance = Wrap->HttpInstance;
422 TcpWrap = &Wrap->TcpWrap;
424 if (!HttpInstance->LocalAddressIsIPv6) {
425 Status =
gBS->CreateEvent (
432 if (EFI_ERROR (Status)) {
436 TcpWrap->Tx4Data.Push =
TRUE;
437 TcpWrap->Tx4Data.Urgent =
FALSE;
438 TcpWrap->Tx4Data.FragmentCount = 1;
439 TcpWrap->Tx4Token.Packet.
TxData = &Wrap->TcpWrap.Tx4Data;
442 Status =
gBS->CreateEvent (
449 if (EFI_ERROR (Status)) {
456 TcpWrap->Tx6Token.Packet.
TxData = &Wrap->TcpWrap.Tx6Data;
479 if (!HttpInstance->LocalAddressIsIPv6) {
480 Status =
gBS->CreateEvent (
484 &HttpInstance->IsRxDone,
485 &HttpInstance->Rx4Token.CompletionToken.Event
487 if (EFI_ERROR (Status)) {
491 HttpInstance->Rx4Data.FragmentCount = 1;
492 HttpInstance->Rx4Token.Packet.RxData = &HttpInstance->Rx4Data;
493 HttpInstance->Rx4Token.CompletionToken.Status = EFI_NOT_READY;
495 Status =
gBS->CreateEvent (
499 &HttpInstance->IsRxDone,
500 &HttpInstance->Rx6Token.CompletionToken.Event
502 if (EFI_ERROR (Status)) {
506 HttpInstance->Rx6Data.FragmentCount = 1;
507 HttpInstance->Rx6Token.Packet.RxData = &HttpInstance->Rx6Data;
508 HttpInstance->Rx6Token.CompletionToken.Status = EFI_NOT_READY;
532 HttpInstance = Wrap->HttpInstance;
533 TcpWrap = &Wrap->TcpWrap;
534 if (!HttpInstance->LocalAddressIsIPv6) {
535 Status =
gBS->CreateEvent (
542 if (EFI_ERROR (Status)) {
546 TcpWrap->Rx4Data.FragmentCount = 1;
547 TcpWrap->Rx4Token.Packet.
RxData = &Wrap->TcpWrap.Rx4Data;
550 Status =
gBS->CreateEvent (
557 if (EFI_ERROR (Status)) {
562 TcpWrap->Rx6Token.Packet.
RxData = &Wrap->TcpWrap.Rx6Data;
582 ASSERT (Wrap !=
NULL);
583 HttpInstance = Wrap->HttpInstance;
585 if (HttpInstance->LocalAddressIsIPv6) {
586 if (Wrap->TcpWrap.Rx6Token.CompletionToken.Event !=
NULL) {
587 gBS->CloseEvent (Wrap->TcpWrap.Rx6Token.CompletionToken.Event);
595 if (Wrap->TcpWrap.Rx4Token.CompletionToken.Event !=
NULL) {
596 gBS->CloseEvent (Wrap->TcpWrap.Rx4Token.CompletionToken.Event);
626 ASSERT (HttpInstance !=
NULL);
627 UsingIpv6 = IpVersion;
634 HttpInstance->Service->ControllerHandle,
635 HttpInstance->Service->Ip4DriverBindingHandle,
636 &gEfiTcp4ServiceBindingProtocolGuid,
637 &HttpInstance->Tcp4ChildHandle
640 if (EFI_ERROR (Status)) {
644 Status =
gBS->OpenProtocol (
645 HttpInstance->Tcp4ChildHandle,
646 &gEfiTcp4ProtocolGuid,
648 HttpInstance->Service->Ip4DriverBindingHandle,
649 HttpInstance->Service->ControllerHandle,
650 EFI_OPEN_PROTOCOL_BY_DRIVER
653 if (EFI_ERROR (Status)) {
657 Status =
gBS->OpenProtocol (
658 HttpInstance->Tcp4ChildHandle,
659 &gEfiTcp4ProtocolGuid,
660 (VOID **)&HttpInstance->Tcp4,
661 HttpInstance->Service->Ip4DriverBindingHandle,
662 HttpInstance->Handle,
663 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
665 if (EFI_ERROR (Status)) {
669 Status =
gBS->OpenProtocol (
670 HttpInstance->Service->Tcp4ChildHandle,
671 &gEfiTcp4ProtocolGuid,
673 HttpInstance->Service->Ip4DriverBindingHandle,
674 HttpInstance->Handle,
675 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
677 if (EFI_ERROR (Status)) {
685 HttpInstance->Service->ControllerHandle,
686 HttpInstance->Service->Ip6DriverBindingHandle,
687 &gEfiTcp6ServiceBindingProtocolGuid,
688 &HttpInstance->Tcp6ChildHandle
691 if (EFI_ERROR (Status)) {
695 Status =
gBS->OpenProtocol (
696 HttpInstance->Tcp6ChildHandle,
697 &gEfiTcp6ProtocolGuid,
699 HttpInstance->Service->Ip6DriverBindingHandle,
700 HttpInstance->Service->ControllerHandle,
701 EFI_OPEN_PROTOCOL_BY_DRIVER
704 if (EFI_ERROR (Status)) {
708 Status =
gBS->OpenProtocol (
709 HttpInstance->Tcp6ChildHandle,
710 &gEfiTcp6ProtocolGuid,
711 (VOID **)&HttpInstance->Tcp6,
712 HttpInstance->Service->Ip6DriverBindingHandle,
713 HttpInstance->Handle,
714 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
717 if (EFI_ERROR (Status)) {
721 Status =
gBS->OpenProtocol (
722 HttpInstance->Service->Tcp6ChildHandle,
723 &gEfiTcp6ProtocolGuid,
725 HttpInstance->Service->Ip6DriverBindingHandle,
726 HttpInstance->Handle,
727 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
730 if (EFI_ERROR (Status)) {
736 if (HttpInstance->Url ==
NULL) {
737 Status = EFI_OUT_OF_RESOURCES;
741 HttpInstance->UrlLen = HTTP_URL_BUFFER_LEN;
746 if (HttpInstance->Tcp4ChildHandle !=
NULL) {
748 HttpInstance->Tcp4ChildHandle,
749 &gEfiTcp4ProtocolGuid,
750 HttpInstance->Service->Ip4DriverBindingHandle,
751 HttpInstance->Service->ControllerHandle
755 HttpInstance->Tcp4ChildHandle,
756 &gEfiTcp4ProtocolGuid,
757 HttpInstance->Service->Ip4DriverBindingHandle,
762 HttpInstance->Service->ControllerHandle,
763 HttpInstance->Service->Ip4DriverBindingHandle,
764 &gEfiTcp4ServiceBindingProtocolGuid,
765 HttpInstance->Tcp4ChildHandle
769 if (HttpInstance->Service->Tcp4ChildHandle !=
NULL) {
771 HttpInstance->Service->Tcp4ChildHandle,
772 &gEfiTcp4ProtocolGuid,
773 HttpInstance->Service->Ip4DriverBindingHandle,
778 if (HttpInstance->Tcp6ChildHandle !=
NULL) {
780 HttpInstance->Tcp6ChildHandle,
781 &gEfiTcp6ProtocolGuid,
782 HttpInstance->Service->Ip6DriverBindingHandle,
783 HttpInstance->Service->ControllerHandle
787 HttpInstance->Tcp6ChildHandle,
788 &gEfiTcp6ProtocolGuid,
789 HttpInstance->Service->Ip6DriverBindingHandle,
794 HttpInstance->Service->ControllerHandle,
795 HttpInstance->Service->Ip6DriverBindingHandle,
796 &gEfiTcp6ServiceBindingProtocolGuid,
797 HttpInstance->Tcp6ChildHandle
801 if (HttpInstance->Service->Tcp6ChildHandle !=
NULL) {
803 HttpInstance->Service->Tcp6ChildHandle,
804 &gEfiTcp6ProtocolGuid,
805 HttpInstance->Service->Ip6DriverBindingHandle,
810 return EFI_UNSUPPORTED;
828 if (HttpInstance->TimeoutEvent !=
NULL) {
829 gBS->CloseEvent (HttpInstance->TimeoutEvent);
830 HttpInstance->TimeoutEvent =
NULL;
833 if (HttpInstance->CacheBody !=
NULL) {
835 HttpInstance->CacheBody =
NULL;
836 HttpInstance->NextMsg =
NULL;
839 if (HttpInstance->RemoteHost !=
NULL) {
840 FreePool (HttpInstance->RemoteHost);
841 HttpInstance->RemoteHost =
NULL;
844 if (HttpInstance->MsgParser !=
NULL) {
846 HttpInstance->MsgParser =
NULL;
849 if (HttpInstance->Url !=
NULL) {
851 HttpInstance->Url =
NULL;
852 HttpInstance->UrlLen = 0;
858 if ((HttpInstance->TlsSb !=
NULL) && HttpInstance->TlsAlreadyCreated) {
862 HttpInstance->TlsSb->DestroyChild (HttpInstance->TlsSb, HttpInstance->Handle);
863 HttpInstance->TlsAlreadyCreated =
FALSE;
866 if (HttpInstance->Tcp4ChildHandle !=
NULL) {
868 HttpInstance->Tcp4ChildHandle,
869 &gEfiTcp4ProtocolGuid,
870 HttpInstance->Service->Ip4DriverBindingHandle,
871 HttpInstance->Service->ControllerHandle
875 HttpInstance->Tcp4ChildHandle,
876 &gEfiTcp4ProtocolGuid,
877 HttpInstance->Service->Ip4DriverBindingHandle,
882 HttpInstance->Service->ControllerHandle,
883 HttpInstance->Service->Ip4DriverBindingHandle,
884 &gEfiTcp4ServiceBindingProtocolGuid,
885 HttpInstance->Tcp4ChildHandle
889 if (HttpInstance->Service->Tcp4ChildHandle !=
NULL) {
891 HttpInstance->Service->Tcp4ChildHandle,
892 &gEfiTcp4ProtocolGuid,
893 HttpInstance->Service->Ip4DriverBindingHandle,
898 if (HttpInstance->Tcp6ChildHandle !=
NULL) {
900 HttpInstance->Tcp6ChildHandle,
901 &gEfiTcp6ProtocolGuid,
902 HttpInstance->Service->Ip6DriverBindingHandle,
903 HttpInstance->Service->ControllerHandle
907 HttpInstance->Tcp6ChildHandle,
908 &gEfiTcp6ProtocolGuid,
909 HttpInstance->Service->Ip6DriverBindingHandle,
914 HttpInstance->Service->ControllerHandle,
915 HttpInstance->Service->Ip6DriverBindingHandle,
916 &gEfiTcp6ServiceBindingProtocolGuid,
917 HttpInstance->Tcp6ChildHandle
921 if (HttpInstance->Service->Tcp6ChildHandle !=
NULL) {
923 HttpInstance->Service->Tcp6ChildHandle,
924 &gEfiTcp6ProtocolGuid,
925 HttpInstance->Service->Ip6DriverBindingHandle,
952 if (!HttpInstance->LocalAddressIsIPv6) {
953 HttpInstance->IsTcp4ConnDone =
FALSE;
954 HttpInstance->Tcp4ConnToken.CompletionToken.Status = EFI_NOT_READY;
955 Status = HttpInstance->Tcp4->Connect (HttpInstance->Tcp4, &HttpInstance->Tcp4ConnToken);
957 if (EFI_ERROR (Status)) {
958 DEBUG ((DEBUG_ERROR,
"HttpCreateConnection: Tcp4->Connect() = %r\n", Status));
962 while (!HttpInstance->IsTcp4ConnDone) {
963 HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
966 Status = HttpInstance->Tcp4ConnToken.CompletionToken.Status;
968 HttpInstance->IsTcp6ConnDone =
FALSE;
969 HttpInstance->Tcp6ConnToken.CompletionToken.Status = EFI_NOT_READY;
970 Status = HttpInstance->Tcp6->Connect (HttpInstance->Tcp6, &HttpInstance->Tcp6ConnToken);
972 if (EFI_ERROR (Status)) {
973 DEBUG ((DEBUG_ERROR,
"HttpCreateConnection: Tcp6->Connect() = %r\n", Status));
977 while (!HttpInstance->IsTcp6ConnDone) {
978 HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
981 Status = HttpInstance->Tcp6ConnToken.CompletionToken.Status;
984 if (!EFI_ERROR (Status)) {
985 HttpInstance->State = HTTP_STATE_TCP_CONNECTED;
1007 if (HttpInstance->State == HTTP_STATE_TCP_CONNECTED) {
1008 if (HttpInstance->LocalAddressIsIPv6) {
1009 HttpInstance->Tcp6CloseToken.AbortOnClose =
TRUE;
1010 HttpInstance->IsTcp6CloseDone =
FALSE;
1011 Status = HttpInstance->Tcp6->Close (HttpInstance->Tcp6, &HttpInstance->Tcp6CloseToken);
1012 if (EFI_ERROR (Status)) {
1016 while (!HttpInstance->IsTcp6CloseDone) {
1017 HttpInstance->Tcp6->Poll (HttpInstance->Tcp6);
1020 HttpInstance->Tcp4CloseToken.AbortOnClose =
TRUE;
1021 HttpInstance->IsTcp4CloseDone =
FALSE;
1022 Status = HttpInstance->Tcp4->Close (HttpInstance->Tcp4, &HttpInstance->Tcp4CloseToken);
1023 if (EFI_ERROR (Status)) {
1027 while (!HttpInstance->IsTcp4CloseDone) {
1028 HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
1033 HttpInstance->State = HTTP_STATE_TCP_CLOSED;
1058 ASSERT (HttpInstance !=
NULL);
1060 Tcp4CfgData = &HttpInstance->Tcp4CfgData;
1063 Tcp4CfgData->TypeOfService = HTTP_TOS_DEAULT;
1064 Tcp4CfgData->TimeToLive = HTTP_TTL_DEAULT;
1065 Tcp4CfgData->ControlOption = &HttpInstance->Tcp4Option;
1067 Tcp4AP = &Tcp4CfgData->AccessPoint;
1068 Tcp4AP->UseDefaultAddress = HttpInstance->IPv4Node.UseDefaultAddress;
1069 if (!Tcp4AP->UseDefaultAddress) {
1070 IP4_COPY_ADDRESS (&Tcp4AP->StationAddress, &HttpInstance->IPv4Node.LocalAddress);
1071 IP4_COPY_ADDRESS (&Tcp4AP->SubnetMask, &HttpInstance->IPv4Node.LocalSubnet);
1074 Tcp4AP->StationPort = HttpInstance->IPv4Node.LocalPort;
1075 Tcp4AP->RemotePort = HttpInstance->RemotePort;
1076 Tcp4AP->ActiveFlag =
TRUE;
1077 IP4_COPY_ADDRESS (&Tcp4AP->RemoteAddress, &HttpInstance->RemoteAddr);
1079 Tcp4Option = Tcp4CfgData->ControlOption;
1080 Tcp4Option->ReceiveBufferSize = HTTP_BUFFER_SIZE_DEAULT;
1081 Tcp4Option->SendBufferSize = HTTP_BUFFER_SIZE_DEAULT;
1082 Tcp4Option->MaxSynBackLog = HTTP_MAX_SYN_BACK_LOG;
1083 Tcp4Option->ConnectionTimeout = HTTP_CONNECTION_TIMEOUT;
1084 Tcp4Option->DataRetries = HTTP_DATA_RETRIES;
1085 Tcp4Option->FinTimeout = HTTP_FIN_TIMEOUT;
1086 Tcp4Option->KeepAliveProbes = HTTP_KEEP_ALIVE_PROBES;
1087 Tcp4Option->KeepAliveTime = HTTP_KEEP_ALIVE_TIME;
1088 Tcp4Option->KeepAliveInterval = HTTP_KEEP_ALIVE_INTERVAL;
1089 Tcp4Option->EnableNagle =
TRUE;
1090 Tcp4Option->EnableWindowScaling =
TRUE;
1091 Tcp4CfgData->ControlOption = Tcp4Option;
1093 if ((HttpInstance->State == HTTP_STATE_TCP_CONNECTED) ||
1094 (HttpInstance->State == HTTP_STATE_TCP_CLOSED))
1096 Status = HttpInstance->Tcp4->Configure (HttpInstance->Tcp4,
NULL);
1097 if (EFI_ERROR (Status)) {
1098 DEBUG ((DEBUG_ERROR,
"HttpConfigureTcp4(NULL) - %r\n", Status));
1102 HttpInstance->State = HTTP_STATE_TCP_UNCONFIGED;
1105 Status = HttpInstance->Tcp4->Configure (HttpInstance->Tcp4, Tcp4CfgData);
1106 if (EFI_ERROR (Status)) {
1107 DEBUG ((DEBUG_ERROR,
"HttpConfigureTcp4 - %r\n", Status));
1112 if (EFI_ERROR (Status)) {
1117 if (EFI_ERROR (Status)) {
1121 HttpInstance->State = HTTP_STATE_TCP_CONFIGED;
1147 ASSERT (HttpInstance !=
NULL);
1149 Tcp6CfgData = &HttpInstance->Tcp6CfgData;
1158 Tcp6Ap->
StationPort = HttpInstance->Ipv6Node.LocalPort;
1159 Tcp6Ap->
RemotePort = HttpInstance->RemotePort;
1160 IP6_COPY_ADDRESS (&Tcp6Ap->
StationAddress, &HttpInstance->Ipv6Node.LocalAddress);
1161 IP6_COPY_ADDRESS (&Tcp6Ap->
RemoteAddress, &HttpInstance->RemoteIpv6Addr);
1176 if ((HttpInstance->State == HTTP_STATE_TCP_CONNECTED) ||
1177 (HttpInstance->State == HTTP_STATE_TCP_CLOSED))
1179 Status = HttpInstance->Tcp6->Configure (HttpInstance->Tcp6,
NULL);
1180 if (EFI_ERROR (Status)) {
1181 DEBUG ((DEBUG_ERROR,
"HttpConfigureTcp6(NULL) - %r\n", Status));
1185 HttpInstance->State = HTTP_STATE_TCP_UNCONFIGED;
1188 Status = HttpInstance->Tcp6->Configure (HttpInstance->Tcp6, Tcp6CfgData);
1189 if (EFI_ERROR (Status)) {
1190 DEBUG ((DEBUG_ERROR,
"HttpConfigureTcp6 - %r\n", Status));
1195 if (EFI_ERROR (Status)) {
1200 if (EFI_ERROR (Status)) {
1204 HttpInstance->State = HTTP_STATE_TCP_CONFIGED;
1228 if ((HttpInstance->State < HTTP_STATE_TCP_CONFIGED) || (HttpInstance->Tcp4 ==
NULL)) {
1229 return EFI_NOT_READY;
1232 Status = HttpInstance->Tcp4->GetModeData (
1240 if (EFI_ERROR (Status)) {
1241 DEBUG ((DEBUG_ERROR,
"Tcp4 GetModeData fail - %x\n", Status));
1245 if (Tcp4State == Tcp4StateEstablished) {
1247 }
else if (Tcp4State > Tcp4StateEstablished ) {
1252 if (EFI_ERROR (Status)) {
1253 DEBUG ((DEBUG_ERROR,
"Tcp4 Connection fail - %x\n", Status));
1260 if (HttpInstance->UseHttps) {
1261 if (HttpInstance->TimeoutEvent ==
NULL) {
1265 Status =
gBS->CreateEvent (
1270 &HttpInstance->TimeoutEvent
1272 if (EFI_ERROR (Status)) {
1281 Status =
gBS->SetTimer (HttpInstance->TimeoutEvent,
TimerRelative, HTTP_CONNECTION_TIMEOUT * TICKS_PER_SECOND);
1282 if (EFI_ERROR (Status)) {
1292 if (EFI_ERROR (Status)) {
1320 if ((HttpInstance->State < HTTP_STATE_TCP_CONFIGED) || (HttpInstance->Tcp6 ==
NULL)) {
1321 return EFI_NOT_READY;
1324 Status = HttpInstance->Tcp6->GetModeData (
1333 if (EFI_ERROR (Status)) {
1334 DEBUG ((DEBUG_ERROR,
"Tcp6 GetModeData fail - %x\n", Status));
1338 if (Tcp6State == Tcp6StateEstablished) {
1340 }
else if (Tcp6State > Tcp6StateEstablished ) {
1345 if (EFI_ERROR (Status)) {
1346 DEBUG ((DEBUG_ERROR,
"Tcp6 Connection fail - %x\n", Status));
1353 if (HttpInstance->UseHttps) {
1354 if (HttpInstance->TimeoutEvent ==
NULL) {
1358 Status =
gBS->CreateEvent (
1363 &HttpInstance->TimeoutEvent
1365 if (EFI_ERROR (Status)) {
1374 Status =
gBS->SetTimer (HttpInstance->TimeoutEvent,
TimerRelative, HTTP_CONNECTION_TIMEOUT * TICKS_PER_SECOND);
1375 if (EFI_ERROR (Status)) {
1385 if (EFI_ERROR (Status)) {
1410 IN BOOLEAN Configure,
1411 IN BOOLEAN TlsConfigure
1416 ASSERT (HttpInstance !=
NULL);
1424 if (EFI_ERROR (Status)) {
1429 if (!HttpInstance->LocalAddressIsIPv6) {
1435 if (EFI_ERROR (Status)) {
1444 if (EFI_ERROR (Status)) {
1453 if (EFI_ERROR (Status)) {
1462 if (EFI_ERROR (Status)) {
1505 TempFragment.Len = 0;
1506 TempFragment.Bulk =
NULL;
1508 Fragment.Bulk =
NULL;
1515 if (HttpInstance->UseHttps) {
1519 TlsRecord =
AllocateZeroPool (TLS_RECORD_HEADER_LENGTH + TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH);
1520 if (TlsRecord ==
NULL) {
1521 Status = EFI_OUT_OF_RESOURCES;
1528 RecordCount = TxStringLen / TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH + 1;
1529 Fragment.Bulk =
AllocateZeroPool (RecordCount * (TLS_RECORD_HEADER_LENGTH + TLS_CIPHERTEXT_RECORD_MAX_PAYLOAD_LENGTH));
1530 if (Fragment.Bulk ==
NULL) {
1531 Status = EFI_OUT_OF_RESOURCES;
1538 RemainingLen = TxStringLen;
1539 while (RemainingLen != 0) {
1540 PayloadSize = (UINT16)
MIN (TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH, RemainingLen);
1543 ((
TLS_RECORD_HEADER *)TlsRecord)->Version.Major = HttpInstance->TlsConfigData.Version.Major;
1544 ((
TLS_RECORD_HEADER *)TlsRecord)->Version.Minor = HttpInstance->TlsConfigData.Version.Minor;
1547 CopyMem (TlsRecord + TLS_RECORD_HEADER_LENGTH, TxString + (TxStringLen - RemainingLen), PayloadSize);
1552 TLS_RECORD_HEADER_LENGTH + PayloadSize,
1556 if (EFI_ERROR (Status)) {
1563 CopyMem (Fragment.Bulk + Fragment.Len, TempFragment.Bulk, TempFragment.Len);
1564 Fragment.Len += TempFragment.Len;
1567 TempFragment.Len = 0;
1568 TempFragment.Bulk =
NULL;
1570 RemainingLen -= (
UINTN)PayloadSize;
1571 ZeroMem (TlsRecord, TLS_RECORD_HEADER_LENGTH + TLS_PLAINTEXT_RECORD_MAX_PAYLOAD_LENGTH);
1578 if (!HttpInstance->LocalAddressIsIPv6) {
1579 Tcp4 = HttpInstance->Tcp4;
1580 Tx4Token = &Wrap->TcpWrap.Tx4Token;
1582 if (HttpInstance->UseHttps) {
1583 Tx4Token->Packet.
TxData->DataLength = Fragment.Len;
1584 Tx4Token->Packet.
TxData->FragmentTable[0].FragmentLength = Fragment.Len;
1585 Tx4Token->Packet.
TxData->FragmentTable[0].FragmentBuffer = (VOID *)Fragment.Bulk;
1587 Tx4Token->Packet.
TxData->DataLength = (UINT32)TxStringLen;
1588 Tx4Token->Packet.
TxData->FragmentTable[0].FragmentLength = (UINT32)TxStringLen;
1589 Tx4Token->Packet.
TxData->FragmentTable[0].FragmentBuffer = (VOID *)TxString;
1594 Wrap->TcpWrap.IsTxDone =
FALSE;
1595 Status = Tcp4->Transmit (Tcp4, Tx4Token);
1596 if (EFI_ERROR (Status)) {
1597 DEBUG ((DEBUG_ERROR,
"Transmit failed: %r\n", Status));
1601 Tcp6 = HttpInstance->Tcp6;
1602 Tx6Token = &Wrap->TcpWrap.Tx6Token;
1604 if (HttpInstance->UseHttps) {
1616 Wrap->TcpWrap.IsTxDone =
FALSE;
1617 Status = Tcp6->Transmit (Tcp6, Tx6Token);
1618 if (EFI_ERROR (Status)) {
1619 DEBUG ((DEBUG_ERROR,
"Transmit failed: %r\n", Status));
1628 if (HttpInstance->UseHttps) {
1629 if (TlsRecord !=
NULL) {
1634 if (Fragment.Bulk !=
NULL) {
1636 Fragment.Bulk =
NULL;
1671 if ((Token == TokenInItem) || (Token->
Event == TokenInItem->
Event)) {
1672 return EFI_ACCESS_DENIED;
1701 if (!ValueInItem->TcpWrap.IsTxDone) {
1702 return EFI_NOT_READY;
1733 UINTN RequestMsgSize;
1738 if (ValueInItem->TcpWrap.IsTxDone) {
1748 return EFI_OUT_OF_RESOURCES;
1757 ValueInItem->HttpToken->
Message,
1764 if (EFI_ERROR (Status) || (
NULL == RequestMsg)) {
1768 ASSERT (RequestMsg !=
NULL);
1774 ValueInItem->HttpInstance,
1776 (UINT8 *)RequestMsg,
1834 CHAR8 **EndofHeader;
1835 CHAR8 **HttpHeaders;
1839 ASSERT (HttpInstance !=
NULL);
1841 EndofHeader = HttpInstance->EndofHeader;
1842 HttpHeaders = HttpInstance->HttpHeaders;
1843 Tcp4 = HttpInstance->Tcp4;
1844 Tcp6 = HttpInstance->Tcp6;
1849 Fragment.Bulk =
NULL;
1851 if (HttpInstance->LocalAddressIsIPv6) {
1852 ASSERT (Tcp6 !=
NULL);
1854 ASSERT (Tcp4 !=
NULL);
1857 if (!HttpInstance->UseHttps) {
1859 if (EFI_ERROR (Status)) {
1864 if (!HttpInstance->LocalAddressIsIPv6) {
1865 if (!HttpInstance->UseHttps) {
1866 Rx4Token = &HttpInstance->Rx4Token;
1868 if (Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer ==
NULL) {
1869 Status = EFI_OUT_OF_RESOURCES;
1877 while (*EndofHeader ==
NULL) {
1878 if (!HttpInstance->UseHttps) {
1879 HttpInstance->IsRxDone =
FALSE;
1880 Rx4Token->Packet.
RxData->DataLength = DEF_BUF_LEN;
1881 Rx4Token->Packet.
RxData->FragmentTable[0].FragmentLength = DEF_BUF_LEN;
1882 Status = Tcp4->Receive (Tcp4, Rx4Token);
1883 if (EFI_ERROR (Status)) {
1884 DEBUG ((DEBUG_ERROR,
"Tcp4 receive failed: %r\n", Status));
1888 while (!HttpInstance->IsRxDone && ((Timeout ==
NULL) || EFI_ERROR (
gBS->CheckEvent (Timeout)))) {
1892 if (!HttpInstance->IsRxDone) {
1902 if (EFI_ERROR (Status)) {
1906 Fragment.Len = Rx4Token->Packet.
RxData->FragmentTable[0].FragmentLength;
1907 Fragment.Bulk = (UINT8 *)Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer;
1909 if (Fragment.Bulk !=
NULL) {
1911 Fragment.Bulk =
NULL;
1914 Status =
HttpsReceive (HttpInstance, &Fragment, Timeout);
1915 if (EFI_ERROR (Status)) {
1916 DEBUG ((DEBUG_ERROR,
"Tcp4 receive failed: %r\n", Status));
1924 *BufferSize = *SizeofHeaders + Fragment.Len;
1926 if (Buffer ==
NULL) {
1927 Status = EFI_OUT_OF_RESOURCES;
1931 if (*HttpHeaders !=
NULL) {
1932 CopyMem (Buffer, *HttpHeaders, *SizeofHeaders);
1937 Buffer + *SizeofHeaders,
1941 *(Buffer + *BufferSize) =
'\0';
1942 *HttpHeaders = Buffer;
1943 *SizeofHeaders = *BufferSize;
1948 *EndofHeader =
AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR);
1954 if ((Rx4Token !=
NULL) && (Rx4Token->Packet.
RxData !=
NULL) && (Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer !=
NULL)) {
1955 FreePool (Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer);
1956 Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer =
NULL;
1957 Fragment.Bulk =
NULL;
1960 if (Fragment.Bulk !=
NULL) {
1962 Fragment.Bulk =
NULL;
1965 if (!HttpInstance->UseHttps) {
1966 Rx6Token = &HttpInstance->Rx6Token;
1969 Status = EFI_OUT_OF_RESOURCES;
1977 while (*EndofHeader ==
NULL) {
1978 if (!HttpInstance->UseHttps) {
1979 HttpInstance->IsRxDone =
FALSE;
1982 Status = Tcp6->Receive (Tcp6, Rx6Token);
1983 if (EFI_ERROR (Status)) {
1984 DEBUG ((DEBUG_ERROR,
"Tcp6 receive failed: %r\n", Status));
1988 while (!HttpInstance->IsRxDone && ((Timeout ==
NULL) || EFI_ERROR (
gBS->CheckEvent (Timeout)))) {
1992 if (!HttpInstance->IsRxDone) {
2002 if (EFI_ERROR (Status)) {
2009 if (Fragment.Bulk !=
NULL) {
2011 Fragment.Bulk =
NULL;
2014 Status =
HttpsReceive (HttpInstance, &Fragment, Timeout);
2015 if (EFI_ERROR (Status)) {
2016 DEBUG ((DEBUG_ERROR,
"Tcp6 receive failed: %r\n", Status));
2024 *BufferSize = *SizeofHeaders + Fragment.Len;
2026 if (Buffer ==
NULL) {
2027 Status = EFI_OUT_OF_RESOURCES;
2031 if (*HttpHeaders !=
NULL) {
2032 CopyMem (Buffer, *HttpHeaders, *SizeofHeaders);
2037 Buffer + *SizeofHeaders,
2041 *(Buffer + *BufferSize) =
'\0';
2042 *HttpHeaders = Buffer;
2043 *SizeofHeaders = *BufferSize;
2048 *EndofHeader =
AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR);
2057 Fragment.Bulk =
NULL;
2060 if (Fragment.Bulk !=
NULL) {
2062 Fragment.Bulk =
NULL;
2069 *EndofHeader = *EndofHeader +
AsciiStrLen (HTTP_END_OF_HDR_STR);
2071 *SizeofHeaders = *EndofHeader - *HttpHeaders;
2099 HttpInstance = Wrap->HttpInstance;
2100 Tcp4 = HttpInstance->Tcp4;
2101 Tcp6 = HttpInstance->Tcp6;
2105 if (HttpInstance->LocalAddressIsIPv6) {
2106 ASSERT (Tcp6 !=
NULL);
2108 ASSERT (Tcp4 !=
NULL);
2111 if (HttpInstance->LocalAddressIsIPv6) {
2112 Rx6Token = &Wrap->TcpWrap.Rx6Token;
2118 Status = Tcp6->Receive (Tcp6, Rx6Token);
2119 if (EFI_ERROR (Status)) {
2120 DEBUG ((DEBUG_ERROR,
"Tcp6 receive failed: %r\n", Status));
2124 Rx4Token = &Wrap->TcpWrap.Rx4Token;
2125 Rx4Token->Packet.
RxData->DataLength = (UINT32)
MIN (MAX_UINT32, HttpMsg->BodyLength);
2126 Rx4Token->Packet.
RxData->FragmentTable[0].FragmentLength = (UINT32)
MIN (MAX_UINT32, HttpMsg->BodyLength);
2127 Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer = (VOID *)HttpMsg->Body;
2130 Status = Tcp4->Receive (Tcp4, Rx4Token);
2131 if (EFI_ERROR (Status)) {
2132 DEBUG ((DEBUG_ERROR,
"Tcp4 receive failed: %r\n", Status));
2155 ASSERT (Wrap !=
NULL);
2156 HttpInstance = Wrap->HttpInstance;
2160 if (HttpInstance->LocalAddressIsIPv6) {
2161 Rx6Token = &Wrap->TcpWrap.Rx6Token;
2170 Rx6Token = &HttpInstance->Rx6Token;
2182 Rx4Token = &Wrap->TcpWrap.Rx4Token;
2191 Rx4Token = &HttpInstance->Rx4Token;
2198 if (Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer !=
NULL) {
2199 FreePool (Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer);
2200 Rx4Token->Packet.
RxData->FragmentTable[0].FragmentBuffer =
NULL;
2225 DEBUG ((DEBUG_INFO,
"HttpNotify: Event - %d, EventStatus - %r\n", Event, EventStatus));
2229 Status =
gBS->LocateHandleBuffer (
2231 &gEdkiiHttpCallbackProtocolGuid,
2237 for (Index = 0; Index < HandleCount; Index++) {
2238 Handle = Handles[Index];
2239 Status =
gBS->HandleProtocol (
2241 &gEdkiiHttpCallbackProtocolGuid,
2242 (VOID **)&HttpCallback
2245 DEBUG ((DEBUG_INFO,
"HttpNotify: Notifying %p\n", HttpCallback));
2246 HttpCallback->Callback (
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
RETURN_STATUS EFIAPI UnicodeStrToAsciiStrS(IN CONST CHAR16 *Source, OUT CHAR8 *Destination, IN UINTN DestMax)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR8 *EFIAPI AsciiStrStr(IN CONST CHAR8 *String, IN CONST CHAR8 *SearchString)
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 QueueDpc(IN EFI_TPL DpcTpl, IN EFI_DPC_PROCEDURE DpcProcedure, IN VOID *DpcContext OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EDKII_HTTP_CALLBACK_EVENT
@ HttpEventTlsConnectSession
EFI_STATUS HttpResponseWorker(IN HTTP_TOKEN_WRAP *Wrap)
EFI_STATUS EFIAPI HttpGenRequestMessage(IN CONST EFI_HTTP_MESSAGE *Message, IN CONST CHAR8 *Url, OUT CHAR8 **RequestMsg, OUT UINTN *RequestMsgSize)
EFI_STATUS EFIAPI HttpParseMessageBody(IN OUT VOID *MsgParser, IN UINTN BodyLength, IN CHAR8 *Body)
VOID EFIAPI HttpFreeMsgParser(IN VOID *MsgParser)
BOOLEAN EFIAPI HttpIsMessageComplete(IN VOID *MsgParser)
VOID HttpTcpTokenCleanup(IN HTTP_TOKEN_WRAP *Wrap)
EFI_STATUS HttpConfigureTcp4(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap)
EFI_STATUS HttpCreateTcpRxEvent(IN HTTP_TOKEN_WRAP *Wrap)
EFI_STATUS HttpInitSession(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap, IN BOOLEAN Configure, IN BOOLEAN TlsConfigure)
EFI_STATUS HttpCreateTcpConnCloseEvent(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS EFIAPI HttpTokenExist(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
EFI_STATUS HttpInitProtocol(IN OUT HTTP_PROTOCOL *HttpInstance, IN BOOLEAN IpVersion)
VOID HttpCleanProtocol(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS HttpConnectTcp4(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS HttpTcpReceiveBody(IN HTTP_TOKEN_WRAP *Wrap, IN EFI_HTTP_MESSAGE *HttpMsg)
EFI_STATUS HttpConnectTcp6(IN HTTP_PROTOCOL *HttpInstance)
VOID EFIAPI HttpCommonNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI HttpTcpReceive(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
EFI_STATUS HttpCloseConnection(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS HttpCreateConnection(IN HTTP_PROTOCOL *HttpInstance)
VOID HttpNotify(IN EDKII_HTTP_CALLBACK_EVENT Event, IN EFI_STATUS EventStatus)
EFI_STATUS EFIAPI HttpTcpTransmit(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
EFI_STATUS HttpTransmitTcp(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap, IN UINT8 *TxString, IN UINTN TxStringLen)
VOID EFIAPI HttpTcpReceiveNotifyDpc(IN VOID *Context)
VOID EFIAPI HttpTcpTransmitNotify(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI HttpTcpReceiveNotify(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI HttpTcpTransmitNotifyDpc(IN VOID *Context)
EFI_STATUS HttpTcpReceiveHeader(IN HTTP_PROTOCOL *HttpInstance, IN OUT UINTN *SizeofHeaders, IN OUT UINTN *BufferSize, IN EFI_EVENT Timeout)
EFI_STATUS HttpCreateTcpRxEventForHeader(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS EFIAPI HttpTcpNotReady(IN NET_MAP *Map, IN NET_MAP_ITEM *Item, IN VOID *Context)
VOID HttpCloseTcpConnCloseEvent(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS HttpCreateTcpTxEvent(IN HTTP_TOKEN_WRAP *Wrap)
VOID HttpCloseTcpRxEvent(IN HTTP_TOKEN_WRAP *Wrap)
EFI_STATUS HttpConfigureTcp6(IN HTTP_PROTOCOL *HttpInstance, IN HTTP_TOKEN_WRAP *Wrap)
EFI_STATUS EFIAPI HttpsReceive(IN HTTP_PROTOCOL *HttpInstance, IN OUT NET_FRAGMENT *Fragment, IN EFI_EVENT Timeout)
EFI_STATUS EFIAPI TlsProcessMessage(IN HTTP_PROTOCOL *HttpInstance, IN UINT8 *Message, IN UINTN MessageSize, IN EFI_TLS_CRYPT_MODE ProcessMode, IN OUT NET_FRAGMENT *Fragment)
EFI_STATUS EFIAPI TlsConnectSession(IN HTTP_PROTOCOL *HttpInstance, IN EFI_EVENT Timeout)
VOID EFIAPI TlsCloseTxRxEvent(IN HTTP_PROTOCOL *HttpInstance)
EFI_STATUS EFIAPI TlsConfigureSession(IN OUT HTTP_PROTOCOL *HttpInstance)
#define DEBUG(Expression)
VOID EFIAPI NetMapClean(IN OUT NET_MAP *Map)
EFI_STATUS EFIAPI NetLibCreateServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN OUT EFI_HANDLE *ChildHandle)
NET_MAP_ITEM *EFIAPI NetMapFindKey(IN NET_MAP *Map, IN VOID *Key)
EFI_STATUS EFIAPI NetLibDestroyServiceChild(IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_GUID *ServiceBindingGuid, IN EFI_HANDLE ChildHandle)
VOID *EFIAPI NetMapRemoveItem(IN OUT NET_MAP *Map, IN OUT NET_MAP_ITEM *Item, OUT VOID **Value OPTIONAL)
EFI_STATUS EFIAPI NetMapIterate(IN NET_MAP *Map, IN NET_MAP_CALLBACK CallBack, IN VOID *Arg OPTIONAL)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_TCP4_CONNECTION_STATE
EFI_TCP6_CONNECTION_STATE
union EFI_HTTP_MESSAGE::@577 Data
EFI_HTTP_REQUEST_DATA * Request
EFI_HTTP_MESSAGE * Message
EFI_TCP4_COMPLETION_TOKEN CompletionToken
EFI_TCP4_TRANSMIT_DATA * TxData
EFI_TCP4_RECEIVE_DATA * RxData
EFI_IPv6_ADDRESS RemoteAddress
EFI_IPv6_ADDRESS StationAddress
EFI_TCP6_ACCESS_POINT AccessPoint
EFI_TCP6_OPTION * ControlOption
VOID * FragmentBuffer
Pointer to the data buffer in the fragment.
UINT32 FragmentLength
Length of data buffer in the fragment.
EFI_TCP6_RECEIVE_DATA * RxData
EFI_TCP6_TRANSMIT_DATA * TxData
EFI_TCP6_COMPLETION_TOKEN CompletionToken
BOOLEAN EnableWindowScaling
EFI_TCP6_FRAGMENT_DATA FragmentTable[1]
EFI_TCP6_FRAGMENT_DATA FragmentTable[1]