39 ASSERT (Ip.Ip4 !=
NULL);
41 return Ip.Ip4->Routes (
43 RouteInfo->DeleteRoute,
44 RouteInfo->SubnetAddress,
45 RouteInfo->SubnetMask,
46 RouteInfo->GatewayAddress
77 return EFI_NOT_STARTED;
80 if (Mode->Tcp4State !=
NULL) {
84 if (Mode->Tcp4ConfigData !=
NULL) {
85 ConfigData = Mode->Tcp4ConfigData;
86 AccessPoint = &(ConfigData->AccessPoint);
87 Option = ConfigData->ControlOption;
89 ConfigData->TypeOfService = Tcb->Tos;
90 ConfigData->TimeToLive = Tcb->Ttl;
92 AccessPoint->UseDefaultAddress = Tcb->UseDefaultAddr;
94 IP4_COPY_ADDRESS (&AccessPoint->StationAddress, &Tcb->LocalEnd.Ip);
96 IP4_COPY_ADDRESS (&AccessPoint->SubnetMask, &Tcb->SubnetMask);
97 AccessPoint->StationPort = NTOHS (Tcb->LocalEnd.Port);
99 IP4_COPY_ADDRESS (&AccessPoint->RemoteAddress, &Tcb->RemoteEnd.Ip);
101 AccessPoint->RemotePort = NTOHS (Tcb->RemoteEnd.Port);
102 AccessPoint->ActiveFlag = (BOOLEAN)(Tcb->State != TCP_LISTEN);
104 if (Option !=
NULL) {
109 Option->ConnectionTimeout = Tcb->ConnectTimeout /
TCP_TICK_HZ;
110 Option->DataRetries = Tcb->MaxRexmit;
111 Option->FinTimeout = Tcb->FinWait2Timeout /
TCP_TICK_HZ;
112 Option->TimeWaitTimeout = Tcb->TimeWaitTimeout /
TCP_TICK_HZ;
113 Option->KeepAliveProbes = Tcb->MaxKeepAlive;
114 Option->KeepAliveTime = Tcb->KeepAliveIdle /
TCP_TICK_HZ;
115 Option->KeepAliveInterval = Tcb->KeepAlivePeriod /
TCP_TICK_HZ;
118 Option->EnableTimeStamp = (BOOLEAN)(!TCP_FLG_ON (Tcb->CtrlFlag,
TCP_CTRL_NO_TS));
119 Option->EnableWindowScaling = (BOOLEAN)(!TCP_FLG_ON (Tcb->CtrlFlag,
TCP_CTRL_NO_WS));
121 Option->EnableSelectiveAck =
FALSE;
122 Option->EnablePathMtuDiscovery =
FALSE;
126 Ip = Tcb->IpInfo->Ip.Ip4;
129 return Ip->GetModeData (Ip, Mode->Ip4ModeData, Mode->MnpConfigData, Mode->SnpModeData);
159 return EFI_NOT_STARTED;
162 if (Mode->Tcp6State !=
NULL) {
166 if (Mode->Tcp6ConfigData !=
NULL) {
167 ConfigData = Mode->Tcp6ConfigData;
174 AccessPoint->
StationPort = NTOHS (Tcb->LocalEnd.Port);
175 AccessPoint->
RemotePort = NTOHS (Tcb->RemoteEnd.Port);
176 AccessPoint->
ActiveFlag = (BOOLEAN)(Tcb->State != TCP_LISTEN);
178 IP6_COPY_ADDRESS (&AccessPoint->
StationAddress, &Tcb->LocalEnd.Ip);
179 IP6_COPY_ADDRESS (&AccessPoint->
RemoteAddress, &Tcb->RemoteEnd.Ip);
181 if (Option !=
NULL) {
203 Ip = Tcb->IpInfo->Ip.Ip6;
206 return Ip->GetModeData (Ip, Mode->Ip6ModeData, Mode->MnpConfigData, Mode->SnpModeData);
233 if (IpVersion == IP_VERSION_4) {
234 IP4_COPY_ADDRESS (&Local, &TcpAp->Tcp4Ap.StationAddress);
235 Port = &TcpAp->Tcp4Ap.StationPort;
236 RandomPort = &mTcp4RandomPort;
238 IP6_COPY_ADDRESS (&Local, &TcpAp->Tcp6Ap.StationAddress);
239 Port = &TcpAp->Tcp6Ap.StationPort;
240 RandomPort = &mTcp6RandomPort;
248 return EFI_INVALID_PARAMETER;
256 if (TCP_PORT_USER_RESERVED == *RandomPort) {
257 *RandomPort = TCP_PORT_KNOWN;
265 if (*RandomPort <= TCP_PORT_KNOWN) {
269 "TcpBind: no port can be allocated for this pcb\n")
271 return EFI_OUT_OF_RESOURCES;
274 *RandomPort = TCP_PORT_KNOWN + 1;
306 if (Sock->DevicePath !=
NULL) {
310 gBS->UninstallProtocolInterface (
312 &gEfiDevicePathProtocolGuid,
317 Sock->DevicePath =
NULL;
324 Tcb->RemoteIpZero =
FALSE;
348 if (Sk->IpVersion == IP_VERSION_4) {
349 IpProtocolGuid = &gEfiIp4ProtocolGuid;
351 IpProtocolGuid = &gEfiIp6ProtocolGuid;
357 DEBUG ((DEBUG_ERROR,
"TcpConfigurePcb: failed to allocate a TCB\n"));
359 return EFI_OUT_OF_RESOURCES;
363 IpIo = ProtoData->TcpService->IpIo;
371 return EFI_OUT_OF_RESOURCES;
377 Status =
gBS->OpenProtocol (
383 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
385 if (EFI_ERROR (Status)) {
397 ProtoData->TcpPcb = Tcb;
417 Tcb = ProtoData->TcpPcb;
419 ASSERT (Tcb !=
NULL);
427 ProtoData->TcpPcb =
NULL;
455 ASSERT ((CfgData !=
NULL) && (Sk !=
NULL) && (Sk->SockHandle !=
NULL));
458 Tcb = TcpProto->TcpPcb;
460 ASSERT (Tcb !=
NULL);
462 if (Sk->IpVersion == IP_VERSION_4) {
468 IpCfgData.Ip4CfgData.
TypeOfService = CfgData->Tcp4CfgData.TypeOfService;
469 IpCfgData.Ip4CfgData.
TimeToLive = CfgData->Tcp4CfgData.TimeToLive;
470 IpCfgData.Ip4CfgData.
UseDefaultAddress = CfgData->Tcp4CfgData.AccessPoint.UseDefaultAddress;
473 &CfgData->Tcp4CfgData.AccessPoint.SubnetMask
478 &CfgData->Tcp4CfgData.AccessPoint.StationAddress
481 ASSERT (Sk->IpVersion == IP_VERSION_6);
485 IpCfgData.Ip6CfgData.
TrafficClass = CfgData->Tcp6CfgData.TrafficClass;
486 IpCfgData.Ip6CfgData.
HopLimit = CfgData->Tcp6CfgData.HopLimit;
490 &CfgData->Tcp6CfgData.AccessPoint.StationAddress
494 &CfgData->Tcp6CfgData.AccessPoint.RemoteAddress
502 if (EFI_ERROR (Status)) {
506 if (Sk->IpVersion == IP_VERSION_4) {
511 &CfgData->Tcp4CfgData.AccessPoint.StationAddress,
515 &CfgData->Tcp4CfgData.AccessPoint.SubnetMask,
522 &CfgData->Tcp6CfgData.AccessPoint.StationAddress,
532 Status =
TcpBind (TcpAp, Sk->IpVersion);
534 if (EFI_ERROR (Status)) {
537 "TcpConfigurePcb: Bind endpoint failed with %r\n",
575 if (Sk->IpVersion == IP_VERSION_4) {
579 Tcb->Ttl = CfgData->Tcp4CfgData.TimeToLive;
580 Tcb->Tos = CfgData->Tcp4CfgData.TypeOfService;
582 Tcb->UseDefaultAddr = CfgData->Tcp4CfgData.AccessPoint.UseDefaultAddress;
584 CopyMem (&Tcb->
LocalEnd.
Ip, &CfgData->Tcp4CfgData.AccessPoint.StationAddress, sizeof (IP4_ADDR));
585 Tcb->
LocalEnd.
Port = HTONS (CfgData->Tcp4CfgData.AccessPoint.StationPort);
586 IP4_COPY_ADDRESS (&Tcb->SubnetMask, &CfgData->Tcp4CfgData.AccessPoint.SubnetMask);
588 CopyMem (&Tcb->
RemoteEnd.
Ip, &CfgData->Tcp4CfgData.AccessPoint.RemoteAddress, sizeof (IP4_ADDR));
589 Tcb->
RemoteEnd.
Port = HTONS (CfgData->Tcp4CfgData.AccessPoint.RemotePort);
591 Option = CfgData->Tcp4CfgData.ControlOption;
593 Tcb->Ttl = CfgData->Tcp6CfgData.HopLimit;
594 Tcb->Tos = CfgData->Tcp6CfgData.TrafficClass;
596 IP6_COPY_ADDRESS (&Tcb->
LocalEnd.
Ip, &CfgData->Tcp6CfgData.AccessPoint.StationAddress);
597 Tcb->
LocalEnd.
Port = HTONS (CfgData->Tcp6CfgData.AccessPoint.StationPort);
599 IP6_COPY_ADDRESS (&Tcb->
RemoteEnd.
Ip, &CfgData->Tcp6CfgData.AccessPoint.RemoteAddress);
600 Tcb->
RemoteEnd.
Port = HTONS (CfgData->Tcp6CfgData.AccessPoint.RemotePort);
608 if (Option !=
NULL) {
611 (UINT32)(TCP_COMP_VAL (
612 TCP_RCV_BUF_SIZE_MIN,
615 Option->ReceiveBufferSize
621 (UINT32)(TCP_COMP_VAL (
622 TCP_SND_BUF_SIZE_MIN,
625 Option->SendBufferSize
632 (UINT32)(TCP_COMP_VAL (
636 Option->MaxSynBackLog
649 TCP_FIN_WAIT2_TIME_MAX,
654 if (Option->TimeWaitTimeout != 0) {
657 TCP_TIME_WAIT_TIME_MAX,
665 if (Option->KeepAliveProbes != 0) {
669 TCP_MAX_KEEPALIVE_MIN,
672 Option->KeepAliveProbes
676 TCP_KEEPALIVE_IDLE_MAX,
681 TCP_KEEPALIVE_PERIOD_MIN,
682 TCP_KEEPALIVE_PERIOD,
683 TCP_KEEPALIVE_PERIOD,
689 TCP_CONNECT_TIME_MIN,
695 if (!Option->EnableNagle) {
699 if (!Option->EnableTimeStamp) {
703 if (!Option->EnableWindowScaling) {
713 if (EFI_ERROR (Status)) {
720 if (((Sk->IpVersion == IP_VERSION_4) && !CfgData->Tcp4CfgData.AccessPoint.ActiveFlag) ||
721 ((Sk->IpVersion == IP_VERSION_6) && !CfgData->Tcp6CfgData.AccessPoint.ActiveFlag)
727 Sk->ConfigureState = SO_CONFIGURED_PASSIVE;
729 Sk->ConfigureState = SO_CONFIGURED_ACTIVE;
732 if (Sk->IpVersion == IP_VERSION_6) {
767 IN VOID *Data OPTIONAL
774 Tcb = ProtoData->TcpPcb;
778 if (Tcb->
Sk->IpVersion == IP_VERSION_4) {
779 ProtoData->TcpService->IpIo->Ip.Ip4->Poll (ProtoData->TcpService->IpIo->Ip.Ip4);
781 ProtoData->TcpService->IpIo->Ip.Ip6->Poll (ProtoData->TcpService->IpIo->Ip.Ip6);
792 ASSERT (Tcb !=
NULL);
798 ASSERT (Tcb !=
NULL);
861 ASSERT ((Data !=
NULL) && (Tcb !=
NULL));
863 if (Tcb->
Sk->IpVersion == IP_VERSION_4) {
873 ASSERT ((Data !=
NULL) && (Tcb !=
NULL) && (Tcb->
Sk->IpVersion == IP_VERSION_4));
879 return EFI_UNSUPPORTED;
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID EFIAPI IpIoRemoveIp(IN IP_IO *IpIo, IN IP_IO_IP_INFO *IpInfo)
EFI_STATUS EFIAPI IpIoConfigIp(IN OUT IP_IO_IP_INFO *IpInfo, IN OUT VOID *IpConfigData OPTIONAL)
IP_IO_IP_INFO *EFIAPI IpIoAddIp(IN OUT IP_IO *IpIo)
#define DEBUG(Expression)
BOOLEAN EFIAPI NetIp6IsUnspecifiedAddr(IN EFI_IPv6_ADDRESS *Ip6)
VOID EFIAPI NetbufFreeList(IN OUT LIST_ENTRY *Head)
#define SOCK_CONNECT
Need to connect to a peer.
#define SOCK_CONSUMED
Application has retrieved data from socket.
#define SOCK_IS_CONFIGURED(Sock)
#define SOCK_ATTACH
Attach current socket to a new PCB.
#define SET_RCV_BUFFSIZE(Sock, Size)
#define SOCK_CONFIGURE
Configure attached PCB.
#define SOCK_POLL
Need to poll to the protocol layer.
#define GET_SND_DATASIZE(Sock)
#define SOCK_CLOSE
Need to close the protocol process.
#define GET_BACKLOG(Sock)
#define SOCK_MODE
Need to get the mode data of the protocol.
VOID SockSetState(IN OUT SOCKET *Sock, IN UINT8 State)
#define SOCK_SND
Need protocol to send something.
#define SOCK_ABORT
Need to reset the protocol process.
#define SOCK_ROUTE
Need to add a route information.
#define SET_BACKLOG(Sock, Value)
#define GET_RCV_BUFFSIZE(Sock)
#define GET_SND_BUFFSIZE(Sock)
#define SET_SND_BUFFSIZE(Sock, Size)
#define SOCK_SNDURG
Need protocol to send urgent data.
#define SOCK_DETACH
Detach current socket from the PCB.
#define SOCK_FLUSH
Flush attached PCB.
#define SOCK_SNDPUSH
Need protocol to send pushed data.
EFI_TCP4_CONNECTION_STATE
EFI_TCP6_CONNECTION_STATE
EFI_STATUS TcpBind(IN TCP_ACCESS_POINT *TcpAp, IN UINT8 IpVersion)
EFI_STATUS TcpDispatcher(IN SOCKET *Sock, IN UINT8 Request, IN VOID *Data OPTIONAL)
VOID TcpFlushPcb(IN OUT TCP_CB *Tcb)
EFI_STATUS TcpAttachPcb(IN SOCKET *Sk)
EFI_STATUS Tcp4GetMode(IN TCP_CB *Tcb, IN OUT TCP4_MODE_DATA *Mode)
EFI_STATUS TcpConfigurePcb(IN SOCKET *Sk, IN TCP_CONFIG_DATA *CfgData)
EFI_STATUS Tcp6GetMode(IN TCP_CB *Tcb, IN OUT TCP6_MODE_DATA *Mode)
EFI_STATUS Tcp4Route(IN TCP_CB *Tcb, IN TCP4_ROUTE_INFO *RouteInfo)
VOID TcpDetachPcb(IN OUT SOCKET *Sk)
INTN TcpOnAppSend(IN OUT TCP_CB *Tcb)
INTN TcpInsertTcb(IN TCP_CB *Tcb)
VOID TcpOnAppConsume(IN TCP_CB *Tcb)
EFI_STATUS TcpOnAppConnect(IN OUT TCP_CB *Tcb)
VOID TcpOnAppClose(IN OUT TCP_CB *Tcb)
BOOLEAN TcpFindTcbByPeer(IN EFI_IP_ADDRESS *Addr, IN TCP_PORTNO Port, IN UINT8 Version)
VOID TcpSetState(IN TCP_CB *Tcb, IN UINT8 State)
VOID TcpOnAppAbort(IN TCP_CB *Tcb)
EFI_STATUS TcpInstallDevicePath(IN SOCKET *Sock)
UINT16 TcpGetRcvMss(IN SOCKET *Sock)
TCP_SEQNO TcpGetMaxSndNxt(IN TCP_CB *Tcb)
#define TCP6_REFRESH_NEIGHBOR_TICK
#define TCP_CTRL_NO_KEEPALIVE
Disable keepalive timer.
#define TCP_CTRL_NO_NAGLE
Disable Nagle algorithm.
#define TCP_CTRL_NO_WS
Disable window scale option.
#define TCP_CTRL_SND_PSH
In PUSH send mode.
#define TCP_KEEPALIVE_IDLE_MIN
First keepalive.
#define TCP_MAX_LOSS
Default max times to retxmit.
#define TCP_TICK_HZ
The frequence of TCP tick.
#define TCP_CTRL_SND_URG
In urgent send mode.
#define TCP_CONGEST_OPEN
TCP is opening its congestion window.
#define TCP_CTRL_NO_TS
Disable Timestamp option.
UINT32 KeepAlivePeriod
Interval for subsequent keep alive probe.
UINT32 Tick
1 tick = 200ms
TCP_PEER RemoteEnd
Remote endpoint.
UINT16 MaxRexmit
The maximum number of retxmit before abort.
UINT8 MaxKeepAlive
Maximum keep alive probe times.
UINT32 Ssthresh
Slow start threshold.
UINT8 CongestState
The current congestion state(RFC3782).
UINT32 TimeWaitTimeout
The TIME_WAIT timeout.
TCP_SEQNO SndUp
Send urgent point.
UINT16 RcvMss
Max receive segment size.
UINT32 Rto
Current RTO, not scaled.
UINT8 State
TCP state, such as SYN_SENT, LISTEN.
TCP_SEQNO SndPsh
Send PUSH point.
UINT32 KeepAliveIdle
Idle time before sending first probe.
LIST_ENTRY RcvQue
Reassemble queue.
UINT16 SndMss
Max send segment size.
UINT32 FinWait2Timeout
The FIN_WAIT_2 timeout.
UINT32 ConnectTimeout
The connect establishment timeout.
UINT32 SRtt
Smoothed RTT, scaled by 8.
SOCKET * Sk
The socket it controlled.
TCP_PEER LocalEnd
Local endpoint.
IP_IO_IP_INFO * IpInfo
Pointer reference to Ip used to send pkt.
LIST_ENTRY List
Back and forward link entry.
BOOLEAN RemoteIpZero
RemoteEnd.Ip is ZERO when configured.
UINT32 CtrlFlag
Control flags, such as NO_NAGLE.
UINT32 CWnd
Sender's congestion window.
LIST_ENTRY SndQue
Retxmission queue.
EFI_IP_ADDRESS Ip
IP address, in network byte order.
TCP_PORTNO Port
Port number, in network byte order.
EFI_HANDLE SockHandle
The virtual handle of the socket.
EFI_IPv4_ADDRESS SubnetMask
EFI_IPv4_ADDRESS StationAddress
BOOLEAN UseDefaultAddress
EFI_IPv6_ADDRESS DestinationAddress
EFI_IPv6_ADDRESS StationAddress
EFI_IPv6_ADDRESS RemoteAddress
EFI_IPv6_ADDRESS StationAddress
EFI_TCP6_ACCESS_POINT AccessPoint
EFI_TCP6_OPTION * ControlOption
BOOLEAN EnableWindowScaling
BOOLEAN EnablePathMtuDiscovery
BOOLEAN EnableSelectiveAck