NetworkPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the NetworkPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
2f88bd3a12
commit
d1050b9dff
@@ -26,10 +26,10 @@
|
||||
VOID
|
||||
EFIAPI
|
||||
HttpIoNotifyDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,8 +42,8 @@ HttpIoNotifyDpc (
|
||||
VOID
|
||||
EFIAPI
|
||||
HttpIoNotify (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -60,11 +60,11 @@ HttpIoNotify (
|
||||
**/
|
||||
VOID
|
||||
HttpIoDestroyIo (
|
||||
IN HTTP_IO *HttpIo
|
||||
IN HTTP_IO *HttpIo
|
||||
)
|
||||
{
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
EFI_EVENT Event;
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
EFI_EVENT Event;
|
||||
|
||||
if (HttpIo == NULL) {
|
||||
return;
|
||||
@@ -128,27 +128,27 @@ HttpIoDestroyIo (
|
||||
**/
|
||||
EFI_STATUS
|
||||
HttpIoCreateIo (
|
||||
IN EFI_HANDLE Image,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINT8 IpVersion,
|
||||
IN HTTP_IO_CONFIG_DATA *ConfigData OPTIONAL,
|
||||
IN HTTP_IO_CALLBACK Callback,
|
||||
IN VOID *Context,
|
||||
OUT HTTP_IO *HttpIo
|
||||
IN EFI_HANDLE Image,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINT8 IpVersion,
|
||||
IN HTTP_IO_CONFIG_DATA *ConfigData OPTIONAL,
|
||||
IN HTTP_IO_CALLBACK Callback,
|
||||
IN VOID *Context,
|
||||
OUT HTTP_IO *HttpIo
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_CONFIG_DATA HttpConfigData;
|
||||
EFI_HTTPv4_ACCESS_POINT Http4AccessPoint;
|
||||
EFI_HTTPv6_ACCESS_POINT Http6AccessPoint;
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_CONFIG_DATA HttpConfigData;
|
||||
EFI_HTTPv4_ACCESS_POINT Http4AccessPoint;
|
||||
EFI_HTTPv6_ACCESS_POINT Http6AccessPoint;
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
EFI_EVENT Event;
|
||||
|
||||
if ((Image == NULL) || (Controller == NULL) || (HttpIo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (IpVersion != IP_VERSION_4 && IpVersion != IP_VERSION_6) {
|
||||
if ((IpVersion != IP_VERSION_4) && (IpVersion != IP_VERSION_6)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ HttpIoCreateIo (
|
||||
Status = gBS->OpenProtocol (
|
||||
HttpIo->Handle,
|
||||
&gEfiHttpProtocolGuid,
|
||||
(VOID **) &Http,
|
||||
(VOID **)&Http,
|
||||
Image,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@@ -183,19 +183,19 @@ HttpIoCreateIo (
|
||||
//
|
||||
// Init the configuration data and configure the HTTP child.
|
||||
//
|
||||
HttpIo->Image = Image;
|
||||
HttpIo->Controller = Controller;
|
||||
HttpIo->IpVersion = IpVersion;
|
||||
HttpIo->Http = Http;
|
||||
HttpIo->Callback = Callback;
|
||||
HttpIo->Context = Context;
|
||||
HttpIo->Timeout = PcdGet32 (PcdHttpIoTimeout);
|
||||
HttpIo->Image = Image;
|
||||
HttpIo->Controller = Controller;
|
||||
HttpIo->IpVersion = IpVersion;
|
||||
HttpIo->Http = Http;
|
||||
HttpIo->Callback = Callback;
|
||||
HttpIo->Context = Context;
|
||||
HttpIo->Timeout = PcdGet32 (PcdHttpIoTimeout);
|
||||
|
||||
if (ConfigData != NULL) {
|
||||
if (HttpIo->IpVersion == IP_VERSION_4) {
|
||||
HttpConfigData.LocalAddressIsIPv6 = FALSE;
|
||||
HttpConfigData.HttpVersion = ConfigData->Config4.HttpVersion;
|
||||
HttpConfigData.TimeOutMillisec = ConfigData->Config4.RequestTimeOut;
|
||||
HttpConfigData.LocalAddressIsIPv6 = FALSE;
|
||||
HttpConfigData.HttpVersion = ConfigData->Config4.HttpVersion;
|
||||
HttpConfigData.TimeOutMillisec = ConfigData->Config4.RequestTimeOut;
|
||||
|
||||
Http4AccessPoint.UseDefaultAddress = ConfigData->Config4.UseDefaultAddress;
|
||||
Http4AccessPoint.LocalPort = ConfigData->Config4.LocalPort;
|
||||
@@ -204,10 +204,10 @@ HttpIoCreateIo (
|
||||
HttpConfigData.AccessPoint.IPv4Node = &Http4AccessPoint;
|
||||
} else {
|
||||
HttpConfigData.LocalAddressIsIPv6 = TRUE;
|
||||
HttpConfigData.HttpVersion = ConfigData->Config6.HttpVersion;
|
||||
HttpConfigData.TimeOutMillisec = ConfigData->Config6.RequestTimeOut;
|
||||
HttpConfigData.HttpVersion = ConfigData->Config6.HttpVersion;
|
||||
HttpConfigData.TimeOutMillisec = ConfigData->Config6.RequestTimeOut;
|
||||
|
||||
Http6AccessPoint.LocalPort = ConfigData->Config6.LocalPort;
|
||||
Http6AccessPoint.LocalPort = ConfigData->Config6.LocalPort;
|
||||
IP6_COPY_ADDRESS (&Http6AccessPoint.LocalAddress, &ConfigData->Config6.LocalIp);
|
||||
HttpConfigData.AccessPoint.IPv6Node = &Http6AccessPoint;
|
||||
}
|
||||
@@ -231,7 +231,8 @@ HttpIoCreateIo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
HttpIo->ReqToken.Event = Event;
|
||||
|
||||
HttpIo->ReqToken.Event = Event;
|
||||
HttpIo->ReqToken.Message = &HttpIo->ReqMessage;
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
@@ -244,7 +245,8 @@ HttpIoCreateIo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
HttpIo->RspToken.Event = Event;
|
||||
|
||||
HttpIo->RspToken.Event = Event;
|
||||
HttpIo->RspToken.Message = &HttpIo->RspMessage;
|
||||
|
||||
//
|
||||
@@ -260,6 +262,7 @@ HttpIoCreateIo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
HttpIo->TimeoutEvent = Event;
|
||||
return EFI_SUCCESS;
|
||||
|
||||
@@ -296,14 +299,14 @@ HttpIoSendRequest (
|
||||
IN VOID *Body
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
|
||||
if (HttpIo == NULL || HttpIo->Http == NULL) {
|
||||
if ((HttpIo == NULL) || (HttpIo->Http == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
HttpIo->ReqToken.Status = EFI_NOT_READY;
|
||||
HttpIo->ReqToken.Status = EFI_NOT_READY;
|
||||
HttpIo->ReqToken.Message->Data.Request = Request;
|
||||
HttpIo->ReqToken.Message->HeaderCount = HeaderCount;
|
||||
HttpIo->ReqToken.Message->Headers = Headers;
|
||||
@@ -312,10 +315,10 @@ HttpIoSendRequest (
|
||||
|
||||
if (HttpIo->Callback != NULL) {
|
||||
Status = HttpIo->Callback (
|
||||
HttpIoRequest,
|
||||
HttpIo->ReqToken.Message,
|
||||
HttpIo->Context
|
||||
);
|
||||
HttpIoRequest,
|
||||
HttpIo->ReqToken.Message,
|
||||
HttpIo->Context
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -324,12 +327,12 @@ HttpIoSendRequest (
|
||||
//
|
||||
// Queue the request token to HTTP instances.
|
||||
//
|
||||
Http = HttpIo->Http;
|
||||
Http = HttpIo->Http;
|
||||
HttpIo->IsTxDone = FALSE;
|
||||
Status = Http->Request (
|
||||
Http,
|
||||
&HttpIo->ReqToken
|
||||
);
|
||||
Status = Http->Request (
|
||||
Http,
|
||||
&HttpIo->ReqToken
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -361,33 +364,34 @@ HttpIoSendRequest (
|
||||
**/
|
||||
EFI_STATUS
|
||||
HttpIoRecvResponse (
|
||||
IN HTTP_IO *HttpIo,
|
||||
IN BOOLEAN RecvMsgHeader,
|
||||
OUT HTTP_IO_RESPONSE_DATA *ResponseData
|
||||
IN HTTP_IO *HttpIo,
|
||||
IN BOOLEAN RecvMsgHeader,
|
||||
OUT HTTP_IO_RESPONSE_DATA *ResponseData
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_PROTOCOL *Http;
|
||||
|
||||
if (HttpIo == NULL || HttpIo->Http == NULL || ResponseData == NULL) {
|
||||
if ((HttpIo == NULL) || (HttpIo->Http == NULL) || (ResponseData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Queue the response token to HTTP instances.
|
||||
//
|
||||
HttpIo->RspToken.Status = EFI_NOT_READY;
|
||||
HttpIo->RspToken.Status = EFI_NOT_READY;
|
||||
if (RecvMsgHeader) {
|
||||
HttpIo->RspToken.Message->Data.Response = &ResponseData->Response;
|
||||
} else {
|
||||
HttpIo->RspToken.Message->Data.Response = NULL;
|
||||
}
|
||||
HttpIo->RspToken.Message->HeaderCount = 0;
|
||||
HttpIo->RspToken.Message->Headers = NULL;
|
||||
HttpIo->RspToken.Message->BodyLength = ResponseData->BodyLength;
|
||||
HttpIo->RspToken.Message->Body = ResponseData->Body;
|
||||
|
||||
Http = HttpIo->Http;
|
||||
HttpIo->RspToken.Message->HeaderCount = 0;
|
||||
HttpIo->RspToken.Message->Headers = NULL;
|
||||
HttpIo->RspToken.Message->BodyLength = ResponseData->BodyLength;
|
||||
HttpIo->RspToken.Message->Body = ResponseData->Body;
|
||||
|
||||
Http = HttpIo->Http;
|
||||
HttpIo->IsRxDone = FALSE;
|
||||
|
||||
//
|
||||
@@ -437,12 +441,13 @@ HttpIoRecvResponse (
|
||||
}
|
||||
|
||||
if ((HttpIo->Callback != NULL) &&
|
||||
(HttpIo->RspToken.Status == EFI_SUCCESS || HttpIo->RspToken.Status == EFI_HTTP_ERROR)) {
|
||||
((HttpIo->RspToken.Status == EFI_SUCCESS) || (HttpIo->RspToken.Status == EFI_HTTP_ERROR)))
|
||||
{
|
||||
Status = HttpIo->Callback (
|
||||
HttpIoResponse,
|
||||
HttpIo->RspToken.Message,
|
||||
HttpIo->Context
|
||||
);
|
||||
HttpIoResponse,
|
||||
HttpIo->RspToken.Message,
|
||||
HttpIo->Context
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -451,7 +456,7 @@ HttpIoRecvResponse (
|
||||
//
|
||||
// Store the received data into the wrapper.
|
||||
//
|
||||
ResponseData->Status = HttpIo->RspToken.Status;
|
||||
ResponseData->Status = HttpIo->RspToken.Status;
|
||||
ResponseData->HeaderCount = HttpIo->RspToken.Message->HeaderCount;
|
||||
ResponseData->Headers = HttpIo->RspToken.Message->Headers;
|
||||
ResponseData->BodyLength = HttpIo->RspToken.Message->BodyLength;
|
||||
@@ -472,20 +477,21 @@ HttpIoRecvResponse (
|
||||
**/
|
||||
EFI_STATUS
|
||||
HttpIoGetContentLength (
|
||||
IN UINTN HeaderCount,
|
||||
IN EFI_HTTP_HEADER *Headers,
|
||||
OUT UINTN *ContentLength
|
||||
IN UINTN HeaderCount,
|
||||
IN EFI_HTTP_HEADER *Headers,
|
||||
OUT UINTN *ContentLength
|
||||
)
|
||||
{
|
||||
EFI_HTTP_HEADER *Header;
|
||||
EFI_HTTP_HEADER *Header;
|
||||
|
||||
Header = HttpFindHeader (HeaderCount, Headers, HTTP_HEADER_CONTENT_LENGTH);
|
||||
if (Header == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
return AsciiStrDecimalToUintnS (Header->FieldValue, (CHAR8 **) NULL, ContentLength);
|
||||
return AsciiStrDecimalToUintnS (Header->FieldValue, (CHAR8 **)NULL, ContentLength);
|
||||
}
|
||||
|
||||
/**
|
||||
Send HTTP request in chunks.
|
||||
|
||||
@@ -499,21 +505,21 @@ HttpIoGetContentLength (
|
||||
**/
|
||||
EFI_STATUS
|
||||
HttpIoSendChunkedTransfer (
|
||||
IN HTTP_IO *HttpIo,
|
||||
IN HTTP_IO_SEND_CHUNK_PROCESS *SendChunkProcess,
|
||||
IN EFI_HTTP_MESSAGE *RequestMessage
|
||||
)
|
||||
IN HTTP_IO *HttpIo,
|
||||
IN HTTP_IO_SEND_CHUNK_PROCESS *SendChunkProcess,
|
||||
IN EFI_HTTP_MESSAGE *RequestMessage
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_HEADER *NewHeaders;
|
||||
EFI_HTTP_HEADER *ContentLengthHeader;
|
||||
UINTN AddNewHeader;
|
||||
UINTN HeaderCount;
|
||||
CHAR8 *MessageBody;
|
||||
UINTN MessageBodyLength;
|
||||
UINTN ChunkLength;
|
||||
CHAR8 ChunkLengthStr [HTTP_IO_CHUNK_SIZE_STRING_LEN];
|
||||
EFI_HTTP_REQUEST_DATA *SentRequestData;
|
||||
EFI_STATUS Status;
|
||||
EFI_HTTP_HEADER *NewHeaders;
|
||||
EFI_HTTP_HEADER *ContentLengthHeader;
|
||||
UINTN AddNewHeader;
|
||||
UINTN HeaderCount;
|
||||
CHAR8 *MessageBody;
|
||||
UINTN MessageBodyLength;
|
||||
UINTN ChunkLength;
|
||||
CHAR8 ChunkLengthStr[HTTP_IO_CHUNK_SIZE_STRING_LEN];
|
||||
EFI_HTTP_REQUEST_DATA *SentRequestData;
|
||||
|
||||
AddNewHeader = 0;
|
||||
NewHeaders = NULL;
|
||||
@@ -522,75 +528,79 @@ HttpIoSendChunkedTransfer (
|
||||
MessageBodyLength = 0;
|
||||
|
||||
switch (*SendChunkProcess) {
|
||||
case HttpIoSendChunkHeaderZeroContent:
|
||||
case HttpIoSendChunkHeaderZeroContent:
|
||||
ContentLengthHeader = HttpFindHeader (RequestMessage->HeaderCount, RequestMessage->Headers, HTTP_HEADER_CONTENT_LENGTH);
|
||||
if (ContentLengthHeader == NULL) {
|
||||
AddNewHeader = 1;
|
||||
}
|
||||
|
||||
NewHeaders = AllocateZeroPool ((RequestMessage->HeaderCount + AddNewHeader) * sizeof(EFI_HTTP_HEADER));
|
||||
CopyMem ((VOID*)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER));
|
||||
NewHeaders = AllocateZeroPool ((RequestMessage->HeaderCount + AddNewHeader) * sizeof (EFI_HTTP_HEADER));
|
||||
CopyMem ((VOID *)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER));
|
||||
if (AddNewHeader == 0) {
|
||||
//
|
||||
// Override content-length to Transfer-Encoding.
|
||||
//
|
||||
ContentLengthHeader = HttpFindHeader (RequestMessage->HeaderCount, NewHeaders, HTTP_HEADER_CONTENT_LENGTH);
|
||||
ContentLengthHeader->FieldName = NULL;
|
||||
ContentLengthHeader = HttpFindHeader (RequestMessage->HeaderCount, NewHeaders, HTTP_HEADER_CONTENT_LENGTH);
|
||||
ContentLengthHeader->FieldName = NULL;
|
||||
ContentLengthHeader->FieldValue = NULL;
|
||||
} else {
|
||||
ContentLengthHeader = NewHeaders + RequestMessage->HeaderCount;
|
||||
}
|
||||
|
||||
HttpSetFieldNameAndValue (ContentLengthHeader, HTTP_HEADER_TRANSFER_ENCODING, HTTP_HEADER_TRANSFER_ENCODING_CHUNKED);
|
||||
HeaderCount = RequestMessage->HeaderCount + AddNewHeader;
|
||||
HeaderCount = RequestMessage->HeaderCount + AddNewHeader;
|
||||
MessageBodyLength = 0;
|
||||
MessageBody = NULL;
|
||||
SentRequestData = RequestMessage->Data.Request;
|
||||
MessageBody = NULL;
|
||||
SentRequestData = RequestMessage->Data.Request;
|
||||
break;
|
||||
|
||||
case HttpIoSendChunkContent:
|
||||
HeaderCount = 0;
|
||||
NewHeaders = NULL;
|
||||
case HttpIoSendChunkContent:
|
||||
HeaderCount = 0;
|
||||
NewHeaders = NULL;
|
||||
SentRequestData = NULL;
|
||||
if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) {
|
||||
MessageBodyLength = HTTP_IO_MAX_SEND_PAYLOAD;
|
||||
} else {
|
||||
MessageBodyLength = RequestMessage->BodyLength;
|
||||
}
|
||||
|
||||
AsciiSPrint (
|
||||
ChunkLengthStr,
|
||||
HTTP_IO_CHUNK_SIZE_STRING_LEN,
|
||||
"%x%c%c",
|
||||
MessageBodyLength,
|
||||
CHUNKED_TRANSFER_CODING_CR,
|
||||
CHUNKED_TRANSFER_CODING_LF
|
||||
);
|
||||
ChunkLengthStr,
|
||||
HTTP_IO_CHUNK_SIZE_STRING_LEN,
|
||||
"%x%c%c",
|
||||
MessageBodyLength,
|
||||
CHUNKED_TRANSFER_CODING_CR,
|
||||
CHUNKED_TRANSFER_CODING_LF
|
||||
);
|
||||
ChunkLength = AsciiStrLen (ChunkLengthStr);
|
||||
MessageBody = AllocatePool (ChunkLength + MessageBodyLength + 2);
|
||||
if (MessageBody == NULL) {
|
||||
DEBUG((DEBUG_ERROR, "Not enough memory for chunk transfer\n"));
|
||||
DEBUG ((DEBUG_ERROR, "Not enough memory for chunk transfer\n"));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Build up the chunk transfer paylaod.
|
||||
//
|
||||
CopyMem (MessageBody, ChunkLengthStr, ChunkLength);
|
||||
CopyMem (MessageBody + ChunkLength, RequestMessage->Body, MessageBodyLength);
|
||||
*(MessageBody + ChunkLength + MessageBodyLength) = CHUNKED_TRANSFER_CODING_CR;
|
||||
*(MessageBody + ChunkLength + MessageBodyLength) = CHUNKED_TRANSFER_CODING_CR;
|
||||
*(MessageBody + ChunkLength + MessageBodyLength + 1) = CHUNKED_TRANSFER_CODING_LF;
|
||||
//
|
||||
// Change variables for the next chunk trasnfer.
|
||||
//
|
||||
RequestMessage->BodyLength -= MessageBodyLength;
|
||||
RequestMessage->Body = (VOID *)((CHAR8 *)RequestMessage->Body + MessageBodyLength);
|
||||
MessageBodyLength += (ChunkLength + 2);
|
||||
RequestMessage->Body = (VOID *)((CHAR8 *)RequestMessage->Body + MessageBodyLength);
|
||||
MessageBodyLength += (ChunkLength + 2);
|
||||
if (RequestMessage->BodyLength == 0) {
|
||||
*SendChunkProcess = HttpIoSendChunkEndChunk;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case HttpIoSendChunkEndChunk:
|
||||
HeaderCount = 0;
|
||||
NewHeaders = NULL;
|
||||
case HttpIoSendChunkEndChunk:
|
||||
HeaderCount = 0;
|
||||
NewHeaders = NULL;
|
||||
SentRequestData = NULL;
|
||||
AsciiSPrint (
|
||||
ChunkLengthStr,
|
||||
@@ -601,17 +611,18 @@ HttpIoSendChunkedTransfer (
|
||||
CHUNKED_TRANSFER_CODING_CR,
|
||||
CHUNKED_TRANSFER_CODING_LF
|
||||
);
|
||||
MessageBody = AllocatePool (AsciiStrLen(ChunkLengthStr));
|
||||
MessageBody = AllocatePool (AsciiStrLen (ChunkLengthStr));
|
||||
if (MessageBody == NULL) {
|
||||
DEBUG((DEBUG_ERROR, "Not enough memory for the end chunk transfer\n"));
|
||||
DEBUG ((DEBUG_ERROR, "Not enough memory for the end chunk transfer\n"));
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
CopyMem (MessageBody, ChunkLengthStr, AsciiStrLen (ChunkLengthStr));
|
||||
MessageBodyLength = AsciiStrLen (ChunkLengthStr);
|
||||
*SendChunkProcess = HttpIoSendChunkFinish;
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -627,16 +638,20 @@ HttpIoSendChunkedTransfer (
|
||||
if (ContentLengthHeader->FieldName != NULL) {
|
||||
FreePool (ContentLengthHeader->FieldName);
|
||||
}
|
||||
|
||||
if (ContentLengthHeader->FieldValue != NULL) {
|
||||
FreePool (ContentLengthHeader->FieldValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (NewHeaders != NULL) {
|
||||
FreePool (NewHeaders);
|
||||
}
|
||||
|
||||
if (MessageBody != NULL) {
|
||||
FreePool (MessageBody);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -661,30 +676,30 @@ HttpIoSendChunkedTransfer (
|
||||
**/
|
||||
EFI_STATUS
|
||||
HttpIoGetChunkedTransferContent (
|
||||
IN HTTP_IO *HttpIo,
|
||||
IN UINTN HeaderCount,
|
||||
IN EFI_HTTP_HEADER *Headers,
|
||||
OUT LIST_ENTRY **ChunkListHead,
|
||||
OUT UINTN *ContentLength
|
||||
IN HTTP_IO *HttpIo,
|
||||
IN UINTN HeaderCount,
|
||||
IN EFI_HTTP_HEADER *Headers,
|
||||
OUT LIST_ENTRY **ChunkListHead,
|
||||
OUT UINTN *ContentLength
|
||||
)
|
||||
{
|
||||
EFI_HTTP_HEADER *Header;
|
||||
CHAR8 ChunkSizeAscii [256];
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
HTTP_IO_RESPONSE_DATA ResponseData;
|
||||
UINTN TotalLength;
|
||||
UINTN MaxTotalLength;
|
||||
LIST_ENTRY *HttpChunks;
|
||||
HTTP_IO_CHUNKS *ThisChunk;
|
||||
LIST_ENTRY *ThisListEntry;
|
||||
EFI_HTTP_HEADER *Header;
|
||||
CHAR8 ChunkSizeAscii[256];
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
HTTP_IO_RESPONSE_DATA ResponseData;
|
||||
UINTN TotalLength;
|
||||
UINTN MaxTotalLength;
|
||||
LIST_ENTRY *HttpChunks;
|
||||
HTTP_IO_CHUNKS *ThisChunk;
|
||||
LIST_ENTRY *ThisListEntry;
|
||||
|
||||
if (ChunkListHead == NULL || ContentLength == NULL) {
|
||||
if ((ChunkListHead == NULL) || (ContentLength == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
*ContentLength = 0;
|
||||
Header = HttpFindHeader (HeaderCount, Headers, HTTP_HEADER_TRANSFER_ENCODING);
|
||||
Header = HttpFindHeader (HeaderCount, Headers, HTTP_HEADER_TRANSFER_ENCODING);
|
||||
if (Header == NULL) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
@@ -692,30 +707,33 @@ HttpIoGetChunkedTransferContent (
|
||||
if (AsciiStrCmp (Header->FieldValue, HTTP_HEADER_TRANSFER_ENCODING_CHUNKED) != 0) {
|
||||
return EFI_NOT_FOUND;
|
||||
}
|
||||
|
||||
//
|
||||
// Loop to get all chunks.
|
||||
//
|
||||
TotalLength = 0;
|
||||
TotalLength = 0;
|
||||
MaxTotalLength = PcdGet32 (PcdMaxHttpChunkTransfer);
|
||||
HttpChunks = (LIST_ENTRY *)AllocateZeroPool (sizeof (LIST_ENTRY));
|
||||
HttpChunks = (LIST_ENTRY *)AllocateZeroPool (sizeof (LIST_ENTRY));
|
||||
if (HttpChunks == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
InitializeListHead (HttpChunks);
|
||||
DEBUG ((DEBUG_INFO, " Chunked transfer\n"));
|
||||
while (TRUE) {
|
||||
ZeroMem((VOID *)&ResponseData, sizeof(HTTP_IO_RESPONSE_DATA));
|
||||
ZeroMem ((VOID *)&ResponseData, sizeof (HTTP_IO_RESPONSE_DATA));
|
||||
ResponseData.BodyLength = HTTP_IO_CHUNKED_TRANSFER_CODING_DATA_LENGTH;
|
||||
ResponseData.Body = ChunkSizeAscii;
|
||||
Status = HttpIoRecvResponse (
|
||||
HttpIo,
|
||||
FALSE,
|
||||
&ResponseData
|
||||
);
|
||||
ResponseData.Body = ChunkSizeAscii;
|
||||
Status = HttpIoRecvResponse (
|
||||
HttpIo,
|
||||
FALSE,
|
||||
&ResponseData
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
//
|
||||
// Decoding Chunked Transfer Coding.
|
||||
// Only decode chunk-size and last chunk.
|
||||
@@ -724,13 +742,14 @@ HttpIoGetChunkedTransferContent (
|
||||
//
|
||||
// Break if this is last chunk.
|
||||
//
|
||||
if (ChunkSizeAscii [0] == CHUNKED_TRANSFER_CODING_LAST_CHUNK) {
|
||||
if (ChunkSizeAscii[0] == CHUNKED_TRANSFER_CODING_LAST_CHUNK) {
|
||||
//
|
||||
// Check if this is a valid Last-Chunk.
|
||||
//
|
||||
if ((ChunkSizeAscii [1] != CHUNKED_TRANSFER_CODING_CR) ||
|
||||
(ChunkSizeAscii [2] != CHUNKED_TRANSFER_CODING_LF)
|
||||
) {
|
||||
if ((ChunkSizeAscii[1] != CHUNKED_TRANSFER_CODING_CR) ||
|
||||
(ChunkSizeAscii[2] != CHUNKED_TRANSFER_CODING_LF)
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, " This is an invalid Last-chunk\n"));
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
goto ExitDeleteChunks;
|
||||
@@ -746,12 +765,13 @@ HttpIoGetChunkedTransferContent (
|
||||
|
||||
InitializeListHead (&ThisChunk->NextChunk);
|
||||
ThisChunk->Length = ResponseData.BodyLength - 1 - 2; // Minus sizeof '0' and CRLF.
|
||||
ThisChunk->Data = (CHAR8 *)AllocatePool (ThisChunk->Length);
|
||||
ThisChunk->Data = (CHAR8 *)AllocatePool (ThisChunk->Length);
|
||||
if (ThisChunk->Data == NULL) {
|
||||
FreePool ((UINT8 *)ThisChunk);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
CopyMem ((UINT8 *)ThisChunk->Data, (UINT8 *)ResponseData.Body + 1, ThisChunk->Length);
|
||||
TotalLength += ThisChunk->Length;
|
||||
InsertTailList (HttpChunks, &ThisChunk->NextChunk);
|
||||
@@ -762,16 +782,18 @@ HttpIoGetChunkedTransferContent (
|
||||
// Get the chunk length
|
||||
//
|
||||
Index = 0;
|
||||
while ((ChunkSizeAscii [Index] != CHUNKED_TRANSFER_CODING_EXTENSION_SEPARATOR) &&
|
||||
(ChunkSizeAscii [Index] != (CHAR8)CHUNKED_TRANSFER_CODING_CR) &&
|
||||
(Index != HTTP_IO_CHUNKED_TRANSFER_CODING_DATA_LENGTH)) {
|
||||
Index ++;
|
||||
while ((ChunkSizeAscii[Index] != CHUNKED_TRANSFER_CODING_EXTENSION_SEPARATOR) &&
|
||||
(ChunkSizeAscii[Index] != (CHAR8)CHUNKED_TRANSFER_CODING_CR) &&
|
||||
(Index != HTTP_IO_CHUNKED_TRANSFER_CODING_DATA_LENGTH))
|
||||
{
|
||||
Index++;
|
||||
}
|
||||
|
||||
if (Index == HTTP_IO_CHUNKED_TRANSFER_CODING_DATA_LENGTH) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
ChunkSizeAscii[Index] = 0;
|
||||
AsciiStrHexToUintnS (ChunkSizeAscii, NULL, ContentLength);
|
||||
DEBUG ((DEBUG_INFO, " Length of this chunk %d\n", *ContentLength));
|
||||
@@ -783,16 +805,18 @@ HttpIoGetChunkedTransferContent (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
ResponseData.BodyLength = *ContentLength;
|
||||
ResponseData.Body = (CHAR8 *)AllocatePool (*ContentLength);
|
||||
ResponseData.Body = (CHAR8 *)AllocatePool (*ContentLength);
|
||||
if (ResponseData.Body == NULL) {
|
||||
FreePool (ThisChunk);
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
InitializeListHead (&ThisChunk->NextChunk);
|
||||
ThisChunk->Length = *ContentLength;
|
||||
ThisChunk->Data = ResponseData.Body;
|
||||
ThisChunk->Data = ResponseData.Body;
|
||||
InsertTailList (HttpChunks, &ThisChunk->NextChunk);
|
||||
Status = HttpIoRecvResponse (
|
||||
HttpIo,
|
||||
@@ -802,33 +826,37 @@ HttpIoGetChunkedTransferContent (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
//
|
||||
// Read CRLF
|
||||
//
|
||||
ZeroMem((VOID *)&ResponseData, sizeof(HTTP_IO_RESPONSE_DATA));
|
||||
ZeroMem ((VOID *)&ResponseData, sizeof (HTTP_IO_RESPONSE_DATA));
|
||||
ResponseData.BodyLength = 2;
|
||||
ResponseData.Body = ChunkSizeAscii;
|
||||
Status = HttpIoRecvResponse (
|
||||
HttpIo,
|
||||
FALSE,
|
||||
&ResponseData
|
||||
);
|
||||
ResponseData.Body = ChunkSizeAscii;
|
||||
Status = HttpIoRecvResponse (
|
||||
HttpIo,
|
||||
FALSE,
|
||||
&ResponseData
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
//
|
||||
// Verify the end of chunk payload.
|
||||
//
|
||||
if ((ChunkSizeAscii [0] != CHUNKED_TRANSFER_CODING_CR) ||
|
||||
(ChunkSizeAscii [1] != CHUNKED_TRANSFER_CODING_LF)
|
||||
) {
|
||||
DEBUG ((DEBUG_ERROR, " This is an invalid End-of-chunk notation.\n"));
|
||||
goto ExitDeleteChunks;
|
||||
if ((ChunkSizeAscii[0] != CHUNKED_TRANSFER_CODING_CR) ||
|
||||
(ChunkSizeAscii[1] != CHUNKED_TRANSFER_CODING_LF)
|
||||
)
|
||||
{
|
||||
DEBUG ((DEBUG_ERROR, " This is an invalid End-of-chunk notation.\n"));
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
|
||||
TotalLength += *ContentLength;
|
||||
if (TotalLength > MaxTotalLength) {
|
||||
DEBUG ((DEBUG_ERROR, " Total chunk transfer payload exceeds the size defined by PcdMaxHttpChunkTransfer.\n"));
|
||||
goto ExitDeleteChunks;
|
||||
DEBUG ((DEBUG_ERROR, " Total chunk transfer payload exceeds the size defined by PcdMaxHttpChunkTransfer.\n"));
|
||||
goto ExitDeleteChunks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,16 +867,19 @@ HttpIoGetChunkedTransferContent (
|
||||
|
||||
ExitDeleteChunks:
|
||||
if (HttpChunks != NULL) {
|
||||
while (!IsListEmpty(HttpChunks)) {
|
||||
while (!IsListEmpty (HttpChunks)) {
|
||||
ThisListEntry = GetFirstNode (HttpChunks);
|
||||
RemoveEntryList (ThisListEntry);
|
||||
ThisChunk = (HTTP_IO_CHUNKS *)ThisListEntry;
|
||||
if (ThisChunk->Data != NULL) {
|
||||
FreePool (ThisChunk->Data);
|
||||
}
|
||||
FreePool(ThisListEntry);
|
||||
|
||||
FreePool (ThisListEntry);
|
||||
}
|
||||
|
||||
FreePool (HttpChunks);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -34,29 +34,29 @@ Header file for HttpLib.
|
||||
//
|
||||
// Field index of the HTTP URL parse result.
|
||||
//
|
||||
#define HTTP_URI_FIELD_SCHEME 0
|
||||
#define HTTP_URI_FIELD_AUTHORITY 1
|
||||
#define HTTP_URI_FIELD_PATH 2
|
||||
#define HTTP_URI_FIELD_QUERY 3
|
||||
#define HTTP_URI_FIELD_FRAGMENT 4
|
||||
#define HTTP_URI_FIELD_USERINFO 5
|
||||
#define HTTP_URI_FIELD_HOST 6
|
||||
#define HTTP_URI_FIELD_PORT 7
|
||||
#define HTTP_URI_FIELD_MAX 8
|
||||
#define HTTP_URI_FIELD_SCHEME 0
|
||||
#define HTTP_URI_FIELD_AUTHORITY 1
|
||||
#define HTTP_URI_FIELD_PATH 2
|
||||
#define HTTP_URI_FIELD_QUERY 3
|
||||
#define HTTP_URI_FIELD_FRAGMENT 4
|
||||
#define HTTP_URI_FIELD_USERINFO 5
|
||||
#define HTTP_URI_FIELD_HOST 6
|
||||
#define HTTP_URI_FIELD_PORT 7
|
||||
#define HTTP_URI_FIELD_MAX 8
|
||||
|
||||
#define HTTP_URI_PORT_MAX_NUM 65535
|
||||
#define HTTP_URI_PORT_MAX_NUM 65535
|
||||
|
||||
//
|
||||
// Structure to store the parse result of a HTTP URL.
|
||||
//
|
||||
typedef struct {
|
||||
UINT32 Offset;
|
||||
UINT32 Length;
|
||||
UINT32 Offset;
|
||||
UINT32 Length;
|
||||
} HTTP_URL_FILED_DATA;
|
||||
|
||||
typedef struct {
|
||||
UINT16 FieldBitMap;
|
||||
HTTP_URL_FILED_DATA FieldData[HTTP_URI_FIELD_MAX];
|
||||
UINT16 FieldBitMap;
|
||||
HTTP_URL_FILED_DATA FieldData[HTTP_URI_FIELD_MAX];
|
||||
} HTTP_URL_PARSER;
|
||||
|
||||
typedef enum {
|
||||
@@ -82,4 +82,3 @@ typedef enum {
|
||||
} HTTP_URL_PARSE_STATE;
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -31,10 +31,10 @@ TcpIoCommonNotify (
|
||||
)
|
||||
{
|
||||
if ((Event == NULL) || (Context == NULL)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
*((BOOLEAN *) Context) = TRUE;
|
||||
*((BOOLEAN *)Context) = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,12 +51,12 @@ TcpIoCommonNotify (
|
||||
**/
|
||||
EFI_STATUS
|
||||
TcpIoGetMapping (
|
||||
IN EFI_TCP6_PROTOCOL *Tcp6,
|
||||
IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData
|
||||
IN EFI_TCP6_PROTOCOL *Tcp6,
|
||||
IN EFI_TCP6_CONFIG_DATA *Tcp6ConfigData
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
|
||||
if ((Tcp6 == NULL) || (Tcp6ConfigData == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -85,7 +85,6 @@ TcpIoGetMapping (
|
||||
}
|
||||
|
||||
while (EFI_ERROR (gBS->CheckEvent (Event))) {
|
||||
|
||||
Tcp6->Poll (Tcp6);
|
||||
|
||||
Status = Tcp6->Configure (Tcp6, Tcp6ConfigData);
|
||||
@@ -124,26 +123,26 @@ ON_EXIT:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TcpIoCreateSocket (
|
||||
IN EFI_HANDLE Image,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINT8 TcpVersion,
|
||||
IN TCP_IO_CONFIG_DATA *ConfigData,
|
||||
OUT TCP_IO *TcpIo
|
||||
IN EFI_HANDLE Image,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN UINT8 TcpVersion,
|
||||
IN TCP_IO_CONFIG_DATA *ConfigData,
|
||||
OUT TCP_IO *TcpIo
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
EFI_GUID *ServiceBindingGuid;
|
||||
EFI_GUID *ProtocolGuid;
|
||||
VOID **Interface;
|
||||
EFI_TCP4_OPTION ControlOption;
|
||||
EFI_TCP4_CONFIG_DATA Tcp4ConfigData;
|
||||
EFI_TCP4_ACCESS_POINT *AccessPoint4;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_CONFIG_DATA Tcp6ConfigData;
|
||||
EFI_TCP6_ACCESS_POINT *AccessPoint6;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_TCP4_RECEIVE_DATA *RxData;
|
||||
EFI_STATUS Status;
|
||||
EFI_EVENT Event;
|
||||
EFI_GUID *ServiceBindingGuid;
|
||||
EFI_GUID *ProtocolGuid;
|
||||
VOID **Interface;
|
||||
EFI_TCP4_OPTION ControlOption;
|
||||
EFI_TCP4_CONFIG_DATA Tcp4ConfigData;
|
||||
EFI_TCP4_ACCESS_POINT *AccessPoint4;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_CONFIG_DATA Tcp6ConfigData;
|
||||
EFI_TCP6_ACCESS_POINT *AccessPoint6;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_TCP4_RECEIVE_DATA *RxData;
|
||||
|
||||
if ((Image == NULL) || (Controller == NULL) || (ConfigData == NULL) || (TcpIo == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -157,11 +156,11 @@ TcpIoCreateSocket (
|
||||
if (TcpVersion == TCP_VERSION_4) {
|
||||
ServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
||||
ProtocolGuid = &gEfiTcp4ProtocolGuid;
|
||||
Interface = (VOID **) (&TcpIo->Tcp.Tcp4);
|
||||
Interface = (VOID **)(&TcpIo->Tcp.Tcp4);
|
||||
} else if (TcpVersion == TCP_VERSION_6) {
|
||||
ServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
||||
ProtocolGuid = &gEfiTcp6ProtocolGuid;
|
||||
Interface = (VOID **) (&TcpIo->Tcp.Tcp6);
|
||||
Interface = (VOID **)(&TcpIo->Tcp.Tcp6);
|
||||
} else {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -194,44 +193,44 @@ TcpIoCreateSocket (
|
||||
}
|
||||
|
||||
if (TcpVersion == TCP_VERSION_4) {
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
} else {
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
}
|
||||
|
||||
TcpIo->Image = Image;
|
||||
TcpIo->Controller = Controller;
|
||||
TcpIo->Image = Image;
|
||||
TcpIo->Controller = Controller;
|
||||
|
||||
//
|
||||
// Set the configuration parameters.
|
||||
//
|
||||
ControlOption.ReceiveBufferSize = 0x200000;
|
||||
ControlOption.SendBufferSize = 0x200000;
|
||||
ControlOption.MaxSynBackLog = 0;
|
||||
ControlOption.ConnectionTimeout = 0;
|
||||
ControlOption.DataRetries = 6;
|
||||
ControlOption.FinTimeout = 0;
|
||||
ControlOption.TimeWaitTimeout = 0;
|
||||
ControlOption.KeepAliveProbes = 4;
|
||||
ControlOption.KeepAliveTime = 0;
|
||||
ControlOption.KeepAliveInterval = 0;
|
||||
ControlOption.EnableNagle = FALSE;
|
||||
ControlOption.EnableTimeStamp = FALSE;
|
||||
ControlOption.EnableWindowScaling = TRUE;
|
||||
ControlOption.EnableSelectiveAck = FALSE;
|
||||
ControlOption.EnablePathMtuDiscovery = FALSE;
|
||||
ControlOption.ReceiveBufferSize = 0x200000;
|
||||
ControlOption.SendBufferSize = 0x200000;
|
||||
ControlOption.MaxSynBackLog = 0;
|
||||
ControlOption.ConnectionTimeout = 0;
|
||||
ControlOption.DataRetries = 6;
|
||||
ControlOption.FinTimeout = 0;
|
||||
ControlOption.TimeWaitTimeout = 0;
|
||||
ControlOption.KeepAliveProbes = 4;
|
||||
ControlOption.KeepAliveTime = 0;
|
||||
ControlOption.KeepAliveInterval = 0;
|
||||
ControlOption.EnableNagle = FALSE;
|
||||
ControlOption.EnableTimeStamp = FALSE;
|
||||
ControlOption.EnableWindowScaling = TRUE;
|
||||
ControlOption.EnableSelectiveAck = FALSE;
|
||||
ControlOption.EnablePathMtuDiscovery = FALSE;
|
||||
|
||||
if (TcpVersion == TCP_VERSION_4) {
|
||||
Tcp4ConfigData.TypeOfService = 8;
|
||||
Tcp4ConfigData.TimeToLive = 255;
|
||||
Tcp4ConfigData.ControlOption = &ControlOption;
|
||||
Tcp4ConfigData.TypeOfService = 8;
|
||||
Tcp4ConfigData.TimeToLive = 255;
|
||||
Tcp4ConfigData.ControlOption = &ControlOption;
|
||||
|
||||
AccessPoint4 = &Tcp4ConfigData.AccessPoint;
|
||||
AccessPoint4 = &Tcp4ConfigData.AccessPoint;
|
||||
|
||||
ZeroMem (AccessPoint4, sizeof (EFI_TCP4_ACCESS_POINT));
|
||||
AccessPoint4->StationPort = ConfigData->Tcp4IoConfigData.StationPort;
|
||||
AccessPoint4->RemotePort = ConfigData->Tcp4IoConfigData.RemotePort;
|
||||
AccessPoint4->ActiveFlag = ConfigData->Tcp4IoConfigData.ActiveFlag;
|
||||
AccessPoint4->StationPort = ConfigData->Tcp4IoConfigData.StationPort;
|
||||
AccessPoint4->RemotePort = ConfigData->Tcp4IoConfigData.RemotePort;
|
||||
AccessPoint4->ActiveFlag = ConfigData->Tcp4IoConfigData.ActiveFlag;
|
||||
|
||||
CopyMem (
|
||||
&AccessPoint4->StationAddress,
|
||||
@@ -275,20 +274,19 @@ TcpIoCreateSocket (
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Tcp6ConfigData.TrafficClass = 0;
|
||||
Tcp6ConfigData.HopLimit = 255;
|
||||
Tcp6ConfigData.ControlOption = (EFI_TCP6_OPTION *) &ControlOption;
|
||||
Tcp6ConfigData.TrafficClass = 0;
|
||||
Tcp6ConfigData.HopLimit = 255;
|
||||
Tcp6ConfigData.ControlOption = (EFI_TCP6_OPTION *)&ControlOption;
|
||||
|
||||
AccessPoint6 = &Tcp6ConfigData.AccessPoint;
|
||||
AccessPoint6 = &Tcp6ConfigData.AccessPoint;
|
||||
|
||||
ZeroMem (AccessPoint6, sizeof (EFI_TCP6_ACCESS_POINT));
|
||||
AccessPoint6->StationPort = ConfigData->Tcp6IoConfigData.StationPort;
|
||||
AccessPoint6->RemotePort = ConfigData->Tcp6IoConfigData.RemotePort;
|
||||
AccessPoint6->ActiveFlag = ConfigData->Tcp6IoConfigData.ActiveFlag;
|
||||
AccessPoint6->StationPort = ConfigData->Tcp6IoConfigData.StationPort;
|
||||
AccessPoint6->RemotePort = ConfigData->Tcp6IoConfigData.RemotePort;
|
||||
AccessPoint6->ActiveFlag = ConfigData->Tcp6IoConfigData.ActiveFlag;
|
||||
|
||||
IP6_COPY_ADDRESS (&AccessPoint6->RemoteAddress, &ConfigData->Tcp6IoConfigData.RemoteIp);
|
||||
|
||||
|
||||
ASSERT (Tcp6 != NULL);
|
||||
//
|
||||
// Configure the TCP6 protocol.
|
||||
@@ -345,7 +343,6 @@ TcpIoCreateSocket (
|
||||
|
||||
TcpIo->TxToken.Tcp4Token.CompletionToken.Event = Event;
|
||||
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_NOTIFY,
|
||||
@@ -359,7 +356,7 @@ TcpIoCreateSocket (
|
||||
|
||||
TcpIo->RxToken.Tcp4Token.CompletionToken.Event = Event;
|
||||
|
||||
RxData = (EFI_TCP4_RECEIVE_DATA *) AllocateZeroPool (sizeof (EFI_TCP4_RECEIVE_DATA));
|
||||
RxData = (EFI_TCP4_RECEIVE_DATA *)AllocateZeroPool (sizeof (EFI_TCP4_RECEIVE_DATA));
|
||||
if (RxData == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_ERROR;
|
||||
@@ -380,7 +377,6 @@ TcpIoCreateSocket (
|
||||
|
||||
TcpIo->CloseToken.Tcp4Token.CompletionToken.Event = Event;
|
||||
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
ON_ERROR:
|
||||
@@ -399,25 +395,25 @@ ON_ERROR:
|
||||
VOID
|
||||
EFIAPI
|
||||
TcpIoDestroySocket (
|
||||
IN TCP_IO *TcpIo
|
||||
IN TCP_IO *TcpIo
|
||||
)
|
||||
{
|
||||
EFI_EVENT Event;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
UINT8 TcpVersion;
|
||||
EFI_GUID *ServiceBindingGuid;
|
||||
EFI_GUID *ProtocolGuid;
|
||||
EFI_HANDLE ChildHandle;
|
||||
EFI_EVENT Event;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
UINT8 TcpVersion;
|
||||
EFI_GUID *ServiceBindingGuid;
|
||||
EFI_GUID *ProtocolGuid;
|
||||
EFI_HANDLE ChildHandle;
|
||||
|
||||
if (TcpIo == NULL) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
TcpVersion = TcpIo->TcpVersion;
|
||||
|
||||
if ((TcpVersion != TCP_VERSION_4) && (TcpVersion != TCP_VERSION_6)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
Event = TcpIo->ConnToken.Tcp4Token.CompletionToken.Event;
|
||||
@@ -457,25 +453,23 @@ TcpIoDestroySocket (
|
||||
Tcp4 = NULL;
|
||||
Tcp6 = NULL;
|
||||
|
||||
|
||||
if (TcpVersion == TCP_VERSION_4) {
|
||||
ServiceBindingGuid = &gEfiTcp4ServiceBindingProtocolGuid;
|
||||
ProtocolGuid = &gEfiTcp4ProtocolGuid;
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
if (Tcp4 != NULL) {
|
||||
Tcp4->Configure (Tcp4, NULL);
|
||||
}
|
||||
} else {
|
||||
ServiceBindingGuid = &gEfiTcp6ServiceBindingProtocolGuid;
|
||||
ProtocolGuid = &gEfiTcp6ProtocolGuid;
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
if (Tcp6 != NULL) {
|
||||
Tcp6->Configure (Tcp6, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if ((Tcp4 != NULL) || (Tcp6 != NULL)) {
|
||||
|
||||
gBS->CloseProtocol (
|
||||
TcpIo->Handle,
|
||||
ProtocolGuid,
|
||||
@@ -502,7 +496,6 @@ TcpIoDestroySocket (
|
||||
}
|
||||
|
||||
if (ChildHandle != NULL) {
|
||||
|
||||
gBS->CloseProtocol (
|
||||
ChildHandle,
|
||||
ProtocolGuid,
|
||||
@@ -539,13 +532,13 @@ TcpIoDestroySocket (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TcpIoConnect (
|
||||
IN OUT TCP_IO *TcpIo,
|
||||
IN EFI_EVENT Timeout OPTIONAL
|
||||
IN OUT TCP_IO *TcpIo,
|
||||
IN EFI_EVENT Timeout OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_STATUS Status;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((TcpIo == NULL) || (TcpIo->Tcp.Tcp4 == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -584,6 +577,7 @@ TcpIoConnect (
|
||||
} else {
|
||||
Tcp6->Cancel (Tcp6, &TcpIo->ConnToken.Tcp6Token.CompletionToken);
|
||||
}
|
||||
|
||||
Status = EFI_TIMEOUT;
|
||||
} else {
|
||||
Status = TcpIo->ConnToken.Tcp4Token.CompletionToken.Status;
|
||||
@@ -613,14 +607,14 @@ TcpIoConnect (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TcpIoAccept (
|
||||
IN OUT TCP_IO *TcpIo,
|
||||
IN EFI_EVENT Timeout OPTIONAL
|
||||
IN OUT TCP_IO *TcpIo,
|
||||
IN EFI_EVENT Timeout OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *ProtocolGuid;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_STATUS Status;
|
||||
EFI_GUID *ProtocolGuid;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
|
||||
if ((TcpIo == NULL) || (TcpIo->Tcp.Tcp4 == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
@@ -659,6 +653,7 @@ TcpIoAccept (
|
||||
} else {
|
||||
Tcp6->Cancel (Tcp6, &TcpIo->ListenToken.Tcp6Token.CompletionToken);
|
||||
}
|
||||
|
||||
Status = EFI_TIMEOUT;
|
||||
} else {
|
||||
Status = TcpIo->ListenToken.Tcp4Token.CompletionToken.Status;
|
||||
@@ -678,12 +673,11 @@ TcpIoAccept (
|
||||
Status = gBS->OpenProtocol (
|
||||
TcpIo->ListenToken.Tcp4Token.NewChildHandle,
|
||||
ProtocolGuid,
|
||||
(VOID **) (&TcpIo->NewTcp.Tcp4),
|
||||
(VOID **)(&TcpIo->NewTcp.Tcp4),
|
||||
TcpIo->Image,
|
||||
TcpIo->Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
return Status;
|
||||
@@ -698,15 +692,15 @@ TcpIoAccept (
|
||||
VOID
|
||||
EFIAPI
|
||||
TcpIoReset (
|
||||
IN OUT TCP_IO *TcpIo
|
||||
IN OUT TCP_IO *TcpIo
|
||||
)
|
||||
{
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_STATUS Status;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_STATUS Status;
|
||||
|
||||
if ((TcpIo == NULL) || (TcpIo->Tcp.Tcp4 == NULL)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
TcpIo->IsCloseDone = FALSE;
|
||||
@@ -715,18 +709,18 @@ TcpIoReset (
|
||||
|
||||
if (TcpIo->TcpVersion == TCP_VERSION_4) {
|
||||
TcpIo->CloseToken.Tcp4Token.AbortOnClose = TRUE;
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
Status = Tcp4->Close (Tcp4, &TcpIo->CloseToken.Tcp4Token);
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
Status = Tcp4->Close (Tcp4, &TcpIo->CloseToken.Tcp4Token);
|
||||
} else if (TcpIo->TcpVersion == TCP_VERSION_6) {
|
||||
TcpIo->CloseToken.Tcp6Token.AbortOnClose = TRUE;
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
Status = Tcp6->Close (Tcp6, &TcpIo->CloseToken.Tcp6Token);
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
Status = Tcp6->Close (Tcp6, &TcpIo->CloseToken.Tcp6Token);
|
||||
} else {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
while (!TcpIo->IsCloseDone) {
|
||||
@@ -738,7 +732,6 @@ TcpIoReset (
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Transmit the Packet to the other endpoint of the socket.
|
||||
|
||||
@@ -757,22 +750,21 @@ TcpIoReset (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TcpIoTransmit (
|
||||
IN TCP_IO *TcpIo,
|
||||
IN NET_BUF *Packet
|
||||
IN TCP_IO *TcpIo,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *Data;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
UINTN Size;
|
||||
EFI_STATUS Status;
|
||||
VOID *Data;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
UINTN Size;
|
||||
|
||||
if ((TcpIo == NULL) || (TcpIo->Tcp.Tcp4 == NULL)|| (Packet == NULL)) {
|
||||
if ((TcpIo == NULL) || (TcpIo->Tcp.Tcp4 == NULL) || (Packet == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (TcpIo->TcpVersion == TCP_VERSION_4) {
|
||||
|
||||
Size = sizeof (EFI_TCP4_TRANSMIT_DATA) +
|
||||
(Packet->BlockOpNum - 1) * sizeof (EFI_TCP4_FRAGMENT_DATA);
|
||||
} else if (TcpIo->TcpVersion == TCP_VERSION_6) {
|
||||
@@ -787,19 +779,19 @@ TcpIoTransmit (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->Push = TRUE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->Urgent = FALSE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->DataLength = Packet->TotalSize;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->Push = TRUE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->Urgent = FALSE;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->DataLength = Packet->TotalSize;
|
||||
|
||||
//
|
||||
// Build the fragment table.
|
||||
//
|
||||
((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentCount = Packet->BlockOpNum;
|
||||
((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentCount = Packet->BlockOpNum;
|
||||
|
||||
NetbufBuildExt (
|
||||
Packet,
|
||||
(NET_FRAGMENT *) &((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentTable[0],
|
||||
&((EFI_TCP4_TRANSMIT_DATA *) Data)->FragmentCount
|
||||
(NET_FRAGMENT *)&((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentTable[0],
|
||||
&((EFI_TCP4_TRANSMIT_DATA *)Data)->FragmentCount
|
||||
);
|
||||
|
||||
Tcp4 = NULL;
|
||||
@@ -810,8 +802,8 @@ TcpIoTransmit (
|
||||
// Transmit the packet.
|
||||
//
|
||||
if (TcpIo->TcpVersion == TCP_VERSION_4) {
|
||||
TcpIo->TxToken.Tcp4Token.Packet.TxData = (EFI_TCP4_TRANSMIT_DATA *) Data;
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
TcpIo->TxToken.Tcp4Token.Packet.TxData = (EFI_TCP4_TRANSMIT_DATA *)Data;
|
||||
Tcp4 = TcpIo->Tcp.Tcp4;
|
||||
if (TcpIo->IsListenDone) {
|
||||
Tcp4 = TcpIo->NewTcp.Tcp4;
|
||||
}
|
||||
@@ -820,10 +812,10 @@ TcpIoTransmit (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Status = Tcp4->Transmit (Tcp4, &TcpIo->TxToken.Tcp4Token);
|
||||
Status = Tcp4->Transmit (Tcp4, &TcpIo->TxToken.Tcp4Token);
|
||||
} else {
|
||||
TcpIo->TxToken.Tcp6Token.Packet.TxData = (EFI_TCP6_TRANSMIT_DATA *) Data;
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
TcpIo->TxToken.Tcp6Token.Packet.TxData = (EFI_TCP6_TRANSMIT_DATA *)Data;
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
if (TcpIo->IsListenDone) {
|
||||
Tcp6 = TcpIo->NewTcp.Tcp6;
|
||||
}
|
||||
@@ -832,7 +824,7 @@ TcpIoTransmit (
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Status = Tcp6->Transmit (Tcp6, &TcpIo->TxToken.Tcp6Token);
|
||||
Status = Tcp6->Transmit (Tcp6, &TcpIo->TxToken.Tcp6Token);
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -847,8 +839,8 @@ TcpIoTransmit (
|
||||
}
|
||||
}
|
||||
|
||||
TcpIo->IsTxDone = FALSE;
|
||||
Status = TcpIo->TxToken.Tcp4Token.CompletionToken.Status;
|
||||
TcpIo->IsTxDone = FALSE;
|
||||
Status = TcpIo->TxToken.Tcp4Token.CompletionToken.Status;
|
||||
|
||||
ON_EXIT:
|
||||
|
||||
@@ -878,21 +870,21 @@ ON_EXIT:
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
TcpIoReceive (
|
||||
IN OUT TCP_IO *TcpIo,
|
||||
IN NET_BUF *Packet,
|
||||
IN BOOLEAN AsyncMode,
|
||||
IN EFI_EVENT Timeout OPTIONAL
|
||||
IN OUT TCP_IO *TcpIo,
|
||||
IN NET_BUF *Packet,
|
||||
IN BOOLEAN AsyncMode,
|
||||
IN EFI_EVENT Timeout OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_TCP4_RECEIVE_DATA *RxData;
|
||||
EFI_STATUS Status;
|
||||
NET_FRAGMENT *Fragment;
|
||||
UINT32 FragmentCount;
|
||||
UINT32 CurrentFragment;
|
||||
EFI_TCP4_PROTOCOL *Tcp4;
|
||||
EFI_TCP6_PROTOCOL *Tcp6;
|
||||
EFI_TCP4_RECEIVE_DATA *RxData;
|
||||
EFI_STATUS Status;
|
||||
NET_FRAGMENT *Fragment;
|
||||
UINT32 FragmentCount;
|
||||
UINT32 CurrentFragment;
|
||||
|
||||
if ((TcpIo == NULL) || (TcpIo->Tcp.Tcp4 == NULL)|| (Packet == NULL)) {
|
||||
if ((TcpIo == NULL) || (TcpIo->Tcp.Tcp4 == NULL) || (Packet == NULL)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -914,7 +906,6 @@ TcpIoReceive (
|
||||
if (Tcp4 == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
} else if (TcpIo->TcpVersion == TCP_VERSION_6) {
|
||||
Tcp6 = TcpIo->Tcp.Tcp6;
|
||||
|
||||
@@ -925,7 +916,6 @@ TcpIoReceive (
|
||||
if (Tcp6 == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
} else {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
@@ -936,19 +926,20 @@ TcpIoReceive (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
//
|
||||
// Build the fragment table.
|
||||
//
|
||||
NetbufBuildExt (Packet, Fragment, &FragmentCount);
|
||||
|
||||
RxData->FragmentCount = 1;
|
||||
CurrentFragment = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
RxData->FragmentCount = 1;
|
||||
CurrentFragment = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
while (CurrentFragment < FragmentCount) {
|
||||
RxData->DataLength = Fragment[CurrentFragment].Len;
|
||||
RxData->FragmentTable[0].FragmentLength = Fragment[CurrentFragment].Len;
|
||||
RxData->FragmentTable[0].FragmentBuffer = Fragment[CurrentFragment].Bulk;
|
||||
RxData->DataLength = Fragment[CurrentFragment].Len;
|
||||
RxData->FragmentTable[0].FragmentLength = Fragment[CurrentFragment].Len;
|
||||
RxData->FragmentTable[0].FragmentBuffer = Fragment[CurrentFragment].Bulk;
|
||||
|
||||
if (TcpIo->TcpVersion == TCP_VERSION_4) {
|
||||
Status = Tcp4->Receive (Tcp4, &TcpIo->RxToken.Tcp4Token);
|
||||
|
@@ -18,7 +18,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DpcLib.h>
|
||||
|
||||
|
||||
/**
|
||||
Free a UDP_TX_TOKEN. The TX event is closed.
|
||||
|
||||
@@ -27,10 +26,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
**/
|
||||
VOID
|
||||
UdpIoFreeTxToken (
|
||||
IN UDP_TX_TOKEN *TxToken
|
||||
IN UDP_TX_TOKEN *TxToken
|
||||
)
|
||||
{
|
||||
|
||||
if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
gBS->CloseEvent (TxToken->Token.Udp4.Event);
|
||||
} else if (TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION) {
|
||||
@@ -50,7 +48,7 @@ UdpIoFreeTxToken (
|
||||
**/
|
||||
VOID
|
||||
UdpIoFreeRxToken (
|
||||
IN UDP_RX_TOKEN *RxToken
|
||||
IN UDP_RX_TOKEN *RxToken
|
||||
)
|
||||
{
|
||||
if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
@@ -76,15 +74,17 @@ UdpIoFreeRxToken (
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoOnDgramSentDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
|
||||
TxToken = (UDP_TX_TOKEN *) Context;
|
||||
TxToken = (UDP_TX_TOKEN *)Context;
|
||||
ASSERT (TxToken->Signature == UDP_IO_TX_SIGNATURE);
|
||||
ASSERT ((TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(TxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(TxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
RemoveEntryList (&TxToken->Link);
|
||||
|
||||
@@ -107,8 +107,8 @@ UdpIoOnDgramSentDpc (
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoOnDgramSent (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -126,12 +126,12 @@ UdpIoOnDgramSent (
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoRecycleDgram (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
|
||||
RxToken = (UDP_RX_TOKEN *) Context;
|
||||
RxToken = (UDP_RX_TOKEN *)Context;
|
||||
|
||||
if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
gBS->SignalEvent (RxToken->Token.Udp4.Packet.RxData->RecycleSignal);
|
||||
@@ -156,26 +156,30 @@ UdpIoRecycleDgram (
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoOnDgramRcvdDpc (
|
||||
IN VOID *Context
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
VOID *Token;
|
||||
VOID *RxData;
|
||||
VOID *Session;
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
UDP_END_POINT EndPoint;
|
||||
NET_BUF *Netbuf;
|
||||
EFI_STATUS Status;
|
||||
VOID *Token;
|
||||
VOID *RxData;
|
||||
VOID *Session;
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
UDP_END_POINT EndPoint;
|
||||
NET_BUF *Netbuf;
|
||||
|
||||
RxToken = (UDP_RX_TOKEN *) Context;
|
||||
RxToken = (UDP_RX_TOKEN *)Context;
|
||||
|
||||
ZeroMem (&EndPoint, sizeof(UDP_END_POINT));
|
||||
ZeroMem (&EndPoint, sizeof (UDP_END_POINT));
|
||||
|
||||
ASSERT ((RxToken->Signature == UDP_IO_RX_SIGNATURE) &&
|
||||
(RxToken == RxToken->UdpIo->RecvRequest));
|
||||
ASSERT (
|
||||
(RxToken->Signature == UDP_IO_RX_SIGNATURE) &&
|
||||
(RxToken == RxToken->UdpIo->RecvRequest)
|
||||
);
|
||||
|
||||
ASSERT ((RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(RxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(RxToken->UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
//
|
||||
// Clear the receive request first in case that the caller
|
||||
@@ -185,15 +189,15 @@ UdpIoOnDgramRcvdDpc (
|
||||
|
||||
if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
Token = &RxToken->Token.Udp4;
|
||||
RxData = ((EFI_UDP4_COMPLETION_TOKEN *) Token)->Packet.RxData;
|
||||
Status = ((EFI_UDP4_COMPLETION_TOKEN *) Token)->Status;
|
||||
RxData = ((EFI_UDP4_COMPLETION_TOKEN *)Token)->Packet.RxData;
|
||||
Status = ((EFI_UDP4_COMPLETION_TOKEN *)Token)->Status;
|
||||
} else {
|
||||
Token = &RxToken->Token.Udp6;
|
||||
RxData = ((EFI_UDP6_COMPLETION_TOKEN *) Token)->Packet.RxData;
|
||||
Status = ((EFI_UDP6_COMPLETION_TOKEN *) Token)->Status;
|
||||
RxData = ((EFI_UDP6_COMPLETION_TOKEN *)Token)->Packet.RxData;
|
||||
Status = ((EFI_UDP6_COMPLETION_TOKEN *)Token)->Status;
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status) || RxData == NULL) {
|
||||
if (EFI_ERROR (Status) || (RxData == NULL)) {
|
||||
if (Status != EFI_ABORTED) {
|
||||
//
|
||||
// Invoke the CallBack only if the reception is not actively aborted.
|
||||
@@ -209,7 +213,7 @@ UdpIoOnDgramRcvdDpc (
|
||||
// Build a NET_BUF from the UDP receive data, then deliver it up.
|
||||
//
|
||||
if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
if (((EFI_UDP4_RECEIVE_DATA *) RxData)->DataLength == 0) {
|
||||
if (((EFI_UDP4_RECEIVE_DATA *)RxData)->DataLength == 0) {
|
||||
//
|
||||
// Discard zero length data payload packet.
|
||||
//
|
||||
@@ -217,42 +221,42 @@ UdpIoOnDgramRcvdDpc (
|
||||
}
|
||||
|
||||
Netbuf = NetbufFromExt (
|
||||
(NET_FRAGMENT *)((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentTable,
|
||||
((EFI_UDP4_RECEIVE_DATA *) RxData)->FragmentCount,
|
||||
(NET_FRAGMENT *)((EFI_UDP4_RECEIVE_DATA *)RxData)->FragmentTable,
|
||||
((EFI_UDP4_RECEIVE_DATA *)RxData)->FragmentCount,
|
||||
0,
|
||||
(UINT32) RxToken->HeadLen,
|
||||
(UINT32)RxToken->HeadLen,
|
||||
UdpIoRecycleDgram,
|
||||
RxToken
|
||||
);
|
||||
|
||||
if (Netbuf == NULL) {
|
||||
gBS->SignalEvent (((EFI_UDP4_RECEIVE_DATA *) RxData)->RecycleSignal);
|
||||
gBS->SignalEvent (((EFI_UDP4_RECEIVE_DATA *)RxData)->RecycleSignal);
|
||||
RxToken->CallBack (NULL, NULL, EFI_OUT_OF_RESOURCES, RxToken->Context);
|
||||
|
||||
UdpIoFreeRxToken (RxToken);
|
||||
return;
|
||||
}
|
||||
|
||||
Session = &((EFI_UDP4_RECEIVE_DATA *) RxData)->UdpSession;
|
||||
EndPoint.LocalPort = ((EFI_UDP4_SESSION_DATA *) Session)->DestinationPort;
|
||||
EndPoint.RemotePort = ((EFI_UDP4_SESSION_DATA *) Session)->SourcePort;
|
||||
Session = &((EFI_UDP4_RECEIVE_DATA *)RxData)->UdpSession;
|
||||
EndPoint.LocalPort = ((EFI_UDP4_SESSION_DATA *)Session)->DestinationPort;
|
||||
EndPoint.RemotePort = ((EFI_UDP4_SESSION_DATA *)Session)->SourcePort;
|
||||
|
||||
CopyMem (
|
||||
&EndPoint.LocalAddr,
|
||||
&((EFI_UDP4_SESSION_DATA *) Session)->DestinationAddress,
|
||||
&((EFI_UDP4_SESSION_DATA *)Session)->DestinationAddress,
|
||||
sizeof (EFI_IPv4_ADDRESS)
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
&EndPoint.RemoteAddr,
|
||||
&((EFI_UDP4_SESSION_DATA *) Session)->SourceAddress,
|
||||
&((EFI_UDP4_SESSION_DATA *)Session)->SourceAddress,
|
||||
sizeof (EFI_IPv4_ADDRESS)
|
||||
);
|
||||
|
||||
EndPoint.LocalAddr.Addr[0] = NTOHL (EndPoint.LocalAddr.Addr[0]);
|
||||
EndPoint.RemoteAddr.Addr[0] = NTOHL (EndPoint.RemoteAddr.Addr[0]);
|
||||
} else {
|
||||
if (((EFI_UDP6_RECEIVE_DATA *) RxData)->DataLength == 0) {
|
||||
if (((EFI_UDP6_RECEIVE_DATA *)RxData)->DataLength == 0) {
|
||||
//
|
||||
// Discard zero length data payload packet.
|
||||
//
|
||||
@@ -260,35 +264,35 @@ UdpIoOnDgramRcvdDpc (
|
||||
}
|
||||
|
||||
Netbuf = NetbufFromExt (
|
||||
(NET_FRAGMENT *)((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentTable,
|
||||
((EFI_UDP6_RECEIVE_DATA *) RxData)->FragmentCount,
|
||||
(NET_FRAGMENT *)((EFI_UDP6_RECEIVE_DATA *)RxData)->FragmentTable,
|
||||
((EFI_UDP6_RECEIVE_DATA *)RxData)->FragmentCount,
|
||||
0,
|
||||
(UINT32) RxToken->HeadLen,
|
||||
(UINT32)RxToken->HeadLen,
|
||||
UdpIoRecycleDgram,
|
||||
RxToken
|
||||
);
|
||||
|
||||
if (Netbuf == NULL) {
|
||||
gBS->SignalEvent (((EFI_UDP6_RECEIVE_DATA *) RxData)->RecycleSignal);
|
||||
gBS->SignalEvent (((EFI_UDP6_RECEIVE_DATA *)RxData)->RecycleSignal);
|
||||
RxToken->CallBack (NULL, NULL, EFI_OUT_OF_RESOURCES, RxToken->Context);
|
||||
|
||||
UdpIoFreeRxToken (RxToken);
|
||||
return;
|
||||
}
|
||||
|
||||
Session = &((EFI_UDP6_RECEIVE_DATA *) RxData)->UdpSession;
|
||||
EndPoint.LocalPort = ((EFI_UDP6_SESSION_DATA *) Session)->DestinationPort;
|
||||
EndPoint.RemotePort = ((EFI_UDP6_SESSION_DATA *) Session)->SourcePort;
|
||||
Session = &((EFI_UDP6_RECEIVE_DATA *)RxData)->UdpSession;
|
||||
EndPoint.LocalPort = ((EFI_UDP6_SESSION_DATA *)Session)->DestinationPort;
|
||||
EndPoint.RemotePort = ((EFI_UDP6_SESSION_DATA *)Session)->SourcePort;
|
||||
|
||||
CopyMem (
|
||||
&EndPoint.LocalAddr,
|
||||
&((EFI_UDP6_SESSION_DATA *) Session)->DestinationAddress,
|
||||
&((EFI_UDP6_SESSION_DATA *)Session)->DestinationAddress,
|
||||
sizeof (EFI_IPv6_ADDRESS)
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
&EndPoint.RemoteAddr,
|
||||
&((EFI_UDP6_SESSION_DATA *) Session)->SourceAddress,
|
||||
&((EFI_UDP6_SESSION_DATA *)Session)->SourceAddress,
|
||||
sizeof (EFI_IPv6_ADDRESS)
|
||||
);
|
||||
|
||||
@@ -301,10 +305,10 @@ UdpIoOnDgramRcvdDpc (
|
||||
|
||||
Resume:
|
||||
if (RxToken->UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
gBS->SignalEvent (((EFI_UDP4_RECEIVE_DATA *) RxData)->RecycleSignal);
|
||||
gBS->SignalEvent (((EFI_UDP4_RECEIVE_DATA *)RxData)->RecycleSignal);
|
||||
RxToken->UdpIo->Protocol.Udp4->Receive (RxToken->UdpIo->Protocol.Udp4, &RxToken->Token.Udp4);
|
||||
} else {
|
||||
gBS->SignalEvent (((EFI_UDP6_RECEIVE_DATA *) RxData)->RecycleSignal);
|
||||
gBS->SignalEvent (((EFI_UDP6_RECEIVE_DATA *)RxData)->RecycleSignal);
|
||||
RxToken->UdpIo->Protocol.Udp6->Receive (RxToken->UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);
|
||||
}
|
||||
}
|
||||
@@ -319,8 +323,8 @@ Resume:
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoOnDgramRcvd (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -342,17 +346,19 @@ UdpIoOnDgramRcvd (
|
||||
**/
|
||||
UDP_RX_TOKEN *
|
||||
UdpIoCreateRxToken (
|
||||
IN UDP_IO *UdpIo,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context,
|
||||
IN UINT32 HeadLen
|
||||
IN UDP_IO *UdpIo,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context,
|
||||
IN UINT32 HeadLen
|
||||
)
|
||||
{
|
||||
UDP_RX_TOKEN *Token;
|
||||
EFI_STATUS Status;
|
||||
UDP_RX_TOKEN *Token;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
Token = AllocatePool (sizeof (UDP_RX_TOKEN));
|
||||
|
||||
@@ -360,14 +366,13 @@ UdpIoCreateRxToken (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Token->Signature = UDP_IO_RX_SIGNATURE;
|
||||
Token->UdpIo = UdpIo;
|
||||
Token->CallBack = CallBack;
|
||||
Token->Context = Context;
|
||||
Token->HeadLen = HeadLen;
|
||||
Token->Signature = UDP_IO_RX_SIGNATURE;
|
||||
Token->UdpIo = UdpIo;
|
||||
Token->CallBack = CallBack;
|
||||
Token->Context = Context;
|
||||
Token->HeadLen = HeadLen;
|
||||
|
||||
if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
|
||||
Token->Token.Udp4.Status = EFI_NOT_READY;
|
||||
Token->Token.Udp4.Packet.RxData = NULL;
|
||||
|
||||
@@ -378,8 +383,7 @@ UdpIoCreateRxToken (
|
||||
Token,
|
||||
&Token->Token.Udp4.Event
|
||||
);
|
||||
} else {
|
||||
|
||||
} else {
|
||||
Token->Token.Udp6.Status = EFI_NOT_READY;
|
||||
Token->Token.Udp6.Packet.RxData = NULL;
|
||||
|
||||
@@ -392,7 +396,6 @@ UdpIoCreateRxToken (
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Token);
|
||||
return NULL;
|
||||
@@ -420,25 +423,27 @@ UdpIoCreateRxToken (
|
||||
**/
|
||||
UDP_TX_TOKEN *
|
||||
UdpIoCreateTxToken (
|
||||
IN UDP_IO *UdpIo,
|
||||
IN NET_BUF *Packet,
|
||||
IN UDP_END_POINT *EndPoint OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *Gateway OPTIONAL,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
IN UDP_IO *UdpIo,
|
||||
IN NET_BUF *Packet,
|
||||
IN UDP_END_POINT *EndPoint OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *Gateway OPTIONAL,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
VOID *Token;
|
||||
VOID *Data;
|
||||
EFI_STATUS Status;
|
||||
UINT32 Count;
|
||||
UINTN Size;
|
||||
IP4_ADDR Ip;
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
VOID *Token;
|
||||
VOID *Data;
|
||||
EFI_STATUS Status;
|
||||
UINT32 Count;
|
||||
UINTN Size;
|
||||
IP4_ADDR Ip;
|
||||
|
||||
ASSERT (Packet != NULL);
|
||||
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
Size = sizeof (UDP_TX_TOKEN) + sizeof (EFI_UDP4_FRAGMENT_DATA) * (Packet->BlockOpNum - 1);
|
||||
@@ -455,24 +460,23 @@ UdpIoCreateTxToken (
|
||||
TxToken->Signature = UDP_IO_TX_SIGNATURE;
|
||||
InitializeListHead (&TxToken->Link);
|
||||
|
||||
TxToken->UdpIo = UdpIo;
|
||||
TxToken->CallBack = CallBack;
|
||||
TxToken->Packet = Packet;
|
||||
TxToken->Context = Context;
|
||||
TxToken->UdpIo = UdpIo;
|
||||
TxToken->CallBack = CallBack;
|
||||
TxToken->Packet = Packet;
|
||||
TxToken->Context = Context;
|
||||
|
||||
Token = &(TxToken->Token);
|
||||
Count = Packet->BlockOpNum;
|
||||
Token = &(TxToken->Token);
|
||||
Count = Packet->BlockOpNum;
|
||||
|
||||
if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
|
||||
((EFI_UDP4_COMPLETION_TOKEN *) Token)->Status = EFI_NOT_READY;
|
||||
((EFI_UDP4_COMPLETION_TOKEN *)Token)->Status = EFI_NOT_READY;
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_NOTIFY,
|
||||
UdpIoOnDgramSent,
|
||||
TxToken,
|
||||
&((EFI_UDP4_COMPLETION_TOKEN *) Token)->Event
|
||||
&((EFI_UDP4_COMPLETION_TOKEN *)Token)->Event
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -480,20 +484,20 @@ UdpIoCreateTxToken (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Data = &(TxToken->Data.Udp4);
|
||||
((EFI_UDP4_COMPLETION_TOKEN *) Token)->Packet.TxData = Data;
|
||||
Data = &(TxToken->Data.Udp4);
|
||||
((EFI_UDP4_COMPLETION_TOKEN *)Token)->Packet.TxData = Data;
|
||||
|
||||
((EFI_UDP4_TRANSMIT_DATA *) Data)->UdpSessionData = NULL;
|
||||
((EFI_UDP4_TRANSMIT_DATA *) Data)->GatewayAddress = NULL;
|
||||
((EFI_UDP4_TRANSMIT_DATA *) Data)->DataLength = Packet->TotalSize;
|
||||
((EFI_UDP4_TRANSMIT_DATA *)Data)->UdpSessionData = NULL;
|
||||
((EFI_UDP4_TRANSMIT_DATA *)Data)->GatewayAddress = NULL;
|
||||
((EFI_UDP4_TRANSMIT_DATA *)Data)->DataLength = Packet->TotalSize;
|
||||
|
||||
NetbufBuildExt (
|
||||
Packet,
|
||||
(NET_FRAGMENT *)((EFI_UDP4_TRANSMIT_DATA *) Data)->FragmentTable,
|
||||
(NET_FRAGMENT *)((EFI_UDP4_TRANSMIT_DATA *)Data)->FragmentTable,
|
||||
&Count
|
||||
);
|
||||
|
||||
((EFI_UDP4_TRANSMIT_DATA *) Data)->FragmentCount = Count;
|
||||
((EFI_UDP4_TRANSMIT_DATA *)Data)->FragmentCount = Count;
|
||||
|
||||
if (EndPoint != NULL) {
|
||||
Ip = HTONL (EndPoint->LocalAddr.Addr[0]);
|
||||
@@ -510,27 +514,25 @@ UdpIoCreateTxToken (
|
||||
sizeof (EFI_IPv4_ADDRESS)
|
||||
);
|
||||
|
||||
TxToken->Session.Udp4.SourcePort = EndPoint->LocalPort;
|
||||
TxToken->Session.Udp4.DestinationPort = EndPoint->RemotePort;
|
||||
((EFI_UDP4_TRANSMIT_DATA *) Data)->UdpSessionData = &(TxToken->Session.Udp4);
|
||||
TxToken->Session.Udp4.SourcePort = EndPoint->LocalPort;
|
||||
TxToken->Session.Udp4.DestinationPort = EndPoint->RemotePort;
|
||||
((EFI_UDP4_TRANSMIT_DATA *)Data)->UdpSessionData = &(TxToken->Session.Udp4);
|
||||
}
|
||||
|
||||
if (Gateway != NULL && (Gateway->Addr[0] != 0)) {
|
||||
if ((Gateway != NULL) && (Gateway->Addr[0] != 0)) {
|
||||
Ip = HTONL (Gateway->Addr[0]);
|
||||
CopyMem (&TxToken->Gateway, &Ip, sizeof (EFI_IPv4_ADDRESS));
|
||||
((EFI_UDP4_TRANSMIT_DATA *) Data)->GatewayAddress = &TxToken->Gateway;
|
||||
((EFI_UDP4_TRANSMIT_DATA *)Data)->GatewayAddress = &TxToken->Gateway;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
((EFI_UDP6_COMPLETION_TOKEN *) Token)->Status = EFI_NOT_READY;
|
||||
((EFI_UDP6_COMPLETION_TOKEN *)Token)->Status = EFI_NOT_READY;
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL,
|
||||
TPL_NOTIFY,
|
||||
UdpIoOnDgramSent,
|
||||
TxToken,
|
||||
&((EFI_UDP6_COMPLETION_TOKEN *) Token)->Event
|
||||
&((EFI_UDP6_COMPLETION_TOKEN *)Token)->Event
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -538,35 +540,35 @@ UdpIoCreateTxToken (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Data = &(TxToken->Data.Udp6);
|
||||
((EFI_UDP6_COMPLETION_TOKEN *) Token)->Packet.TxData = Data;
|
||||
((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData = NULL;
|
||||
((EFI_UDP6_TRANSMIT_DATA *) Data)->DataLength = Packet->TotalSize;
|
||||
Data = &(TxToken->Data.Udp6);
|
||||
((EFI_UDP6_COMPLETION_TOKEN *)Token)->Packet.TxData = Data;
|
||||
((EFI_UDP6_TRANSMIT_DATA *)Data)->UdpSessionData = NULL;
|
||||
((EFI_UDP6_TRANSMIT_DATA *)Data)->DataLength = Packet->TotalSize;
|
||||
|
||||
NetbufBuildExt (
|
||||
Packet,
|
||||
(NET_FRAGMENT *)((EFI_UDP6_TRANSMIT_DATA *) Data)->FragmentTable,
|
||||
(NET_FRAGMENT *)((EFI_UDP6_TRANSMIT_DATA *)Data)->FragmentTable,
|
||||
&Count
|
||||
);
|
||||
|
||||
((EFI_UDP6_TRANSMIT_DATA *) Data)->FragmentCount = Count;
|
||||
((EFI_UDP6_TRANSMIT_DATA *)Data)->FragmentCount = Count;
|
||||
|
||||
if (EndPoint != NULL) {
|
||||
CopyMem (
|
||||
&TxToken->Session.Udp6.SourceAddress,
|
||||
&EndPoint->LocalAddr.v6,
|
||||
sizeof(EFI_IPv6_ADDRESS)
|
||||
sizeof (EFI_IPv6_ADDRESS)
|
||||
);
|
||||
|
||||
CopyMem (
|
||||
&TxToken->Session.Udp6.DestinationAddress,
|
||||
&EndPoint->RemoteAddr.v6,
|
||||
sizeof(EFI_IPv6_ADDRESS)
|
||||
sizeof (EFI_IPv6_ADDRESS)
|
||||
);
|
||||
|
||||
TxToken->Session.Udp6.SourcePort = EndPoint->LocalPort;
|
||||
TxToken->Session.Udp6.DestinationPort = EndPoint->RemotePort;
|
||||
((EFI_UDP6_TRANSMIT_DATA *) Data)->UdpSessionData = &(TxToken->Session.Udp6);
|
||||
TxToken->Session.Udp6.SourcePort = EndPoint->LocalPort;
|
||||
TxToken->Session.Udp6.DestinationPort = EndPoint->RemotePort;
|
||||
((EFI_UDP6_TRANSMIT_DATA *)Data)->UdpSessionData = &(TxToken->Session.Udp6);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -598,15 +600,15 @@ UdpIoCreateTxToken (
|
||||
UDP_IO *
|
||||
EFIAPI
|
||||
UdpIoCreateIo (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN UDP_IO_CONFIG Configure,
|
||||
IN UINT8 UdpVersion,
|
||||
IN VOID *Context
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN UDP_IO_CONFIG Configure,
|
||||
IN UINT8 UdpVersion,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UDP_IO *UdpIo;
|
||||
EFI_STATUS Status;
|
||||
UDP_IO *UdpIo;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT (Configure != NULL);
|
||||
ASSERT ((UdpVersion == UDP_IO_UDP4_VERSION) || (UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
@@ -617,17 +619,17 @@ UdpIoCreateIo (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
UdpIo->UdpVersion = UdpVersion;
|
||||
UdpIo->Signature = UDP_IO_SIGNATURE;
|
||||
UdpIo->UdpVersion = UdpVersion;
|
||||
UdpIo->Signature = UDP_IO_SIGNATURE;
|
||||
InitializeListHead (&UdpIo->Link);
|
||||
UdpIo->RefCnt = 1;
|
||||
UdpIo->RefCnt = 1;
|
||||
|
||||
UdpIo->Controller = Controller;
|
||||
UdpIo->Image = ImageHandle;
|
||||
UdpIo->Controller = Controller;
|
||||
UdpIo->Image = ImageHandle;
|
||||
|
||||
InitializeListHead (&UdpIo->SentDatagram);
|
||||
UdpIo->RecvRequest = NULL;
|
||||
UdpIo->UdpHandle = NULL;
|
||||
UdpIo->RecvRequest = NULL;
|
||||
UdpIo->UdpHandle = NULL;
|
||||
|
||||
if (UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
//
|
||||
@@ -647,7 +649,7 @@ UdpIoCreateIo (
|
||||
Status = gBS->OpenProtocol (
|
||||
UdpIo->UdpHandle,
|
||||
&gEfiUdp4ProtocolGuid,
|
||||
(VOID **) &UdpIo->Protocol.Udp4,
|
||||
(VOID **)&UdpIo->Protocol.Udp4,
|
||||
ImageHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@@ -672,9 +674,7 @@ UdpIoCreateIo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto CLOSE_PROTOCOL;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
Status = NetLibCreateServiceChild (
|
||||
Controller,
|
||||
ImageHandle,
|
||||
@@ -689,7 +689,7 @@ UdpIoCreateIo (
|
||||
Status = gBS->OpenProtocol (
|
||||
UdpIo->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
(VOID **) &UdpIo->Protocol.Udp6,
|
||||
(VOID **)&UdpIo->Protocol.Udp6,
|
||||
ImageHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_BY_DRIVER
|
||||
@@ -763,24 +763,25 @@ FREE_MEM:
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoCancelDgrams (
|
||||
IN UDP_IO *UdpIo,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UDP_IO_TO_CANCEL ToCancel OPTIONAL,
|
||||
IN VOID *Context OPTIONAL
|
||||
IN UDP_IO *UdpIo,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN UDP_IO_TO_CANCEL ToCancel OPTIONAL,
|
||||
IN VOID *Context OPTIONAL
|
||||
)
|
||||
{
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
LIST_ENTRY *Entry;
|
||||
LIST_ENTRY *Next;
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
|
||||
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
NET_LIST_FOR_EACH_SAFE (Entry, Next, &UdpIo->SentDatagram) {
|
||||
TxToken = NET_LIST_USER_STRUCT (Entry, UDP_TX_TOKEN, Link);
|
||||
|
||||
if ((ToCancel == NULL) || (ToCancel (TxToken, Context))) {
|
||||
|
||||
if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
UdpIo->Protocol.Udp4->Cancel (UdpIo->Protocol.Udp4, &TxToken->Token.Udp4);
|
||||
} else {
|
||||
@@ -806,14 +807,16 @@ UdpIoCancelDgrams (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UdpIoFreeIo (
|
||||
IN UDP_IO *UdpIo
|
||||
IN UDP_IO *UdpIo
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
EFI_STATUS Status;
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
|
||||
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
//
|
||||
// Cancel all the sent datagram and receive requests. The
|
||||
@@ -826,7 +829,6 @@ UdpIoFreeIo (
|
||||
UdpIoCancelDgrams (UdpIo, EFI_ABORTED, NULL, NULL);
|
||||
|
||||
if (UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) {
|
||||
|
||||
if ((RxToken = UdpIo->RecvRequest) != NULL) {
|
||||
Status = UdpIo->Protocol.Udp4->Cancel (UdpIo->Protocol.Udp4, &RxToken->Token.Udp4);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -856,9 +858,7 @@ UdpIoFreeIo (
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ((RxToken = UdpIo->RecvRequest) != NULL) {
|
||||
Status = UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);
|
||||
if (EFI_ERROR (Status)) {
|
||||
@@ -870,11 +870,11 @@ UdpIoFreeIo (
|
||||
// Close then destroy the Udp6 child
|
||||
//
|
||||
Status = gBS->CloseProtocol (
|
||||
UdpIo->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
UdpIo->Image,
|
||||
UdpIo->Controller
|
||||
);
|
||||
UdpIo->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
UdpIo->Image,
|
||||
UdpIo->Controller
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@@ -890,7 +890,7 @@ UdpIoFreeIo (
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsListEmpty(&UdpIo->Link)) {
|
||||
if (!IsListEmpty (&UdpIo->Link)) {
|
||||
RemoveEntryList (&UdpIo->Link);
|
||||
}
|
||||
|
||||
@@ -898,7 +898,6 @@ UdpIoFreeIo (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Clean up the UDP_IO without freeing it. The function is called when
|
||||
user wants to re-use the UDP_IO later.
|
||||
@@ -914,13 +913,15 @@ UdpIoFreeIo (
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoCleanIo (
|
||||
IN UDP_IO *UdpIo
|
||||
IN UDP_IO *UdpIo
|
||||
)
|
||||
{
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
|
||||
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
//
|
||||
// Cancel all the sent datagram and receive requests.
|
||||
@@ -933,7 +934,6 @@ UdpIoCleanIo (
|
||||
}
|
||||
|
||||
UdpIo->Protocol.Udp4->Configure (UdpIo->Protocol.Udp4, NULL);
|
||||
|
||||
} else {
|
||||
if ((RxToken = UdpIo->RecvRequest) != NULL) {
|
||||
UdpIo->Protocol.Udp6->Cancel (UdpIo->Protocol.Udp6, &RxToken->Token.Udp6);
|
||||
@@ -969,19 +969,21 @@ UdpIoCleanIo (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UdpIoSendDatagram (
|
||||
IN UDP_IO *UdpIo,
|
||||
IN NET_BUF *Packet,
|
||||
IN UDP_END_POINT *EndPoint OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *Gateway OPTIONAL,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
IN UDP_IO *UdpIo,
|
||||
IN NET_BUF *Packet,
|
||||
IN UDP_END_POINT *EndPoint OPTIONAL,
|
||||
IN EFI_IP_ADDRESS *Gateway OPTIONAL,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
EFI_STATUS Status;
|
||||
UDP_TX_TOKEN *TxToken;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
TxToken = UdpIoCreateTxToken (UdpIo, Packet, EndPoint, Gateway, CallBack, Context);
|
||||
|
||||
@@ -1010,7 +1012,6 @@ UdpIoSendDatagram (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
The select function to cancel a single sent datagram.
|
||||
|
||||
@@ -1023,13 +1024,13 @@ UdpIoSendDatagram (
|
||||
BOOLEAN
|
||||
EFIAPI
|
||||
UdpIoCancelSingleDgram (
|
||||
IN UDP_TX_TOKEN *Token,
|
||||
IN VOID *Context
|
||||
IN UDP_TX_TOKEN *Token,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
NET_BUF *Packet;
|
||||
NET_BUF *Packet;
|
||||
|
||||
Packet = (NET_BUF *) Context;
|
||||
Packet = (NET_BUF *)Context;
|
||||
|
||||
if (Token->Packet == Packet) {
|
||||
return TRUE;
|
||||
@@ -1048,8 +1049,8 @@ UdpIoCancelSingleDgram (
|
||||
VOID
|
||||
EFIAPI
|
||||
UdpIoCancelSentDatagram (
|
||||
IN UDP_IO *UdpIo,
|
||||
IN NET_BUF *Packet
|
||||
IN UDP_IO *UdpIo,
|
||||
IN NET_BUF *Packet
|
||||
)
|
||||
{
|
||||
UdpIoCancelDgrams (UdpIo, EFI_ABORTED, UdpIoCancelSingleDgram, Packet);
|
||||
@@ -1081,17 +1082,19 @@ UdpIoCancelSentDatagram (
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
UdpIoRecvDatagram (
|
||||
IN UDP_IO *UdpIo,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context,
|
||||
IN UINT32 HeadLen
|
||||
IN UDP_IO *UdpIo,
|
||||
IN UDP_IO_CALLBACK CallBack,
|
||||
IN VOID *Context,
|
||||
IN UINT32 HeadLen
|
||||
)
|
||||
{
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
EFI_STATUS Status;
|
||||
UDP_RX_TOKEN *RxToken;
|
||||
EFI_STATUS Status;
|
||||
|
||||
ASSERT ((UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION));
|
||||
ASSERT (
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP4_VERSION) ||
|
||||
(UdpIo->UdpVersion == UDP_IO_UDP6_VERSION)
|
||||
);
|
||||
|
||||
if (UdpIo->RecvRequest != NULL) {
|
||||
return EFI_ALREADY_STARTED;
|
||||
|
Reference in New Issue
Block a user