]>
Commit | Line | Data |
---|---|---|
d7ce7006 | 1 | /** @file\r |
2 | Definitions for the Socket layer driver.\r | |
3 | \r | |
4 | Copyright (c) 2011, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | #ifndef _SOCKET_H_\r | |
15 | #define _SOCKET_H_\r | |
16 | \r | |
17 | #include <Efi/EfiSocketLib.h>\r | |
18 | \r | |
19 | //------------------------------------------------------------------------------\r | |
20 | // Constants\r | |
21 | //------------------------------------------------------------------------------\r | |
22 | \r | |
23 | #define DEBUG_SOCKET 0x20000000 ///< Display Socket related messages\r | |
24 | #define DEBUG_BIND 0x10000000 ///< Display bind related messages\r | |
25 | #define DEBUG_LISTEN 0x08000000 ///< Display listen related messages\r | |
26 | #define DEBUG_CONNECTION 0x04000000 ///< Display connection list related messages\r | |
27 | #define DEBUG_POLL 0x02000000 ///< Display poll messages\r | |
28 | #define DEBUG_ACCEPT 0x01000000 ///< Display accept related messages\r | |
29 | #define DEBUG_RX 0x00800000 ///< Display receive messages\r | |
30 | #define DEBUG_TX 0x00400000 ///< Display transmit messages\r | |
31 | #define DEBUG_CLOSE 0x00200000 ///< Display close messages\r | |
32 | #define DEBUG_CONNECT 0x00100000 ///< Display connect messages\r | |
a88c3163 | 33 | #define DEBUG_OPTION 0x00080000 ///< Display option messages\r |
d7ce7006 | 34 | \r |
35 | #define MAX_PENDING_CONNECTIONS 1 ///< Maximum connection FIFO depth\r | |
7d5c23a7 | 36 | #define MAX_RX_DATA 0x01000000 ///< Maximum receive data size\r |
a88c3163 | 37 | #define MAX_TX_DATA ( MAX_RX_DATA * 2 ) ///< Maximum buffered transmit data in bytes\r |
7d5c23a7 | 38 | #define RX_PACKET_DATA 0x00100000 ///< Maximum number of bytes in a RX packet\r |
a88c3163 | 39 | #define MAX_UDP_RETRANSMIT 16 ///< UDP retransmit attempts to handle address not mapped\r |
d7ce7006 | 40 | \r |
a88c3163 | 41 | #define ESL_STRUCTURE_ALIGNMENT_BYTES 15 ///< Number of bytes for structure alignment\r |
42 | #define ESL_STRUCTURE_ALIGNMENT_MASK ( ~ESL_STRUCTURE_ALIGNMENT_BYTES ) ///< Mask to align structures\r | |
d7ce7006 | 43 | \r |
a88c3163 | 44 | #define LAYER_SIGNATURE SIGNATURE_32 ('S','k','t','L') ///< ESL_LAYER memory signature\r |
45 | #define SERVICE_SIGNATURE SIGNATURE_32 ('S','k','t','S') ///< ESL_SERVICE memory signature\r | |
46 | #define SOCKET_SIGNATURE SIGNATURE_32 ('S','c','k','t') ///< ESL_SOCKET memory signature\r | |
47 | #define PORT_SIGNATURE SIGNATURE_32 ('P','o','r','t') ///< ESL_PORT memory signature\r | |
d7ce7006 | 48 | \r |
a88c3163 | 49 | \r |
50 | /**\r | |
51 | Socket states\r | |
52 | **/\r | |
d7ce7006 | 53 | typedef enum\r |
54 | {\r | |
55 | SOCKET_STATE_NOT_CONFIGURED = 0, ///< socket call was successful\r | |
56 | SOCKET_STATE_BOUND, ///< bind call was successful\r | |
57 | SOCKET_STATE_LISTENING, ///< listen call was successful\r | |
58 | SOCKET_STATE_NO_PORTS, ///< No ports available\r | |
59 | SOCKET_STATE_IN_FIFO, ///< Socket on FIFO\r | |
60 | SOCKET_STATE_CONNECTING, ///< Connecting to a remote system\r | |
61 | SOCKET_STATE_CONNECTED, ///< Accept or connect call was successful\r | |
62 | \r | |
63 | //\r | |
64 | // Close state must be the last in the list\r | |
65 | //\r | |
66 | SOCKET_STATE_CLOSED ///< Close call was successful\r | |
67 | } SOCKET_STATE;\r | |
68 | \r | |
a88c3163 | 69 | \r |
70 | /**\r | |
71 | Port states\r | |
72 | **/\r | |
d7ce7006 | 73 | typedef enum\r |
74 | {\r | |
75 | PORT_STATE_ALLOCATED = 0, ///< Port allocated\r | |
76 | PORT_STATE_OPEN, ///< Port opened\r | |
77 | PORT_STATE_RX_ERROR, ///< Receive error detected\r | |
78 | \r | |
79 | //\r | |
a88c3163 | 80 | // Close state must be last in the list!\r |
81 | //\r | |
82 | // Using < <= > >= in tests code to detect port close state\r | |
83 | // machine has started\r | |
d7ce7006 | 84 | //\r |
85 | PORT_STATE_CLOSE_STARTED, ///< Close started on port\r | |
86 | PORT_STATE_CLOSE_TX_DONE, ///< Transmits shutdown\r | |
a88c3163 | 87 | PORT_STATE_CLOSE_DONE, ///< Port close operation complete\r |
88 | PORT_STATE_CLOSE_RX_DONE ///< Receives shutdown\r | |
d7ce7006 | 89 | } PORT_STATE;\r |
90 | \r | |
91 | //------------------------------------------------------------------------------\r | |
92 | // Data Types\r | |
93 | //------------------------------------------------------------------------------\r | |
94 | \r | |
a88c3163 | 95 | typedef struct _ESL_IO_MGMT ESL_IO_MGMT;///< Forward declaration\r |
96 | typedef struct _ESL_PACKET ESL_PACKET; ///< Forward declaration\r | |
97 | typedef struct _ESL_PORT ESL_PORT; ///< Forward declaration\r | |
98 | typedef struct _ESL_SOCKET ESL_SOCKET; ///< Forward declaration\r | |
99 | \r | |
100 | /**\r | |
101 | Receive context for SOCK_RAW sockets using IPv4.\r | |
102 | **/\r | |
103 | typedef struct\r | |
104 | {\r | |
105 | EFI_IP4_RECEIVE_DATA * pRxData; ///< Receive operation description\r | |
106 | } ESL_IP4_RX_DATA;\r | |
107 | \r | |
108 | \r | |
109 | /**\r | |
110 | Transmit context for SOCK_RAW sockets using IPv4.\r | |
111 | **/\r | |
112 | typedef struct\r | |
113 | {\r | |
114 | EFI_IP4_OVERRIDE_DATA Override; ///< Override data\r | |
115 | EFI_IP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r | |
116 | UINT8 Buffer[ 1 ]; ///< Data buffer\r | |
117 | } ESL_IP4_TX_DATA;\r | |
d7ce7006 | 118 | \r |
a88c3163 | 119 | \r |
120 | /**\r | |
121 | Receive context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv4.\r | |
122 | **/\r | |
d7ce7006 | 123 | typedef struct\r |
124 | {\r | |
125 | EFI_TCP4_RECEIVE_DATA RxData; ///< Receive operation description\r | |
a88c3163 | 126 | UINT8 Buffer[ RX_PACKET_DATA ]; ///< Data buffer\r |
127 | } ESL_TCP4_RX_DATA;\r | |
128 | \r | |
d7ce7006 | 129 | \r |
a88c3163 | 130 | /**\r |
131 | Transmit context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv4.\r | |
132 | **/\r | |
d7ce7006 | 133 | typedef struct\r |
134 | {\r | |
135 | EFI_TCP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r | |
a88c3163 | 136 | UINT8 Buffer[ 1 ]; ///< Data buffer\r |
137 | } ESL_TCP4_TX_DATA;\r | |
d7ce7006 | 138 | \r |
a88c3163 | 139 | \r |
3bdf9aae | 140 | /**\r |
141 | Receive context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.\r | |
142 | **/\r | |
143 | typedef struct\r | |
144 | {\r | |
145 | EFI_TCP6_RECEIVE_DATA RxData; ///< Receive operation description\r | |
146 | UINT8 Buffer[ RX_PACKET_DATA ]; ///< Data buffer\r | |
147 | } ESL_TCP6_RX_DATA;\r | |
148 | \r | |
149 | \r | |
150 | /**\r | |
151 | Transmit context for SOCK_STREAM and SOCK_SEQPACKET sockets using TCPv6.\r | |
152 | **/\r | |
153 | typedef struct\r | |
154 | {\r | |
155 | EFI_TCP6_TRANSMIT_DATA TxData; ///< Transmit operation description\r | |
156 | UINT8 Buffer[ 1 ]; ///< Data buffer\r | |
157 | } ESL_TCP6_TX_DATA;\r | |
158 | \r | |
159 | \r | |
a88c3163 | 160 | /**\r |
161 | Receive context for SOCK_DGRAM sockets using UDPv4.\r | |
162 | **/\r | |
d7ce7006 | 163 | typedef struct\r |
164 | {\r | |
a88c3163 | 165 | EFI_UDP4_SESSION_DATA Session; ///< Remote network address\r |
166 | EFI_UDP4_RECEIVE_DATA * pRxData; ///< Receive operation description\r | |
167 | } ESL_UDP4_RX_DATA;\r | |
d7ce7006 | 168 | \r |
a88c3163 | 169 | \r |
170 | /**\r | |
171 | Transmit context for SOCK_DGRAM sockets using UDPv4.\r | |
172 | **/\r | |
d7ce7006 | 173 | typedef struct\r |
174 | {\r | |
175 | EFI_UDP4_SESSION_DATA Session; ///< Remote network address\r | |
176 | EFI_UDP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r | |
a88c3163 | 177 | UINTN RetransmitCount; ///< Retransmit to handle ARP negotiation\r |
178 | UINT8 Buffer[ 1 ]; ///< Data buffer\r | |
179 | } ESL_UDP4_TX_DATA;\r | |
180 | \r | |
d7ce7006 | 181 | \r |
3bdf9aae | 182 | /**\r |
183 | Receive context for SOCK_DGRAM sockets using UDPv6.\r | |
184 | **/\r | |
185 | typedef struct\r | |
186 | {\r | |
187 | EFI_UDP6_SESSION_DATA Session; ///< Remote network address\r | |
188 | EFI_UDP6_RECEIVE_DATA * pRxData; ///< Receive operation description\r | |
189 | } ESL_UDP6_RX_DATA;\r | |
190 | \r | |
191 | \r | |
192 | /**\r | |
193 | Transmit context for SOCK_DGRAM sockets using UDPv6.\r | |
194 | **/\r | |
195 | typedef struct\r | |
196 | {\r | |
197 | EFI_UDP6_SESSION_DATA Session; ///< Remote network address\r | |
198 | EFI_UDP6_TRANSMIT_DATA TxData; ///< Transmit operation description\r | |
199 | UINTN RetransmitCount; ///< Retransmit to handle ARP negotiation\r | |
200 | UINT8 Buffer[ 1 ]; ///< Data buffer\r | |
201 | } ESL_UDP6_TX_DATA;\r | |
202 | \r | |
203 | \r | |
a88c3163 | 204 | /**\r |
205 | Network specific context for transmit and receive packets.\r | |
206 | **/\r | |
207 | typedef struct _ESL_PACKET {\r | |
208 | ESL_PACKET * pNext; ///< Next packet in the receive list\r | |
d7ce7006 | 209 | size_t PacketSize; ///< Size of this data structure\r |
a88c3163 | 210 | size_t ValidBytes; ///< Length of valid data in bytes\r |
211 | UINT8 * pBuffer; ///< Current data pointer\r | |
d7ce7006 | 212 | union {\r |
a88c3163 | 213 | ESL_IP4_RX_DATA Ip4Rx; ///< Receive operation description\r |
214 | ESL_IP4_TX_DATA Ip4Tx; ///< Transmit operation description\r | |
215 | ESL_TCP4_RX_DATA Tcp4Rx; ///< Receive operation description\r | |
216 | ESL_TCP4_TX_DATA Tcp4Tx; ///< Transmit operation description\r | |
3bdf9aae | 217 | ESL_TCP6_RX_DATA Tcp6Rx; ///< Receive operation description\r |
218 | ESL_TCP6_TX_DATA Tcp6Tx; ///< Transmit operation description\r | |
a88c3163 | 219 | ESL_UDP4_RX_DATA Udp4Rx; ///< Receive operation description\r |
220 | ESL_UDP4_TX_DATA Udp4Tx; ///< Transmit operation description\r | |
3bdf9aae | 221 | ESL_UDP6_RX_DATA Udp6Rx; ///< Receive operation description\r |
222 | ESL_UDP6_TX_DATA Udp6Tx; ///< Transmit operation description\r | |
a88c3163 | 223 | } Op; ///< Network specific context\r |
224 | } GCC_ESL_PACKET;\r | |
d7ce7006 | 225 | \r |
226 | /**\r | |
227 | Service control structure\r | |
228 | \r | |
229 | The driver uses this structure to manage the network devices.\r | |
230 | **/\r | |
a88c3163 | 231 | typedef struct _ESL_SERVICE {\r |
d7ce7006 | 232 | UINTN Signature; ///< Structure identification\r |
233 | \r | |
234 | //\r | |
235 | // Links\r | |
236 | //\r | |
a88c3163 | 237 | ESL_SERVICE * pNext; ///< Next service in the service list\r |
d7ce7006 | 238 | \r |
239 | //\r | |
240 | // Service data\r | |
241 | //\r | |
a88c3163 | 242 | CONST ESL_SOCKET_BINDING * pSocketBinding; ///< Name and shutdown routine\r |
243 | EFI_HANDLE Controller; ///< Controller for the service\r | |
244 | EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Network layer service binding interface\r | |
d7ce7006 | 245 | \r |
246 | //\r | |
247 | // Network data\r | |
248 | //\r | |
a88c3163 | 249 | ESL_PORT * pPortList; ///< List of ports using this service\r |
250 | }GCC_ESL_SERVICE;\r | |
d7ce7006 | 251 | \r |
252 | /**\r | |
a88c3163 | 253 | IO management structure\r |
d7ce7006 | 254 | \r |
a88c3163 | 255 | This structure manages a single operation with the network.\r |
256 | **/\r | |
257 | typedef struct _ESL_IO_MGMT {\r | |
258 | ESL_IO_MGMT * pNext; ///< Next TX management structure\r | |
259 | ESL_PORT * pPort; ///< Port structure address\r | |
260 | ESL_PACKET * pPacket; ///< Packet structure address\r | |
261 | union {\r | |
262 | EFI_IP4_COMPLETION_TOKEN Ip4Rx; ///< IP4 receive token\r | |
263 | EFI_IP4_COMPLETION_TOKEN Ip4Tx; ///< IP4 transmit token\r | |
264 | EFI_TCP4_IO_TOKEN Tcp4Rx; ///< TCP4 receive token\r | |
265 | EFI_TCP4_IO_TOKEN Tcp4Tx; ///< TCP4 transmit token\r | |
3bdf9aae | 266 | EFI_TCP6_IO_TOKEN Tcp6Rx; ///< TCP6 receive token\r |
267 | EFI_TCP6_IO_TOKEN Tcp6Tx; ///< TCP6 transmit token\r | |
a88c3163 | 268 | EFI_UDP4_COMPLETION_TOKEN Udp4Rx; ///< UDP4 receive token\r |
269 | EFI_UDP4_COMPLETION_TOKEN Udp4Tx; ///< UDP4 transmit token\r | |
3bdf9aae | 270 | EFI_UDP6_COMPLETION_TOKEN Udp6Rx; ///< UDP6 receive token\r |
271 | EFI_UDP6_COMPLETION_TOKEN Udp6Tx; ///< UDP6 transmit token\r | |
a88c3163 | 272 | } Token; ///< Completion token for the network operation\r |
58081f2c | 273 | } GCC_IO_MGMT;\r |
a88c3163 | 274 | \r |
275 | /**\r | |
276 | IP4 context structure\r | |
d7ce7006 | 277 | \r |
a88c3163 | 278 | The driver uses this structure to manage the IP4 connections.\r |
d7ce7006 | 279 | **/\r |
a88c3163 | 280 | typedef struct {\r |
281 | //\r | |
282 | // IP4 context\r | |
283 | //\r | |
284 | EFI_IP4_MODE_DATA ModeData; ///< IP4 mode data, includes configuration data\r | |
285 | EFI_IPv4_ADDRESS DestinationAddress; ///< Default destination address\r | |
286 | } ESL_IP4_CONTEXT;\r | |
287 | \r | |
d7ce7006 | 288 | \r |
289 | /**\r | |
290 | TCP4 context structure\r | |
291 | \r | |
292 | The driver uses this structure to manage the TCP4 connections.\r | |
293 | **/\r | |
294 | typedef struct {\r | |
295 | //\r | |
296 | // TCP4 context\r | |
297 | //\r | |
a88c3163 | 298 | EFI_TCP4_CONFIG_DATA ConfigData; ///< TCP4 configuration data\r |
299 | EFI_TCP4_OPTION Option; ///< TCP4 port options\r | |
d7ce7006 | 300 | \r |
301 | //\r | |
302 | // Tokens\r | |
303 | //\r | |
a88c3163 | 304 | EFI_TCP4_LISTEN_TOKEN ListenToken; ///< Listen control\r |
d7ce7006 | 305 | EFI_TCP4_CONNECTION_TOKEN ConnectToken; ///< Connection control\r |
a88c3163 | 306 | EFI_TCP4_CLOSE_TOKEN CloseToken; ///< Close control\r |
307 | } ESL_TCP4_CONTEXT;\r | |
d7ce7006 | 308 | \r |
3bdf9aae | 309 | /**\r |
310 | TCP6 context structure\r | |
311 | \r | |
312 | The driver uses this structure to manage the TCP6 connections.\r | |
313 | **/\r | |
314 | typedef struct {\r | |
315 | //\r | |
316 | // TCP6 context\r | |
317 | //\r | |
318 | EFI_TCP6_CONFIG_DATA ConfigData; ///< TCP6 configuration data\r | |
319 | EFI_TCP6_OPTION Option; ///< TCP6 port options\r | |
320 | \r | |
321 | //\r | |
322 | // Tokens\r | |
323 | //\r | |
324 | EFI_TCP6_LISTEN_TOKEN ListenToken; ///< Listen control\r | |
325 | EFI_TCP6_CONNECTION_TOKEN ConnectToken; ///< Connection control\r | |
326 | EFI_TCP6_CLOSE_TOKEN CloseToken; ///< Close control\r | |
327 | } ESL_TCP6_CONTEXT;\r | |
328 | \r | |
d7ce7006 | 329 | /**\r |
330 | UDP4 context structure\r | |
331 | \r | |
332 | The driver uses this structure to manage the UDP4 connections.\r | |
333 | **/\r | |
334 | typedef struct {\r | |
335 | //\r | |
336 | // UDP4 context\r | |
337 | //\r | |
d7ce7006 | 338 | EFI_UDP4_CONFIG_DATA ConfigData; ///< UDP4 configuration data\r |
a88c3163 | 339 | } ESL_UDP4_CONTEXT;\r |
d7ce7006 | 340 | \r |
3bdf9aae | 341 | /**\r |
342 | UDP6 context structure\r | |
343 | \r | |
344 | The driver uses this structure to manage the UDP6 connections.\r | |
345 | **/\r | |
346 | typedef struct {\r | |
347 | //\r | |
348 | // UDP6 context\r | |
349 | //\r | |
350 | EFI_UDP6_CONFIG_DATA ConfigData; ///< UDP6 configuration data\r | |
351 | } ESL_UDP6_CONTEXT;\r | |
352 | \r | |
d7ce7006 | 353 | \r |
a88c3163 | 354 | /**\r |
355 | Configure the network layer.\r | |
356 | \r | |
357 | @param [in] pProtocol Protocol structure address\r | |
358 | @param [in] pConfigData Address of the confiuration data\r | |
359 | \r | |
360 | @return Returns EFI_SUCCESS if the operation is successfully\r | |
361 | started.\r | |
362 | **/\r | |
363 | typedef\r | |
364 | EFI_STATUS\r | |
985fef80 | 365 | (EFIAPI * PFN_NET_CONFIGURE) (\r |
a88c3163 | 366 | IN VOID * pProtocol,\r |
367 | IN VOID * pConfigData\r | |
368 | );\r | |
369 | \r | |
370 | /**\r | |
371 | Hand an I/O operation to the network layer.\r | |
372 | \r | |
373 | @param [in] pProtocol Protocol structure address\r | |
374 | @param [in] pToken Completion token address\r | |
d7ce7006 | 375 | \r |
a88c3163 | 376 | @return Returns EFI_SUCCESS if the operation is successfully\r |
377 | started.\r | |
378 | **/\r | |
379 | typedef\r | |
380 | EFI_STATUS\r | |
985fef80 | 381 | (EFIAPI * PFN_NET_IO_START) (\r |
a88c3163 | 382 | IN VOID * pProtocol,\r |
383 | IN VOID * pToken\r | |
384 | );\r | |
d7ce7006 | 385 | \r |
3bdf9aae | 386 | /**\r |
387 | Poll the LAN adapter for receive packets.\r | |
388 | \r | |
389 | @param [in] pProtocol Protocol structure address\r | |
390 | @param [in] pToken Completion token address\r | |
391 | \r | |
392 | @return Returns EFI_SUCCESS if the operation is successfully\r | |
393 | started.\r | |
394 | **/\r | |
395 | typedef\r | |
396 | EFI_STATUS\r | |
985fef80 | 397 | (EFIAPI * PFN_NET_POLL) (\r |
3bdf9aae | 398 | IN VOID * pProtocol\r |
399 | );\r | |
400 | \r | |
d7ce7006 | 401 | /**\r |
402 | Port control structure\r | |
403 | \r | |
404 | The driver uses this structure to manager the socket's connection\r | |
405 | with the network driver.\r | |
406 | **/\r | |
a88c3163 | 407 | typedef struct _ESL_PORT {\r |
d7ce7006 | 408 | UINTN Signature; ///< Structure identification\r |
409 | \r | |
410 | //\r | |
411 | // List links\r | |
412 | //\r | |
a88c3163 | 413 | ESL_PORT * pLinkService; ///< Link in service port list\r |
414 | ESL_PORT * pLinkSocket; ///< Link in socket port list\r | |
d7ce7006 | 415 | \r |
416 | //\r | |
417 | // Structures\r | |
418 | //\r | |
a88c3163 | 419 | ESL_SERVICE * pService; ///< Service for this port\r |
420 | ESL_SOCKET * pSocket; ///< Socket for this port\r | |
d7ce7006 | 421 | \r |
422 | //\r | |
a88c3163 | 423 | // Eliminate the pService references during port close\r |
d7ce7006 | 424 | //\r |
a88c3163 | 425 | EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Service binding for network layer\r |
426 | CONST ESL_SOCKET_BINDING * pSocketBinding; ///< Socket binding for network layer\r | |
d7ce7006 | 427 | \r |
428 | //\r | |
a88c3163 | 429 | // Port management\r |
d7ce7006 | 430 | //\r |
a88c3163 | 431 | EFI_HANDLE Handle; ///< Network port handle\r |
432 | PORT_STATE State; ///< State of the port\r | |
433 | UINTN DebugFlags; ///< Debug flags used to close the port\r | |
434 | BOOLEAN bCloseNow; ///< TRUE = Close the port immediately\r | |
435 | BOOLEAN bConfigured; ///< TRUE = Configure call made to network layer\r | |
436 | PFN_NET_CONFIGURE pfnConfigure; ///< Configure the network layer\r | |
d7ce7006 | 437 | \r |
438 | //\r | |
439 | // Transmit data management\r | |
440 | //\r | |
a88c3163 | 441 | BOOLEAN bTxFlowControl; ///< TX flow control applied\r |
442 | PFN_NET_IO_START pfnTxStart; ///< Start a transmit on the network\r | |
443 | ESL_IO_MGMT * pTxActive; ///< Normal data queue\r | |
444 | ESL_IO_MGMT * pTxFree; ///< Normal free queue\r | |
d7ce7006 | 445 | \r |
a88c3163 | 446 | ESL_IO_MGMT * pTxOobActive; ///< Urgent data queue\r |
447 | ESL_IO_MGMT * pTxOobFree; ///< Urgent free queue\r | |
d7ce7006 | 448 | \r |
449 | //\r | |
a88c3163 | 450 | // Receive data management\r |
d7ce7006 | 451 | //\r |
a88c3163 | 452 | PFN_NET_IO_START pfnRxCancel; ///< Cancel a receive on the network\r |
3bdf9aae | 453 | PFN_NET_POLL pfnRxPoll; ///< Poll the LAN adapter for receive packets\r |
a88c3163 | 454 | PFN_NET_IO_START pfnRxStart; ///< Start a receive on the network\r |
455 | ESL_IO_MGMT * pRxActive; ///< Active receive operation queue\r | |
456 | ESL_IO_MGMT * pRxFree; ///< Free structure queue\r | |
d7ce7006 | 457 | \r |
458 | //\r | |
a88c3163 | 459 | // Protocol specific management data\r |
d7ce7006 | 460 | //\r |
a88c3163 | 461 | union {\r |
462 | VOID * v; ///< VOID pointer\r | |
463 | EFI_IP4_PROTOCOL * IPv4; ///< IP4 protocol pointer\r | |
464 | EFI_TCP4_PROTOCOL * TCPv4; ///< TCP4 protocol pointer\r | |
3bdf9aae | 465 | EFI_TCP6_PROTOCOL * TCPv6; ///< TCP6 protocol pointer\r |
a88c3163 | 466 | EFI_UDP4_PROTOCOL * UDPv4; ///< UDP4 protocol pointer\r |
3bdf9aae | 467 | EFI_UDP6_PROTOCOL * UDPv6; ///< UDP6 protocol pointer\r |
a88c3163 | 468 | } pProtocol; ///< Protocol structure address\r |
469 | union {\r | |
470 | ESL_IP4_CONTEXT Ip4; ///< IPv4 management data\r | |
471 | ESL_TCP4_CONTEXT Tcp4; ///< TCPv4 management data\r | |
3bdf9aae | 472 | ESL_TCP6_CONTEXT Tcp6; ///< TCPv6 management data\r |
a88c3163 | 473 | ESL_UDP4_CONTEXT Udp4; ///< UDPv4 management data\r |
3bdf9aae | 474 | ESL_UDP6_CONTEXT Udp6; ///< UDPv6 management data\r |
a88c3163 | 475 | } Context; ///< Network specific context\r |
476 | }GCC_ESL_PORT;\r | |
d7ce7006 | 477 | \r |
478 | /**\r | |
479 | Accept a network connection.\r | |
480 | \r | |
d7ce7006 | 481 | @param [in] pSocket Address of the socket structure.\r |
482 | \r | |
483 | @param [in] pSockAddr Address of a buffer to receive the remote\r | |
484 | network address.\r | |
485 | \r | |
486 | @param [in, out] pSockAddrLength Length in bytes of the address buffer.\r | |
487 | On output specifies the length of the\r | |
488 | remote network address.\r | |
489 | \r | |
490 | @retval EFI_SUCCESS Remote address is available\r | |
491 | @retval Others Remote address not available\r | |
492 | \r | |
493 | **/\r | |
a88c3163 | 494 | typedef\r |
d7ce7006 | 495 | EFI_STATUS\r |
a88c3163 | 496 | (* PFN_API_ACCEPT) (\r |
497 | IN ESL_SOCKET * pSocket,\r | |
d7ce7006 | 498 | IN struct sockaddr * pSockAddr,\r |
499 | IN OUT socklen_t * pSockAddrLength\r | |
500 | );\r | |
501 | \r | |
502 | /**\r | |
a88c3163 | 503 | Poll for completion of the connection attempt.\r |
d7ce7006 | 504 | \r |
a88c3163 | 505 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r |
d7ce7006 | 506 | \r |
a88c3163 | 507 | @retval EFI_SUCCESS The connection was successfully established.\r |
508 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
509 | @retval Others The connection attempt failed.\r | |
d7ce7006 | 510 | \r |
511 | **/\r | |
a88c3163 | 512 | typedef\r |
d7ce7006 | 513 | EFI_STATUS\r |
a88c3163 | 514 | (* PFN_API_CONNECT_POLL) (\r |
515 | IN ESL_SOCKET * pSocket\r | |
d7ce7006 | 516 | );\r |
517 | \r | |
518 | /**\r | |
a88c3163 | 519 | Attempt to connect to a remote TCP port\r |
520 | \r | |
521 | This routine starts the connection processing for a SOCK_STREAM\r | |
522 | or SOCK_SEQPAKCET socket using the TCP network layer.\r | |
d7ce7006 | 523 | \r |
a88c3163 | 524 | This routine is called by ::EslSocketConnect to initiate the TCP\r |
525 | network specific connect operations.\r | |
d7ce7006 | 526 | \r |
a88c3163 | 527 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r |
d7ce7006 | 528 | \r |
529 | @retval EFI_SUCCESS The connection was successfully established.\r | |
530 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
531 | @retval Others The connection attempt failed.\r | |
532 | \r | |
533 | **/\r | |
a88c3163 | 534 | typedef\r |
d7ce7006 | 535 | EFI_STATUS\r |
a88c3163 | 536 | (* PFN_API_CONNECT_START) (\r |
537 | IN ESL_SOCKET * pSocket\r | |
d7ce7006 | 538 | );\r |
539 | \r | |
540 | /**\r | |
a88c3163 | 541 | Get the local socket address\r |
d7ce7006 | 542 | \r |
a88c3163 | 543 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
d7ce7006 | 544 | \r |
a88c3163 | 545 | @param [out] pAddress Network address to receive the local system address\r |
d7ce7006 | 546 | \r |
547 | **/\r | |
a88c3163 | 548 | typedef\r |
549 | VOID\r | |
550 | (* PFN_API_LOCAL_ADDR_GET) (\r | |
551 | IN ESL_PORT * pPort,\r | |
552 | OUT struct sockaddr * pAddress\r | |
d7ce7006 | 553 | );\r |
554 | \r | |
555 | /**\r | |
a88c3163 | 556 | Set the local port address.\r |
d7ce7006 | 557 | \r |
a88c3163 | 558 | This routine sets the local port address.\r |
d7ce7006 | 559 | \r |
a88c3163 | 560 | This support routine is called by ::EslSocketPortAllocate.\r |
d7ce7006 | 561 | \r |
a88c3163 | 562 | @param [in] ppPort Address of an ESL_PORT structure\r |
563 | @param [in] pSockAddr Address of a sockaddr structure that contains the\r | |
564 | connection point on the local machine. An IPv4 address\r | |
565 | of INADDR_ANY specifies that the connection is made to\r | |
566 | all of the network stacks on the platform. Specifying a\r | |
567 | specific IPv4 address restricts the connection to the\r | |
568 | network stack supporting that address. Specifying zero\r | |
569 | for the port causes the network layer to assign a port\r | |
570 | number from the dynamic range. Specifying a specific\r | |
571 | port number causes the network layer to use that port.\r | |
572 | @param [in] bBindTest TRUE = run bind testing\r | |
d7ce7006 | 573 | \r |
a88c3163 | 574 | @retval EFI_SUCCESS The operation was successful\r |
d7ce7006 | 575 | \r |
a88c3163 | 576 | **/\r |
577 | typedef\r | |
d7ce7006 | 578 | EFI_STATUS\r |
a88c3163 | 579 | (* PFN_API_LOCAL_ADDR_SET) (\r |
580 | IN ESL_PORT * pPort,\r | |
581 | IN CONST struct sockaddr * pSockAddr,\r | |
582 | IN BOOLEAN bBindTest\r | |
d7ce7006 | 583 | );\r |
584 | \r | |
58081f2c | 585 | /**\r |
586 | Process the completion event\r | |
587 | \r | |
588 | This routine handles the I/O completion event.\r | |
589 | \r | |
590 | This routine is called by the low level network driver when\r | |
591 | the operation is completed.\r | |
592 | \r | |
593 | @param [in] Event The receive completion event\r | |
594 | \r | |
595 | @param [in] pIo The address of an ::ESL_IO_MGMT structure\r | |
596 | \r | |
597 | **/\r | |
598 | typedef\r | |
599 | VOID\r | |
600 | (* PFN_API_IO_COMPLETE) (\r | |
601 | IN EFI_EVENT Event,\r | |
602 | IN ESL_IO_MGMT * pIo\r | |
603 | );\r | |
604 | \r | |
d7ce7006 | 605 | /**\r |
a88c3163 | 606 | Determine if the socket is configured.\r |
d7ce7006 | 607 | \r |
d7ce7006 | 608 | \r |
a88c3163 | 609 | @param [in] pSocket Address of a ESL_SOCKET structure\r |
610 | \r | |
611 | @retval EFI_SUCCESS - The port is connected\r | |
612 | @retval EFI_NOT_STARTED - The port is not connected\r | |
d7ce7006 | 613 | \r |
a88c3163 | 614 | **/\r |
615 | typedef\r | |
616 | EFI_STATUS\r | |
617 | (* PFN_API_IS_CONFIGURED) (\r | |
618 | IN ESL_SOCKET * pSocket\r | |
d7ce7006 | 619 | );\r |
620 | \r | |
621 | /**\r | |
622 | Establish the known port to listen for network connections.\r | |
623 | \r | |
d7ce7006 | 624 | @param [in] pSocket Address of the socket structure.\r |
a88c3163 | 625 | \r |
d7ce7006 | 626 | @retval EFI_SUCCESS - Socket successfully created\r |
627 | @retval Other - Failed to enable the socket for listen\r | |
628 | \r | |
629 | **/\r | |
a88c3163 | 630 | typedef\r |
d7ce7006 | 631 | EFI_STATUS\r |
a88c3163 | 632 | (* PFN_API_LISTEN) (\r |
633 | IN ESL_SOCKET * pSocket\r | |
d7ce7006 | 634 | );\r |
635 | \r | |
636 | /**\r | |
a88c3163 | 637 | Get the option value\r |
d7ce7006 | 638 | \r |
a88c3163 | 639 | Retrieve the protocol options one at a time by name.\r |
d7ce7006 | 640 | \r |
a88c3163 | 641 | @param [in] pSocket Address of a ESL_SOCKET structure\r |
642 | @param [in] OptionName Name of the option\r | |
643 | @param [out] ppOptionData Buffer to receive address of option value\r | |
644 | @param [out] pOptionLength Buffer to receive the option length\r | |
d7ce7006 | 645 | \r |
a88c3163 | 646 | @retval EFI_SUCCESS - Socket data successfully received\r |
d7ce7006 | 647 | \r |
648 | **/\r | |
a88c3163 | 649 | typedef\r |
d7ce7006 | 650 | EFI_STATUS\r |
a88c3163 | 651 | (* PFN_API_OPTION_GET) (\r |
652 | IN ESL_SOCKET * pSocket,\r | |
653 | IN int OptionName,\r | |
654 | OUT CONST void ** __restrict ppOptionData,\r | |
655 | OUT socklen_t * __restrict pOptionLength\r | |
d7ce7006 | 656 | );\r |
657 | \r | |
658 | /**\r | |
a88c3163 | 659 | Set the option value\r |
d7ce7006 | 660 | \r |
a88c3163 | 661 | Adjust the protocol options one at a time by name.\r |
d7ce7006 | 662 | \r |
a88c3163 | 663 | @param [in] pSocket Address of a ESL_SOCKET structure\r |
664 | @param [in] OptionName Name of the option\r | |
665 | @param [in] pOptionValue Buffer containing the option value\r | |
666 | @param [in] OptionLength Length of the buffer in bytes\r | |
d7ce7006 | 667 | \r |
a88c3163 | 668 | @retval EFI_SUCCESS - Option successfully set\r |
669 | \r | |
670 | **/\r | |
671 | typedef\r | |
d7ce7006 | 672 | EFI_STATUS\r |
a88c3163 | 673 | (* PFN_API_OPTION_SET) (\r |
674 | IN ESL_SOCKET * pSocket,\r | |
675 | IN int OptionName,\r | |
676 | IN CONST void * pOptionValue,\r | |
677 | IN socklen_t OptionLength\r | |
d7ce7006 | 678 | );\r |
679 | \r | |
680 | /**\r | |
a88c3163 | 681 | Free a receive packet\r |
d7ce7006 | 682 | \r |
a88c3163 | 683 | This routine performs the network specific operations necessary\r |
684 | to free a receive packet.\r | |
d7ce7006 | 685 | \r |
a88c3163 | 686 | This routine is called by ::EslSocketPortCloseTxDone to free a\r |
687 | receive packet.\r | |
688 | \r | |
689 | @param [in] pPacket Address of an ::ESL_PACKET structure.\r | |
690 | @param [in, out] pRxBytes Address of the count of RX bytes\r | |
d7ce7006 | 691 | \r |
692 | **/\r | |
a88c3163 | 693 | typedef\r |
d7ce7006 | 694 | VOID\r |
a88c3163 | 695 | (* PFN_API_PACKET_FREE) (\r |
696 | IN ESL_PACKET * pPacket,\r | |
697 | IN OUT size_t * pRxBytes\r | |
d7ce7006 | 698 | );\r |
699 | \r | |
700 | /**\r | |
a88c3163 | 701 | Initialize the network specific portions of an ::ESL_PORT structure.\r |
d7ce7006 | 702 | \r |
a88c3163 | 703 | This routine initializes the network specific portions of an\r |
704 | ::ESL_PORT structure for use by the socket.\r | |
d7ce7006 | 705 | \r |
a88c3163 | 706 | This support routine is called by ::EslSocketPortAllocate\r |
707 | to connect the socket with the underlying network adapter\r | |
708 | running the IPv4 protocol.\r | |
d7ce7006 | 709 | \r |
a88c3163 | 710 | @param [in] ppPort Address of an ESL_PORT structure\r |
711 | @param [in] DebugFlags Flags for debug messages\r | |
d7ce7006 | 712 | \r |
a88c3163 | 713 | @retval EFI_SUCCESS - Socket successfully created\r |
714 | \r | |
715 | **/\r | |
716 | typedef\r | |
d7ce7006 | 717 | EFI_STATUS\r |
a88c3163 | 718 | (* PFN_API_PORT_ALLOC) (\r |
719 | IN ESL_PORT * pPort,\r | |
720 | IN UINTN DebugFlags\r | |
d7ce7006 | 721 | );\r |
722 | \r | |
723 | /**\r | |
a88c3163 | 724 | Close a network specific port.\r |
d7ce7006 | 725 | \r |
a88c3163 | 726 | This routine releases the resources allocated by the\r |
727 | network specific PortAllocate routine.\r | |
728 | \r | |
729 | This routine is called by ::EslSocketPortCloseRxDone as\r | |
730 | the last step of closing processing.\r | |
731 | See the \ref PortCloseStateMachine section.\r | |
732 | \r | |
733 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
734 | \r | |
735 | @retval EFI_SUCCESS The port is closed\r | |
736 | @retval other Port close error\r | |
d7ce7006 | 737 | \r |
738 | **/\r | |
a88c3163 | 739 | typedef\r |
d7ce7006 | 740 | EFI_STATUS\r |
a88c3163 | 741 | (* PFN_API_PORT_CLOSE) (\r |
742 | IN ESL_PORT * pPort\r | |
d7ce7006 | 743 | );\r |
744 | \r | |
745 | /**\r | |
a88c3163 | 746 | Perform the network specific close operation on the port.\r |
d7ce7006 | 747 | \r |
a88c3163 | 748 | This routine performs the network specific operation to\r |
749 | shutdown receive operations on the port.\r | |
d7ce7006 | 750 | \r |
a88c3163 | 751 | This routine is called by the ::EslSocketPortCloseTxDone\r |
752 | routine after the port completes all of the transmission.\r | |
d7ce7006 | 753 | \r |
a88c3163 | 754 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
755 | \r | |
756 | @retval EFI_SUCCESS The port is closed, not normally returned\r | |
d7ce7006 | 757 | @retval EFI_NOT_READY The port is still closing\r |
758 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
759 | most likely the routine was called already.\r | |
760 | \r | |
761 | **/\r | |
a88c3163 | 762 | typedef\r |
d7ce7006 | 763 | EFI_STATUS\r |
a88c3163 | 764 | (* PFN_API_PORT_CLOSE_OP) (\r |
765 | IN ESL_PORT * pPort\r | |
d7ce7006 | 766 | );\r |
767 | \r | |
768 | /**\r | |
769 | Receive data from a network connection.\r | |
770 | \r | |
a88c3163 | 771 | This routine attempts to return buffered data to the caller. The\r |
772 | data is removed from the urgent queue if the message flag MSG_OOB\r | |
773 | is specified, otherwise data is removed from the normal queue.\r | |
774 | See the \ref ReceiveEngine section.\r | |
d7ce7006 | 775 | \r |
a88c3163 | 776 | This routine is called by ::EslSocketReceive to handle the network\r |
777 | specific receive operation.\r | |
778 | \r | |
779 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
780 | \r | |
781 | @param [in] pPacket Address of an ::ESL_PACKET structure.\r | |
d7ce7006 | 782 | \r |
a88c3163 | 783 | @param [in] pbConsumePacket Address of a BOOLEAN indicating if the packet is to be consumed\r |
d7ce7006 | 784 | \r |
785 | @param [in] BufferLength Length of the the buffer\r | |
786 | \r | |
787 | @param [in] pBuffer Address of a buffer to receive the data.\r | |
788 | \r | |
789 | @param [in] pDataLength Number of received data bytes in the buffer.\r | |
790 | \r | |
791 | @param [out] pAddress Network address to receive the remote system address\r | |
792 | \r | |
a88c3163 | 793 | @param [out] pSkipBytes Address to receive the number of bytes skipped\r |
d7ce7006 | 794 | \r |
a88c3163 | 795 | @return Returns the address of the next free byte in the buffer.\r |
d7ce7006 | 796 | \r |
797 | **/\r | |
a88c3163 | 798 | typedef\r |
799 | UINT8 *\r | |
800 | (* PFN_API_RECEIVE) (\r | |
801 | IN ESL_PORT * pPort,\r | |
802 | IN ESL_PACKET * pPacket,\r | |
803 | IN BOOLEAN * pbConsumePacket,\r | |
d7ce7006 | 804 | IN size_t BufferLength,\r |
805 | IN UINT8 * pBuffer,\r | |
806 | OUT size_t * pDataLength,\r | |
807 | OUT struct sockaddr * pAddress,\r | |
a88c3163 | 808 | OUT size_t * pSkipBytes\r |
d7ce7006 | 809 | );\r |
810 | \r | |
811 | /**\r | |
a88c3163 | 812 | Get the remote socket address\r |
d7ce7006 | 813 | \r |
a88c3163 | 814 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
d7ce7006 | 815 | \r |
a88c3163 | 816 | @param [out] pAddress Network address to receive the remote system address\r |
817 | \r | |
818 | **/\r | |
819 | typedef\r | |
820 | VOID\r | |
821 | (* PFN_API_REMOTE_ADDR_GET) (\r | |
822 | IN ESL_PORT * pPort,\r | |
823 | OUT struct sockaddr * pAddress\r | |
d7ce7006 | 824 | );\r |
825 | \r | |
826 | /**\r | |
a88c3163 | 827 | Set the remote address\r |
d7ce7006 | 828 | \r |
a88c3163 | 829 | This routine sets the remote address in the port.\r |
d7ce7006 | 830 | \r |
a88c3163 | 831 | This routine is called by ::EslSocketConnect to specify the\r |
832 | remote network address.\r | |
d7ce7006 | 833 | \r |
a88c3163 | 834 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
d7ce7006 | 835 | \r |
a88c3163 | 836 | @param [in] pSockAddr Network address of the remote system.\r |
d7ce7006 | 837 | \r |
a88c3163 | 838 | @param [in] SockAddrLength Length in bytes of the network address.\r |
d7ce7006 | 839 | \r |
a88c3163 | 840 | @retval EFI_SUCCESS The operation was successful\r |
d7ce7006 | 841 | \r |
842 | **/\r | |
a88c3163 | 843 | typedef\r |
844 | EFI_STATUS\r | |
845 | (* PFN_API_REMOTE_ADDR_SET) (\r | |
846 | IN ESL_PORT * pPort,\r | |
847 | IN CONST struct sockaddr * pSockAddr,\r | |
848 | IN socklen_t SockAddrLength\r | |
d7ce7006 | 849 | );\r |
850 | \r | |
d7ce7006 | 851 | /**\r |
a88c3163 | 852 | Start a receive operation\r |
d7ce7006 | 853 | \r |
a88c3163 | 854 | This routine prepares a packet for the receive operation.\r |
855 | See the \ref ReceiveEngine section.\r | |
d7ce7006 | 856 | \r |
a88c3163 | 857 | This support routine is called by EslSocketRxStart.\r |
858 | \r | |
859 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
860 | @param [in] pIo Address of an ::ESL_IO_MGMT structure.\r | |
d7ce7006 | 861 | \r |
862 | **/\r | |
a88c3163 | 863 | typedef\r |
864 | VOID\r | |
865 | (* PFN_API_RX_START) (\r | |
866 | IN ESL_PORT * pPort,\r | |
867 | IN ESL_IO_MGMT * pIo\r | |
d7ce7006 | 868 | );\r |
869 | \r | |
870 | /**\r | |
871 | Buffer data for transmission over a network connection.\r | |
872 | \r | |
a88c3163 | 873 | @param [in] pSocket Address of a ESL_SOCKET structure\r |
d7ce7006 | 874 | \r |
d7ce7006 | 875 | @param [in] Flags Message control flags\r |
a88c3163 | 876 | \r |
d7ce7006 | 877 | @param [in] BufferLength Length of the the buffer\r |
a88c3163 | 878 | \r |
d7ce7006 | 879 | @param [in] pBuffer Address of a buffer to receive the data.\r |
a88c3163 | 880 | \r |
d7ce7006 | 881 | @param [in] pDataLength Number of received data bytes in the buffer.\r |
882 | \r | |
a88c3163 | 883 | @param [in] pAddress Network address of the remote system address\r |
884 | \r | |
885 | @param [in] AddressLength Length of the remote network address structure\r | |
886 | \r | |
d7ce7006 | 887 | @retval EFI_SUCCESS - Socket data successfully buffered\r |
888 | \r | |
a88c3163 | 889 | **/\r |
890 | typedef\r | |
d7ce7006 | 891 | EFI_STATUS\r |
a88c3163 | 892 | (* PFN_API_TRANSMIT) (\r |
893 | IN ESL_SOCKET * pSocket,\r | |
d7ce7006 | 894 | IN int Flags,\r |
895 | IN size_t BufferLength,\r | |
896 | IN CONST UINT8 * pBuffer,\r | |
a88c3163 | 897 | OUT size_t * pDataLength,\r |
898 | IN const struct sockaddr * pAddress,\r | |
899 | IN socklen_t AddressLength\r | |
d7ce7006 | 900 | );\r |
901 | \r | |
902 | /**\r | |
a88c3163 | 903 | Process the transmit completion\r |
d7ce7006 | 904 | \r |
a88c3163 | 905 | This routine calls ::EslSocketTxComplete to handle the\r |
906 | transmit completion.\r | |
d7ce7006 | 907 | \r |
a88c3163 | 908 | This routine is called by the network layers upon the completion\r |
909 | of a transmit operation.\r | |
910 | \r | |
911 | @param [in] Event The urgent transmit completion event\r | |
912 | \r | |
913 | @param [in] pIo The ESL_IO_MGMT structure address\r | |
d7ce7006 | 914 | \r |
915 | **/\r | |
a88c3163 | 916 | typedef\r |
d7ce7006 | 917 | VOID\r |
a88c3163 | 918 | (* PFN_API_TX_COMPLETE) (\r |
d7ce7006 | 919 | IN EFI_EVENT Event,\r |
a88c3163 | 920 | IN ESL_IO_MGMT * pIo\r |
d7ce7006 | 921 | );\r |
922 | \r | |
2dc09dd5 LL |
923 | /**\r |
924 | Verify the adapter's IP address\r | |
925 | \r | |
926 | This support routine is called by EslSocketBindTest.\r | |
927 | \r | |
928 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
929 | @param [in] pConfigData Address of the configuration data\r | |
930 | \r | |
931 | @retval EFI_SUCCESS - The IP address is valid\r | |
932 | @retval EFI_NOT_STARTED - The IP address is invalid\r | |
933 | \r | |
934 | **/\r | |
935 | typedef\r | |
936 | EFI_STATUS\r | |
937 | (* PFN_API_VERIFY_LOCAL_IP_ADDRESS) (\r | |
938 | IN ESL_PORT * pPort,\r | |
939 | IN VOID * pConfigData\r | |
940 | );\r | |
941 | \r | |
d7ce7006 | 942 | /**\r |
a88c3163 | 943 | Socket type control structure\r |
944 | \r | |
945 | This driver uses this structure to define the API for the socket type.\r | |
946 | **/\r | |
947 | typedef struct {\r | |
948 | CONST CHAR8 * pName; ///< Protocol name\r | |
949 | int DefaultProtocol; ///< Default protocol\r | |
950 | UINTN ConfigDataOffset; ///< Offset in ::ESL_PORT to the configuration data\r | |
951 | UINTN ServiceListOffset; ///< Offset in ::ESL_LAYER for the list of services\r | |
952 | socklen_t MinimumAddressLength; ///< Minimum address length in bytes\r | |
953 | socklen_t AddressLength; ///< Address length in bytes\r | |
954 | sa_family_t AddressFamily; ///< Address family\r | |
955 | UINTN RxPacketBytes; ///< Length of the RX packet allocation\r | |
956 | UINTN RxZeroBytes; ///< Number of bytes to zero in RX packet\r | |
957 | UINTN RxBufferOffset; ///< Offset of buffer address in ESL_IO_MGMT structure\r | |
958 | BOOLEAN bOobSupported; ///< TRUE if out-of-band messages are supported\r | |
959 | int BindTestErrno; ///< errno value if EslSocketBindTest fails\r | |
960 | PFN_API_ACCEPT pfnAccept; ///< Accept a network connection\r | |
961 | PFN_API_CONNECT_POLL pfnConnectPoll; ///< Poll for connection complete\r | |
962 | PFN_API_CONNECT_START pfnConnectStart; ///< Start the connection to a remote system\r | |
963 | PFN_API_IS_CONFIGURED pfnIsConfigured; ///< Determine if the socket is configured\r | |
964 | PFN_API_LOCAL_ADDR_GET pfnLocalAddrGet; ///< Get the local address\r | |
965 | PFN_API_LOCAL_ADDR_SET pfnLocalAddrSet; ///< Set the local address\r | |
966 | PFN_API_LISTEN pfnListen; ///< Listen for connections on known server port\r | |
967 | PFN_API_OPTION_GET pfnOptionGet; ///< Get the option value\r | |
968 | PFN_API_OPTION_SET pfnOptionSet; ///< Set the option value\r | |
969 | PFN_API_PACKET_FREE pfnPacketFree; ///< Free the receive packet\r | |
970 | PFN_API_PORT_ALLOC pfnPortAllocate; ///< Allocate the network specific resources for the port\r | |
971 | PFN_API_PORT_CLOSE pfnPortClose; ///< Close the network specific resources for the port\r | |
972 | PFN_API_PORT_CLOSE_OP pfnPortCloseOp; ///< Perform the close operation on the port\r | |
973 | BOOLEAN bPortCloseComplete; ///< TRUE = Close is complete after close operation\r | |
974 | PFN_API_RECEIVE pfnReceive; ///< Attempt to receive some data\r | |
975 | PFN_API_REMOTE_ADDR_GET pfnRemoteAddrGet; ///< Get remote address\r | |
976 | PFN_API_REMOTE_ADDR_SET pfnRemoteAddrSet; ///< Set the remote system address\r | |
58081f2c | 977 | PFN_API_IO_COMPLETE pfnRxComplete; ///< RX completion\r |
a88c3163 | 978 | PFN_API_RX_START pfnRxStart; ///< Start a network specific receive operation\r |
979 | PFN_API_TRANSMIT pfnTransmit; ///< Attempt to buffer a packet for transmit\r | |
980 | PFN_API_TX_COMPLETE pfnTxComplete; ///< TX completion for normal data\r | |
981 | PFN_API_TX_COMPLETE pfnTxOobComplete; ///< TX completion for urgent data\r | |
2dc09dd5 | 982 | PFN_API_VERIFY_LOCAL_IP_ADDRESS pfnVerifyLocalIpAddress; ///< Verify the local IP address\r |
a88c3163 | 983 | } ESL_PROTOCOL_API;\r |
d7ce7006 | 984 | \r |
d7ce7006 | 985 | \r |
a88c3163 | 986 | /**\r |
987 | Socket control structure\r | |
d7ce7006 | 988 | \r |
a88c3163 | 989 | The driver uses this structure to manage the socket.\r |
d7ce7006 | 990 | **/\r |
a88c3163 | 991 | typedef struct _ESL_SOCKET {\r |
992 | UINTN Signature; ///< Structure identification\r | |
d7ce7006 | 993 | \r |
a88c3163 | 994 | //\r |
995 | // Protocol binding\r | |
996 | //\r | |
997 | EFI_SOCKET_PROTOCOL SocketProtocol; ///< Socket protocol declaration\r | |
998 | CONST ESL_PROTOCOL_API * pApi; ///< API for the protocol\r | |
999 | \r | |
1000 | //\r | |
1001 | // Socket management\r | |
1002 | //\r | |
1003 | ESL_SOCKET * pNext; ///< Next socket in the list of sockets\r | |
1004 | int errno; ///< Error information for this socket\r | |
1005 | EFI_STATUS Status; ///< Asyncronous error information for this socket\r | |
1006 | SOCKET_STATE State; ///< Socket state\r | |
1007 | UINT32 DebugFlags; ///< Debug flags\r | |
d7ce7006 | 1008 | \r |
a88c3163 | 1009 | //\r |
1010 | // Socket options\r | |
1011 | //\r | |
f74dc4bb | 1012 | BOOLEAN bIncludeHeader; ///< TRUE if including the IP header\r |
a88c3163 | 1013 | BOOLEAN bListenCalled; ///< TRUE if listen was successfully called\r |
1014 | BOOLEAN bOobInLine; ///< TRUE if out-of-band messages are to be received inline with normal data\r | |
f74dc4bb | 1015 | BOOLEAN bReUseAddr; ///< TRUE if using same address is allowed\r |
d7ce7006 | 1016 | \r |
a88c3163 | 1017 | //\r |
1018 | // Socket data\r | |
1019 | //\r | |
1020 | int Domain; ///< Specifies family of protocols\r | |
1021 | int Type; ///< Specifies how to make network connection\r | |
1022 | int Protocol; ///< Specifies lower layer protocol to use\r | |
f74dc4bb | 1023 | BOOLEAN bAddressSet; ///< Set when the address is specified\r |
a88c3163 | 1024 | BOOLEAN bConfigured; ///< Set after the socket is configured\r |
d7ce7006 | 1025 | \r |
a88c3163 | 1026 | BOOLEAN bRxDisable; ///< Receive disabled via shutdown\r |
1027 | size_t RxBytes; ///< Total Rx bytes\r | |
1028 | size_t RxOobBytes; ///< Urgent Rx bytes\r | |
1029 | EFI_STATUS RxError; ///< Error during receive\r | |
d7ce7006 | 1030 | \r |
a88c3163 | 1031 | BOOLEAN bTxDisable; ///< Transmit disabled via shutdown\r |
1032 | size_t TxBytes; ///< Normal Tx bytes\r | |
1033 | size_t TxOobBytes; ///< Urgent Tx bytes\r | |
1034 | EFI_STATUS TxError; ///< Error during transmit\r | |
1035 | \r | |
1036 | //\r | |
1037 | // Pending connection data\r | |
1038 | //\r | |
1039 | BOOLEAN bConnected; ///< Set when connected, cleared by poll\r | |
1040 | EFI_STATUS ConnectStatus; ///< Connection status\r | |
1041 | UINTN MaxFifoDepth; ///< Maximum FIFO depth\r | |
1042 | UINTN FifoDepth; ///< Number of sockets in the FIFO\r | |
1043 | ESL_SOCKET * pFifoHead; ///< Head of the FIFO\r | |
1044 | ESL_SOCKET * pFifoTail; ///< Tail of the FIFO\r | |
1045 | ESL_SOCKET * pNextConnection; ///< Link in the FIFO\r | |
1046 | \r | |
1047 | //\r | |
1048 | // Network use\r | |
1049 | //\r | |
1050 | ESL_PORT * pPortList; ///< List of ports managed by this socket\r | |
1051 | EFI_EVENT WaitAccept; ///< Wait for accept completion\r | |
1052 | \r | |
1053 | //\r | |
1054 | // Receive data management\r | |
1055 | //\r | |
1056 | UINT32 MaxRxBuf; ///< Maximum size of the receive buffer\r | |
1057 | struct timeval RxTimeout; ///< Receive timeout\r | |
1058 | ESL_PACKET * pRxFree; ///< Free packet list\r | |
1059 | ESL_PACKET * pRxOobPacketListHead;///< Urgent data list head\r | |
1060 | ESL_PACKET * pRxOobPacketListTail;///< Urgent data list tail\r | |
1061 | ESL_PACKET * pRxPacketListHead; ///< Normal data list head\r | |
1062 | ESL_PACKET * pRxPacketListTail; ///< Normal data list tail\r | |
1063 | \r | |
1064 | //\r | |
1065 | // Transmit data management\r | |
1066 | //\r | |
1067 | UINTN TxPacketOffset; ///< Offset for data pointer in ::ESL_PACKET\r | |
1068 | UINTN TxTokenEventOffset; ///< Offset to the Event in the TX token\r | |
1069 | UINTN TxTokenOffset; ///< Offset for data pointer in TX token\r | |
1070 | UINT32 MaxTxBuf; ///< Maximum size of the transmit buffer\r | |
1071 | ESL_PACKET * pTxOobPacketListHead;///< Urgent data list head\r | |
1072 | ESL_PACKET * pTxOobPacketListTail;///< Urgent data list tail\r | |
1073 | ESL_PACKET * pTxPacketListHead; ///< Normal data list head\r | |
1074 | ESL_PACKET * pTxPacketListTail; ///< Normal data list tail\r | |
1075 | }GCC_ESL_SOCKET;\r | |
1076 | \r | |
1077 | #define SOCKET_FROM_PROTOCOL(a) CR (a, ESL_SOCKET, SocketProtocol, SOCKET_SIGNATURE) ///< Locate ESL_SOCKET from protocol\r | |
d7ce7006 | 1078 | \r |
1079 | /**\r | |
a88c3163 | 1080 | Socket layer control structure\r |
d7ce7006 | 1081 | \r |
a88c3163 | 1082 | The driver uses this structure to manage the driver.\r |
1083 | **/\r | |
1084 | typedef struct {\r | |
1085 | UINTN Signature; ///< Structure identification\r | |
d7ce7006 | 1086 | \r |
a88c3163 | 1087 | //\r |
1088 | // Service binding interface\r | |
1089 | //\r | |
1090 | CONST EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Driver's binding\r | |
d7ce7006 | 1091 | \r |
a88c3163 | 1092 | //\r |
1093 | // Image data\r | |
1094 | //\r | |
1095 | EFI_HANDLE ImageHandle; ///< Image handle\r | |
d7ce7006 | 1096 | \r |
a88c3163 | 1097 | //\r |
1098 | // Network services\r | |
1099 | //\r | |
1100 | ESL_SERVICE * pIp4List; ///< List of Ip4 services\r | |
1101 | ESL_SERVICE * pTcp4List; ///< List of Tcp4 services\r | |
3bdf9aae | 1102 | ESL_SERVICE * pTcp6List; ///< List of Tcp6 services\r |
a88c3163 | 1103 | ESL_SERVICE * pUdp4List; ///< List of Udp4 services\r |
3bdf9aae | 1104 | ESL_SERVICE * pUdp6List; ///< List of Udp6 services\r |
d7ce7006 | 1105 | \r |
a88c3163 | 1106 | //\r |
1107 | // Socket management\r | |
1108 | //\r | |
1109 | ESL_SOCKET * pSocketList; ///< List of sockets\r | |
1110 | } ESL_LAYER;\r | |
d7ce7006 | 1111 | \r |
a88c3163 | 1112 | #define LAYER_FROM_SERVICE(a) CR (a, ESL_LAYER, ServiceBinding, LAYER_SIGNATURE) ///< Locate ESL_LAYER from service binding\r |
d7ce7006 | 1113 | \r |
a88c3163 | 1114 | //------------------------------------------------------------------------------\r |
1115 | // Data\r | |
1116 | //------------------------------------------------------------------------------\r | |
1117 | \r | |
1118 | extern ESL_LAYER mEslLayer;\r | |
1119 | \r | |
1120 | extern CONST ESL_PROTOCOL_API cEslIp4Api;\r | |
3bdf9aae | 1121 | extern CONST ESL_PROTOCOL_API cEslIp6Api;\r |
a88c3163 | 1122 | extern CONST ESL_PROTOCOL_API cEslTcp4Api;\r |
3bdf9aae | 1123 | extern CONST ESL_PROTOCOL_API cEslTcp6Api;\r |
a88c3163 | 1124 | extern CONST ESL_PROTOCOL_API cEslUdp4Api;\r |
3bdf9aae | 1125 | extern CONST ESL_PROTOCOL_API cEslUdp6Api;\r |
d7ce7006 | 1126 | \r |
a88c3163 | 1127 | extern CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding;\r |
d7ce7006 | 1128 | \r |
a88c3163 | 1129 | //------------------------------------------------------------------------------\r |
1130 | // Socket Support Routines\r | |
1131 | //------------------------------------------------------------------------------\r | |
1132 | \r | |
1133 | /**\r | |
1134 | Allocate and initialize a ESL_SOCKET structure.\r | |
1135 | \r | |
1136 | This support function allocates an ::ESL_SOCKET structure\r | |
1137 | and installs a protocol on ChildHandle. If pChildHandle is a\r | |
1138 | pointer to NULL, then a new handle is created and returned in\r | |
1139 | pChildHandle. If pChildHandle is not a pointer to NULL, then\r | |
1140 | the protocol installs on the existing pChildHandle.\r | |
d7ce7006 | 1141 | \r |
a88c3163 | 1142 | @param [in, out] pChildHandle Pointer to the handle of the child to create.\r |
1143 | If it is NULL, then a new handle is created.\r | |
1144 | If it is a pointer to an existing UEFI handle, \r | |
1145 | then the protocol is added to the existing UEFI\r | |
1146 | handle.\r | |
1147 | @param [in] DebugFlags Flags for debug messages\r | |
1148 | @param [in, out] ppSocket The buffer to receive an ::ESL_SOCKET structure address.\r | |
d7ce7006 | 1149 | \r |
a88c3163 | 1150 | @retval EFI_SUCCESS The protocol was added to ChildHandle.\r |
1151 | @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r | |
1152 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create\r | |
1153 | the child\r | |
1154 | @retval other The child handle was not created\r | |
1155 | \r | |
d7ce7006 | 1156 | **/\r |
1157 | EFI_STATUS\r | |
1158 | EFIAPI\r | |
a88c3163 | 1159 | EslSocketAllocate (\r |
1160 | IN OUT EFI_HANDLE * pChildHandle,\r | |
1161 | IN UINTN DebugFlags,\r | |
1162 | IN OUT ESL_SOCKET ** ppSocket\r | |
d7ce7006 | 1163 | );\r |
1164 | \r | |
1165 | /**\r | |
a88c3163 | 1166 | Test the bind configuration.\r |
d7ce7006 | 1167 | \r |
a88c3163 | 1168 | @param [in] pPort Address of the ::ESL_PORT structure.\r |
1169 | @param [in] ErrnoValue errno value if test fails\r | |
d7ce7006 | 1170 | \r |
a88c3163 | 1171 | @retval EFI_SUCCESS The connection was successfully established.\r |
1172 | @retval Others The connection attempt failed.\r | |
d7ce7006 | 1173 | \r |
1174 | **/\r | |
1175 | EFI_STATUS\r | |
a88c3163 | 1176 | EslSocketBindTest (\r |
1177 | IN ESL_PORT * pPort,\r | |
1178 | IN int ErrnoValue\r | |
d7ce7006 | 1179 | );\r |
1180 | \r | |
1181 | /**\r | |
a88c3163 | 1182 | Copy a fragmented buffer into a destination buffer.\r |
d7ce7006 | 1183 | \r |
a88c3163 | 1184 | This support routine copies a fragmented buffer to the caller specified buffer.\r |
d7ce7006 | 1185 | \r |
a88c3163 | 1186 | This routine is called by ::EslIp4Receive and ::EslUdp4Receive.\r |
d7ce7006 | 1187 | \r |
a88c3163 | 1188 | @param [in] FragmentCount Number of fragments in the table\r |
d7ce7006 | 1189 | \r |
a88c3163 | 1190 | @param [in] pFragmentTable Address of an EFI_IP4_FRAGMENT_DATA structure\r |
d7ce7006 | 1191 | \r |
a88c3163 | 1192 | @param [in] BufferLength Length of the the buffer\r |
d7ce7006 | 1193 | \r |
a88c3163 | 1194 | @param [in] pBuffer Address of a buffer to receive the data.\r |
1195 | \r | |
1196 | @param [in] pDataLength Number of received data bytes in the buffer.\r | |
1197 | \r | |
1198 | @return Returns the address of the next free byte in the buffer.\r | |
d7ce7006 | 1199 | \r |
1200 | **/\r | |
a88c3163 | 1201 | UINT8 *\r |
1202 | EslSocketCopyFragmentedBuffer (\r | |
1203 | IN UINT32 FragmentCount,\r | |
1204 | IN EFI_IP4_FRAGMENT_DATA * pFragmentTable,\r | |
1205 | IN size_t BufferLength,\r | |
1206 | IN UINT8 * pBuffer,\r | |
1207 | OUT size_t * pDataLength\r | |
d7ce7006 | 1208 | );\r |
1209 | \r | |
4652be0c | 1210 | /**\r |
1211 | Free the socket.\r | |
1212 | \r | |
1213 | This routine frees the socket structure and handle resources.\r | |
1214 | \r | |
1215 | The ::close routine calls EslServiceFreeProtocol which then calls\r | |
1216 | this routine to free the socket context structure and close the\r | |
1217 | handle.\r | |
1218 | \r | |
1219 | @param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.\r | |
1220 | \r | |
1221 | @param [out] pErrno Address to receive the errno value upon completion.\r | |
1222 | \r | |
1223 | @retval EFI_SUCCESS The socket resources were returned successfully.\r | |
1224 | \r | |
1225 | **/\r | |
1226 | EFI_STATUS\r | |
1227 | EslSocketFree (\r | |
1228 | IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r | |
1229 | IN int * pErrno\r | |
1230 | );\r | |
1231 | \r | |
d7ce7006 | 1232 | /**\r |
a88c3163 | 1233 | Free the ESL_IO_MGMT event and structure\r |
d7ce7006 | 1234 | \r |
a88c3163 | 1235 | This support routine walks the free list to close the event in\r |
1236 | the ESL_IO_MGMT structure and remove the structure from the free\r | |
1237 | list.\r | |
d7ce7006 | 1238 | \r |
a88c3163 | 1239 | See the \ref TransmitEngine section.\r |
d7ce7006 | 1240 | \r |
a88c3163 | 1241 | @param [in] pPort Address of an ::ESL_PORT structure\r |
1242 | @param [in] ppFreeQueue Address of the free queue head\r | |
1243 | @param [in] DebugFlags Flags for debug messages\r | |
1244 | @param [in] pEventName Zero terminated string containing the event name\r | |
1245 | \r | |
1246 | @retval EFI_SUCCESS - The structures were properly initialized\r | |
d7ce7006 | 1247 | \r |
1248 | **/\r | |
1249 | EFI_STATUS\r | |
a88c3163 | 1250 | EslSocketIoFree (\r |
1251 | IN ESL_PORT * pPort,\r | |
1252 | IN ESL_IO_MGMT ** ppFreeQueue,\r | |
1253 | IN UINTN DebugFlags,\r | |
1254 | IN CHAR8 * pEventName\r | |
d7ce7006 | 1255 | );\r |
1256 | \r | |
1257 | /**\r | |
a88c3163 | 1258 | Initialize the ESL_IO_MGMT structures\r |
d7ce7006 | 1259 | \r |
a88c3163 | 1260 | This support routine initializes the ESL_IO_MGMT structure and\r |
1261 | places them on to a free list.\r | |
d7ce7006 | 1262 | \r |
a88c3163 | 1263 | This routine is called by the PortAllocate routines to prepare\r |
1264 | the transmit engines. See the \ref TransmitEngine section.\r | |
d7ce7006 | 1265 | \r |
a88c3163 | 1266 | @param [in] pPort Address of an ::ESL_PORT structure\r |
1267 | @param [in, out] ppIo Address containing the first structure address. Upon\r | |
1268 | return this buffer contains the next structure address.\r | |
1269 | @param [in] TokenCount Number of structures to initialize\r | |
1270 | @param [in] ppFreeQueue Address of the free queue head\r | |
1271 | @param [in] DebugFlags Flags for debug messages\r | |
1272 | @param [in] pEventName Zero terminated string containing the event name\r | |
1273 | @param [in] pfnCompletion Completion routine address\r | |
d7ce7006 | 1274 | \r |
a88c3163 | 1275 | @retval EFI_SUCCESS - The structures were properly initialized\r |
1276 | \r | |
1277 | **/\r | |
d7ce7006 | 1278 | EFI_STATUS\r |
a88c3163 | 1279 | EslSocketIoInit (\r |
1280 | IN ESL_PORT * pPort,\r | |
1281 | IN ESL_IO_MGMT ** ppIo,\r | |
1282 | IN UINTN TokenCount,\r | |
1283 | IN ESL_IO_MGMT ** ppFreeQueue,\r | |
1284 | IN UINTN DebugFlags,\r | |
1285 | IN CHAR8 * pEventName,\r | |
58081f2c | 1286 | IN PFN_API_IO_COMPLETE pfnCompletion\r |
d7ce7006 | 1287 | );\r |
1288 | \r | |
1289 | /**\r | |
a88c3163 | 1290 | Determine if the socket is configured\r |
d7ce7006 | 1291 | \r |
a88c3163 | 1292 | This support routine is called to determine if the socket if the\r |
1293 | configuration call was made to the network layer. The following\r | |
1294 | routines call this routine to verify that they may be successful\r | |
1295 | in their operations:\r | |
1296 | <ul>\r | |
1297 | <li>::EslSocketGetLocalAddress</li>\r | |
1298 | <li>::EslSocketGetPeerAddress</li>\r | |
1299 | <li>::EslSocketPoll</li>\r | |
1300 | <li>::EslSocketReceive</li>\r | |
1301 | <li>::EslSocketTransmit</li>\r | |
1302 | </ul>\r | |
d7ce7006 | 1303 | \r |
a88c3163 | 1304 | @param [in] pSocket Address of an ::ESL_SOCKET structure\r |
d7ce7006 | 1305 | \r |
a88c3163 | 1306 | @retval EFI_SUCCESS - The socket is configured\r |
d7ce7006 | 1307 | \r |
1308 | **/\r | |
1309 | EFI_STATUS\r | |
a88c3163 | 1310 | EslSocketIsConfigured (\r |
1311 | IN ESL_SOCKET * pSocket\r | |
d7ce7006 | 1312 | );\r |
1313 | \r | |
1314 | /**\r | |
a88c3163 | 1315 | Allocate a packet for a receive or transmit operation\r |
d7ce7006 | 1316 | \r |
a88c3163 | 1317 | This support routine is called by ::EslSocketRxStart and the\r |
1318 | network specific TxBuffer routines to get buffer space for the\r | |
1319 | next operation.\r | |
d7ce7006 | 1320 | \r |
a88c3163 | 1321 | @param [in] ppPacket Address to receive the ::ESL_PACKET structure\r |
1322 | @param [in] LengthInBytes Length of the packet structure\r | |
1323 | @param [in] ZeroBytes Length of packet to zero\r | |
1324 | @param [in] DebugFlags Flags for debug messages\r | |
d7ce7006 | 1325 | \r |
a88c3163 | 1326 | @retval EFI_SUCCESS - The packet was allocated successfully\r |
d7ce7006 | 1327 | \r |
a88c3163 | 1328 | **/\r |
d7ce7006 | 1329 | EFI_STATUS\r |
a88c3163 | 1330 | EslSocketPacketAllocate (\r |
1331 | IN ESL_PACKET ** ppPacket,\r | |
1332 | IN size_t LengthInBytes,\r | |
1333 | IN size_t ZeroBytes,\r | |
1334 | IN UINTN DebugFlags\r | |
d7ce7006 | 1335 | );\r |
1336 | \r | |
1337 | /**\r | |
a88c3163 | 1338 | Free a packet used for receive or transmit operation\r |
d7ce7006 | 1339 | \r |
a88c3163 | 1340 | This support routine is called by the network specific Close\r |
1341 | and TxComplete routines and during error cases in RxComplete\r | |
1342 | and TxBuffer. Note that the network layers typically place\r | |
1343 | receive packets on the ESL_SOCKET::pRxFree list for reuse.\r | |
d7ce7006 | 1344 | \r |
a88c3163 | 1345 | @param [in] pPacket Address of an ::ESL_PACKET structure\r |
1346 | @param [in] DebugFlags Flags for debug messages\r | |
d7ce7006 | 1347 | \r |
a88c3163 | 1348 | @retval EFI_SUCCESS - The packet was allocated successfully\r |
d7ce7006 | 1349 | \r |
a88c3163 | 1350 | **/\r |
1351 | EFI_STATUS\r | |
1352 | EslSocketPacketFree (\r | |
1353 | IN ESL_PACKET * pPacket,\r | |
1354 | IN UINTN DebugFlags\r | |
1355 | );\r | |
d7ce7006 | 1356 | \r |
a88c3163 | 1357 | /**\r |
1358 | Allocate and initialize a ESL_PORT structure.\r | |
d7ce7006 | 1359 | \r |
a88c3163 | 1360 | This routine initializes an ::ESL_PORT structure for use by\r |
1361 | the socket. This routine calls a routine via\r | |
1362 | ESL_PROTOCOL_API::pfnPortAllocate to initialize the network\r | |
1363 | specific resources. The resources are released later by the\r | |
1364 | \ref PortCloseStateMachine.\r | |
d7ce7006 | 1365 | \r |
a88c3163 | 1366 | This support routine is called by ::EslSocketBind and\r |
1367 | ::EslTcp4ListenComplete to connect the socket with the\r | |
1368 | underlying network adapter to the socket.\r | |
d7ce7006 | 1369 | \r |
a88c3163 | 1370 | @param [in] pSocket Address of an ::ESL_SOCKET structure.\r |
1371 | @param [in] pService Address of an ::ESL_SERVICE structure.\r | |
1372 | @param [in] ChildHandle TCP4 child handle\r | |
1373 | @param [in] pSockAddr Address of a sockaddr structure that contains the\r | |
1374 | connection point on the local machine. An IPv4 address\r | |
1375 | of INADDR_ANY specifies that the connection is made to\r | |
1376 | all of the network stacks on the platform. Specifying a\r | |
1377 | specific IPv4 address restricts the connection to the\r | |
1378 | network stack supporting that address. Specifying zero\r | |
1379 | for the port causes the network layer to assign a port\r | |
1380 | number from the dynamic range. Specifying a specific\r | |
1381 | port number causes the network layer to use that port.\r | |
1382 | @param [in] bBindTest TRUE if EslSocketBindTest should be called\r | |
1383 | @param [in] DebugFlags Flags for debug messages\r | |
1384 | @param [out] ppPort Buffer to receive new ::ESL_PORT structure address\r | |
d7ce7006 | 1385 | \r |
a88c3163 | 1386 | @retval EFI_SUCCESS - Socket successfully created\r |
d7ce7006 | 1387 | \r |
a88c3163 | 1388 | **/\r |
d7ce7006 | 1389 | EFI_STATUS\r |
a88c3163 | 1390 | EslSocketPortAllocate (\r |
1391 | IN ESL_SOCKET * pSocket,\r | |
1392 | IN ESL_SERVICE * pService,\r | |
1393 | IN EFI_HANDLE ChildHandle,\r | |
1394 | IN CONST struct sockaddr * pSockAddr,\r | |
1395 | IN BOOLEAN bBindTest,\r | |
1396 | IN UINTN DebugFlags,\r | |
1397 | OUT ESL_PORT ** ppPort\r | |
d7ce7006 | 1398 | );\r |
1399 | \r | |
1400 | /**\r | |
a88c3163 | 1401 | Close a port.\r |
1402 | \r | |
1403 | This routine releases the resources allocated by ::EslSocketPortAllocate.\r | |
1404 | This routine calls ESL_PROTOCOL_API::pfnPortClose to release the network\r | |
1405 | specific resources.\r | |
1406 | \r | |
1407 | This routine is called by:\r | |
1408 | <ul>\r | |
1409 | <li>::EslIp4PortAllocate - Port initialization failure</li>\r | |
1410 | <li>::EslSocketPortCloseRxDone - Last step of close processing</li>\r | |
1411 | <li>::EslTcp4ConnectComplete - Connection failure and reducint the port list to a single port</li>\r | |
1412 | <li>::EslTcp4PortAllocate - Port initialization failure</li>\r | |
1413 | <li>::EslUdp4PortAllocate - Port initialization failure</li>\r | |
1414 | </ul>\r | |
1415 | See the \ref PortCloseStateMachine section.\r | |
d7ce7006 | 1416 | \r |
a88c3163 | 1417 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
d7ce7006 | 1418 | \r |
a88c3163 | 1419 | @retval EFI_SUCCESS The port is closed\r |
1420 | @retval other Port close error\r | |
1421 | \r | |
1422 | **/\r | |
d7ce7006 | 1423 | EFI_STATUS\r |
a88c3163 | 1424 | EslSocketPortClose (\r |
1425 | IN ESL_PORT * pPort\r | |
d7ce7006 | 1426 | );\r |
1427 | \r | |
1428 | /**\r | |
a88c3163 | 1429 | Process the port close completion event\r |
d7ce7006 | 1430 | \r |
a88c3163 | 1431 | This routine attempts to complete the port close operation.\r |
d7ce7006 | 1432 | \r |
a88c3163 | 1433 | This routine is called by the TCP layer upon completion of\r |
1434 | the close operation.\r | |
1435 | See the \ref PortCloseStateMachine section.\r | |
d7ce7006 | 1436 | \r |
a88c3163 | 1437 | @param [in] Event The close completion event\r |
1438 | \r | |
1439 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
d7ce7006 | 1440 | \r |
1441 | **/\r | |
1442 | VOID\r | |
a88c3163 | 1443 | EslSocketPortCloseComplete (\r |
d7ce7006 | 1444 | IN EFI_EVENT Event,\r |
a88c3163 | 1445 | IN ESL_PORT * pPort\r |
d7ce7006 | 1446 | );\r |
1447 | \r | |
1448 | /**\r | |
a88c3163 | 1449 | Port close state 3\r |
d7ce7006 | 1450 | \r |
a88c3163 | 1451 | This routine determines the state of the receive operations and\r |
1452 | continues the close operation after the pending receive operations\r | |
1453 | are cancelled.\r | |
d7ce7006 | 1454 | \r |
a88c3163 | 1455 | This routine is called by\r |
1456 | <ul>\r | |
1457 | <li>::EslIp4RxComplete</li>\r | |
1458 | <li>::EslSocketPortCloseComplete</li>\r | |
1459 | <li>::EslSocketPortCloseTxDone</li>\r | |
1460 | <li>::EslUdp4RxComplete</li>\r | |
1461 | </ul>\r | |
1462 | to determine the state of the receive operations.\r | |
1463 | See the \ref PortCloseStateMachine section.\r | |
1464 | \r | |
1465 | @param [in] pPort Address of an ::ESL_PORT structure.\r | |
1466 | \r | |
1467 | @retval EFI_SUCCESS The port is closed\r | |
1468 | @retval EFI_NOT_READY The port is still closing\r | |
1469 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
1470 | most likely the routine was called already.\r | |
1471 | \r | |
1472 | **/\r | |
1473 | EFI_STATUS\r | |
1474 | EslSocketPortCloseRxDone (\r | |
1475 | IN ESL_PORT * pPort\r | |
d7ce7006 | 1476 | );\r |
1477 | \r | |
1478 | /**\r | |
a88c3163 | 1479 | Start the close operation on a port, state 1.\r |
d7ce7006 | 1480 | \r |
a88c3163 | 1481 | This routine marks the port as closed and initiates the \ref\r |
1482 | PortCloseStateMachine. The first step is to allow the \ref\r | |
1483 | TransmitEngine to run down.\r | |
d7ce7006 | 1484 | \r |
a88c3163 | 1485 | This routine is called by ::EslSocketCloseStart to initiate the socket\r |
1486 | network specific close operation on the socket.\r | |
d7ce7006 | 1487 | \r |
a88c3163 | 1488 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
1489 | @param [in] bCloseNow Set TRUE to abort active transfers\r | |
1490 | @param [in] DebugFlags Flags for debug messages\r | |
1491 | \r | |
1492 | @retval EFI_SUCCESS The port is closed, not normally returned\r | |
1493 | @retval EFI_NOT_READY The port has started the closing process\r | |
1494 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
1495 | most likely the routine was called already.\r | |
1496 | \r | |
1497 | **/\r | |
1498 | EFI_STATUS\r | |
1499 | EslSocketPortCloseStart (\r | |
1500 | IN ESL_PORT * pPort,\r | |
1501 | IN BOOLEAN bCloseNow,\r | |
1502 | IN UINTN DebugFlags\r | |
d7ce7006 | 1503 | );\r |
1504 | \r | |
1505 | /**\r | |
a88c3163 | 1506 | Port close state 2\r |
1507 | \r | |
1508 | This routine determines the state of the transmit engine and\r | |
1509 | continue the close operation after the transmission is complete.\r | |
1510 | The next step is to stop the \ref ReceiveEngine.\r | |
1511 | See the \ref PortCloseStateMachine section.\r | |
d7ce7006 | 1512 | \r |
a88c3163 | 1513 | This routine is called by ::EslSocketPortCloseStart to determine\r |
1514 | if the transmission is complete.\r | |
d7ce7006 | 1515 | \r |
a88c3163 | 1516 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
1517 | \r | |
1518 | @retval EFI_SUCCESS The port is closed, not normally returned\r | |
1519 | @retval EFI_NOT_READY The port is still closing\r | |
1520 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
1521 | most likely the routine was called already.\r | |
d7ce7006 | 1522 | \r |
1523 | **/\r | |
a88c3163 | 1524 | EFI_STATUS\r |
1525 | EslSocketPortCloseTxDone (\r | |
1526 | IN ESL_PORT * pPort\r | |
d7ce7006 | 1527 | );\r |
1528 | \r | |
1529 | /**\r | |
a88c3163 | 1530 | Cancel the receive operations\r |
d7ce7006 | 1531 | \r |
a88c3163 | 1532 | This routine cancels a pending receive operation.\r |
1533 | See the \ref ReceiveEngine section.\r | |
d7ce7006 | 1534 | \r |
a88c3163 | 1535 | This routine is called by ::EslSocketShutdown when the socket\r |
1536 | layer is being shutdown.\r | |
d7ce7006 | 1537 | \r |
a88c3163 | 1538 | @param [in] pPort Address of an ::ESL_PORT structure\r |
1539 | @param [in] pIo Address of an ::ESL_IO_MGMT structure\r | |
1540 | \r | |
1541 | **/\r | |
d7ce7006 | 1542 | VOID\r |
a88c3163 | 1543 | EslSocketRxCancel (\r |
1544 | IN ESL_PORT * pPort,\r | |
1545 | IN ESL_IO_MGMT * pIo\r | |
d7ce7006 | 1546 | );\r |
1547 | \r | |
1548 | /**\r | |
a88c3163 | 1549 | Process the receive completion\r |
d7ce7006 | 1550 | \r |
a88c3163 | 1551 | This routine queues the data in FIFO order in either the urgent\r |
1552 | or normal data queues depending upon the type of data received.\r | |
1553 | See the \ref ReceiveEngine section.\r | |
d7ce7006 | 1554 | \r |
a88c3163 | 1555 | This routine is called when some data is received by:\r |
1556 | <ul>\r | |
1557 | <li>::EslIp4RxComplete</li>\r | |
1558 | <li>::EslTcp4RxComplete</li>\r | |
1559 | <li>::EslUdp4RxComplete</li>\r | |
1560 | </ul>\r | |
d7ce7006 | 1561 | \r |
a88c3163 | 1562 | @param [in] pIo Address of an ::ESL_IO_MGMT structure\r |
1563 | @param [in] Status Receive status\r | |
1564 | @param [in] LengthInBytes Length of the receive data\r | |
1565 | @param [in] bUrgent TRUE if urgent data is received and FALSE\r | |
1566 | for normal data.\r | |
d7ce7006 | 1567 | \r |
a88c3163 | 1568 | **/\r |
1569 | VOID\r | |
1570 | EslSocketRxComplete (\r | |
1571 | IN ESL_IO_MGMT * pIo,\r | |
1572 | IN EFI_STATUS Status,\r | |
1573 | IN UINTN LengthInBytes,\r | |
1574 | IN BOOLEAN bUrgent\r | |
1575 | );\r | |
d7ce7006 | 1576 | \r |
3bdf9aae | 1577 | /**\r |
1578 | Poll a socket for pending receive activity.\r | |
1579 | \r | |
1580 | This routine is called at elivated TPL and extends the idle\r | |
1581 | loop which polls a socket down into the LAN driver layer to\r | |
1582 | determine if there is any receive activity.\r | |
1583 | \r | |
1584 | The ::EslSocketPoll, ::EslSocketReceive and ::EslSocketTransmit\r | |
1585 | routines call this routine when there is nothing to do.\r | |
1586 | \r | |
1587 | @param [in] pSocket Address of an ::EFI_SOCKET structure.\r | |
1588 | \r | |
1589 | **/\r | |
1590 | VOID\r | |
1591 | EslSocketRxPoll (\r | |
1592 | IN ESL_SOCKET * pSocket\r | |
1593 | );\r | |
1594 | \r | |
a88c3163 | 1595 | /**\r |
1596 | Start a receive operation\r | |
d7ce7006 | 1597 | \r |
a88c3163 | 1598 | This routine posts a receive buffer to the network adapter.\r |
1599 | See the \ref ReceiveEngine section.\r | |
d7ce7006 | 1600 | \r |
a88c3163 | 1601 | This support routine is called by:\r |
1602 | <ul>\r | |
1603 | <li>::EslIp4Receive to restart the receive engine to release flow control.</li>\r | |
1604 | <li>::EslIp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r | |
1605 | <li>::EslIp4SocketIsConfigured to start the recevie engine for the new socket.</li>\r | |
1606 | <li>::EslTcp4ListenComplete to start the recevie engine for the new socket.</li>\r | |
1607 | <li>::EslTcp4Receive to restart the receive engine to release flow control.</li>\r | |
1608 | <li>::EslTcp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r | |
1609 | <li>::EslUdp4Receive to restart the receive engine to release flow control.</li>\r | |
1610 | <li>::EslUdp4RxComplete to continue the operation of the receive engine if flow control is not being applied.</li>\r | |
1611 | <li>::EslUdp4SocketIsConfigured to start the recevie engine for the new socket.</li>\r | |
1612 | </ul>\r | |
d7ce7006 | 1613 | \r |
a88c3163 | 1614 | @param [in] pPort Address of an ::ESL_PORT structure.\r |
d7ce7006 | 1615 | \r |
a88c3163 | 1616 | **/\r |
1617 | VOID\r | |
1618 | EslSocketRxStart (\r | |
1619 | IN ESL_PORT * pPort\r | |
1620 | );\r | |
d7ce7006 | 1621 | \r |
a88c3163 | 1622 | /**\r |
1623 | Complete the transmit operation\r | |
1624 | \r | |
1625 | This support routine handles the transmit completion processing for\r | |
1626 | the various network layers. It frees the ::ESL_IO_MGMT structure\r | |
1627 | and and frees packet resources by calling ::EslSocketPacketFree.\r | |
1628 | Transmit errors are logged in ESL_SOCKET::TxError.\r | |
1629 | See the \ref TransmitEngine section.\r | |
1630 | \r | |
1631 | This routine is called by:\r | |
1632 | <ul>\r | |
1633 | <li>::EslIp4TxComplete</li>\r | |
1634 | <li>::EslTcp4TxComplete</li>\r | |
1635 | <li>::EslTcp4TxOobComplete</li>\r | |
1636 | <li>::EslUdp4TxComplete</li>\r | |
1637 | </ul>\r | |
1638 | \r | |
1639 | @param [in] pIo Address of an ::ESL_IO_MGMT structure\r | |
1640 | @param [in] LengthInBytes Length of the data in bytes\r | |
1641 | @param [in] Status Transmit operation status\r | |
1642 | @param [in] pQueueType Zero terminated string describing queue type\r | |
1643 | @param [in] ppQueueHead Transmit queue head address\r | |
1644 | @param [in] ppQueueTail Transmit queue tail address\r | |
1645 | @param [in] ppActive Active transmit queue address\r | |
1646 | @param [in] ppFree Free transmit queue address\r | |
d7ce7006 | 1647 | \r |
a88c3163 | 1648 | **/\r |
1649 | VOID\r | |
1650 | EslSocketTxComplete (\r | |
1651 | IN ESL_IO_MGMT * pIo,\r | |
1652 | IN UINT32 LengthInBytes,\r | |
1653 | IN EFI_STATUS Status,\r | |
1654 | IN CONST CHAR8 * pQueueType,\r | |
1655 | IN ESL_PACKET ** ppQueueHead,\r | |
1656 | IN ESL_PACKET ** ppQueueTail,\r | |
1657 | IN ESL_IO_MGMT ** ppActive,\r | |
1658 | IN ESL_IO_MGMT ** ppFree\r | |
d7ce7006 | 1659 | );\r |
1660 | \r | |
1661 | /**\r | |
1662 | Transmit data using a network connection.\r | |
1663 | \r | |
a88c3163 | 1664 | This support routine starts a transmit operation on the\r |
1665 | underlying network layer.\r | |
1666 | \r | |
1667 | The network specific code calls this routine to start a\r | |
1668 | transmit operation. See the \ref TransmitEngine section.\r | |
1669 | \r | |
1670 | @param [in] pPort Address of an ::ESL_PORT structure\r | |
1671 | @param [in] ppQueueHead Transmit queue head address\r | |
1672 | @param [in] ppQueueTail Transmit queue tail address\r | |
1673 | @param [in] ppActive Active transmit queue address\r | |
1674 | @param [in] ppFree Free transmit queue address\r | |
d7ce7006 | 1675 | \r |
1676 | **/\r | |
1677 | VOID\r | |
a88c3163 | 1678 | EslSocketTxStart (\r |
1679 | IN ESL_PORT * pPort,\r | |
1680 | IN ESL_PACKET ** ppQueueHead,\r | |
1681 | IN ESL_PACKET ** ppQueueTail,\r | |
1682 | IN ESL_IO_MGMT ** ppActive,\r | |
1683 | IN ESL_IO_MGMT ** ppFree\r | |
d7ce7006 | 1684 | );\r |
1685 | \r | |
1686 | //------------------------------------------------------------------------------\r | |
1687 | \r | |
1688 | #endif // _SOCKET_H_\r |