tcp4main.c
来自「EFI BIOS是Intel提出的下一代的BIOS标准。这里上传的Edk源代码是」· C语言 代码 · 共 618 行 · 第 1/2 页
C
618 行
EFI_STATUS
EFIAPI
Tcp4Accept (
IN EFI_TCP4_PROTOCOL *This,
IN EFI_TCP4_LISTEN_TOKEN *ListenToken
)
/*++
Routine Description:
Listen on the passive instance to accept an incoming connection request.
Arguments:
This - Pointer to the EFI_TCP4_PROTOCOL instance
ListenToken - Pointer to the listen token to return when operation
finishes.
Returns:
EFI_SUCCESS - The listen token has been queued successfully.
EFI_NOT_STARTED - The EFI_TCP4_PROTOCOL instance hasn't been
configured.
EFI_ACCESS_DENIED - The instatnce is not a passive one or it is not
in Tcp4StateListen state or a same listen token
has already existed in the listen token queue of
this TCP instance.
EFI_INVALID_PARAMETER - One or more parameters are invalid.
EFI_OUT_OF_RESOURCES - Could not allocate enough resources to finish
the operation.
EFI_DEVICE_ERROR - An unexpected system or network error occurred.
--*/
{
SOCKET *Sock;
if (NULL == This ||
NULL == ListenToken ||
NULL == ListenToken->CompletionToken.Event) {
return EFI_INVALID_PARAMETER;
}
Sock = SOCK_FROM_THIS (This);
return SockAccept (Sock, ListenToken);
}
EFI_STATUS
EFIAPI
Tcp4Transmit (
IN EFI_TCP4_PROTOCOL *This,
IN EFI_TCP4_IO_TOKEN *Token
)
/*++
Routine Description:
Queues outgoing data into the transmit queue
Arguments:
This - Pointer to the EFI_TCP4_PROTOCOL instance
Token - Pointer to the completion token to queue to the transmit queue
Returns:
EFI_SUCCESS - The data has been queued for transmission
EFI_NOT_STARTED - The EFI_TCP4_PROTOCOL instance hasn't been
configured.
EFI_NO_MAPPING - When using a default address, configuration
(DHCP, BOOTP, RARP, etc.) is not finished yet.
EFI_INVALID_PARAMETER - One or more parameters are invalid
EFI_ACCESS_DENIED - One or more of the following conditions is TRUE:
* A transmit completion token with the same
Token-> CompletionToken.Event was already in
the transmission queue.
* The current instance is in Tcp4StateClosed state
* The current instance is a passive one and it is
in Tcp4StateListen state.
* User has called Close() to disconnect this
connection.
EFI_NOT_READY - The completion token could not be queued because
the transmit queue is full.
EFI_OUT_OF_RESOURCES - Could not queue the transmit data because of
resource shortage.
EFI_NETWORK_UNREACHABLE - There is no route to the destination network or
address.
--*/
{
SOCKET *Sock;
EFI_STATUS Status;
if (NULL == This ||
NULL == Token ||
NULL == Token->CompletionToken.Event ||
NULL == Token->Packet.TxData ||
0 == Token->Packet.TxData->FragmentCount ||
0 == Token->Packet.TxData->DataLength
) {
return EFI_INVALID_PARAMETER;
}
Status = Tcp4ChkDataBuf (
Token->Packet.TxData->DataLength,
Token->Packet.TxData->FragmentCount,
Token->Packet.TxData->FragmentTable
);
if (EFI_ERROR (Status)) {
return Status;
}
Sock = SOCK_FROM_THIS (This);
return SockSend (Sock, Token);
}
EFI_STATUS
EFIAPI
Tcp4Receive (
IN EFI_TCP4_PROTOCOL *This,
IN EFI_TCP4_IO_TOKEN *Token
)
/*++
Routine Description:
Place an asynchronous receive request into the receiving queue.
Arguments:
This - Pointer to the EFI_TCP4_PROTOCOL instance.
Token - Pointer to a token that is associated with the receive
data descriptor.
Returns:
EFI_SUCCESS - The receive completion token was cached
EFI_NOT_STARTED - The EFI_TCP4_PROTOCOL instance hasn't been
configured.
EFI_NO_MAPPING - When using a default address, configuration
(DHCP, BOOTP, RARP, etc.) is not finished yet.
EFI_INVALID_PARAMETER - One or more parameters are invalid.
EFI_OUT_OF_RESOURCES - The receive completion token could not be queued
due to a lack of system resources.
EFI_DEVICE_ERROR - An unexpected system or network error occurred.
EFI_ACCESS_DENIED - One or more of the following conditions is TRUE:
* A receive completion token with the same
Token->CompletionToken.Event was already in
the receive queue.
* The current instance is in Tcp4StateClosed state.
* The current instance is a passive one and it
is in Tcp4StateListen state.
* User has called Close() to disconnect this
connection.
EFI_CONNECTION_FIN - The communication peer has closed the connection
and there is no any buffered data in the receive
buffer of this instance.
EFI_NOT_READY - The receive request could not be queued because
the receive queue is full.
--*/
{
SOCKET *Sock;
EFI_STATUS Status;
if (NULL == This ||
NULL == Token ||
NULL == Token->CompletionToken.Event ||
NULL == Token->Packet.RxData ||
0 == Token->Packet.RxData->FragmentCount ||
0 == Token->Packet.RxData->DataLength
) {
return EFI_INVALID_PARAMETER;
}
Status = Tcp4ChkDataBuf (
Token->Packet.RxData->DataLength,
Token->Packet.RxData->FragmentCount,
Token->Packet.RxData->FragmentTable
);
if (EFI_ERROR (Status)) {
return Status;
}
Sock = SOCK_FROM_THIS (This);
return SockRcv (Sock, Token);
}
EFI_STATUS
EFIAPI
Tcp4Close (
IN EFI_TCP4_PROTOCOL *This,
IN EFI_TCP4_CLOSE_TOKEN *CloseToken
)
/*++
Routine Description:
Disconnecting a TCP connection gracefully or reset a TCP connection.
Arguments:
This - Pointer to the EFI_TCP4_PROTOCOL instance
CloseToken - Pointer to the close token to return when operation finishes.
Returns:
EFI_SUCCESS - The operation completed successfully
EFI_NOT_STARTED - The EFI_TCP4_PROTOCOL instance hasn't been
configured.
EFI_ACCESS_DENIED - One or more of the following are TRUE:
* Configure() has been called with TcpConfigData
set to NULL and this function has not returned.
* Previous Close() call on this instance has not
finished.
EFI_INVALID_PARAMETER - One ore more parameters are invalid
EFI_OUT_OF_RESOURCES - Could not allocate enough resource to finish the
operation
EFI_DEVICE_ERROR - Any unexpected and not belonged to above category
error.
--*/
{
SOCKET *Sock;
if (NULL == This ||
NULL == CloseToken ||
NULL == CloseToken->CompletionToken.Event) {
return EFI_INVALID_PARAMETER;
}
Sock = SOCK_FROM_THIS (This);
return SockClose (Sock, CloseToken, CloseToken->AbortOnClose);
}
EFI_STATUS
EFIAPI
Tcp4Cancel (
IN EFI_TCP4_PROTOCOL * This,
IN EFI_TCP4_COMPLETION_TOKEN * Token OPTIONAL
)
/*++
Routine Description:
Abort an asynchronous connection, listen, transmission or receive request.
Arguments:
This - Pointer to the EFI_TCP4_PROTOCOL instance.
Token - Pointer to a token that has been issued by Connect(), Accept(),
Transmit() or Receive(). If NULL, all pending tokens issued by
above four functions will be aborted.
Returns:
EFI_UNSUPPORTED - The operation is not supported in current implementation.
--*/
{
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
Tcp4Poll (
IN EFI_TCP4_PROTOCOL *This
)
/*++
Routine Description:
Poll to receive incoming data and transmit outgoing segments.
Arguments:
This - Pointer to the EFI_TCP4_PROTOCOL instance.
Returns:
EFI_SUCCESS - Incoming or outgoing data was processed.
EFI_INVALID_PARAMETER - This is NULL.
EFI_DEVICE_ERROR - An unexpected system or network error occurred.
EFI_NOT_READY - No incoming or outgoing data was processed.
EFI_TIMEOUT - Data was dropped out of the transmission or
receive queue. Consider increasing the polling rate.
--*/
{
SOCKET *Sock;
EFI_STATUS Status;
if (NULL == This) {
return EFI_INVALID_PARAMETER;
}
Sock = SOCK_FROM_THIS (This);
Status = Sock->ProtoHandler (Sock, SOCK_POLL, NULL);
return Status;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?