+++ /dev/null
-/** @file\r
- I/O interfaces between TCP and IpIo.\r
-\r
-Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php<BR>\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "Tcp4Main.h"\r
-\r
-\r
-/**\r
- Packet receive callback function provided to IP_IO, used to call\r
- the proper function to handle the packet received by IP.\r
-\r
- @param Status Status of the received packet.\r
- @param IcmpErr ICMP error number.\r
- @param NetSession Pointer to the net session of this packet.\r
- @param Pkt Pointer to the recieved packet.\r
- @param Context Pointer to the context configured in IpIoOpen(), not used\r
- now.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-Tcp4RxCallback (\r
- IN EFI_STATUS Status,\r
- IN UINT8 IcmpErr,\r
- IN EFI_NET_SESSION_DATA *NetSession,\r
- IN NET_BUF *Pkt,\r
- IN VOID *Context OPTIONAL\r
- )\r
-{\r
- if (EFI_SUCCESS == Status) {\r
- TcpInput (Pkt, NetSession->Source.Addr[0], NetSession->Dest.Addr[0]);\r
- } else {\r
- TcpIcmpInput (Pkt, IcmpErr, NetSession->Source.Addr[0], NetSession->Dest.Addr[0]);\r
- }\r
-}\r
-\r
-\r
-/**\r
- Send the segment to IP via IpIo function.\r
-\r
- @param Tcb Pointer to the TCP_CB of this TCP instance.\r
- @param Nbuf Pointer to the TCP segment to be sent.\r
- @param Src Source address of the TCP segment.\r
- @param Dest Destination address of the TCP segment.\r
-\r
- @retval 0 The segment was sent out successfully.\r
- @retval -1 The segment was failed to send.\r
-\r
-**/\r
-INTN\r
-TcpSendIpPacket (\r
- IN TCP_CB *Tcb,\r
- IN NET_BUF *Nbuf,\r
- IN UINT32 Src,\r
- IN UINT32 Dest\r
- )\r
-{\r
- EFI_STATUS Status;\r
- IP_IO *IpIo;\r
- IP_IO_OVERRIDE Override;\r
- SOCKET *Sock;\r
- VOID *IpSender;\r
- TCP4_PROTO_DATA *TcpProto;\r
- EFI_IP_ADDRESS Source;\r
- EFI_IP_ADDRESS Destination;\r
-\r
- Source.Addr[0] = Src;\r
- Destination.Addr[0] = Dest;\r
-\r
- if (NULL == Tcb) {\r
-\r
- IpIo = NULL;\r
- IpSender = IpIoFindSender (&IpIo, IP_VERSION_4, &Source);\r
-\r
- if (IpSender == NULL) {\r
- DEBUG ((EFI_D_WARN, "TcpSendIpPacket: No appropriate IpSender.\n"));\r
- return -1;\r
- }\r
- } else {\r
-\r
- Sock = Tcb->Sk;\r
- TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;\r
- IpIo = TcpProto->TcpService->IpIo;\r
- IpSender = Tcb->IpInfo;\r
- }\r
-\r
- Override.Ip4OverrideData.TypeOfService = 0;\r
- Override.Ip4OverrideData.TimeToLive = 255;\r
- Override.Ip4OverrideData.DoNotFragment = FALSE;\r
- Override.Ip4OverrideData.Protocol = EFI_IP_PROTO_TCP;\r
- ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
- CopyMem (&Override.Ip4OverrideData.SourceAddress, &Src, sizeof (EFI_IPv4_ADDRESS));\r
-\r
- Status = IpIoSend (IpIo, Nbuf, IpSender, NULL, NULL, &Destination, &Override);\r
-\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "TcpSendIpPacket: return %r error\n", Status));\r
- return -1;\r
- }\r
-\r
- return 0;\r
-}\r