/** @file\r
Miscellaneous routines for HttpDxe driver.\r
\r
-Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
//\r
Status = NetLibCreateServiceChild (\r
HttpInstance->Service->ControllerHandle,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
&gEfiTcp4ServiceBindingProtocolGuid,\r
&HttpInstance->Tcp4ChildHandle\r
);\r
HttpInstance->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
(VOID **) &Interface,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Service->ControllerHandle,\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
);\r
HttpInstance->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
(VOID **) &HttpInstance->Tcp4,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Handle,\r
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
);\r
HttpInstance->Service->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
(VOID **) &Interface,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Handle,\r
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
);\r
//\r
Status = NetLibCreateServiceChild (\r
HttpInstance->Service->ControllerHandle,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
&gEfiTcp6ServiceBindingProtocolGuid,\r
&HttpInstance->Tcp6ChildHandle\r
);\r
HttpInstance->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
(VOID **) &Interface,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Service->ControllerHandle,\r
EFI_OPEN_PROTOCOL_BY_DRIVER\r
);\r
HttpInstance->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
(VOID **) &HttpInstance->Tcp6,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Handle,\r
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
);\r
HttpInstance->Service->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
(VOID **) &Interface,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Handle,\r
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER\r
);\r
gBS->CloseProtocol (\r
HttpInstance->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Service->ControllerHandle\r
);\r
\r
gBS->CloseProtocol (\r
HttpInstance->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Handle\r
); \r
\r
NetLibDestroyServiceChild (\r
HttpInstance->Service->ControllerHandle,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
&gEfiTcp4ServiceBindingProtocolGuid,\r
HttpInstance->Tcp4ChildHandle\r
);\r
gBS->CloseProtocol (\r
HttpInstance->Service->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Handle\r
);\r
}\r
gBS->CloseProtocol (\r
HttpInstance->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Service->ControllerHandle\r
);\r
\r
gBS->CloseProtocol (\r
HttpInstance->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Handle\r
);\r
\r
NetLibDestroyServiceChild (\r
HttpInstance->Service->ControllerHandle,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
&gEfiTcp6ServiceBindingProtocolGuid,\r
HttpInstance->Tcp6ChildHandle\r
);\r
gBS->CloseProtocol (\r
HttpInstance->Service->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Handle\r
);\r
}\r
NetMapClean (&HttpInstance->TxTokens);\r
NetMapClean (&HttpInstance->RxTokens);\r
\r
+ if (HttpInstance->TlsSb != NULL && HttpInstance->TlsChildHandle != NULL) {\r
+ //\r
+ // Destroy the TLS instance. \r
+ //\r
+ HttpInstance->TlsSb->DestroyChild (HttpInstance->TlsSb, HttpInstance->TlsChildHandle);\r
+ }\r
+\r
if (HttpInstance->Tcp4ChildHandle != NULL) {\r
gBS->CloseProtocol (\r
HttpInstance->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Service->ControllerHandle\r
);\r
\r
gBS->CloseProtocol (\r
HttpInstance->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Handle\r
);\r
\r
NetLibDestroyServiceChild (\r
HttpInstance->Service->ControllerHandle,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
&gEfiTcp4ServiceBindingProtocolGuid,\r
HttpInstance->Tcp4ChildHandle\r
);\r
gBS->CloseProtocol (\r
HttpInstance->Service->Tcp4ChildHandle,\r
&gEfiTcp4ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip4DriverBindingHandle,\r
HttpInstance->Handle\r
);\r
} \r
gBS->CloseProtocol (\r
HttpInstance->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Service->ControllerHandle\r
);\r
\r
gBS->CloseProtocol (\r
HttpInstance->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Handle\r
);\r
\r
NetLibDestroyServiceChild (\r
HttpInstance->Service->ControllerHandle,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
&gEfiTcp6ServiceBindingProtocolGuid,\r
HttpInstance->Tcp6ChildHandle\r
);\r
gBS->CloseProtocol (\r
HttpInstance->Service->Tcp6ChildHandle,\r
&gEfiTcp6ProtocolGuid,\r
- HttpInstance->Service->ImageHandle,\r
+ HttpInstance->Service->Ip6DriverBindingHandle,\r
HttpInstance->Handle\r
);\r
}\r
Status = EFI_OUT_OF_RESOURCES;\r
return Status;\r
}\r
- ((TLS_RECORD_HEADER *) Buffer)->ContentType = TLS_CONTENT_TYPE_APPLICATION_DATA;\r
+ ((TLS_RECORD_HEADER *) Buffer)->ContentType = TlsContentTypeApplicationData;\r
((TLS_RECORD_HEADER *) Buffer)->Version.Major = HttpInstance->TlsConfigData.Version.Major;\r
((TLS_RECORD_HEADER *) Buffer)->Version.Minor = HttpInstance->TlsConfigData.Version.Minor;\r
((TLS_RECORD_HEADER *) Buffer)->Length = (UINT16) (TxStringLen);\r
//\r
// Check whether we received end of HTTP headers.\r
//\r
- *EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR); \r
+ *EndofHeader = AsciiStrStr (*HttpHeaders, HTTP_END_OF_HDR_STR);\r
};\r
\r
//\r
//\r
// Skip the CRLF after the HTTP headers.\r
//\r
- *EndofHeader = *EndofHeader + AsciiStrLen (HTTP_END_OF_HDR_STR); \r
+ *EndofHeader = *EndofHeader + AsciiStrLen (HTTP_END_OF_HDR_STR);\r
+\r
+ *SizeofHeaders = *EndofHeader - *HttpHeaders;\r
\r
return EFI_SUCCESS;\r
}\r
\r
if (HttpInstance->LocalAddressIsIPv6) {\r
Rx6Token = &Wrap->TcpWrap.Rx6Token;\r
- Rx6Token ->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength;\r
- Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) HttpMsg->BodyLength;\r
+ Rx6Token ->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength);\r
+ Rx6Token ->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength);\r
Rx6Token ->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body;\r
Rx6Token->CompletionToken.Status = EFI_NOT_READY;\r
\r
}\r
} else {\r
Rx4Token = &Wrap->TcpWrap.Rx4Token;\r
- Rx4Token->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength;\r
- Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) HttpMsg->BodyLength;\r
+ Rx4Token->Packet.RxData->DataLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength);\r
+ Rx4Token->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) MIN (MAX_UINT32, HttpMsg->BodyLength);\r
Rx4Token->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body;\r
\r
Rx4Token->CompletionToken.Status = EFI_NOT_READY;\r