]>
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 | |
33 | \r | |
34 | #define MAX_PENDING_CONNECTIONS 1 ///< Maximum connection FIFO depth\r | |
35 | #define MAX_RX_DATA 65536 ///< Maximum receive data size\r | |
36 | #define MAX_TX_DATA ( MAX_RX_DATA * 2 )\r | |
37 | #define RX_PACKET_DATA 16384 ///< Maximum number of bytes in a RX packet\r | |
38 | \r | |
39 | #define LAYER_SIGNATURE SIGNATURE_32('S','k','t','L') ///< DT_LAYER memory signature\r | |
40 | #define SERVICE_SIGNATURE SIGNATURE_32('S','k','t','S') ///< DT_SERVICE memory signature\r | |
41 | #define SOCKET_SIGNATURE SIGNATURE_32('S','c','k','t') ///< DT_SOCKET memory signature\r | |
42 | #define PORT_SIGNATURE SIGNATURE_32('P','o','r','t') ///< DT_PORT memory signature\r | |
43 | \r | |
44 | typedef enum\r | |
45 | {\r | |
46 | NETWORK_TYPE_UNKNOWN = 0,\r | |
47 | NETWORK_TYPE_RAW,\r | |
48 | NETWORK_TYPE_TCP4,\r | |
49 | NETWORK_TYPE_TCP6,\r | |
50 | NETWORK_TYPE_UDP4,\r | |
51 | NETWORK_TYPE_UDP6\r | |
52 | } NETWORK_TYPE;\r | |
53 | \r | |
54 | typedef enum\r | |
55 | {\r | |
56 | SOCKET_STATE_NOT_CONFIGURED = 0, ///< socket call was successful\r | |
57 | SOCKET_STATE_BOUND, ///< bind call was successful\r | |
58 | SOCKET_STATE_LISTENING, ///< listen call was successful\r | |
59 | SOCKET_STATE_NO_PORTS, ///< No ports available\r | |
60 | SOCKET_STATE_IN_FIFO, ///< Socket on FIFO\r | |
61 | SOCKET_STATE_CONNECTING, ///< Connecting to a remote system\r | |
62 | SOCKET_STATE_CONNECTED, ///< Accept or connect call was successful\r | |
63 | \r | |
64 | //\r | |
65 | // Close state must be the last in the list\r | |
66 | //\r | |
67 | SOCKET_STATE_CLOSED ///< Close call was successful\r | |
68 | } SOCKET_STATE;\r | |
69 | \r | |
70 | typedef enum\r | |
71 | {\r | |
72 | PORT_STATE_ALLOCATED = 0, ///< Port allocated\r | |
73 | PORT_STATE_OPEN, ///< Port opened\r | |
74 | PORT_STATE_RX_ERROR, ///< Receive error detected\r | |
75 | \r | |
76 | //\r | |
77 | // Close state must be last in the list\r | |
78 | //\r | |
79 | PORT_STATE_CLOSE_STARTED, ///< Close started on port\r | |
80 | PORT_STATE_CLOSE_TX_DONE, ///< Transmits shutdown\r | |
81 | PORT_STATE_CLOSE_RX_DONE, ///< Receives shutdown\r | |
82 | PORT_STATE_CLOSE_DONE ///< Port close operation complete\r | |
83 | } PORT_STATE;\r | |
84 | \r | |
85 | //------------------------------------------------------------------------------\r | |
86 | // Data Types\r | |
87 | //------------------------------------------------------------------------------\r | |
88 | \r | |
89 | typedef struct _DT_PACKET DT_PACKET; ///< Forward declaration\r | |
90 | typedef struct _DT_PORT DT_PORT; ///< Forward declaration\r | |
91 | typedef struct _DT_SOCKET DT_SOCKET; ///< Forward declaration\r | |
92 | \r | |
93 | typedef struct\r | |
94 | {\r | |
95 | EFI_TCP4_RECEIVE_DATA RxData; ///< Receive operation description\r | |
96 | size_t ValidBytes; ///< Length of valid data in bytes\r | |
97 | UINT8 * pBuffer; ///< Current data pointer\r | |
98 | UINT8 Buffer [ RX_PACKET_DATA ]; ///< Data buffer\r | |
99 | } DT_TCP4_RX_DATA;\r | |
100 | \r | |
101 | typedef struct\r | |
102 | {\r | |
103 | EFI_TCP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r | |
104 | UINT8 Buffer [ 1 ]; ///< Data buffer\r | |
105 | } DT_TCP4_TX_DATA;\r | |
106 | \r | |
107 | typedef struct\r | |
108 | {\r | |
109 | EFI_UDP4_SESSION_DATA Session; ///< * Remote network address\r | |
110 | EFI_UDP4_RECEIVE_DATA * pRxData; ///< * Receive operation description\r | |
111 | } DT_UDP4_RX_DATA;\r | |
112 | \r | |
113 | typedef struct\r | |
114 | {\r | |
115 | EFI_UDP4_SESSION_DATA Session; ///< Remote network address\r | |
116 | EFI_UDP4_TRANSMIT_DATA TxData; ///< Transmit operation description\r | |
117 | UINT8 Buffer [ 1 ]; ///< Data buffer\r | |
118 | } DT_UDP4_TX_DATA;\r | |
119 | \r | |
120 | typedef struct _DT_PACKET {\r | |
121 | DT_PACKET * pNext; ///< Next packet in the receive list\r | |
122 | size_t PacketSize; ///< Size of this data structure\r | |
123 | union {\r | |
124 | DT_TCP4_RX_DATA Tcp4Rx; ///< Receive operation description\r | |
125 | DT_TCP4_TX_DATA Tcp4Tx; ///< Transmit operation description\r | |
126 | DT_UDP4_RX_DATA Udp4Rx; ///< Receive operation description\r | |
127 | DT_UDP4_TX_DATA Udp4Tx; ///< Transmit operation description\r | |
128 | } Op;\r | |
129 | } GCC_DT_PACKET;\r | |
130 | \r | |
131 | /**\r | |
132 | Service control structure\r | |
133 | \r | |
134 | The driver uses this structure to manage the network devices.\r | |
135 | **/\r | |
136 | typedef struct _DT_SERVICE {\r | |
137 | UINTN Signature; ///< Structure identification\r | |
138 | \r | |
139 | //\r | |
140 | // Links\r | |
141 | //\r | |
142 | DT_SERVICE * pNext; ///< Next service in the service list\r | |
143 | \r | |
144 | //\r | |
145 | // Service data\r | |
146 | //\r | |
147 | CONST DT_SOCKET_BINDING * pSocketBinding; ///< Name and shutdown routine\r | |
148 | EFI_HANDLE Controller; ///< Controller for the service\r | |
149 | VOID * pInterface; ///< Network layer service binding interface\r | |
150 | \r | |
151 | //\r | |
152 | // Network data\r | |
153 | //\r | |
154 | NETWORK_TYPE NetworkType; ///< Type of network service\r | |
155 | DT_PORT * pPortList; ///< List of ports using this service\r | |
156 | }GCC_DT_SERVICE;\r | |
157 | \r | |
158 | /**\r | |
159 | Start the close operation on a TCP4 port.\r | |
160 | \r | |
161 | @param [in] pPort Address of the port structure.\r | |
162 | @param [in] bAbort Set TRUE to abort active transfers\r | |
163 | @param [in] DebugFlags Flags for debug messages\r | |
164 | \r | |
165 | **/\r | |
166 | typedef\r | |
167 | EFI_STATUS\r | |
168 | PFN_PORT_CLOSE_START (\r | |
169 | IN DT_PORT * pPort,\r | |
170 | IN BOOLEAN bAbort,\r | |
171 | IN UINTN DebugFlags\r | |
172 | );\r | |
173 | \r | |
174 | /**\r | |
175 | TCP4 context structure\r | |
176 | \r | |
177 | The driver uses this structure to manage the TCP4 connections.\r | |
178 | **/\r | |
179 | typedef struct {\r | |
180 | //\r | |
181 | // TCP4 context\r | |
182 | //\r | |
183 | EFI_HANDLE Handle; ///< TCP4 port handle\r | |
184 | EFI_TCP4_PROTOCOL * pProtocol; ///< TCP4 protocol pointer\r | |
185 | EFI_TCP4_CONFIG_DATA ConfigData; ///< TCP4 configuration data\r | |
186 | EFI_TCP4_OPTION Option; ///< TCP4 port options\r | |
187 | BOOLEAN bConfigured; ///< TRUE if configuration was successful\r | |
188 | \r | |
189 | //\r | |
190 | // Tokens\r | |
191 | //\r | |
192 | EFI_TCP4_LISTEN_TOKEN ListenToken; ///< Listen control\r | |
193 | EFI_TCP4_CONNECTION_TOKEN ConnectToken; ///< Connection control\r | |
194 | EFI_TCP4_CLOSE_TOKEN CloseToken; ///< Close control\r | |
195 | \r | |
196 | //\r | |
197 | // Receive data management\r | |
198 | //\r | |
199 | EFI_TCP4_IO_TOKEN RxToken; ///< Receive token\r | |
200 | DT_PACKET * pReceivePending; ///< Receive operation in progress\r | |
201 | \r | |
202 | //\r | |
203 | // Transmit data management\r | |
204 | //\r | |
205 | EFI_TCP4_IO_TOKEN TxOobToken; ///< Urgent data token\r | |
206 | DT_PACKET * pTxOobPacket; ///< Urgent data in progress\r | |
207 | \r | |
208 | EFI_TCP4_IO_TOKEN TxToken; ///< Normal data token\r | |
209 | DT_PACKET * pTxPacket; ///< Normal transmit in progress\r | |
210 | } DT_TCP4_CONTEXT;\r | |
211 | \r | |
212 | /**\r | |
213 | UDP4 context structure\r | |
214 | \r | |
215 | The driver uses this structure to manage the UDP4 connections.\r | |
216 | **/\r | |
217 | typedef struct {\r | |
218 | //\r | |
219 | // UDP4 context\r | |
220 | //\r | |
221 | EFI_HANDLE Handle; ///< UDP4 port handle\r | |
222 | EFI_UDP4_PROTOCOL * pProtocol; ///< UDP4 protocol pointer\r | |
223 | EFI_UDP4_CONFIG_DATA ConfigData; ///< UDP4 configuration data\r | |
224 | BOOLEAN bConfigured; ///< TRUE if configuration was successful\r | |
225 | \r | |
226 | //\r | |
227 | // Receive data management\r | |
228 | //\r | |
229 | EFI_UDP4_COMPLETION_TOKEN RxToken;///< Receive token\r | |
230 | DT_PACKET * pReceivePending; ///< Receive operation in progress\r | |
231 | \r | |
232 | //\r | |
233 | // Transmit data management\r | |
234 | //\r | |
235 | EFI_UDP4_COMPLETION_TOKEN TxToken;///< Transmit token\r | |
236 | DT_PACKET * pTxPacket; ///< Transmit in progress\r | |
237 | } DT_UDP4_CONTEXT;\r | |
238 | \r | |
239 | \r | |
240 | /**\r | |
241 | Port control structure\r | |
242 | \r | |
243 | The driver uses this structure to manager the socket's connection\r | |
244 | with the network driver.\r | |
245 | **/\r | |
246 | typedef struct _DT_PORT {\r | |
247 | UINTN Signature; ///< Structure identification\r | |
248 | \r | |
249 | //\r | |
250 | // List links\r | |
251 | //\r | |
252 | DT_PORT * pLinkService; ///< Link in service port list\r | |
253 | DT_PORT * pLinkSocket; ///< Link in socket port list\r | |
254 | \r | |
255 | //\r | |
256 | // Structures\r | |
257 | //\r | |
258 | DT_SERVICE * pService; ///< Service for this port\r | |
259 | DT_SOCKET * pSocket; ///< Socket for this port\r | |
260 | // PFN_CLOSE_PORT pfnClosePort; ///< Routine to immediately close the port\r | |
261 | PFN_PORT_CLOSE_START * pfnCloseStart; ///< Routine to start closing the port\r | |
262 | \r | |
263 | //\r | |
264 | // Protocol specific management data\r | |
265 | //\r | |
266 | PORT_STATE State; ///< State of the port\r | |
267 | UINTN DebugFlags; ///< Debug flags used to close the port\r | |
268 | BOOLEAN bCloseNow; ///< TRUE = Close the port immediately\r | |
269 | \r | |
270 | union {\r | |
271 | DT_TCP4_CONTEXT Tcp4; ///< TCPv4 management data\r | |
272 | DT_UDP4_CONTEXT Udp4; ///< UDPv4 management data\r | |
273 | } Context;\r | |
274 | }GCC_DT_PORT;\r | |
275 | \r | |
276 | /**\r | |
277 | Socket control structure\r | |
278 | \r | |
279 | The driver uses this structure to manage the socket.\r | |
280 | **/\r | |
281 | typedef struct _DT_SOCKET {\r | |
282 | UINTN Signature; ///< Structure identification\r | |
283 | \r | |
284 | //\r | |
285 | // Protocol binding\r | |
286 | //\r | |
287 | EFI_SOCKET_PROTOCOL SocketProtocol; ///< Socket protocol declaration\r | |
288 | \r | |
289 | //\r | |
290 | // Socket management\r | |
291 | //\r | |
292 | DT_SOCKET * pNext; ///< Next socket in the list of sockets\r | |
293 | int errno; ///< Error information for this socket\r | |
294 | EFI_STATUS Status; ///< Asyncronous error information for this socket\r | |
295 | SOCKET_STATE State; ///< Socket state\r | |
296 | \r | |
297 | //\r | |
298 | // Socket data\r | |
299 | //\r | |
300 | int Domain; ///< Specifies family of protocols\r | |
301 | int Type; ///< Specifies how to make network connection\r | |
302 | int Protocol; ///< Specifies lower layer protocol to use\r | |
303 | BOOLEAN bConfigured; ///< Set after the socket is configured\r | |
304 | \r | |
305 | BOOLEAN bRxDisable; ///< Receive disabled via shutdown\r | |
306 | size_t RxBytes; ///< Total Rx bytes\r | |
307 | size_t RxOobBytes; ///< Urgent Rx bytes\r | |
308 | EFI_STATUS RxError; ///< Error during receive\r | |
309 | \r | |
310 | BOOLEAN bTxDisable; ///< Transmit disabled via shutdown\r | |
311 | size_t TxBytes; ///< Normal Tx bytes\r | |
312 | size_t TxOobBytes; ///< Urgent Tx bytes\r | |
313 | EFI_STATUS TxError; ///< Error during transmit\r | |
314 | \r | |
315 | //\r | |
316 | // Pending connection data\r | |
317 | //\r | |
318 | BOOLEAN bConnected; ///< Set when connected, cleared by poll\r | |
319 | EFI_STATUS ConnectStatus; ///< Connection status\r | |
320 | UINTN MaxFifoDepth; ///< Maximum FIFO depth\r | |
321 | UINTN FifoDepth; ///< Number of sockets in the FIFO\r | |
322 | DT_SOCKET * pFifoHead; ///< Head of the FIFO\r | |
323 | DT_SOCKET * pFifoTail; ///< Tail of the FIFO\r | |
324 | DT_SOCKET * pNextConnection; ///< Link in the FIFO\r | |
325 | \r | |
326 | //\r | |
327 | // Network use\r | |
328 | //\r | |
329 | DT_PORT * pPortList; ///< List of ports managed by this socket\r | |
330 | EFI_EVENT WaitAccept; ///< Wait for accept completion\r | |
331 | \r | |
332 | //\r | |
333 | // Receive data management\r | |
334 | //\r | |
335 | UINT32 MaxRxBuf; ///< Maximum size of the receive buffer\r | |
336 | struct timeval RxTimeout; ///< Receive timeout\r | |
337 | DT_PACKET * pRxFree; ///< Free packet list\r | |
338 | DT_PACKET * pRxOobPacketListHead; ///< Urgent data list head\r | |
339 | DT_PACKET * pRxOobPacketListTail; ///< Urgent data list tail\r | |
340 | DT_PACKET * pRxPacketListHead; ///< Normal data list head\r | |
341 | DT_PACKET * pRxPacketListTail; ///< Normal data list tail\r | |
342 | \r | |
343 | //\r | |
344 | // Transmit data management\r | |
345 | //\r | |
346 | UINT32 MaxTxBuf; ///< Maximum size of the transmit buffer\r | |
347 | DT_PACKET * pTxOobPacketListHead; ///< Urgent data list head\r | |
348 | DT_PACKET * pTxOobPacketListTail; ///< Urgent data list tail\r | |
349 | DT_PACKET * pTxPacketListHead; ///< Normal data list head\r | |
350 | DT_PACKET * pTxPacketListTail; ///< Normal data list tail\r | |
351 | }GCC_DT_SOCKET;\r | |
352 | \r | |
353 | #define SOCKET_FROM_PROTOCOL(a) CR(a, DT_SOCKET, SocketProtocol, SOCKET_SIGNATURE) ///< Locate DT_SOCKET from protocol\r | |
354 | \r | |
355 | /**\r | |
356 | Socket layer control structure\r | |
357 | \r | |
358 | The driver uses this structure to manage the driver.\r | |
359 | **/\r | |
360 | typedef struct {\r | |
361 | UINTN Signature; ///< Structure identification\r | |
362 | \r | |
363 | //\r | |
364 | // Service binding interface\r | |
365 | //\r | |
366 | EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;///< Driver's binding\r | |
367 | \r | |
368 | //\r | |
369 | // Image data\r | |
370 | //\r | |
371 | EFI_HANDLE ImageHandle; ///< Image handle\r | |
372 | \r | |
373 | //\r | |
374 | // Network services\r | |
375 | //\r | |
376 | DT_SERVICE * pTcp4List; ///< List of Tcp4 services\r | |
377 | DT_SERVICE * pUdp4List; ///< List of Udp4 services\r | |
378 | \r | |
379 | //\r | |
380 | // Socket management\r | |
381 | //\r | |
382 | DT_SOCKET * pSocketList; ///< List of sockets\r | |
383 | \r | |
384 | //\r | |
385 | // TCP4 service\r | |
386 | //\r | |
387 | UINTN TcpCloseMax4; ///< Number of entries in the ring buffer\r | |
388 | UINTN TcpCloseIn4; ///< Offset into TcpClose4 ring buffer - Close request\r | |
389 | UINTN TcpCloseOut4; ///< Offset into TcpClose4 ring buffer - Close operation\r | |
390 | EFI_TCP4_PROTOCOL ** ppTcpClose4; ///< Ring buffer to close TCP4 ports\r | |
391 | } DT_LAYER;\r | |
392 | \r | |
393 | #define LAYER_FROM_SERVICE(a) CR(a, DT_LAYER, ServiceBinding, LAYER_SIGNATURE) ///< Locate DT_LAYER from service binding\r | |
394 | \r | |
395 | //------------------------------------------------------------------------------\r | |
396 | // Data\r | |
397 | //------------------------------------------------------------------------------\r | |
398 | \r | |
399 | extern DT_LAYER mEslLayer;\r | |
400 | \r | |
401 | //------------------------------------------------------------------------------\r | |
402 | // Socket Support Routines\r | |
403 | //------------------------------------------------------------------------------\r | |
404 | \r | |
405 | /**\r | |
406 | Allocate and initialize a DT_SOCKET structure.\r | |
407 | \r | |
408 | The ::SocketAllocate() function allocates a DT_SOCKET structure\r | |
409 | and installs a protocol on ChildHandle. If pChildHandle is a\r | |
410 | pointer to NULL, then a new handle is created and returned in\r | |
411 | pChildHandle. If pChildHandle is not a pointer to NULL, then\r | |
412 | the protocol installs on the existing pChildHandle.\r | |
413 | \r | |
414 | @param [in, out] pChildHandle Pointer to the handle of the child to create.\r | |
415 | If it is NULL, then a new handle is created.\r | |
416 | If it is a pointer to an existing UEFI handle, \r | |
417 | then the protocol is added to the existing UEFI\r | |
418 | handle.\r | |
419 | @param [in] DebugFlags Flags for debug messages\r | |
420 | @param [in, out] ppSocket The buffer to receive the DT_SOCKET structure address.\r | |
421 | \r | |
422 | @retval EFI_SUCCESS The protocol was added to ChildHandle.\r | |
423 | @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r | |
424 | @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r | |
425 | the child\r | |
426 | @retval other The child handle was not created\r | |
427 | \r | |
428 | **/\r | |
429 | EFI_STATUS\r | |
430 | EFIAPI\r | |
431 | EslSocketAllocate (\r | |
432 | IN OUT EFI_HANDLE * pChildHandle,\r | |
433 | IN UINTN DebugFlags,\r | |
434 | IN OUT DT_SOCKET ** ppSocket\r | |
435 | );\r | |
436 | \r | |
437 | /**\r | |
438 | Allocate a packet for a receive or transmit operation\r | |
439 | \r | |
440 | @param [in] ppPacket Address to receive the DT_PACKET structure\r | |
441 | @param [in] LengthInBytes Length of the packet structure\r | |
442 | @param [in] DebugFlags Flags for debug messages\r | |
443 | \r | |
444 | @retval EFI_SUCCESS - The packet was allocated successfully\r | |
445 | \r | |
446 | **/\r | |
447 | EFI_STATUS\r | |
448 | EslSocketPacketAllocate (\r | |
449 | IN DT_PACKET ** ppPacket,\r | |
450 | IN size_t LengthInBytes,\r | |
451 | IN UINTN DebugFlags\r | |
452 | );\r | |
453 | \r | |
454 | /**\r | |
455 | Free a packet used for receive or transmit operation\r | |
456 | \r | |
457 | @param [in] pPacket Address of the DT_PACKET structure\r | |
458 | @param [in] DebugFlags Flags for debug messages\r | |
459 | \r | |
460 | @retval EFI_SUCCESS - The packet was allocated successfully\r | |
461 | \r | |
462 | **/\r | |
463 | EFI_STATUS\r | |
464 | EslSocketPacketFree (\r | |
465 | IN DT_PACKET * pPacket,\r | |
466 | IN UINTN DebugFlags\r | |
467 | );\r | |
468 | \r | |
469 | //------------------------------------------------------------------------------\r | |
470 | // Tcp4 Routines\r | |
471 | //------------------------------------------------------------------------------\r | |
472 | \r | |
473 | /**\r | |
474 | Accept a network connection.\r | |
475 | \r | |
476 | The SocketAccept routine waits for a network connection to the socket.\r | |
477 | It is able to return the remote network address to the caller if\r | |
478 | requested.\r | |
479 | \r | |
480 | @param [in] pSocket Address of the socket structure.\r | |
481 | \r | |
482 | @param [in] pSockAddr Address of a buffer to receive the remote\r | |
483 | network address.\r | |
484 | \r | |
485 | @param [in, out] pSockAddrLength Length in bytes of the address buffer.\r | |
486 | On output specifies the length of the\r | |
487 | remote network address.\r | |
488 | \r | |
489 | @retval EFI_SUCCESS Remote address is available\r | |
490 | @retval Others Remote address not available\r | |
491 | \r | |
492 | **/\r | |
493 | EFI_STATUS\r | |
494 | EslTcpAccept4 (\r | |
495 | IN DT_SOCKET * pSocket,\r | |
496 | IN struct sockaddr * pSockAddr,\r | |
497 | IN OUT socklen_t * pSockAddrLength\r | |
498 | );\r | |
499 | \r | |
500 | /**\r | |
501 | Bind a name to a socket.\r | |
502 | \r | |
503 | The ::TcpBind4 routine connects a name to A TCP4 stack on the local machine.\r | |
504 | \r | |
505 | @param [in] pSocket Address of the socket structure.\r | |
506 | \r | |
507 | @param [in] pSockAddr Address of a sockaddr structure that contains the\r | |
508 | connection point on the local machine. An IPv4 address\r | |
509 | of INADDR_ANY specifies that the connection is made to\r | |
510 | all of the network stacks on the platform. Specifying a\r | |
511 | specific IPv4 address restricts the connection to the\r | |
512 | network stack supporting that address. Specifying zero\r | |
513 | for the port causes the network layer to assign a port\r | |
514 | number from the dynamic range. Specifying a specific\r | |
515 | port number causes the network layer to use that port.\r | |
516 | \r | |
517 | @param [in] SockAddrLen Specifies the length in bytes of the sockaddr structure.\r | |
518 | \r | |
519 | @retval EFI_SUCCESS - Socket successfully created\r | |
520 | \r | |
521 | **/\r | |
522 | EFI_STATUS\r | |
523 | EslTcpBind4 (\r | |
524 | IN DT_SOCKET * pSocket,\r | |
525 | IN const struct sockaddr * pSockAddr,\r | |
526 | IN socklen_t SockAddrLength\r | |
527 | );\r | |
528 | \r | |
529 | /**\r | |
530 | Poll for completion of the connection attempt.\r | |
531 | \r | |
532 | The ::TcpConnectPoll4 routine determines when the connection\r | |
533 | attempt transitions from being in process to being complete.\r | |
534 | \r | |
535 | @param [in] pSocket Address of the socket structure.\r | |
536 | \r | |
537 | @retval EFI_SUCCESS The connection was successfully established.\r | |
538 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
539 | @retval Others The connection attempt failed.\r | |
540 | \r | |
541 | **/\r | |
542 | EFI_STATUS\r | |
543 | EslTcpConnectPoll4 (\r | |
544 | IN DT_SOCKET * pSocket\r | |
545 | );\r | |
546 | \r | |
547 | /**\r | |
548 | Connect to a remote system via the network.\r | |
549 | \r | |
550 | The ::TcpConnectStart4= routine starts the connection processing\r | |
551 | for a TCP4 port.\r | |
552 | \r | |
553 | @param [in] pSocket Address of the socket structure.\r | |
554 | \r | |
555 | @param [in] pSockAddr Network address of the remote system.\r | |
556 | \r | |
557 | @param [in] SockAddrLength Length in bytes of the network address.\r | |
558 | \r | |
559 | @retval EFI_SUCCESS The connection was successfully established.\r | |
560 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
561 | @retval Others The connection attempt failed.\r | |
562 | \r | |
563 | **/\r | |
564 | EFI_STATUS\r | |
565 | EslTcpConnectStart4 (\r | |
566 | IN DT_SOCKET * pSocket,\r | |
567 | IN const struct sockaddr * pSockAddr,\r | |
568 | IN socklen_t SockAddrLength\r | |
569 | );\r | |
570 | \r | |
571 | /**\r | |
572 | Initialize the TCP4 service.\r | |
573 | \r | |
574 | This routine initializes the TCP4 service after its service binding\r | |
575 | protocol was located on a controller.\r | |
576 | \r | |
577 | @param [in] pService DT_SERVICE structure address\r | |
578 | \r | |
579 | @retval EFI_SUCCESS The service was properly initialized\r | |
580 | @retval other A failure occurred during the service initialization\r | |
581 | \r | |
582 | **/\r | |
583 | EFI_STATUS\r | |
584 | EFIAPI\r | |
585 | EslTcpInitialize4 (\r | |
586 | IN DT_SERVICE * pService\r | |
587 | );\r | |
588 | \r | |
589 | /**\r | |
590 | Get the local socket address\r | |
591 | \r | |
592 | @param [in] pSocket Address of the socket structure.\r | |
593 | \r | |
594 | @param [out] pAddress Network address to receive the local system address\r | |
595 | \r | |
596 | @param [in,out] pAddressLength Length of the local network address structure\r | |
597 | \r | |
598 | @retval EFI_SUCCESS - Address available\r | |
599 | @retval Other - Failed to get the address\r | |
600 | \r | |
601 | **/\r | |
602 | EFI_STATUS\r | |
603 | EslTcpGetLocalAddress4 (\r | |
604 | IN DT_SOCKET * pSocket,\r | |
605 | OUT struct sockaddr * pAddress,\r | |
606 | IN OUT socklen_t * pAddressLength\r | |
607 | );\r | |
608 | \r | |
609 | /**\r | |
610 | Get the remote socket address\r | |
611 | \r | |
612 | @param [in] pSocket Address of the socket structure.\r | |
613 | \r | |
614 | @param [out] pAddress Network address to receive the remote system address\r | |
615 | \r | |
616 | @param [in,out] pAddressLength Length of the remote network address structure\r | |
617 | \r | |
618 | @retval EFI_SUCCESS - Address available\r | |
619 | @retval Other - Failed to get the address\r | |
620 | \r | |
621 | **/\r | |
622 | EFI_STATUS\r | |
623 | EslTcpGetRemoteAddress4 (\r | |
624 | IN DT_SOCKET * pSocket,\r | |
625 | OUT struct sockaddr * pAddress,\r | |
626 | IN OUT socklen_t * pAddressLength\r | |
627 | );\r | |
628 | \r | |
629 | /**\r | |
630 | Establish the known port to listen for network connections.\r | |
631 | \r | |
632 | The ::Tcp4Listen routine places the port into a state that enables connection\r | |
633 | attempts. Connections are placed into FIFO order in a queue to be serviced\r | |
634 | by the application. The application calls the ::Tcp4Accept routine to remove\r | |
635 | the next connection from the queue and get the associated socket. The\r | |
636 | <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html">POSIX</a>\r | |
637 | documentation for the listen routine is available online for reference.\r | |
638 | \r | |
639 | @param [in] pSocket Address of the socket structure.\r | |
640 | \r | |
641 | @retval EFI_SUCCESS - Socket successfully created\r | |
642 | @retval Other - Failed to enable the socket for listen\r | |
643 | \r | |
644 | **/\r | |
645 | EFI_STATUS\r | |
646 | EslTcpListen4 (\r | |
647 | IN DT_SOCKET * pSocket\r | |
648 | );\r | |
649 | \r | |
650 | /**\r | |
651 | Process the connection attempt\r | |
652 | \r | |
653 | A system has initiated a connection attempt with a socket in the\r | |
654 | listen state. Attempt to complete the connection.\r | |
655 | \r | |
656 | @param Event The listeen completion event\r | |
657 | \r | |
658 | @param pPort The DT_PORT structure address\r | |
659 | \r | |
660 | **/\r | |
661 | VOID\r | |
662 | EslTcpListenComplete4 (\r | |
663 | IN EFI_EVENT Event,\r | |
664 | IN DT_PORT * pPort\r | |
665 | );\r | |
666 | \r | |
667 | /**\r | |
668 | Allocate and initialize a DT_PORT structure.\r | |
669 | \r | |
670 | @param [in] pSocket Address of the socket structure.\r | |
671 | @param [in] pService Address of the DT_SERVICE structure.\r | |
672 | @param [in] ChildHandle TCP4 child handle\r | |
673 | @param [in] pIpAddress Buffer containing IP4 network address of the local host\r | |
674 | @param [in] PortNumber Tcp4 port number\r | |
675 | @param [in] DebugFlags Flags for debug messages\r | |
676 | @param [out] ppPort Buffer to receive new DT_PORT structure address\r | |
677 | \r | |
678 | @retval EFI_SUCCESS - Socket successfully created\r | |
679 | \r | |
680 | **/\r | |
681 | EFI_STATUS\r | |
682 | EslTcpPortAllocate4 (\r | |
683 | IN DT_SOCKET * pSocket,\r | |
684 | IN DT_SERVICE * pService,\r | |
685 | IN EFI_HANDLE ChildHandle,\r | |
686 | IN CONST UINT8 *pIpAddress,\r | |
687 | IN UINT16 PortNumber,\r | |
688 | IN UINTN DebugFlags,\r | |
689 | OUT DT_PORT ** ppPort\r | |
690 | );\r | |
691 | \r | |
692 | /**\r | |
693 | Close a TCP4 port.\r | |
694 | \r | |
695 | This routine releases the resources allocated by\r | |
696 | ::TcpPortAllocate4().\r | |
697 | \r | |
698 | @param [in] pPort Address of the port structure.\r | |
699 | \r | |
700 | @retval EFI_SUCCESS The port is closed\r | |
701 | @retval other Port close error\r | |
702 | \r | |
703 | **/\r | |
704 | EFI_STATUS\r | |
705 | EslTcpPortClose4 (\r | |
706 | IN DT_PORT * pPort\r | |
707 | );\r | |
708 | \r | |
709 | /**\r | |
710 | Process the port close completion\r | |
711 | \r | |
712 | @param Event The close completion event\r | |
713 | \r | |
714 | @param pPort The DT_PORT structure address\r | |
715 | \r | |
716 | **/\r | |
717 | VOID\r | |
718 | EslTcpPortCloseComplete4 (\r | |
719 | IN EFI_EVENT Event,\r | |
720 | IN DT_PORT * pPort\r | |
721 | );\r | |
722 | \r | |
723 | /**\r | |
724 | Port close state 3\r | |
725 | \r | |
726 | Continue the close operation after the receive is complete.\r | |
727 | \r | |
728 | @param [in] pPort Address of the port structure.\r | |
729 | \r | |
730 | @retval EFI_SUCCESS The port is closed\r | |
731 | @retval EFI_NOT_READY The port is still closing\r | |
732 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
733 | most likely the routine was called already.\r | |
734 | \r | |
735 | **/\r | |
736 | EFI_STATUS\r | |
737 | EslTcpPortCloseRxDone4 (\r | |
738 | IN DT_PORT * pPort\r | |
739 | );\r | |
740 | \r | |
741 | /**\r | |
742 | Start the close operation on a TCP4 port.\r | |
743 | \r | |
744 | @param [in] pPort Address of the port structure.\r | |
745 | @param [in] bAbort Set TRUE to abort active transfers\r | |
746 | @param [in] DebugFlags Flags for debug messages\r | |
747 | \r | |
748 | **/\r | |
749 | EFI_STATUS\r | |
750 | EslTcpPortCloseStart4 (\r | |
751 | IN DT_PORT * pPort,\r | |
752 | IN BOOLEAN bAbort,\r | |
753 | IN UINTN DebugFlags\r | |
754 | );\r | |
755 | \r | |
756 | /**\r | |
757 | Port close state 2\r | |
758 | \r | |
759 | Continue the close operation after the transmission is complete.\r | |
760 | \r | |
761 | @param [in] pPort Address of the port structure.\r | |
762 | \r | |
763 | @retval EFI_NOT_READY The port is still closing\r | |
764 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
765 | most likely the routine was called already.\r | |
766 | \r | |
767 | **/\r | |
768 | EFI_STATUS\r | |
769 | EslTcpPortCloseTxDone4 (\r | |
770 | IN DT_PORT * pPort\r | |
771 | );\r | |
772 | \r | |
773 | /**\r | |
774 | Receive data from a network connection.\r | |
775 | \r | |
776 | \r | |
777 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
778 | \r | |
779 | @param [in] Flags Message control flags\r | |
780 | \r | |
781 | @param [in] BufferLength Length of the the buffer\r | |
782 | \r | |
783 | @param [in] pBuffer Address of a buffer to receive the data.\r | |
784 | \r | |
785 | @param [in] pDataLength Number of received data bytes in the buffer.\r | |
786 | \r | |
787 | @param [out] pAddress Network address to receive the remote system address\r | |
788 | \r | |
789 | @param [in,out] pAddressLength Length of the remote network address structure\r | |
790 | \r | |
791 | @retval EFI_SUCCESS - Socket data successfully received\r | |
792 | \r | |
793 | **/\r | |
794 | EFI_STATUS\r | |
795 | EslTcpReceive4 (\r | |
796 | IN DT_SOCKET * pSocket,\r | |
797 | IN INT32 Flags,\r | |
798 | IN size_t BufferLength,\r | |
799 | IN UINT8 * pBuffer,\r | |
800 | OUT size_t * pDataLength,\r | |
801 | OUT struct sockaddr * pAddress,\r | |
802 | IN OUT socklen_t * pAddressLength\r | |
803 | );\r | |
804 | \r | |
805 | /**\r | |
806 | Cancel the receive operations\r | |
807 | \r | |
808 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
809 | \r | |
810 | @retval EFI_SUCCESS - The cancel was successful\r | |
811 | \r | |
812 | **/\r | |
813 | EFI_STATUS\r | |
814 | EslTcpRxCancel4 (\r | |
815 | IN DT_SOCKET * pSocket\r | |
816 | );\r | |
817 | \r | |
818 | /**\r | |
819 | Process the receive completion\r | |
820 | \r | |
821 | Buffer the data that was just received.\r | |
822 | \r | |
823 | @param Event The receive completion event\r | |
824 | \r | |
825 | @param pPort The DT_PORT structure address\r | |
826 | \r | |
827 | **/\r | |
828 | VOID\r | |
829 | EslTcpRxComplete4 (\r | |
830 | IN EFI_EVENT Event,\r | |
831 | IN DT_PORT * pPort\r | |
832 | );\r | |
833 | \r | |
834 | /**\r | |
835 | Start a receive operation\r | |
836 | \r | |
837 | @param [in] pPort Address of the DT_PORT structure.\r | |
838 | \r | |
839 | **/\r | |
840 | VOID\r | |
841 | EslTcpRxStart4 (\r | |
842 | IN DT_PORT * pPort\r | |
843 | );\r | |
844 | \r | |
845 | /**\r | |
846 | Shutdown the TCP4 service.\r | |
847 | \r | |
848 | This routine undoes the work performed by ::TcpInitialize4.\r | |
849 | \r | |
850 | @param [in] pService DT_SERVICE structure address\r | |
851 | \r | |
852 | **/\r | |
853 | VOID\r | |
854 | EFIAPI\r | |
855 | EslTcpShutdown4 (\r | |
856 | IN DT_SERVICE * pService\r | |
857 | );\r | |
858 | \r | |
859 | /**\r | |
860 | Determine if the socket is configured.\r | |
861 | \r | |
862 | \r | |
863 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
864 | \r | |
865 | @retval EFI_SUCCESS - The port is connected\r | |
866 | @retval EFI_NOT_STARTED - The port is not connected\r | |
867 | \r | |
868 | **/\r | |
869 | EFI_STATUS\r | |
870 | EslTcpSocketIsConfigured4 (\r | |
871 | IN DT_SOCKET * pSocket\r | |
872 | );\r | |
873 | \r | |
874 | /**\r | |
875 | Buffer data for transmission over a network connection.\r | |
876 | \r | |
877 | This routine is called by the socket layer API to buffer\r | |
878 | data for transmission. When necessary, this routine will\r | |
879 | start the transmit engine that performs the data transmission\r | |
880 | on the network connection.\r | |
881 | \r | |
882 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
883 | \r | |
884 | @param [in] Flags Message control flags\r | |
885 | \r | |
886 | @param [in] BufferLength Length of the the buffer\r | |
887 | \r | |
888 | @param [in] pBuffer Address of a buffer to receive the data.\r | |
889 | \r | |
890 | @param [in] pDataLength Number of received data bytes in the buffer.\r | |
891 | \r | |
892 | @retval EFI_SUCCESS - Socket data successfully buffered\r | |
893 | \r | |
894 | **/\r | |
895 | EFI_STATUS\r | |
896 | EslTcpTxBuffer4 (\r | |
897 | IN DT_SOCKET * pSocket,\r | |
898 | IN int Flags,\r | |
899 | IN size_t BufferLength,\r | |
900 | IN CONST UINT8 * pBuffer,\r | |
901 | OUT size_t * pDataLength\r | |
902 | );\r | |
903 | \r | |
904 | /**\r | |
905 | Process the normal data transmit completion\r | |
906 | \r | |
907 | @param Event The normal transmit completion event\r | |
908 | \r | |
909 | @param pPort The DT_PORT structure address\r | |
910 | \r | |
911 | **/\r | |
912 | VOID\r | |
913 | EslTcpTxComplete4 (\r | |
914 | IN EFI_EVENT Event,\r | |
915 | IN DT_PORT * pPort\r | |
916 | );\r | |
917 | \r | |
918 | /**\r | |
919 | Process the urgent data transmit completion\r | |
920 | \r | |
921 | @param Event The urgent transmit completion event\r | |
922 | \r | |
923 | @param pPort The DT_PORT structure address\r | |
924 | \r | |
925 | **/\r | |
926 | VOID\r | |
927 | EslTcpTxOobComplete4 (\r | |
928 | IN EFI_EVENT Event,\r | |
929 | IN DT_PORT * pPort\r | |
930 | );\r | |
931 | \r | |
932 | /**\r | |
933 | Transmit data using a network connection.\r | |
934 | \r | |
935 | \r | |
936 | @param [in] pPort Address of a DT_PORT structure\r | |
937 | @param [in] pToken Address of either the OOB or normal transmit token\r | |
938 | @param [in] ppQueueHead Transmit queue head address\r | |
939 | @param [in] ppQueueTail Transmit queue tail address\r | |
940 | @param [in] ppPacket Active transmit packet address\r | |
941 | \r | |
942 | **/\r | |
943 | VOID\r | |
944 | EslTcpTxStart4 (\r | |
945 | IN DT_PORT * pPort,\r | |
946 | IN EFI_TCP4_IO_TOKEN * pToken,\r | |
947 | IN DT_PACKET ** ppQueueHead,\r | |
948 | IN DT_PACKET ** ppQueueTail,\r | |
949 | IN DT_PACKET ** ppPacket\r | |
950 | );\r | |
951 | \r | |
952 | //------------------------------------------------------------------------------\r | |
953 | // Udp4 Routines\r | |
954 | //------------------------------------------------------------------------------\r | |
955 | \r | |
956 | /**\r | |
957 | Bind a name to a socket.\r | |
958 | \r | |
959 | The ::UdpBind4 routine connects a name to a UDP4 stack on the local machine.\r | |
960 | \r | |
961 | @param [in] pSocket Address of the socket structure.\r | |
962 | \r | |
963 | @param [in] pSockAddr Address of a sockaddr structure that contains the\r | |
964 | connection point on the local machine. An IPv4 address\r | |
965 | of INADDR_ANY specifies that the connection is made to\r | |
966 | all of the network stacks on the platform. Specifying a\r | |
967 | specific IPv4 address restricts the connection to the\r | |
968 | network stack supporting that address. Specifying zero\r | |
969 | for the port causes the network layer to assign a port\r | |
970 | number from the dynamic range. Specifying a specific\r | |
971 | port number causes the network layer to use that port.\r | |
972 | \r | |
973 | @param [in] SockAddrLen Specifies the length in bytes of the sockaddr structure.\r | |
974 | \r | |
975 | @retval EFI_SUCCESS - Socket successfully created\r | |
976 | \r | |
977 | **/\r | |
978 | EFI_STATUS\r | |
979 | EslUdpBind4 (\r | |
980 | IN DT_SOCKET * pSocket,\r | |
981 | IN const struct sockaddr * pSockAddr,\r | |
982 | IN socklen_t SockAddrLength\r | |
983 | );\r | |
984 | \r | |
985 | /**\r | |
986 | Initialize the UDP4 service.\r | |
987 | \r | |
988 | This routine initializes the UDP4 service after its service binding\r | |
989 | protocol was located on a controller.\r | |
990 | \r | |
991 | @param [in] pService DT_SERVICE structure address\r | |
992 | \r | |
993 | @retval EFI_SUCCESS The service was properly initialized\r | |
994 | @retval other A failure occurred during the service initialization\r | |
995 | \r | |
996 | **/\r | |
997 | EFI_STATUS\r | |
998 | EFIAPI\r | |
999 | EslUdpInitialize4 (\r | |
1000 | IN DT_SERVICE * pService\r | |
1001 | );\r | |
1002 | \r | |
1003 | /**\r | |
1004 | Allocate and initialize a DT_PORT structure.\r | |
1005 | \r | |
1006 | @param [in] pSocket Address of the socket structure.\r | |
1007 | @param [in] pService Address of the DT_SERVICE structure.\r | |
1008 | @param [in] ChildHandle Udp4 child handle\r | |
1009 | @param [in] pIpAddress Buffer containing IP4 network address of the local host\r | |
1010 | @param [in] PortNumber Udp4 port number\r | |
1011 | @param [in] DebugFlags Flags for debug messages\r | |
1012 | @param [out] ppPort Buffer to receive new DT_PORT structure address\r | |
1013 | \r | |
1014 | @retval EFI_SUCCESS - Socket successfully created\r | |
1015 | \r | |
1016 | **/\r | |
1017 | EFI_STATUS\r | |
1018 | EslUdpPortAllocate4 (\r | |
1019 | IN DT_SOCKET * pSocket,\r | |
1020 | IN DT_SERVICE * pService,\r | |
1021 | IN EFI_HANDLE ChildHandle,\r | |
1022 | IN CONST UINT8 * pIpAddress,\r | |
1023 | IN UINT16 PortNumber,\r | |
1024 | IN UINTN DebugFlags,\r | |
1025 | OUT DT_PORT ** ppPort\r | |
1026 | );\r | |
1027 | \r | |
1028 | /**\r | |
1029 | Close a UDP4 port.\r | |
1030 | \r | |
1031 | This routine releases the resources allocated by\r | |
1032 | ::UdpPortAllocate4().\r | |
1033 | \r | |
1034 | @param [in] pPort Address of the port structure.\r | |
1035 | \r | |
1036 | @retval EFI_SUCCESS The port is closed\r | |
1037 | @retval other Port close error\r | |
1038 | \r | |
1039 | **/\r | |
1040 | EFI_STATUS\r | |
1041 | EslUdpPortClose4 (\r | |
1042 | IN DT_PORT * pPort\r | |
1043 | );\r | |
1044 | \r | |
1045 | /**\r | |
1046 | Start the close operation on a UDP4 port, state 1.\r | |
1047 | \r | |
1048 | Closing a port goes through the following states:\r | |
1049 | 1. Port close starting - Mark the port as closing and wait for transmission to complete\r | |
1050 | 2. Port TX close done - Transmissions complete, close the port and abort the receives\r | |
1051 | 3. Port RX close done - Receive operations complete, close the port\r | |
1052 | 4. Port closed - Release the port resources\r | |
1053 | \r | |
1054 | @param [in] pPort Address of the port structure.\r | |
1055 | @param [in] bCloseNow Set TRUE to abort active transfers\r | |
1056 | @param [in] DebugFlags Flags for debug messages\r | |
1057 | \r | |
1058 | @retval EFI_SUCCESS The port is closed, not normally returned\r | |
1059 | @retval EFI_NOT_READY The port has started the closing process\r | |
1060 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
1061 | most likely the routine was called already.\r | |
1062 | \r | |
1063 | **/\r | |
1064 | EFI_STATUS\r | |
1065 | EslUdpPortCloseStart4 (\r | |
1066 | IN DT_PORT * pPort,\r | |
1067 | IN BOOLEAN bCloseNow,\r | |
1068 | IN UINTN DebugFlags\r | |
1069 | );\r | |
1070 | \r | |
1071 | /**\r | |
1072 | Port close state 2\r | |
1073 | \r | |
1074 | Continue the close operation after the transmission is complete.\r | |
1075 | \r | |
1076 | @param [in] pPort Address of the port structure.\r | |
1077 | \r | |
1078 | @retval EFI_SUCCESS The port is closed, not normally returned\r | |
1079 | @retval EFI_NOT_READY The port is still closing\r | |
1080 | @retval EFI_ALREADY_STARTED Error, the port is in the wrong state,\r | |
1081 | most likely the routine was called already.\r | |
1082 | \r | |
1083 | **/\r | |
1084 | EFI_STATUS\r | |
1085 | EslUdpPortCloseTxDone4 (\r | |
1086 | IN DT_PORT * pPort\r | |
1087 | );\r | |
1088 | \r | |
1089 | /**\r | |
1090 | Connect to a remote system via the network.\r | |
1091 | \r | |
1092 | The ::UdpConnectStart4= routine sets the remote address for the connection.\r | |
1093 | \r | |
1094 | @param [in] pSocket Address of the socket structure.\r | |
1095 | \r | |
1096 | @param [in] pSockAddr Network address of the remote system.\r | |
1097 | \r | |
1098 | @param [in] SockAddrLength Length in bytes of the network address.\r | |
1099 | \r | |
1100 | @retval EFI_SUCCESS The connection was successfully established.\r | |
1101 | @retval EFI_NOT_READY The connection is in progress, call this routine again.\r | |
1102 | @retval Others The connection attempt failed.\r | |
1103 | \r | |
1104 | **/\r | |
1105 | EFI_STATUS\r | |
1106 | EslUdpConnect4 (\r | |
1107 | IN DT_SOCKET * pSocket,\r | |
1108 | IN const struct sockaddr * pSockAddr,\r | |
1109 | IN socklen_t SockAddrLength\r | |
1110 | );\r | |
1111 | \r | |
1112 | /**\r | |
1113 | Get the local socket address\r | |
1114 | \r | |
1115 | @param [in] pSocket Address of the socket structure.\r | |
1116 | \r | |
1117 | @param [out] pAddress Network address to receive the local system address\r | |
1118 | \r | |
1119 | @param [in,out] pAddressLength Length of the local network address structure\r | |
1120 | \r | |
1121 | @retval EFI_SUCCESS - Address available\r | |
1122 | @retval Other - Failed to get the address\r | |
1123 | \r | |
1124 | **/\r | |
1125 | EFI_STATUS\r | |
1126 | EslUdpGetLocalAddress4 (\r | |
1127 | IN DT_SOCKET * pSocket,\r | |
1128 | OUT struct sockaddr * pAddress,\r | |
1129 | IN OUT socklen_t * pAddressLength\r | |
1130 | );\r | |
1131 | \r | |
1132 | /**\r | |
1133 | Get the remote socket address\r | |
1134 | \r | |
1135 | @param [in] pSocket Address of the socket structure.\r | |
1136 | \r | |
1137 | @param [out] pAddress Network address to receive the remote system address\r | |
1138 | \r | |
1139 | @param [in,out] pAddressLength Length of the remote network address structure\r | |
1140 | \r | |
1141 | @retval EFI_SUCCESS - Address available\r | |
1142 | @retval Other - Failed to get the address\r | |
1143 | \r | |
1144 | **/\r | |
1145 | EFI_STATUS\r | |
1146 | EslUdpGetRemoteAddress4 (\r | |
1147 | IN DT_SOCKET * pSocket,\r | |
1148 | OUT struct sockaddr * pAddress,\r | |
1149 | IN OUT socklen_t * pAddressLength\r | |
1150 | );\r | |
1151 | \r | |
1152 | /**\r | |
1153 | Receive data from a network connection.\r | |
1154 | \r | |
1155 | To minimize the number of buffer copies, the ::UdpRxComplete4\r | |
1156 | routine queues the UDP4 driver's buffer to a list of datagrams\r | |
1157 | waiting to be received. The socket driver holds on to the\r | |
1158 | buffers from the UDP4 driver until the application layer requests\r | |
1159 | the data or the socket is closed.\r | |
1160 | \r | |
1161 | The application calls this routine in the socket layer to\r | |
1162 | receive datagrams from one or more remote systems. This routine\r | |
1163 | removes the next available datagram from the list of datagrams\r | |
1164 | and copies the data from the UDP4 driver's buffer into the\r | |
1165 | application's buffer. The UDP4 driver's buffer is then returned.\r | |
1166 | \r | |
1167 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
1168 | \r | |
1169 | @param [in] Flags Message control flags\r | |
1170 | \r | |
1171 | @param [in] BufferLength Length of the the buffer\r | |
1172 | \r | |
1173 | @param [in] pBuffer Address of a buffer to receive the data.\r | |
1174 | \r | |
1175 | @param [in] pDataLength Number of received data bytes in the buffer.\r | |
1176 | \r | |
1177 | @param [out] pAddress Network address to receive the remote system address\r | |
1178 | \r | |
1179 | @param [in,out] pAddressLength Length of the remote network address structure\r | |
1180 | \r | |
1181 | @retval EFI_SUCCESS - Socket data successfully received\r | |
1182 | \r | |
1183 | **/\r | |
1184 | EFI_STATUS\r | |
1185 | EslUdpReceive4 (\r | |
1186 | IN DT_SOCKET * pSocket,\r | |
1187 | IN INT32 Flags,\r | |
1188 | IN size_t BufferLength,\r | |
1189 | IN UINT8 * pBuffer,\r | |
1190 | OUT size_t * pDataLength,\r | |
1191 | OUT struct sockaddr * pAddress,\r | |
1192 | IN OUT socklen_t * pAddressLength\r | |
1193 | );\r | |
1194 | \r | |
1195 | /**\r | |
1196 | Cancel the receive operations\r | |
1197 | \r | |
1198 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
1199 | \r | |
1200 | @retval EFI_SUCCESS - The cancel was successful\r | |
1201 | \r | |
1202 | **/\r | |
1203 | EFI_STATUS\r | |
1204 | EslUdpRxCancel4 (\r | |
1205 | IN DT_SOCKET * pSocket\r | |
1206 | );\r | |
1207 | \r | |
1208 | /**\r | |
1209 | Process the receive completion\r | |
1210 | \r | |
1211 | Keep the UDP4 driver's buffer and append it to the list of\r | |
1212 | datagrams for the application to receive. The UDP4 driver's\r | |
1213 | buffer will be returned by either ::UdpReceive4 or\r | |
1214 | ::UdpPortCloseTxDone4.\r | |
1215 | \r | |
1216 | @param Event The receive completion event\r | |
1217 | \r | |
1218 | @param pPort The DT_PORT structure address\r | |
1219 | \r | |
1220 | **/\r | |
1221 | VOID\r | |
1222 | EslUdpRxComplete4 (\r | |
1223 | IN EFI_EVENT Event,\r | |
1224 | IN DT_PORT * pPort\r | |
1225 | );\r | |
1226 | \r | |
1227 | /**\r | |
1228 | Start a receive operation\r | |
1229 | \r | |
1230 | @param [in] pPort Address of the DT_PORT structure.\r | |
1231 | \r | |
1232 | **/\r | |
1233 | VOID\r | |
1234 | EslUdpRxStart4 (\r | |
1235 | IN DT_PORT * pPort\r | |
1236 | );\r | |
1237 | \r | |
1238 | /**\r | |
1239 | Determine if the socket is configured.\r | |
1240 | \r | |
1241 | \r | |
1242 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
1243 | \r | |
1244 | @retval EFI_SUCCESS - The port is connected\r | |
1245 | @retval EFI_NOT_STARTED - The port is not connected\r | |
1246 | \r | |
1247 | **/\r | |
1248 | EFI_STATUS\r | |
1249 | EslUdpSocketIsConfigured4 (\r | |
1250 | IN DT_SOCKET * pSocket\r | |
1251 | );\r | |
1252 | \r | |
1253 | /**\r | |
1254 | Process the transmit completion\r | |
1255 | \r | |
1256 | @param Event The normal transmit completion event\r | |
1257 | \r | |
1258 | @param pPort The DT_PORT structure address\r | |
1259 | \r | |
1260 | **/\r | |
1261 | VOID\r | |
1262 | EslUdpTxComplete4 (\r | |
1263 | IN EFI_EVENT Event,\r | |
1264 | IN DT_PORT * pPort\r | |
1265 | );\r | |
1266 | \r | |
1267 | /**\r | |
1268 | Shutdown the UDP4 service.\r | |
1269 | \r | |
1270 | This routine undoes the work performed by ::UdpInitialize4.\r | |
1271 | \r | |
1272 | @param [in] pService DT_SERVICE structure address\r | |
1273 | \r | |
1274 | **/\r | |
1275 | VOID\r | |
1276 | EFIAPI\r | |
1277 | EslUdpShutdown4 (\r | |
1278 | IN DT_SERVICE * pService\r | |
1279 | );\r | |
1280 | \r | |
1281 | /**\r | |
1282 | Buffer data for transmission over a network connection.\r | |
1283 | \r | |
1284 | This routine is called by the socket layer API to buffer\r | |
1285 | data for transmission. The data is copied into a local buffer\r | |
1286 | freeing the application buffer for reuse upon return. When\r | |
1287 | necessary, this routine will start the transmit engine that\r | |
1288 | performs the data transmission on the network connection. The\r | |
1289 | transmit engine transmits the data a packet at a time over the\r | |
1290 | network connection.\r | |
1291 | \r | |
1292 | Transmission errors are returned during the next transmission or\r | |
1293 | during the close operation. Only buffering errors are returned\r | |
1294 | during the current transmission attempt.\r | |
1295 | \r | |
1296 | @param [in] pSocket Address of a DT_SOCKET structure\r | |
1297 | \r | |
1298 | @param [in] Flags Message control flags\r | |
1299 | \r | |
1300 | @param [in] BufferLength Length of the the buffer\r | |
1301 | \r | |
1302 | @param [in] pBuffer Address of a buffer to receive the data.\r | |
1303 | \r | |
1304 | @param [in] pDataLength Number of received data bytes in the buffer.\r | |
1305 | \r | |
1306 | @param [in] pAddress Network address of the remote system address\r | |
1307 | \r | |
1308 | @param [in] AddressLength Length of the remote network address structure\r | |
1309 | \r | |
1310 | @retval EFI_SUCCESS - Socket data successfully buffered\r | |
1311 | \r | |
1312 | **/\r | |
1313 | EFI_STATUS\r | |
1314 | EslUdpTxBuffer4 (\r | |
1315 | IN DT_SOCKET * pSocket,\r | |
1316 | IN int Flags,\r | |
1317 | IN size_t BufferLength,\r | |
1318 | IN CONST UINT8 * pBuffer,\r | |
1319 | OUT size_t * pDataLength,\r | |
1320 | IN const struct sockaddr * pAddress,\r | |
1321 | IN socklen_t AddressLength\r | |
1322 | );\r | |
1323 | \r | |
1324 | /**\r | |
1325 | Transmit data using a network connection.\r | |
1326 | \r | |
1327 | @param [in] pPort Address of a DT_PORT structure\r | |
1328 | \r | |
1329 | **/\r | |
1330 | VOID\r | |
1331 | EslUdpTxStart4 (\r | |
1332 | IN DT_PORT * pPort\r | |
1333 | );\r | |
1334 | \r | |
1335 | //------------------------------------------------------------------------------\r | |
1336 | \r | |
1337 | #endif // _SOCKET_H_\r |