]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Include/Library/TcpIoLib.h
NetworkPkg/Library: Fix various typos
[mirror_edk2.git] / NetworkPkg / Include / Library / TcpIoLib.h
CommitLineData
4bad9ada 1/** @file\r
2 This library is used to share code between UEFI network stack modules.\r
3 It provides the helper routines to access TCP service.\r
4\r
d1102dba 5Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 6SPDX-License-Identifier: BSD-2-Clause-Patent\r
4bad9ada 7\r
4b738c76
HT
8**/\r
9\r
10#ifndef _TCP_IO_H_\r
4bad9ada 11#define _TCP_IO_H_\r
12\r
13\r
14#include <Protocol/Tcp4.h>\r
15#include <Protocol/Tcp6.h>\r
16\r
4b738c76 17#include <Library/NetLib.h>\r
4bad9ada 18\r
19#define TCP_VERSION_4 IP_VERSION_4\r
20#define TCP_VERSION_6 IP_VERSION_6\r
21\r
4b738c76
HT
22///\r
23/// 10 seconds\r
24///\r
4bad9ada 25#define TCP_GET_MAPPING_TIMEOUT 100000000U\r
26\r
27\r
28typedef struct {\r
29 EFI_IPv4_ADDRESS LocalIp;\r
30 EFI_IPv4_ADDRESS SubnetMask;\r
31 EFI_IPv4_ADDRESS Gateway;\r
32\r
33 UINT16 StationPort;\r
34 EFI_IPv4_ADDRESS RemoteIp;\r
35 UINT16 RemotePort;\r
36 BOOLEAN ActiveFlag;\r
4b738c76 37} TCP4_IO_CONFIG_DATA;\r
4bad9ada 38\r
4b738c76 39typedef struct {\r
4bad9ada 40 UINT16 StationPort;\r
41 EFI_IPv6_ADDRESS RemoteIp;\r
4b738c76 42 UINT16 RemotePort;\r
4bad9ada 43 BOOLEAN ActiveFlag;\r
44} TCP6_IO_CONFIG_DATA;\r
45\r
46typedef union {\r
47 TCP4_IO_CONFIG_DATA Tcp4IoConfigData;\r
48 TCP6_IO_CONFIG_DATA Tcp6IoConfigData;\r
49} TCP_IO_CONFIG_DATA;\r
50\r
51typedef union {\r
52 EFI_TCP4_PROTOCOL *Tcp4;\r
53 EFI_TCP6_PROTOCOL *Tcp6;\r
54} TCP_IO_PROTOCOL;\r
55\r
56typedef union {\r
57 EFI_TCP4_CONNECTION_TOKEN Tcp4Token;\r
58 EFI_TCP6_CONNECTION_TOKEN Tcp6Token;\r
59} TCP_IO_CONNECTION_TOKEN;\r
60\r
61typedef union {\r
62 EFI_TCP4_IO_TOKEN Tcp4Token;\r
63 EFI_TCP6_IO_TOKEN Tcp6Token;\r
64} TCP_IO_IO_TOKEN;\r
65\r
66typedef union {\r
67 EFI_TCP4_CLOSE_TOKEN Tcp4Token;\r
68 EFI_TCP6_CLOSE_TOKEN Tcp6Token;\r
69} TCP_IO_CLOSE_TOKEN;\r
70\r
71typedef union {\r
72 EFI_TCP4_LISTEN_TOKEN Tcp4Token;\r
73 EFI_TCP6_LISTEN_TOKEN Tcp6Token;\r
74} TCP_IO_LISTEN_TOKEN;\r
75\r
76\r
77typedef struct {\r
78 UINT8 TcpVersion;\r
79 EFI_HANDLE Image;\r
80 EFI_HANDLE Controller;\r
81 EFI_HANDLE Handle;\r
d1102dba 82\r
4bad9ada 83 TCP_IO_PROTOCOL Tcp;\r
84 TCP_IO_PROTOCOL NewTcp;\r
85 TCP_IO_CONNECTION_TOKEN ConnToken;\r
86 TCP_IO_IO_TOKEN TxToken;\r
87 TCP_IO_IO_TOKEN RxToken;\r
88 TCP_IO_CLOSE_TOKEN CloseToken;\r
89 TCP_IO_LISTEN_TOKEN ListenToken;\r
d1102dba 90\r
4bad9ada 91 BOOLEAN IsConnDone;\r
92 BOOLEAN IsTxDone;\r
93 BOOLEAN IsRxDone;\r
94 BOOLEAN IsCloseDone;\r
95 BOOLEAN IsListenDone;\r
96} TCP_IO;\r
97\r
98/**\r
d1102dba 99 Create a TCP socket with the specified configuration data.\r
4bad9ada 100\r
101 @param[in] Image The handle of the driver image.\r
102 @param[in] Controller The handle of the controller.\r
103 @param[in] TcpVersion The version of Tcp, TCP_VERSION_4 or TCP_VERSION_6.\r
104 @param[in] ConfigData The Tcp configuration data.\r
105 @param[out] TcpIo The TcpIo.\r
d1102dba 106\r
4bad9ada 107 @retval EFI_SUCCESS The TCP socket is created and configured.\r
108 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
4b738c76 109 @retval EFI_UNSUPPORTED One or more of the control options are not\r
4bad9ada 110 supported in the implementation.\r
8322eb77 111 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
4bad9ada 112 @retval Others Failed to create the TCP socket or configure it.\r
113\r
114**/\r
8322eb77 115EFI_STATUS\r
4bad9ada 116EFIAPI\r
4b738c76
HT
117TcpIoCreateSocket (\r
118 IN EFI_HANDLE Image,\r
4bad9ada 119 IN EFI_HANDLE Controller,\r
4b738c76
HT
120 IN UINT8 TcpVersion,\r
121 IN TCP_IO_CONFIG_DATA *ConfigData,\r
122 OUT TCP_IO *TcpIo\r
123 );\r
124\r
125/**\r
d1102dba 126 Destroy the socket.\r
4b738c76
HT
127\r
128 @param[in] TcpIo The TcpIo which wraps the socket to be destroyed.\r
129\r
130**/\r
131VOID\r
4bad9ada 132EFIAPI\r
4b738c76
HT
133TcpIoDestroySocket (\r
134 IN TCP_IO *TcpIo\r
135 );\r
136\r
4bad9ada 137/**\r
138 Connect to the other endpoint of the TCP socket.\r
139\r
140 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
b5035efa 141 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.\r
d1102dba 142\r
4bad9ada 143 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket\r
144 successfully.\r
145 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the\r
146 TCP socket in the specified time period.\r
147 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
148 @retval EFI_UNSUPPORTED One or more of the control options are not\r
149 supported in the implementation.\r
150 @retval Others Other errors as indicated.\r
151\r
152**/\r
4b738c76 153EFI_STATUS\r
4bad9ada 154EFIAPI\r
4b738c76
HT
155TcpIoConnect (\r
156 IN OUT TCP_IO *TcpIo,\r
b5035efa 157 IN EFI_EVENT Timeout OPTIONAL\r
4b738c76 158 );\r
4bad9ada 159\r
160/**\r
161 Accept the incomding request from the other endpoint of the TCP socket.\r
162\r
163 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
b5035efa 164 @param[in] Timeout The time to wait for connection done. Set to NULL for infinite wait.\r
4bad9ada 165\r
d1102dba 166\r
4bad9ada 167 @retval EFI_SUCCESS Connect to the other endpoint of the TCP socket\r
168 successfully.\r
169 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
170 @retval EFI_UNSUPPORTED One or more of the control options are not\r
171 supported in the implementation.\r
172\r
173 @retval EFI_TIMEOUT Failed to connect to the other endpoint of the\r
174 TCP socket in the specified time period.\r
175 @retval Others Other errors as indicated.\r
176\r
177**/\r
178EFI_STATUS\r
179EFIAPI\r
180TcpIoAccept (\r
181 IN OUT TCP_IO *TcpIo,\r
b5035efa 182 IN EFI_EVENT Timeout OPTIONAL\r
4bad9ada 183 );\r
d1102dba 184\r
4b738c76
HT
185/**\r
186 Reset the socket.\r
187\r
188 @param[in, out] TcpIo The TcpIo wrapping the TCP socket.\r
189\r
190**/\r
191VOID\r
4bad9ada 192EFIAPI\r
4b738c76
HT
193TcpIoReset (\r
194 IN OUT TCP_IO *TcpIo\r
195 );\r
196\r
4bad9ada 197/**\r
198 Transmit the Packet to the other endpoint of the socket.\r
199\r
200 @param[in] TcpIo The TcpIo wrapping the TCP socket.\r
201 @param[in] Packet The packet to transmit.\r
d1102dba 202\r
6deb4baa 203 @retval EFI_SUCCESS The packet is transmitted.\r
4bad9ada 204 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
205 @retval EFI_UNSUPPORTED One or more of the control options are not\r
206 supported in the implementation.\r
207 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
208 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
209 @retval Others Other errors as indicated.\r
210\r
211**/\r
4b738c76 212EFI_STATUS\r
4bad9ada 213EFIAPI\r
4b738c76
HT
214TcpIoTransmit (\r
215 IN TCP_IO *TcpIo,\r
216 IN NET_BUF *Packet\r
217 );\r
218\r
4bad9ada 219/**\r
220 Receive data from the socket.\r
221\r
222 @param[in, out] TcpIo The TcpIo which wraps the socket to be destroyed.\r
223 @param[in] Packet The buffer to hold the data copy from the socket rx buffer.\r
6deb4baa 224 @param[in] AsyncMode Is this receive asynchronous or not.\r
4bad9ada 225 @param[in] Timeout The time to wait for receiving the amount of data the Packet\r
b5035efa 226 can hold. Set to NULL for infinite wait.\r
4bad9ada 227\r
228 @retval EFI_SUCCESS The required amount of data is received from the socket.\r
229 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
230 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred.\r
6deb4baa 231 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r
4bad9ada 232 @retval EFI_TIMEOUT Failed to receive the required amount of data in the\r
233 specified time period.\r
234 @retval Others Other errors as indicated.\r
235\r
236**/\r
4b738c76 237EFI_STATUS\r
4bad9ada 238EFIAPI\r
4b738c76
HT
239TcpIoReceive (\r
240 IN OUT TCP_IO *TcpIo,\r
241 IN NET_BUF *Packet,\r
242 IN BOOLEAN AsyncMode,\r
b5035efa 243 IN EFI_EVENT Timeout OPTIONAL\r
4b738c76 244 );\r
4bad9ada 245\r
246#endif\r
247\r