2 Misc support routines for tcp.
4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php<BR>
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include <Library/DevicePathLib.h>
20 LIST_ENTRY mTcpRunQue
= {
25 LIST_ENTRY mTcpListenQue
= {
30 TCP_SEQNO mTcpGlobalIss
= 0x4d7e980b;
32 CHAR16
*mTcpStateName
[] = {
48 Initialize the Tcb local related members.
50 @param Tcb Pointer to the TCP_CB of this TCP instance.
59 // Compute the checksum of the fixed parts of pseudo header
61 Tcb
->HeadSum
= NetPseudoHeadChecksum (
68 Tcb
->Iss
= TcpGetIss ();
69 Tcb
->SndUna
= Tcb
->Iss
;
70 Tcb
->SndNxt
= Tcb
->Iss
;
72 Tcb
->SndWl2
= Tcb
->Iss
;
75 Tcb
->RcvWnd
= GET_RCV_BUFFSIZE (Tcb
->Sk
);
78 // First window size is never scaled
85 Initialize the peer related members.
87 @param Tcb Pointer to the TCP_CB of this TCP instance.
88 @param Seg Pointer to the segment that contains the peer's
90 @param Opt Pointer to the options announced by the peer.
102 ASSERT ((Tcb
!= NULL
) && (Seg
!= NULL
) && (Opt
!= NULL
));
103 ASSERT (TCP_FLG_ON (Seg
->Flag
, TCP_FLG_SYN
));
105 Tcb
->SndWnd
= Seg
->Wnd
;
106 Tcb
->SndWndMax
= Tcb
->SndWnd
;
107 Tcb
->SndWl1
= Seg
->Seq
;
109 if (TCP_FLG_ON (Seg
->Flag
, TCP_FLG_ACK
)) {
110 Tcb
->SndWl2
= Seg
->Ack
;
112 Tcb
->SndWl2
= Tcb
->Iss
+ 1;
115 if (TCP_FLG_ON (Opt
->Flag
, TCP_OPTION_RCVD_MSS
)) {
116 Tcb
->SndMss
= (UINT16
) MAX (64, Opt
->Mss
);
118 RcvMss
= TcpGetRcvMss (Tcb
->Sk
);
119 if (Tcb
->SndMss
> RcvMss
) {
120 Tcb
->SndMss
= RcvMss
;
125 // One end doesn't support MSS option, use default.
130 Tcb
->CWnd
= Tcb
->SndMss
;
133 Tcb
->RcvNxt
= Tcb
->Irs
+ 1;
135 Tcb
->RcvWl2
= Tcb
->RcvNxt
;
137 if (TCP_FLG_ON (Opt
->Flag
, TCP_OPTION_RCVD_WS
) &&
138 !TCP_FLG_ON (Tcb
->CtrlFlag
, TCP_CTRL_NO_WS
)) {
140 Tcb
->SndWndScale
= Opt
->WndScale
;
142 Tcb
->RcvWndScale
= TcpComputeScale (Tcb
);
143 TCP_SET_FLG (Tcb
->CtrlFlag
, TCP_CTRL_RCVD_WS
);
147 // One end doesn't support window scale option. use zero.
149 Tcb
->RcvWndScale
= 0;
152 if (TCP_FLG_ON (Opt
->Flag
, TCP_OPTION_RCVD_TS
) &&
153 !TCP_FLG_ON (Tcb
->CtrlFlag
, TCP_CTRL_NO_TS
)) {
155 TCP_SET_FLG (Tcb
->CtrlFlag
, TCP_CTRL_SND_TS
);
156 TCP_SET_FLG (Tcb
->CtrlFlag
, TCP_CTRL_RCVD_TS
);
159 // Compute the effective SndMss per RFC1122
160 // section 4.2.2.6. If timestamp option is
161 // enabled, it will always occupy 12 bytes.
163 Tcb
->SndMss
-= TCP_OPTION_TS_ALIGNED_LEN
;
169 Locate a listen TCB that matchs the Local and Remote.
171 @param Local Pointer to the local (IP, Port).
172 @param Remote Pointer to the remote (IP, Port).
174 @return Pointer to the TCP_CB with the least number of wildcard,
175 if NULL no match is found.
193 NET_LIST_FOR_EACH (Entry
, &mTcpListenQue
) {
194 Node
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
196 if ((Local
->Port
!= Node
->LocalEnd
.Port
) ||
197 !TCP_PEER_MATCH (Remote
, &Node
->RemoteEnd
) ||
198 !TCP_PEER_MATCH (Local
, &Node
->LocalEnd
)) {
204 // Compute the number of wildcard
207 if (Node
->RemoteEnd
.Ip
== 0) {
211 if (Node
->RemoteEnd
.Port
== 0) {
215 if (Node
->LocalEnd
.Ip
== 0) {
234 Try to find one Tcb whose <Ip, Port> equals to <IN Addr, IN Port>.
236 @param Addr Pointer to the IP address needs to match.
237 @param Port The port number needs to match.
239 @return The Tcb which matches the <Addr Port> paire exists or not.
244 IN EFI_IPv4_ADDRESS
*Addr
,
248 TCP_PORTNO LocalPort
;
252 ASSERT ((Addr
!= NULL
) && (Port
!= 0));
254 LocalPort
= HTONS (Port
);
256 NET_LIST_FOR_EACH (Entry
, &mTcpListenQue
) {
257 Tcb
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
259 if (EFI_IP4_EQUAL (Addr
, &Tcb
->LocalEnd
.Ip
) &&
260 (LocalPort
== Tcb
->LocalEnd
.Port
)) {
266 NET_LIST_FOR_EACH (Entry
, &mTcpRunQue
) {
267 Tcb
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
269 if (EFI_IP4_EQUAL (Addr
, &Tcb
->LocalEnd
.Ip
) &&
270 (LocalPort
== Tcb
->LocalEnd
.Port
)) {
281 Locate the TCP_CB related to the socket pair.
283 @param LocalPort The local port number.
284 @param LocalIp The local IP address.
285 @param RemotePort The remote port number.
286 @param RemoteIp The remote IP address.
287 @param Syn Whether to search the listen sockets, if TRUE, the
288 listen sockets are searched.
290 @return Pointer to the related TCP_CB, if NULL no match is found.
295 IN TCP_PORTNO LocalPort
,
297 IN TCP_PORTNO RemotePort
,
307 Local
.Port
= LocalPort
;
310 Remote
.Port
= RemotePort
;
311 Remote
.Ip
= RemoteIp
;
314 // First check for exact match.
316 NET_LIST_FOR_EACH (Entry
, &mTcpRunQue
) {
317 Tcb
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
319 if (TCP_PEER_EQUAL (&Remote
, &Tcb
->RemoteEnd
) &&
320 TCP_PEER_EQUAL (&Local
, &Tcb
->LocalEnd
)) {
322 RemoveEntryList (&Tcb
->List
);
323 InsertHeadList (&mTcpRunQue
, &Tcb
->List
);
330 // Only check listen queue when SYN flag is on
333 return TcpLocateListenTcb (&Local
, &Remote
);
341 Insert a Tcb into the proper queue.
343 @param Tcb Pointer to the TCP_CB to be inserted.
345 @retval 0 The Tcb is inserted successfully.
346 @retval -1 Error condition occurred.
357 TCP4_PROTO_DATA
*TcpProto
;
361 ((Tcb
->State
== TCP_LISTEN
) ||
362 (Tcb
->State
== TCP_SYN_SENT
) ||
363 (Tcb
->State
== TCP_SYN_RCVD
) ||
364 (Tcb
->State
== TCP_CLOSED
))
367 if (Tcb
->LocalEnd
.Port
== 0) {
373 if (Tcb
->State
== TCP_LISTEN
) {
374 Head
= &mTcpListenQue
;
378 // Check that Tcb isn't already on the list.
380 NET_LIST_FOR_EACH (Entry
, Head
) {
381 Node
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
383 if (TCP_PEER_EQUAL (&Tcb
->LocalEnd
, &Node
->LocalEnd
) &&
384 TCP_PEER_EQUAL (&Tcb
->RemoteEnd
, &Node
->RemoteEnd
)) {
390 InsertHeadList (Head
, &Tcb
->List
);
392 TcpProto
= (TCP4_PROTO_DATA
*) Tcb
->Sk
->ProtoReserved
;
393 TcpSetVariableData (TcpProto
->TcpService
);
400 Clone a TCB_CB from Tcb.
402 @param Tcb Pointer to the TCP_CB to be cloned.
404 @return Pointer to the new cloned TCP_CB, if NULL error condition occurred.
414 Clone
= AllocatePool (sizeof (TCP_CB
));
421 CopyMem (Clone
, Tcb
, sizeof (TCP_CB
));
424 // Increate the reference count of the shared IpInfo.
426 NET_GET_REF (Tcb
->IpInfo
);
428 InitializeListHead (&Clone
->List
);
429 InitializeListHead (&Clone
->SndQue
);
430 InitializeListHead (&Clone
->RcvQue
);
432 Clone
->Sk
= SockClone (Tcb
->Sk
);
433 if (Clone
->Sk
== NULL
) {
434 DEBUG ((EFI_D_ERROR
, "TcpCloneTcb: failed to clone a sock\n"));
439 ((TCP4_PROTO_DATA
*) (Clone
->Sk
->ProtoReserved
))->TcpPcb
= Clone
;
446 Compute an ISS to be used by a new connection.
448 @return The result ISS.
456 mTcpGlobalIss
+= 2048;
457 return mTcpGlobalIss
;
464 @param Sock Pointer to the socket to get mss
466 @return The mss size.
474 EFI_IP4_MODE_DATA Ip4Mode
;
475 TCP4_PROTO_DATA
*TcpProto
;
476 EFI_IP4_PROTOCOL
*Ip
;
478 ASSERT (Sock
!= NULL
);
480 TcpProto
= (TCP4_PROTO_DATA
*) Sock
->ProtoReserved
;
481 Ip
= TcpProto
->TcpService
->IpIo
->Ip
.Ip4
;
484 Ip
->GetModeData (Ip
, &Ip4Mode
, NULL
, NULL
);
486 return (UINT16
) (Ip4Mode
.MaxPacketSize
- sizeof (TCP_HEAD
));
493 @param Tcb Pointer to the TCP_CB of this TCP instance.
494 @param State The state to be set.
503 ASSERT (Tcb
->State
< (sizeof (mTcpStateName
) / sizeof (CHAR16
*)));
504 ASSERT (State
< (sizeof (mTcpStateName
) / sizeof (CHAR16
*)));
508 "Tcb (%p) state %s --> %s\n",
510 mTcpStateName
[Tcb
->State
],
511 mTcpStateName
[State
])
517 case TCP_ESTABLISHED
:
519 SockConnEstablished (Tcb
->Sk
);
521 if (Tcb
->Parent
!= NULL
) {
523 // A new connection is accepted by a listening socket, install
526 TcpInstallDevicePath (Tcb
->Sk
);
533 SockConnClosed (Tcb
->Sk
);
543 Compute the TCP segment's checksum.
545 @param Nbuf Pointer to the buffer that contains the TCP
547 @param HeadSum The checksum value of the fixed part of pseudo
550 @return The checksum value.
561 Checksum
= NetbufChecksum (Nbuf
);
562 Checksum
= NetAddChecksum (Checksum
, HeadSum
);
564 Checksum
= NetAddChecksum (
566 HTONS ((UINT16
) Nbuf
->TotalSize
)
569 return (UINT16
) ~Checksum
;
573 Translate the information from the head of the received TCP
574 segment Nbuf contains and fill it into a TCP_SEG structure.
576 @param Tcb Pointer to the TCP_CB of this TCP instance.
577 @param Nbuf Pointer to the buffer contains the TCP segment.
579 @return Pointer to the TCP_SEG that contains the translated TCP head information.
591 Seg
= TCPSEG_NETBUF (Nbuf
);
592 Head
= (TCP_HEAD
*) NetbufGetByte (Nbuf
, 0, NULL
);
595 Seg
->Seq
= NTOHL (Head
->Seq
);
596 Seg
->Ack
= NTOHL (Head
->Ack
);
597 Seg
->End
= Seg
->Seq
+ (Nbuf
->TotalSize
- (Head
->HeadLen
<< 2));
599 Seg
->Urg
= NTOHS (Head
->Urg
);
600 Seg
->Wnd
= (NTOHS (Head
->Wnd
) << Tcb
->SndWndScale
);
601 Seg
->Flag
= Head
->Flag
;
604 // SYN and FIN flag occupy one sequence space each.
606 if (TCP_FLG_ON (Seg
->Flag
, TCP_FLG_SYN
)) {
608 // RFC requires that initial window not be scaled
610 Seg
->Wnd
= NTOHS (Head
->Wnd
);
614 if (TCP_FLG_ON (Seg
->Flag
, TCP_FLG_FIN
)) {
623 Reset the connection related with Tcb.
625 @param Tcb Pointer to the TCP_CB of the connection to be
637 Nbuf
= NetbufAlloc (TCP_MAX_HEAD
);
643 Nhead
= (TCP_HEAD
*) NetbufAllocSpace (
649 ASSERT (Nhead
!= NULL
);
653 Nhead
->Flag
= TCP_FLG_RST
;
654 Nhead
->Seq
= HTONL (Tcb
->SndNxt
);
655 Nhead
->Ack
= HTONL (Tcb
->RcvNxt
);
656 Nhead
->SrcPort
= Tcb
->LocalEnd
.Port
;
657 Nhead
->DstPort
= Tcb
->RemoteEnd
.Port
;
658 Nhead
->HeadLen
= (sizeof (TCP_HEAD
) >> 2);
660 Nhead
->Wnd
= HTONS (0xFFFF);
663 Nhead
->Checksum
= TcpChecksum (Nbuf
, Tcb
->HeadSum
);
665 TcpSendIpPacket (Tcb
, Nbuf
, Tcb
->LocalEnd
.Ip
, Tcb
->RemoteEnd
.Ip
);
672 Initialize an active connection.
674 @param Tcb Pointer to the TCP_CB that wants to initiate a
683 TcpInitTcbLocal (Tcb
);
684 TcpSetState (Tcb
, TCP_SYN_SENT
);
686 TcpSetTimer (Tcb
, TCP_TIMER_CONNECT
, Tcb
->ConnectTimeout
);
687 TcpToSendData (Tcb
, 1);
692 Initiate the connection close procedure, called when
693 applications want to close the connection.
695 @param Tcb Pointer to the TCP_CB of this TCP instance.
703 ASSERT (Tcb
!= NULL
);
705 if (!IsListEmpty (&Tcb
->RcvQue
) || GET_RCV_DATASIZE (Tcb
->Sk
) != 0) {
707 DEBUG ((EFI_D_WARN
, "TcpOnAppClose: connection reset "
708 "because data is lost for TCB %p\n", Tcb
));
710 TcpResetConnection (Tcb
);
715 switch (Tcb
->State
) {
719 TcpSetState (Tcb
, TCP_CLOSED
);
723 case TCP_ESTABLISHED
:
724 TcpSetState (Tcb
, TCP_FIN_WAIT_1
);
728 TcpSetState (Tcb
, TCP_LAST_ACK
);
734 TcpToSendData (Tcb
, 1);
739 Check whether the application's newly delivered data can be sent out.
741 @param Tcb Pointer to the TCP_CB of this TCP instance.
743 @retval 0 Whether the data is sent out or is buffered for
745 @retval -1 The Tcb is not in a state that data is permitted to
755 switch (Tcb
->State
) {
766 case TCP_ESTABLISHED
:
768 TcpToSendData (Tcb
, 0);
787 Application has consumed some data, check whether
788 to send a window updata ack or a delayed ack.
790 @param Tcb Pointer to the TCP_CB of this TCP instance.
800 switch (Tcb
->State
) {
811 case TCP_ESTABLISHED
:
812 TcpOld
= TcpRcvWinOld (Tcb
);
813 if (TcpRcvWinNow (Tcb
) > TcpOld
) {
815 if (TcpOld
< Tcb
->RcvMss
) {
817 DEBUG ((EFI_D_INFO
, "TcpOnAppConsume: send a window"
818 " update for a window closed Tcb %p\n", Tcb
));
821 } else if (Tcb
->DelayedAck
== 0) {
823 DEBUG ((EFI_D_INFO
, "TcpOnAppConsume: scheduled a delayed"
824 " ACK to update window for Tcb %p\n", Tcb
));
849 Abort the connection by sending a reset segment, called
850 when the application wants to abort the connection.
852 @param Tcb Pointer to the TCP_CB of the TCP instance.
860 DEBUG ((EFI_D_WARN
, "TcpOnAppAbort: connection reset "
861 "issued by application for TCB %p\n", Tcb
));
863 switch (Tcb
->State
) {
865 case TCP_ESTABLISHED
:
869 TcpResetConnection (Tcb
);
875 TcpSetState (Tcb
, TCP_CLOSED
);
880 Set the Tdp4 variable data.
882 @param Tcp4Service Pointer to Tcp4 service data.
884 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable.
885 @retval other Set variable failed.
890 IN TCP4_SERVICE_DATA
*Tcp4Service
893 UINT32 NumConfiguredInstance
;
896 TCP4_PROTO_DATA
*TcpProto
;
897 UINTN VariableDataSize
;
898 EFI_TCP4_VARIABLE_DATA
*Tcp4VariableData
;
899 EFI_TCP4_SERVICE_POINT
*Tcp4ServicePoint
;
900 CHAR16
*NewMacString
;
903 NumConfiguredInstance
= 0;
906 // Go through the running queue to count the instances.
908 NET_LIST_FOR_EACH (Entry
, &mTcpRunQue
) {
909 TcpPcb
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
911 TcpProto
= (TCP4_PROTO_DATA
*) TcpPcb
->Sk
->ProtoReserved
;
913 if (TcpProto
->TcpService
== Tcp4Service
) {
915 // This tcp instance belongs to the Tcp4Service.
917 NumConfiguredInstance
++;
922 // Go through the listening queue to count the instances.
924 NET_LIST_FOR_EACH (Entry
, &mTcpListenQue
) {
925 TcpPcb
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
927 TcpProto
= (TCP4_PROTO_DATA
*) TcpPcb
->Sk
->ProtoReserved
;
929 if (TcpProto
->TcpService
== Tcp4Service
) {
931 // This tcp instance belongs to the Tcp4Service.
933 NumConfiguredInstance
++;
938 // Calculate the size of the Tcp4VariableData. As there may be no Tcp4 child,
939 // we should add extra buffer for the service points only if the number of configured
940 // children is more than 1.
942 VariableDataSize
= sizeof (EFI_TCP4_VARIABLE_DATA
);
944 if (NumConfiguredInstance
> 1) {
945 VariableDataSize
+= sizeof (EFI_TCP4_SERVICE_POINT
) * (NumConfiguredInstance
- 1);
948 Tcp4VariableData
= AllocatePool (VariableDataSize
);
949 if (Tcp4VariableData
== NULL
) {
950 return EFI_OUT_OF_RESOURCES
;
953 Tcp4VariableData
->DriverHandle
= Tcp4Service
->DriverBindingHandle
;
954 Tcp4VariableData
->ServiceCount
= NumConfiguredInstance
;
956 Tcp4ServicePoint
= &Tcp4VariableData
->Services
[0];
959 // Go through the running queue to fill the service points.
961 NET_LIST_FOR_EACH (Entry
, &mTcpRunQue
) {
962 TcpPcb
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
964 TcpProto
= (TCP4_PROTO_DATA
*) TcpPcb
->Sk
->ProtoReserved
;
966 if (TcpProto
->TcpService
== Tcp4Service
) {
968 // This tcp instance belongs to the Tcp4Service.
970 Tcp4ServicePoint
->InstanceHandle
= TcpPcb
->Sk
->SockHandle
;
971 CopyMem (&Tcp4ServicePoint
->LocalAddress
, &TcpPcb
->LocalEnd
.Ip
, sizeof (EFI_IPv4_ADDRESS
));
972 Tcp4ServicePoint
->LocalPort
= NTOHS (TcpPcb
->LocalEnd
.Port
);
973 CopyMem (&Tcp4ServicePoint
->RemoteAddress
, &TcpPcb
->RemoteEnd
.Ip
, sizeof (EFI_IPv4_ADDRESS
));
974 Tcp4ServicePoint
->RemotePort
= NTOHS (TcpPcb
->RemoteEnd
.Port
);
981 // Go through the listening queue to fill the service points.
983 NET_LIST_FOR_EACH (Entry
, &mTcpListenQue
) {
984 TcpPcb
= NET_LIST_USER_STRUCT (Entry
, TCP_CB
, List
);
986 TcpProto
= (TCP4_PROTO_DATA
*) TcpPcb
->Sk
->ProtoReserved
;
988 if (TcpProto
->TcpService
== Tcp4Service
) {
990 // This tcp instance belongs to the Tcp4Service.
992 Tcp4ServicePoint
->InstanceHandle
= TcpPcb
->Sk
->SockHandle
;
993 CopyMem (&Tcp4ServicePoint
->LocalAddress
, &TcpPcb
->LocalEnd
.Ip
, sizeof (EFI_IPv4_ADDRESS
));
994 Tcp4ServicePoint
->LocalPort
= NTOHS (TcpPcb
->LocalEnd
.Port
);
995 CopyMem (&Tcp4ServicePoint
->RemoteAddress
, &TcpPcb
->RemoteEnd
.Ip
, sizeof (EFI_IPv4_ADDRESS
));
996 Tcp4ServicePoint
->RemotePort
= NTOHS (TcpPcb
->RemoteEnd
.Port
);
1003 // Get the mac string.
1005 Status
= NetLibGetMacString (
1006 Tcp4Service
->ControllerHandle
,
1007 Tcp4Service
->DriverBindingHandle
,
1010 if (EFI_ERROR (Status
)) {
1014 if (Tcp4Service
->MacString
!= NULL
) {
1016 // The variable is set already, we're going to update it.
1018 if (StrCmp (Tcp4Service
->MacString
, NewMacString
) != 0) {
1020 // The mac address is changed, delete the previous variable first.
1023 Tcp4Service
->MacString
,
1024 &gEfiTcp4ServiceBindingProtocolGuid
,
1025 EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1031 FreePool (Tcp4Service
->MacString
);
1034 Tcp4Service
->MacString
= NewMacString
;
1036 Status
= gRT
->SetVariable (
1037 Tcp4Service
->MacString
,
1038 &gEfiTcp4ServiceBindingProtocolGuid
,
1039 EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1041 (VOID
*) Tcp4VariableData
1046 FreePool (Tcp4VariableData
);
1053 Clear the variable and free the resource.
1055 @param Tcp4Service Pointer to Tcp4 service data.
1059 TcpClearVariableData (
1060 IN TCP4_SERVICE_DATA
*Tcp4Service
1063 ASSERT (Tcp4Service
->MacString
!= NULL
);
1066 Tcp4Service
->MacString
,
1067 &gEfiTcp4ServiceBindingProtocolGuid
,
1068 EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1073 FreePool (Tcp4Service
->MacString
);
1074 Tcp4Service
->MacString
= NULL
;
1078 Install the device path protocol on the TCP instance.
1080 @param Sock Pointer to the socket representing the TCP instance.
1082 @retval EFI_SUCCESS The device path protocol is installed.
1083 @retval other Failed to install the device path protocol.
1087 TcpInstallDevicePath (
1091 TCP4_PROTO_DATA
*TcpProto
;
1092 TCP4_SERVICE_DATA
*TcpService
;
1094 IPv4_DEVICE_PATH Ip4DPathNode
;
1096 TCP_PORTNO LocalPort
;
1097 TCP_PORTNO RemotePort
;
1099 TcpProto
= (TCP4_PROTO_DATA
*) Sock
->ProtoReserved
;
1100 TcpService
= TcpProto
->TcpService
;
1101 Tcb
= TcpProto
->TcpPcb
;
1103 LocalPort
= NTOHS (Tcb
->LocalEnd
.Port
);
1104 RemotePort
= NTOHS (Tcb
->RemoteEnd
.Port
);
1105 NetLibCreateIPv4DPathNode (
1107 TcpService
->ControllerHandle
,
1116 Sock
->DevicePath
= AppendDevicePathNode (
1117 Sock
->ParentDevicePath
,
1118 (EFI_DEVICE_PATH_PROTOCOL
*) &Ip4DPathNode
1120 if (Sock
->DevicePath
== NULL
) {
1121 return EFI_OUT_OF_RESOURCES
;
1124 Status
= gBS
->InstallProtocolInterface (
1126 &gEfiDevicePathProtocolGuid
,
1127 EFI_NATIVE_INTERFACE
,
1130 if (EFI_ERROR (Status
)) {
1131 FreePool (Sock
->DevicePath
);