]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Io.c
Fixed GCC 4.4 build issues due to EFIAPI not being used when required.
[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
e798cd87 31EFIAPI\r
8a67d61d 32Tcp4RxCallback (\r
33 IN EFI_STATUS Status,\r
b45b45b2 34 IN UINT8 IcmpErr,\r
8a67d61d 35 IN EFI_NET_SESSION_DATA *NetSession,\r
36 IN NET_BUF *Pkt,\r
37 IN VOID *Context OPTIONAL\r
38 )\r
39{\r
40 if (EFI_SUCCESS == Status) {\r
fb115c61 41 TcpInput (Pkt, NetSession->Source.Addr[0], NetSession->Dest.Addr[0]);\r
8a67d61d 42 } else {\r
fb115c61 43 TcpIcmpInput (Pkt, IcmpErr, NetSession->Source.Addr[0], NetSession->Dest.Addr[0]);\r
8a67d61d 44 }\r
45}\r
46\r
47\r
48/**\r
49 Send the segment to IP via IpIo function.\r
50\r
51 @param Tcb Pointer to the TCP_CB of this TCP instance.\r
52 @param Nbuf Pointer to the TCP segment to be sent.\r
53 @param Src Source address of the TCP segment.\r
54 @param Dest Destination address of the TCP segment.\r
55\r
56 @retval 0 The segment was sent out successfully.\r
57 @retval -1 The segment was failed to send.\r
58\r
59**/\r
60INTN\r
61TcpSendIpPacket (\r
62 IN TCP_CB *Tcb,\r
63 IN NET_BUF *Nbuf,\r
64 IN UINT32 Src,\r
65 IN UINT32 Dest\r
66 )\r
67{\r
68 EFI_STATUS Status;\r
69 IP_IO *IpIo;\r
70 IP_IO_OVERRIDE Override;\r
71 SOCKET *Sock;\r
72 VOID *IpSender;\r
73 TCP4_PROTO_DATA *TcpProto;\r
fb115c61 74 EFI_IP_ADDRESS Source;\r
75 EFI_IP_ADDRESS Destination;\r
76\r
77 Source.Addr[0] = Src;\r
78 Destination.Addr[0] = Dest;\r
8a67d61d 79\r
80 if (NULL == Tcb) {\r
81\r
82 IpIo = NULL;\r
fb115c61 83 IpSender = IpIoFindSender (&IpIo, IP_VERSION_4, &Source);\r
8a67d61d 84\r
85 if (IpSender == NULL) {\r
e48e37fc 86 DEBUG ((EFI_D_WARN, "TcpSendIpPacket: No appropriate IpSender.\n"));\r
8a67d61d 87 return -1;\r
88 }\r
89 } else {\r
90\r
91 Sock = Tcb->Sk;\r
92 TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;\r
93 IpIo = TcpProto->TcpService->IpIo;\r
94 IpSender = Tcb->IpInfo;\r
95 }\r
96\r
fb115c61 97 Override.Ip4OverrideData.TypeOfService = 0;\r
98 Override.Ip4OverrideData.TimeToLive = 255;\r
99 Override.Ip4OverrideData.DoNotFragment = FALSE;\r
100 Override.Ip4OverrideData.Protocol = EFI_IP_PROTO_TCP;\r
101 ZeroMem (&Override.Ip4OverrideData.GatewayAddress, sizeof (EFI_IPv4_ADDRESS));\r
102 CopyMem (&Override.Ip4OverrideData.SourceAddress, &Src, sizeof (EFI_IPv4_ADDRESS));\r
8a67d61d 103\r
fb115c61 104 Status = IpIoSend (IpIo, Nbuf, IpSender, NULL, NULL, &Destination, &Override);\r
8a67d61d 105\r
106 if (EFI_ERROR (Status)) {\r
e48e37fc 107 DEBUG ((EFI_D_ERROR, "TcpSendIpPacket: return %r error\n", Status));\r
8a67d61d 108 return -1;\r
109 }\r
110\r
111 return 0;\r
112}\r