EDK2 doxygen online documents - Firmware Encoding Index 1
EDK2 doxygen online documents - Firmware Encoding Index

NetworkPkg/TcpDxe/TcpIo.c

Go to the documentation of this file.
00001 
00016 #include "TcpMain.h"
00017 
00031 VOID
00032 EFIAPI
00033 TcpRxCallback (
00034   IN EFI_STATUS                       Status,
00035   IN UINT8                            IcmpErr,
00036   IN EFI_NET_SESSION_DATA             *NetSession,
00037   IN NET_BUF                          *Pkt,
00038   IN VOID                             *Context    OPTIONAL
00039   )
00040 {
00041   if (EFI_SUCCESS == Status) {
00042     TcpInput (Pkt, &NetSession->Source, &NetSession->Dest, NetSession->IpVersion);
00043   } else {
00044     TcpIcmpInput (
00045       Pkt,
00046       IcmpErr,
00047       &NetSession->Source,
00048       &NetSession->Dest,
00049       NetSession->IpVersion
00050       );
00051   }
00052 }
00053 
00067 INTN
00068 TcpSendIpPacket (
00069   IN TCP_CB          *Tcb,
00070   IN NET_BUF         *Nbuf,
00071   IN EFI_IP_ADDRESS  *Src,
00072   IN EFI_IP_ADDRESS  *Dest,
00073   IN UINT8           Version
00074   )
00075 {
00076   EFI_STATUS       Status;
00077   IP_IO            *IpIo;
00078   IP_IO_OVERRIDE   Override;
00079   SOCKET           *Sock;
00080   VOID             *IpSender;
00081   TCP_PROTO_DATA  *TcpProto;
00082 
00083   if (NULL == Tcb) {
00084 
00085     IpIo     = NULL;
00086     IpSender = IpIoFindSender (&IpIo, Version, Src);
00087 
00088     if (IpSender == NULL) {
00089       DEBUG ((EFI_D_WARN, "TcpSendIpPacket: No appropriate IpSender.\n"));
00090       return -1;
00091     }
00092 
00093     if (Version == IP_VERSION_6) {
00094       //
00095       // It's tricky here. EFI IPv6 Spec don't allow an instance overriding the
00096       // destination address if the dest is already specified through the
00097       // configuration data. Here we get the IpIo we need and use the default IP
00098       // instance in this IpIo to send the packet. The dest address is configured
00099       // to be the unspecified address for the default IP instance.
00100       //
00101       IpSender = NULL;
00102     }
00103   } else {
00104 
00105     Sock     = Tcb->Sk;
00106     TcpProto = (TCP_PROTO_DATA *) Sock->ProtoReserved;
00107     IpIo     = TcpProto->TcpService->IpIo;
00108     IpSender = Tcb->IpInfo;
00109 
00110     if (Version == IP_VERSION_6) {
00111       //
00112       // It's IPv6 and this TCP segment belongs to a solid TCB, in such case
00113       // the destination address can't be overridden, so reset the Dest to NULL.
00114       //
00115       Dest = NULL;
00116     }
00117   }
00118 
00119   ASSERT (Version == IpIo->IpVersion);
00120 
00121   if (Version == IP_VERSION_4) {
00122     Override.Ip4OverrideData.TypeOfService = 0;
00123     Override.Ip4OverrideData.TimeToLive    = 255;
00124     Override.Ip4OverrideData.DoNotFragment = FALSE;
00125     Override.Ip4OverrideData.Protocol      = EFI_IP_PROTO_TCP;
00126     ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
00127     CopyMem (&Override.Ip4OverrideData.SourceAddress, Src, sizeof (EFI_IPv4_ADDRESS));
00128   } else {
00129     Override.Ip6OverrideData.Protocol  = EFI_IP_PROTO_TCP;
00130     Override.Ip6OverrideData.HopLimit  = 255;
00131     Override.Ip6OverrideData.FlowLabel = 0;
00132   }
00133 
00134   Status = IpIoSend (IpIo, Nbuf, IpSender, NULL, NULL, Dest, &Override);
00135 
00136   if (EFI_ERROR (Status)) {
00137     DEBUG ((EFI_D_ERROR, "TcpSendIpPacket: return %r error\n", Status));
00138     return -1;
00139   }
00140 
00141   return 0;
00142 }
00143 
00162 EFI_STATUS
00163 Tcp6RefreshNeighbor (
00164   IN TCP_CB          *Tcb,
00165   IN EFI_IP_ADDRESS  *Neighbor,
00166   IN UINT32          Timeout
00167   )
00168 {
00169   IP_IO            *IpIo;
00170   SOCKET           *Sock;
00171   TCP_PROTO_DATA  *TcpProto;
00172 
00173   if (NULL == Tcb) {
00174     IpIo = NULL;
00175     IpIoFindSender (&IpIo, IP_VERSION_6, Neighbor);
00176 
00177     if (IpIo == NULL) {
00178       DEBUG ((EFI_D_WARN, "Tcp6AddNeighbor: No appropriate IpIo.\n"));
00179       return EFI_NOT_STARTED;
00180     }
00181 
00182   } else {
00183     Sock     = Tcb->Sk;
00184     TcpProto = (TCP_PROTO_DATA *) Sock->ProtoReserved;
00185     IpIo     = TcpProto->TcpService->IpIo;
00186   }
00187 
00188   return IpIoRefreshNeighbor (IpIo, Neighbor, Timeout);
00189 }
00190 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines