diff options
12 files changed, 100 insertions, 95 deletions
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c index 7cd3a84f27..1e27bfbf97 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c @@ -83,7 +83,6 @@ SockTcpDataToRcv ( UINT32 DataLen;
TCP_RSV_DATA *TcpRsvData;
BOOLEAN Urg;
-
ASSERT ((SockBuffer != NULL) && (IsUrg != NULL) && (BufLen > 0));
RcvBufEntry = SockBufFirst (SockBuffer);
@@ -232,7 +231,6 @@ SockProcessRcvToken ( SockSetTcpRxData (Sock, RxData, TokenRcvdBytes, IsUrg);
NetbufQueTrim (Sock->RcvBuffer.DataQueue, TokenRcvdBytes);
-// SOCK_TRIM_RCV_BUFF (Sock, TokenRcvdBytes);
SIGNAL_TOKEN (&(RcvToken->Token), EFI_SUCCESS);
return TokenRcvdBytes;
@@ -545,7 +543,7 @@ OnError: @param SockInitData Pointer to the initial data of the socket.
- @return Pointer to the newly created socket.
+ @return Pointer to the newly created socket, return NULL when exception occured.
**/
SOCKET *
@@ -934,7 +932,9 @@ SockClone ( /**
Called by the low layer protocol to indicate the socket a connection is
- established. This function just changes the socket's state to SO_CONNECTED
+ established.
+
+ This function just changes the socket's state to SO_CONNECTED
and signals the token used for connection establishment.
@param Sock Pointer to the socket associated with the
@@ -961,12 +961,14 @@ SockConnEstablished ( /**
- Called by the low layer protocol to indicate the connection is closed; This
- function flushes the socket, sets the state to SO_CLOSED and signals the close
- token.
+ Called by the low layer protocol to indicate the connection is closed.
+
+ This function flushes the socket, sets the state to SO_CLOSED and signals
+ the close token.
@param Sock Pointer to the socket associated with the closed
connection.
+
**/
VOID
SockConnClosed (
@@ -989,7 +991,8 @@ SockConnClosed ( /**
- Called by low layer protocol to indicate that some data is sent or processed;
+ Called by low layer protocol to indicate that some data is sent or processed.
+
This function trims the sent data in the socket send buffer, signals the data
token if proper.
@@ -1078,7 +1081,8 @@ SockGetDataToSend ( /**
- Called by the low layer protocol to deliver received data to socket layer;
+ Called by the low layer protocol to deliver received data to socket layer.
+
This function will append the data to the socket receive buffer, set ther
urgent data length and then check if any receive token can be signaled.
@@ -1184,11 +1188,11 @@ SockRcvdErr ( /**
- Called by the low layer protocol to indicate that there
- will be no more data from the communication peer; This
- function set the socket's state to SO_NO_MORE_DATA and
- signal all queued IO tokens with the error status
- EFI_CONNECTION_FIN.
+ Called by the low layer protocol to indicate that there will be no more data
+ from the communication peer.
+
+ This function set the socket's state to SO_NO_MORE_DATA and signal all queued
+ IO tokens with the error status EFI_CONNECTION_FIN.
@param Sock Pointer to the socket.
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c index dd359823b4..c075695467 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c @@ -856,8 +856,8 @@ Exit: **/
EFI_STATUS
SockGetMode (
- IN SOCKET *Sock,
- IN VOID *Mode
+ IN SOCKET *Sock,
+ IN OUT VOID *Mode
)
{
return Sock->ProtoHandler (Sock, SOCK_MODE, Mode);
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h index 11406ed6d0..e0f9540930 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h @@ -114,7 +114,7 @@ typedef enum { #define SOCK_IS_NO_MORE_DATA(Sock) (0 != ((Sock)->Flag & SO_NO_MORE_DATA))
-#define SOCK_SIGNATURE SIGNATURE_32 ('S', 'O', 'C', 'K')
+#define SOCK_SIGNATURE EFI_SIGNATURE_32 ('S', 'O', 'C', 'K')
#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)
@@ -198,17 +198,6 @@ typedef enum { } SOCK_TYPE;
///
-/// The handler of protocol for request from socket.
-///
-typedef
-EFI_STATUS
-(*SOCK_PROTO_HANDLER) (
- IN SOCKET *Socket, ///< The socket issuing the request to protocol
- IN SOCK_REQUEST Request, ///< The request issued by socket
- IN VOID *RequestData ///< The request related data
- );
-
-///
/// The buffer structure of rcvd data and send data used by socket.
///
typedef struct _SOCK_BUFFER {
@@ -217,7 +206,27 @@ typedef struct _SOCK_BUFFER { NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data
} SOCK_BUFFER;
-
+/**
+ The handler of protocol for request from socket.
+
+ @param Socket The socket issuing the request to protocol
+ @param Request The request issued by socket
+ @param RequestData The request related data
+
+ @retval EFI_SUCCESS The socket request is completed successfully.
+ @retval other The error status returned by the corresponding TCP
+ layer function.
+
+**/
+typedef
+EFI_STATUS
+(*SOCK_PROTO_HANDLER) (
+ IN SOCKET *Socket,
+ IN SOCK_REQUEST Request,
+ IN VOID *RequestData
+ );
+
+
//
// Socket provided oprerations for low layer protocol
//
@@ -241,7 +250,9 @@ SockSetState ( /**
Called by the low layer protocol to indicate the socket a connection is
- established. This function just changes the socket's state to SO_CONNECTED
+ established.
+
+ This function just changes the socket's state to SO_CONNECTED
and signals the token used for connection establishment.
@param Sock Pointer to the socket associated with the
@@ -254,9 +265,10 @@ SockConnEstablished ( );
/**
- Called by the low layer protocol to indicate the connection is closed; This
- function flushes the socket, sets the state to SO_CLOSED and signals the close
- token.
+ Called by the low layer protocol to indicate the connection is closed.
+
+ This function flushes the socket, sets the state to SO_CLOSED and signals
+ the close token.
@param Sock Pointer to the socket associated with the closed
connection.
@@ -268,7 +280,8 @@ SockConnClosed ( );
/**
- Called by low layer protocol to indicate that some data is sent or processed;
+ Called by low layer protocol to indicate that some data is sent or processed.
+
This function trims the sent data in the socket send buffer, signals the data
token if proper.
@@ -305,10 +318,10 @@ SockGetDataToSend ( /**
Called by the low layer protocol to indicate that there
- will be no more data from the communication peer; This
- function set the socket's state to SO_NO_MORE_DATA and
- signal all queued IO tokens with the error status
- EFI_CONNECTION_FIN.
+ will be no more data from the communication peer.
+
+ This function set the socket's state to SO_NO_MORE_DATA and
+ signal all queued IO tokens with the error status EFI_CONNECTION_FIN.
@param Sock Pointer to the socket.
@@ -319,7 +332,8 @@ SockNoMoreData ( );
/**
- Called by the low layer protocol to deliver received data to socket layer;
+ Called by the low layer protocol to deliver received data to socket layer.
+
This function will append the data to the socket receive buffer, set ther
urgent data length and then check if any receive token can be signaled.
@@ -720,8 +734,8 @@ SockClose ( **/
EFI_STATUS
SockGetMode (
- IN SOCKET *Sock,
- IN VOID *Mode
+ IN SOCKET *Sock,
+ IN OUT VOID *Mode
);
/**
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c index 62574fecf1..dbc82b51c1 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c @@ -69,8 +69,8 @@ Tcp4Route ( **/
EFI_STATUS
Tcp4GetMode (
- IN TCP_CB *Tcb,
- IN TCP4_MODE_DATA *Mode
+ IN TCP_CB *Tcb,
+ IN OUT TCP4_MODE_DATA *Mode
)
{
SOCKET *Sock;
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c index 921332cbe0..94a1753b81 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c @@ -629,8 +629,8 @@ Tcp4DestroySocketCallback ( EFI_STATUS
EFIAPI
Tcp4ServiceBindingCreateChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE *ChildHandle
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN OUT EFI_HANDLE *ChildHandle
)
{
SOCKET *Sock;
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h index 44ff26575b..ba8c8c23f1 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h @@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/ServiceBinding.h>
#include <Library/IpIoLib.h>
-#define TCP4_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', '4')
+#define TCP4_DRIVER_SIGNATURE EFI_SIGNATURE_32 ('T', 'C', 'P', '4')
#define TCP4_PORT_KNOWN 1024
#define TCP4_PORT_USER_RESERVED 65535
@@ -29,12 +29,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. Tcp4ServiceBinding, \
TCP4_DRIVER_SIGNATURE \
)
-
+
+///
+/// TCP heartbeat tick timer.
+///
typedef struct _TCP4_HEARTBEAT_TIMER {
- EFI_EVENT TimerEvent;
- INTN RefCnt;
+ EFI_EVENT TimerEvent; ///< The event assoiated with the timer
+ INTN RefCnt; ///< Number of reference
} TCP4_HEARTBEAT_TIMER;
+///
+/// TCP service data
+///
typedef struct _TCP4_SERVICE_DATA {
UINT32 Signature;
EFI_HANDLE ControllerHandle;
@@ -45,6 +51,13 @@ typedef struct _TCP4_SERVICE_DATA { LIST_ENTRY SocketList;
} TCP4_SERVICE_DATA;
+///
+/// TCP protocol data
+///
+typedef struct _TCP4_PROTO_DATA {
+ TCP4_SERVICE_DATA *TcpService;
+ TCP_CB *TcpPcb;
+} TCP4_PROTO_DATA;
/**
@@ -112,10 +125,6 @@ Tcp4Dispatcher ( IN VOID *Data OPTIONAL
);
-typedef struct _TCP4_PROTO_DATA {
- TCP4_SERVICE_DATA *TcpService;
- TCP_CB *TcpPcb;
-} TCP4_PROTO_DATA;
/**
The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
@@ -299,8 +308,8 @@ Tcp4DestroySocketCallback ( EFI_STATUS
EFIAPI
Tcp4ServiceBindingCreateChild (
- IN EFI_SERVICE_BINDING_PROTOCOL *This,
- IN EFI_HANDLE *ChildHandle
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN OUT EFI_HANDLE *ChildHandle
);
/**
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h index 21922c7a02..b0edceaab9 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Func.h @@ -149,7 +149,7 @@ TcpGetRcvMss ( VOID
TcpSetState (
IN TCP_CB *Tcb,
- IN TCP_STATES State
+ IN UINT8 State
);
//
@@ -518,10 +518,8 @@ TcpComputeRtt ( @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Nbuf Pointer to the NET_BUF containing the received tcp segment.
- @return 0 The data is trimmed.
-
**/
-INTN
+VOID
TcpTrimInWnd (
IN TCP_CB *Tcb,
IN NET_BUF *Nbuf
@@ -608,7 +606,7 @@ TcpOnAppConnect ( @param Tcb Pointer to the TCP_CB of this TCP instance.
**/
-INTN
+VOID
TcpOnAppConsume (
IN TCP_CB *Tcb
);
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c index 7f80958c7d..38fb6ade42 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Input.c @@ -257,10 +257,8 @@ TcpComputeRtt ( @param Left The sequence number of the window's left edge.
@param Right The sequence number of the window's right edge.
- @return 0 The data is successfully trimmed.
-
**/
-INTN
+VOID
TcpTrimSegment (
IN NET_BUF *Nbuf,
IN TCP_SEQNO Left,
@@ -284,7 +282,6 @@ TcpTrimSegment ( Seg->Seq = Seg->End;
NetbufTrim (Nbuf, Nbuf->TotalSize, NET_BUF_HEAD);
- return 0;
}
//
@@ -338,7 +335,6 @@ TcpTrimSegment ( }
ASSERT (TcpVerifySegment (Nbuf) != 0);
- return 0;
}
@@ -348,16 +344,14 @@ TcpTrimSegment ( @param Tcb Pointer to the TCP_CB of this TCP instance.
@param Nbuf Pointer to the NET_BUF containing the received tcp segment.
- @return 0 The data is trimmed.
-
**/
-INTN
+VOID
TcpTrimInWnd (
IN TCP_CB *Tcb,
IN NET_BUF *Nbuf
)
{
- return TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd);
+ TcpTrimSegment (Nbuf, Tcb->RcvNxt, Tcb->RcvWl2 + Tcb->RcvWnd);
}
@@ -1272,8 +1266,6 @@ NO_UPDATE: TcpClose (Tcb);
}
break;
- default:
- break;
}
//
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c index 204c9d9881..9fa9e8315a 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Misc.c @@ -99,7 +99,7 @@ TcpInitTcbPeer ( {
UINT16 RcvMss;
- ASSERT (Tcb && Seg && Opt);
+ ASSERT ((Tcb != NULL) && (Seg != NULL) && (Opt != NULL));
ASSERT (TCP_FLG_ON (Seg->Flag, TCP_FLG_SYN));
Tcb->SndWnd = Seg->Wnd;
@@ -497,7 +497,7 @@ TcpGetRcvMss ( VOID
TcpSetState (
IN TCP_CB *Tcb,
- IN TCP_STATES State
+ IN UINT8 State
)
{
DEBUG (
@@ -508,7 +508,7 @@ TcpSetState ( mTcpStateName[State])
);
- Tcb->State = (TCP_STATES)State;
+ Tcb->State = State;
switch (State) {
case TCP_ESTABLISHED:
@@ -791,7 +791,7 @@ TcpOnAppSend ( @param Tcb Pointer to the TCP_CB of this TCP instance.
**/
-INTN
+VOID
TcpOnAppConsume (
IN TCP_CB *Tcb
)
@@ -800,17 +800,14 @@ TcpOnAppConsume ( switch (Tcb->State) {
case TCP_CLOSED:
- return -1;
- break;
+ return;
case TCP_LISTEN:
- return -1;
- break;
+ return;
case TCP_SYN_SENT:
case TCP_SYN_RCVD:
- return 0;
- break;
+ return;
case TCP_ESTABLISHED:
TcpOld = TcpRcvWinOld (Tcb);
@@ -834,19 +831,15 @@ TcpOnAppConsume ( break;
case TCP_CLOSE_WAIT:
- return 0;
- break;
+ return;
case TCP_FIN_WAIT_1:
case TCP_FIN_WAIT_2:
case TCP_CLOSING:
case TCP_LAST_ACK:
case TCP_TIME_WAIT:
- return -1;
- break;
+ return;
}
-
- return -1;
}
@@ -873,8 +866,6 @@ TcpOnAppAbort ( case TCP_CLOSE_WAIT:
TcpResetConnection (Tcb);
break;
- default:
- break;
}
TcpSetState (Tcb, TCP_CLOSED);
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c index f12b2c5b4c..4d68c298ea 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Output.c @@ -832,9 +832,6 @@ SEND_AGAIN: }
if (TcpTransmitSegment (Tcb, Nbuf) != 0) {
- //
- // TODO: double check this
- //
NetbufTrim (Nbuf, (Nbuf->Tcp->HeadLen << 2), NET_BUF_HEAD);
Nbuf->Tcp = NULL;
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h index 8bb99caac0..f1eaad5be1 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h @@ -182,7 +182,7 @@ struct _TCP_CB { //
// RFC793 and RFC1122 defined variables
//
- TCP_STATES State; ///< TCP state, such as SYN_SENT, LISTEN
+ UINT8 State; ///< TCP state, such as SYN_SENT, LISTEN
UINT8 DelayedAck; ///< Number of delayed ACKs
UINT16 HeadSum; ///< Checksum of the fixed parts of pesudo
///< header: Src IP, Dst IP, 0, Protocol,
@@ -342,7 +342,7 @@ extern UINT32 mTcpTick; typedef
VOID
(*TCP_TIMER_HANDLER) (
- IN TCP_CB * Tcb
+ IN TCP_CB *Tcb
);
#include "Tcp4Func.h"
diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c index 8ef9d2cedd..945a5cac22 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Timer.c @@ -211,7 +211,7 @@ TcpProbeTimeout ( //
if ((TcpDataToSend (Tcb, 1) != 0) && (TcpToSendData (Tcb, 1) > 0)) {
- ASSERT (TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_REXMIT));
+ ASSERT (TCP_TIMER_ON (Tcb->EnabledTimer, TCP_TIMER_REXMIT) != 0);
return ;
}
|