]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c
Fixed GCC 4.4 build issue. All protocols and public interfaces must specify EFIAPI...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Io.c
CommitLineData
8a67d61d 1/** @file\r
dfc1f033 2 I/O interfaces between TCP and IpIo.\r
8a67d61d 3\r
fb115c61 4Copyright (c) 2005 - 2009, Intel Corporation<BR>\r
8a67d61d 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
dfc1f033 8http://opensource.org/licenses/bsd-license.php<BR>\r
8a67d61d 9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
8a67d61d 13**/\r
14\r
8a67d61d 15#include "Tcp4Main.h"\r
16\r
17\r
18/**\r
19 Packet receive callback function provided to IP_IO, used to call\r
20 the proper function to handle the packet received by IP.\r
21\r
22 @param Status Status of the received packet.\r
23 @param IcmpErr ICMP error number.\r
24 @param NetSession Pointer to the net session of this packet.\r
25 @param Pkt Pointer to the recieved packet.\r
26 @param Context Pointer to the context configured in IpIoOpen(), not used\r
27 now.\r
28\r
8a67d61d 29**/\r
30VOID\r
31Tcp4RxCallback (\r
32 IN EFI_STATUS Status,\r
b45b45b2 33 IN UINT8 IcmpErr,\r
8a67d61d 34 IN EFI_NET_SESSION_DATA *NetSession,\r
35 IN NET_BUF *Pkt,\r
36 IN VOID *Context OPTIONAL\r
37 )\r
38{\r
39 if (EFI_SUCCESS == Status) {\r
fb115c61 40 TcpInput (Pkt, NetSession->Source.Addr[0], NetSession->Dest.Addr[0]);\r
8a67d61d 41 } else {\r
fb115c61 42 TcpIcmpInput (Pkt, IcmpErr, NetSession->Source.Addr[0], NetSession->Dest.Addr[0]);\r
8a67d61d 43 }\r
44}\r
45\r
46\r
47/**\r
48 Send the segment to IP via IpIo function.\r
49\r
50 @param Tcb Pointer to the TCP_CB of this TCP instance.\r
51 @param Nbuf Pointer to the TCP segment to be sent.\r
52 @param Src Source address of the TCP segment.\r
53 @param Dest Destination address of the TCP segment.\r
54\r
55 @retval 0 The segment was sent out successfully.\r
56 @retval -1 The segment was failed to send.\r
57\r
58**/\r
59INTN\r
60TcpSendIpPacket (\r
61 IN TCP_CB *Tcb,\r
62 IN NET_BUF *Nbuf,\r
63 IN UINT32 Src,\r
64 IN UINT32 Dest\r
65 )\r
66{\r
67 EFI_STATUS Status;\r
68 IP_IO *IpIo;\r
69 IP_IO_OVERRIDE Override;\r
70 SOCKET *Sock;\r
71 VOID *IpSender;\r
72 TCP4_PROTO_DATA *TcpProto;\r
fb115c61 73 EFI_IP_ADDRESS Source;\r
74 EFI_IP_ADDRESS Destination;\r
75\r
76 Source.Addr[0] = Src;\r
77 Destination.Addr[0] = Dest;\r
8a67d61d 78\r
79 if (NULL == Tcb) {\r
80\r
81 IpIo = NULL;\r
fb115c61 82 IpSender = IpIoFindSender (&IpIo, IP_VERSION_4, &Source);\r
8a67d61d 83\r
84 if (IpSender == NULL) {\r
e48e37fc 85 DEBUG ((EFI_D_WARN, "TcpSendIpPacket: No appropriate IpSender.\n"));\r
8a67d61d 86 return -1;\r
87 }\r
88 } else {\r
89\r
90 Sock = Tcb->Sk;\r
91 TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;\r
92 IpIo = TcpProto->TcpService->IpIo;\r
93 IpSender = Tcb->IpInfo;\r
94 }\r
95\r
fb115c61 96 Override.Ip4OverrideData.TypeOfService = 0;\r
97 Override.Ip4OverrideData.TimeToLive = 255;\r
98 Override.Ip4OverrideData.DoNotFragment = FALSE;\r
99 Override.Ip4OverrideData.Protocol = EFI_IP_PROTO_TCP;\r
100 ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
101 CopyMem (&Override.Ip4OverrideData.SourceAddress, &Src, sizeof (EFI_IPv4_ADDRESS));\r
8a67d61d 102\r
fb115c61 103 Status = IpIoSend (IpIo, Nbuf, IpSender, NULL, NULL, &Destination, &Override);\r
8a67d61d 104\r
105 if (EFI_ERROR (Status)) {\r
e48e37fc 106 DEBUG ((EFI_D_ERROR, "TcpSendIpPacket: return %r error\n", Status));\r
8a67d61d 107 return -1;\r
108 }\r
109\r
110 return 0;\r
111}\r