]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
Fix the IN OUT modifier for parameters.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Socket.h
CommitLineData
83cbd279 1/** @file\r
2\r
dfc1f033 3Copyright (c) 2005 - 2006, Intel Corporation<BR>\r
83cbd279 4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
dfc1f033 7http://opensource.org/licenses/bsd-license.php<BR>\r
83cbd279 8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
83cbd279 12**/\r
13\r
14#ifndef _SOCKET_H_\r
15#define _SOCKET_H_\r
16\r
77f00155 17#include <Uefi.h>\r
8a67d61d 18\r
eaf343ff 19#include <Protocol/Ip4.h>\r
83cbd279 20#include <Protocol/Tcp4.h>\r
8a67d61d 21#include <Protocol/Udp4.h>\r
83cbd279 22\r
8a67d61d 23#include <Library/NetLib.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/UefiRuntimeServicesTableLib.h>\r
8a67d61d 26#include <Library/UefiBootServicesTableLib.h>\r
83cbd279 27#include <Library/UefiLib.h>\r
83cbd279 28\r
29#define SOCK_SND_BUF 0\r
30#define SOCK_RCV_BUF 1\r
31\r
dfc1f033 32#define SOCK_BUFF_LOW_WATER (2 * 1024)\r
33#define SOCK_RCV_BUFF_SIZE (8 * 1024)\r
34#define SOCK_SND_BUFF_SIZE (8 * 1024)\r
83cbd279 35#define SOCK_BACKLOG 5\r
36\r
37#define PROTO_RESERVED_LEN 20\r
38\r
39#define SO_NO_MORE_DATA 0x0001\r
40\r
41//\r
42//\r
43//\r
44// When a socket is created it enters into SO_UNCONFIGURED,\r
45// no actions can be taken on this socket, only after calling\r
46// SockConfigure. The state transition diagram of socket is\r
47// as following:\r
48//\r
49// SO_UNCONFIGURED --- SO_CONFIGURED --- SO_CONNECTING\r
50// ^ | |\r
51// | ---> SO_LISTENING |\r
52// | |\r
53// |------------------SO_DISCONNECTING<-- SO_CONNECTED\r
54//\r
55// A passive socket can only go into SO_LISTENING and\r
56// SO_UNCONFIGURED state. SO_XXXING state is a middle state\r
57// when a socket is undergoing a protocol procedure such\r
58// as requesting a TCP connection.\r
59//\r
60//\r
61//\r
dfc1f033 62\r
63///\r
64/// Socket state\r
65///\r
83cbd279 66typedef enum {\r
67 SO_CLOSED = 0,\r
68 SO_LISTENING,\r
69 SO_CONNECTING,\r
70 SO_CONNECTED,\r
71 SO_DISCONNECTING\r
72} SOCK_STATE;\r
73\r
dfc1f033 74///\r
75/// Socket configure state\r
76///\r
83cbd279 77typedef enum {\r
78 SO_UNCONFIGURED = 0,\r
79 SO_CONFIGURED_ACTIVE,\r
80 SO_CONFIGURED_PASSIVE,\r
81 SO_NO_MAPPING\r
82} SOCK_CONFIGURE_STATE;\r
83\r
84#define SOCK_NO_MORE_DATA(Sock) ((Sock)->Flag |= SO_NO_MORE_DATA)\r
85\r
86#define SOCK_IS_UNCONFIGURED(Sock) ((Sock)->ConfigureState == SO_UNCONFIGURED)\r
87\r
88#define SOCK_IS_CONFIGURED(Sock) \\r
89 (((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE) || \\r
90 ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE))\r
91\r
92#define SOCK_IS_CONFIGURED_ACTIVE(Sock) \\r
93 ((Sock)->ConfigureState == SO_CONFIGURED_ACTIVE)\r
94\r
95#define SOCK_IS_CONNECTED_PASSIVE(Sock) \\r
96 ((Sock)->ConfigureState == SO_CONFIGURED_PASSIVE)\r
97\r
98#define SOCK_IS_NO_MAPPING(Sock) \\r
99 ((Sock)->ConfigureState == SO_NO_MAPPING)\r
100\r
dfc1f033 101#define SOCK_IS_CLOSED(Sock) ((Sock)->State == SO_CLOSED)\r
83cbd279 102\r
dfc1f033 103#define SOCK_IS_LISTENING(Sock) ((Sock)->State == SO_LISTENING)\r
83cbd279 104\r
dfc1f033 105#define SOCK_IS_CONNECTING(Sock) ((Sock)->State == SO_CONNECTING)\r
83cbd279 106\r
dfc1f033 107#define SOCK_IS_CONNECTED(Sock) ((Sock)->State == SO_CONNECTED)\r
83cbd279 108\r
dfc1f033 109#define SOCK_IS_DISCONNECTING(Sock) ((Sock)->State == SO_DISCONNECTING)\r
83cbd279 110\r
dfc1f033 111#define SOCK_IS_NO_MORE_DATA(Sock) (0 != ((Sock)->Flag & SO_NO_MORE_DATA))\r
83cbd279 112\r
7dc2fc3d 113#define SOCK_SIGNATURE SIGNATURE_32 ('S', 'O', 'C', 'K')\r
83cbd279 114\r
dfc1f033 115#define SOCK_FROM_THIS(a) CR ((a), SOCKET, NetProtocol, SOCK_SIGNATURE)\r
83cbd279 116\r
117#define SET_RCV_BUFFSIZE(Sock, Size) ((Sock)->RcvBuffer.HighWater = (Size))\r
118\r
119#define GET_RCV_BUFFSIZE(Sock) ((Sock)->RcvBuffer.HighWater)\r
120\r
121#define GET_RCV_DATASIZE(Sock) (((Sock)->RcvBuffer.DataQueue)->BufSize)\r
122\r
123#define SET_SND_BUFFSIZE(Sock, Size) ((Sock)->SndBuffer.HighWater = (Size))\r
124\r
125#define GET_SND_BUFFSIZE(Sock) ((Sock)->SndBuffer.HighWater)\r
126\r
127#define GET_SND_DATASIZE(Sock) (((Sock)->SndBuffer.DataQueue)->BufSize)\r
128\r
129#define SET_BACKLOG(Sock, Value) ((Sock)->BackLog = (Value))\r
130\r
131#define GET_BACKLOG(Sock) ((Sock)->BackLog)\r
132\r
133#define SOCK_ERROR(Sock, Error) ((Sock)->SockError = (Error))\r
134\r
135#define SND_BUF_HDR_LEN(Sock) \\r
136 ((SockBufFirst (&((Sock)->SndBuffer)))->TotalSize)\r
137\r
138#define RCV_BUF_HDR_LEN(Sock) \\r
139 ((SockBufFirst (&((Sock)->RcvBuffer)))->TotalSize)\r
140\r
141#define SOCK_FROM_TOKEN(Token) (((SOCK_TOKEN *) (Token))->Sock)\r
142\r
143#define PROTO_TOKEN_FORM_SOCK(SockToken, Type) \\r
144 ((Type *) (((SOCK_TOKEN *) (SockToken))->Token))\r
145\r
146typedef struct _SOCKET SOCKET;\r
147\r
dfc1f033 148///\r
149/// Socket completion token\r
150///\r
83cbd279 151typedef struct _SOCK_COMPLETION_TOKEN {\r
dfc1f033 152 EFI_EVENT Event; ///< The event to be issued\r
153 EFI_STATUS Status; ///< The status to be issued\r
83cbd279 154} SOCK_COMPLETION_TOKEN;\r
155\r
dfc1f033 156///\r
157/// The application token with data packet\r
158///\r
83cbd279 159typedef struct _SOCK_IO_TOKEN {\r
160 SOCK_COMPLETION_TOKEN Token;\r
161 union {\r
162 VOID *RxData;\r
163 VOID *TxData;\r
164 } Packet;\r
165} SOCK_IO_TOKEN;\r
166\r
dfc1f033 167///\r
168/// The request issued from socket layer to protocol layer. \r
169///\r
83cbd279 170typedef enum {\r
dfc1f033 171 SOCK_ATTACH, ///< Attach current socket to a new PCB\r
172 SOCK_DETACH, ///< Detach current socket from the PCB\r
173 SOCK_CONFIGURE, ///< Configure attached PCB\r
174 SOCK_FLUSH, ///< Flush attached PCB\r
175 SOCK_SND, ///< Need protocol to send something\r
176 SOCK_SNDPUSH, ///< Need protocol to send pushed data\r
177 SOCK_SNDURG, ///< Need protocol to send urgent data\r
178 SOCK_CONSUMED, ///< Application has retrieved data from socket\r
179 SOCK_CONNECT, ///< Need to connect to a peer\r
180 SOCK_CLOSE, ///< Need to close the protocol process\r
181 SOCK_ABORT, ///< Need to reset the protocol process\r
182 SOCK_POLL, ///< Need to poll to the protocol layer\r
183 SOCK_ROUTE, ///< Need to add a route information\r
184 SOCK_MODE, ///< Need to get the mode data of the protocol\r
185 SOCK_GROUP ///< Need to join a mcast group\r
83cbd279 186} SOCK_REQUEST;\r
187\r
dfc1f033 188///\r
189/// The socket type.\r
190///\r
83cbd279 191typedef enum {\r
dfc1f033 192 SOCK_DGRAM, ///< This socket providing datagram service\r
193 SOCK_STREAM ///< This socket providing stream service\r
83cbd279 194} SOCK_TYPE;\r
195\r
dfc1f033 196///\r
197/// The buffer structure of rcvd data and send data used by socket.\r
198///\r
83cbd279 199typedef struct _SOCK_BUFFER {\r
dfc1f033 200 UINT32 HighWater; ///< The buffersize upper limit of sock_buffer\r
201 UINT32 LowWater; ///< The low warter mark of sock_buffer\r
202 NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data\r
83cbd279 203} SOCK_BUFFER;\r
204\r
276dcc1b 205/**\r
206 The handler of protocol for request from socket.\r
207 \r
208 @param Socket The socket issuing the request to protocol\r
209 @param Request The request issued by socket\r
210 @param RequestData The request related data\r
211 \r
212 @retval EFI_SUCCESS The socket request is completed successfully.\r
213 @retval other The error status returned by the corresponding TCP\r
214 layer function.\r
215 \r
216**/\r
217typedef\r
218EFI_STATUS\r
219(*SOCK_PROTO_HANDLER) (\r
220 IN SOCKET *Socket,\r
221 IN SOCK_REQUEST Request,\r
222 IN VOID *RequestData\r
223 );\r
224 \r
225 \r
83cbd279 226//\r
dfc1f033 227// Socket provided oprerations for low layer protocol\r
83cbd279 228//\r
229\r
230//\r
dfc1f033 231// Socket provided operations for user interface\r
83cbd279 232//\r
dfc1f033 233\r
234/**\r
235 Set the state of the socket.\r
236\r
237 @param Sock Pointer to the socket.\r
238 @param State The new state to be set.\r
239\r
240**/\r
83cbd279 241VOID\r
242SockSetState (\r
77f00155 243 IN OUT SOCKET *Sock,\r
244 IN SOCK_STATE State\r
83cbd279 245 );\r
246\r
dfc1f033 247/**\r
248 Called by the low layer protocol to indicate the socket a connection is \r
276dcc1b 249 established. \r
250 \r
251 This function just changes the socket's state to SO_CONNECTED \r
dfc1f033 252 and signals the token used for connection establishment.\r
253\r
254 @param Sock Pointer to the socket associated with the\r
255 established connection.\r
256 \r
257**/\r
83cbd279 258VOID\r
259SockConnEstablished (\r
260 IN SOCKET *Sock\r
261 );\r
262\r
dfc1f033 263/**\r
276dcc1b 264 Called by the low layer protocol to indicate the connection is closed.\r
265 \r
266 This function flushes the socket, sets the state to SO_CLOSED and signals \r
267 the close token.\r
dfc1f033 268\r
269 @param Sock Pointer to the socket associated with the closed\r
270 connection.\r
271 \r
272**/\r
83cbd279 273VOID\r
274SockConnClosed (\r
77f00155 275 IN OUT SOCKET *Sock\r
83cbd279 276 );\r
277\r
dfc1f033 278/**\r
276dcc1b 279 Called by low layer protocol to indicate that some data is sent or processed.\r
280 \r
dfc1f033 281 This function trims the sent data in the socket send buffer, signals the data \r
282 token if proper.\r
283\r
284 @param Sock Pointer to the socket.\r
285 @param Count The length of the data processed or sent, in bytes.\r
286\r
287**/\r
83cbd279 288VOID\r
289SockDataSent (\r
dfc1f033 290 IN SOCKET *Sock,\r
291 IN UINT32 Count\r
83cbd279 292 );\r
293\r
dfc1f033 294/**\r
295 Called by the low layer protocol to copy some data in socket send\r
296 buffer starting from the specific offset to a buffer provided by\r
297 the caller.\r
298\r
299 @param Sock Pointer to the socket.\r
300 @param Offset The start point of the data to be copied.\r
301 @param Len The length of the data to be copied.\r
302 @param Dest Pointer to the destination to copy the data.\r
303\r
304 @return The data size copied.\r
305\r
306**/\r
83cbd279 307UINT32\r
308SockGetDataToSend (\r
dfc1f033 309 IN SOCKET *Sock,\r
310 IN UINT32 Offset,\r
311 IN UINT32 Len,\r
312 IN UINT8 *Dest\r
83cbd279 313 );\r
314\r
dfc1f033 315/**\r
316 Called by the low layer protocol to indicate that there\r
276dcc1b 317 will be no more data from the communication peer.\r
318 \r
319 This function set the socket's state to SO_NO_MORE_DATA and\r
320 signal all queued IO tokens with the error status EFI_CONNECTION_FIN.\r
dfc1f033 321\r
322 @param Sock Pointer to the socket.\r
323\r
324**/\r
83cbd279 325VOID\r
326SockNoMoreData (\r
77f00155 327 IN OUT SOCKET *Sock\r
83cbd279 328 );\r
329\r
dfc1f033 330/**\r
276dcc1b 331 Called by the low layer protocol to deliver received data to socket layer.\r
332 \r
dfc1f033 333 This function will append the data to the socket receive buffer, set ther \r
334 urgent data length and then check if any receive token can be signaled.\r
335\r
336 @param Sock Pointer to the socket.\r
337 @param NetBuffer Pointer to the buffer that contains the received\r
338 data.\r
339 @param UrgLen The length of the urgent data in the received data.\r
340\r
341**/\r
83cbd279 342VOID\r
343SockDataRcvd (\r
77f00155 344 IN SOCKET *Sock,\r
345 IN OUT NET_BUF *NetBuffer,\r
346 IN UINT32 UrgLen\r
83cbd279 347 );\r
348\r
dfc1f033 349/**\r
350 Get the length of the free space of the specific socket buffer.\r
351\r
352 @param Sock Pointer to the socket.\r
353 @param Which Flag to indicate which socket buffer to check,\r
354 either send buffer or receive buffer.\r
355\r
356 @return The length of the free space, in bytes.\r
357\r
358**/\r
83cbd279 359UINT32\r
360SockGetFreeSpace (\r
dfc1f033 361 IN SOCKET *Sock,\r
362 IN UINT32 Which\r
83cbd279 363 );\r
364\r
dfc1f033 365/**\r
366 Clone a new socket including its associated protocol control block.\r
367\r
368 @param Sock Pointer to the socket to be cloned.\r
369\r
370 @return Pointer to the newly cloned socket. If NULL, error condition occurred.\r
371\r
372**/\r
373SOCKET *\r
83cbd279 374SockClone (\r
375 IN SOCKET *Sock\r
376 );\r
377\r
dfc1f033 378/**\r
379 Signal the receive token with the specific error or\r
380 set socket error code after error is received.\r
381\r
382 @param Sock Pointer to the socket.\r
383 @param Error The error code received.\r
384\r
385**/\r
83cbd279 386VOID\r
387SockRcvdErr (\r
77f00155 388 IN OUT SOCKET *Sock,\r
389 IN EFI_STATUS Error\r
83cbd279 390 );\r
391\r
dfc1f033 392///\r
393/// Proto type of the create callback\r
394///\r
4f6e31e4 395typedef\r
396EFI_STATUS\r
397(*SOCK_CREATE_CALLBACK) (\r
398 IN SOCKET *This,\r
399 IN VOID *Context\r
400 );\r
dfc1f033 401 \r
402///\r
403/// Proto type of the destroy callback \r
404///\r
4f6e31e4 405typedef\r
406VOID\r
407(*SOCK_DESTROY_CALLBACK) (\r
408 IN SOCKET *This,\r
409 IN VOID *Context\r
410 );\r
411\r
dfc1f033 412///\r
413/// The initialize data for create a new socket.\r
414///\r
4f6e31e4 415typedef struct _SOCK_INIT_DATA {\r
416 SOCK_TYPE Type;\r
417 SOCK_STATE State;\r
418\r
dfc1f033 419 SOCKET *Parent; ///< The parent of this socket\r
420 UINT32 BackLog; ///< The connection limit for listening socket\r
421 UINT32 SndBufferSize; ///< The high warter mark of send buffer\r
422 UINT32 RcvBufferSize; ///< The high warter mark of receive buffer\r
423 VOID *Protocol; ///< The pointer to protocol function template\r
424 ///< wanted to install on socket\r
4f6e31e4 425\r
426 //\r
427 // Callbacks after socket is created and before socket is to be destroyed.\r
428 //\r
dfc1f033 429 SOCK_CREATE_CALLBACK CreateCallback; ///< Callback after created\r
430 SOCK_DESTROY_CALLBACK DestroyCallback; ///< Callback before destroied\r
431 VOID *Context; ///< The context of the callback\r
4f6e31e4 432\r
433 //\r
434 // Opaque protocol data.\r
435 //\r
436 VOID *ProtoData;\r
437 UINT32 DataSize;\r
438\r
dfc1f033 439 SOCK_PROTO_HANDLER ProtoHandler; ///< The handler of protocol for socket request\r
4f6e31e4 440\r
dfc1f033 441 EFI_HANDLE DriverBinding; ///< The driver binding handle\r
4f6e31e4 442} SOCK_INIT_DATA;\r
85511ddf 443\r
dfc1f033 444///\r
445/// The union type of TCP and UDP protocol.\r
446/// \r
447typedef union _NET_PROTOCOL {\r
448 EFI_TCP4_PROTOCOL TcpProtocol; ///< Tcp protocol\r
449 EFI_UDP4_PROTOCOL UdpProtocol; ///< Udp protocol\r
85511ddf 450} NET_PROTOCOL;\r
dfc1f033 451\r
452///\r
453/// The socket structure representing a network service access point\r
454///\r
83cbd279 455struct _SOCKET {\r
456\r
457 //\r
dfc1f033 458 // Socket description information\r
83cbd279 459 //\r
dfc1f033 460 UINT32 Signature; ///< Signature of the socket\r
461 EFI_HANDLE SockHandle; ///< The virtual handle of the socket\r
462 EFI_HANDLE DriverBinding; ///< Socket's driver binding protocol\r
83cbd279 463 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
464 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
e48e37fc 465 LIST_ENTRY Link; \r
83cbd279 466 SOCK_CONFIGURE_STATE ConfigureState;\r
467 SOCK_TYPE Type;\r
468 SOCK_STATE State;\r
469 UINT16 Flag;\r
dfc1f033 470 EFI_LOCK Lock; ///< The lock of socket\r
471 SOCK_BUFFER SndBuffer; ///< Send buffer of application's data\r
472 SOCK_BUFFER RcvBuffer; ///< Receive buffer of received data\r
473 EFI_STATUS SockError; ///< The error returned by low layer protocol\r
83cbd279 474 BOOLEAN IsDestroyed;\r
475\r
476 //\r
dfc1f033 477 // Fields used to manage the connection request\r
83cbd279 478 //\r
dfc1f033 479 UINT32 BackLog; ///< the limit of connection to this socket\r
480 UINT32 ConnCnt; ///< the current count of connections to it\r
481 SOCKET *Parent; ///< listening parent that accept the connection\r
482 LIST_ENTRY ConnectionList; ///< the connections maintained by this socket\r
483 \r
83cbd279 484 //\r
dfc1f033 485 // The queue to buffer application's asynchronous token\r
83cbd279 486 //\r
e48e37fc 487 LIST_ENTRY ListenTokenList;\r
488 LIST_ENTRY RcvTokenList;\r
489 LIST_ENTRY SndTokenList;\r
490 LIST_ENTRY ProcessingSndTokenList;\r
83cbd279 491\r
dfc1f033 492 SOCK_COMPLETION_TOKEN *ConnectionToken; ///< app's token to signal if connected\r
493 SOCK_COMPLETION_TOKEN *CloseToken; ///< app's token to signal if closed\r
83cbd279 494\r
495 //\r
dfc1f033 496 // Interface for low level protocol\r
83cbd279 497 //\r
dfc1f033 498 SOCK_PROTO_HANDLER ProtoHandler; ///< The request handler of protocol\r
499 UINT8 ProtoReserved[PROTO_RESERVED_LEN]; ///< Data fields reserved for protocol\r
500 NET_PROTOCOL NetProtocol; ///< TCP or UDP protocol socket used\r
4f6e31e4 501\r
502 //\r
dfc1f033 503 // Callbacks after socket is created and before socket is to be destroyed.\r
4f6e31e4 504 //\r
dfc1f033 505 SOCK_CREATE_CALLBACK CreateCallback; ///< Callback after created\r
506 SOCK_DESTROY_CALLBACK DestroyCallback; ///< Callback before destroied\r
507 VOID *Context; ///< The context of the callback\r
83cbd279 508};\r
509\r
dfc1f033 510///\r
511/// The token structure buffered in socket layer.\r
512///\r
83cbd279 513typedef struct _SOCK_TOKEN {\r
dfc1f033 514 LIST_ENTRY TokenList; ///< The entry to add in the token list\r
515 SOCK_COMPLETION_TOKEN *Token; ///< The application's token\r
516 UINT32 RemainDataLen; ///< Unprocessed data length\r
517 SOCKET *Sock; ///< The poninter to the socket this token\r
518 ///< belongs to\r
83cbd279 519} SOCK_TOKEN;\r
520\r
dfc1f033 521///\r
522/// Reserved data to access the NET_BUF delivered by UDP driver.\r
523///\r
83cbd279 524typedef struct _UDP_RSV_DATA {\r
525 EFI_TIME TimeStamp;\r
526 EFI_UDP4_SESSION_DATA Session;\r
527} UDP_RSV_DATA;\r
528\r
dfc1f033 529///\r
530/// Reserved data to access the NET_BUF delivered by TCP driver.\r
531///\r
83cbd279 532typedef struct _TCP_RSV_DATA {\r
533 UINT32 UrgLen;\r
534} TCP_RSV_DATA;\r
535\r
dfc1f033 536/**\r
537 Create a socket and its associated protocol control block\r
538 with the intial data SockInitData and protocol specific\r
539 data ProtoData.\r
540\r
541 @param SockInitData Inital data to setting the socket.\r
542 \r
543 @return Pointer to the newly created socket. If NULL, error condition occured.\r
544\r
545**/\r
546SOCKET *\r
83cbd279 547SockCreateChild (\r
4f6e31e4 548 IN SOCK_INIT_DATA *SockInitData\r
83cbd279 549 );\r
550\r
dfc1f033 551/**\r
552 Destory the socket Sock and its associated protocol control block.\r
553\r
554 @param Sock The socket to be destroyed.\r
555\r
556 @retval EFI_SUCCESS The socket Sock is destroyed successfully.\r
557 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
558\r
559**/\r
83cbd279 560EFI_STATUS\r
561SockDestroyChild (\r
dfc1f033 562 IN SOCKET *Sock\r
83cbd279 563 );\r
564\r
dfc1f033 565/**\r
566 Configure the specific socket Sock using configuration data ConfigData.\r
567\r
568 @param Sock Pointer to the socket to be configured.\r
569 @param ConfigData Pointer to the configuration data.\r
570\r
571 @retval EFI_SUCCESS The socket is configured successfully.\r
572 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket or the\r
573 socket is already configured.\r
574\r
575**/\r
83cbd279 576EFI_STATUS\r
577SockConfigure (\r
578 IN SOCKET *Sock,\r
579 IN VOID *ConfigData\r
580 );\r
581\r
dfc1f033 582/**\r
583 Initiate a connection establishment process.\r
584\r
585 @param Sock Pointer to the socket to initiate the initate the\r
586 connection.\r
587 @param Token Pointer to the token used for the connection\r
588 operation.\r
589\r
590 @retval EFI_SUCCESS The connection is initialized successfully.\r
591 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
592 socket is closed, or the socket is not configured to\r
593 be an active one, or the token is already in one of\r
594 this socket's lists.\r
595 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
596 finished.\r
597 @retval EFI_NOT_STARTED The socket is not configured.\r
598\r
599**/\r
83cbd279 600EFI_STATUS\r
601SockConnect (\r
602 IN SOCKET *Sock,\r
603 IN VOID *Token\r
604 );\r
605\r
dfc1f033 606/**\r
607 Issue a listen token to get an existed connected network instance\r
608 or wait for a connection if there is none.\r
609\r
610 @param Sock Pointer to the socket to accept connections.\r
611 @param Token The token to accept a connection.\r
612\r
613 @retval EFI_SUCCESS Either a connection is accpeted or the Token is\r
614 buffered for further acception.\r
615 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
616 socket is closed, or the socket is not configured to\r
617 be a passive one, or the token is already in one of\r
618 this socket's lists.\r
619 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
620 finished.\r
621 @retval EFI_NOT_STARTED The socket is not configured.\r
622 @retval EFI_OUT_OF_RESOURCE Failed to buffer the Token due to memory limit.\r
623\r
624**/\r
83cbd279 625EFI_STATUS\r
626SockAccept (\r
627 IN SOCKET *Sock,\r
628 IN VOID *Token\r
629 );\r
630\r
dfc1f033 631/**\r
632 Issue a token with data to the socket to send out.\r
633\r
634 @param Sock Pointer to the socket to process the token with\r
635 data.\r
636 @param Token The token with data that needs to send out.\r
637\r
638 @retval EFI_SUCCESS The token is processed successfully.\r
639 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
640 socket is closed, or the socket is not in a\r
641 synchronized state , or the token is already in one\r
642 of this socket's lists.\r
643 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
644 finished.\r
645 @retval EFI_NOT_STARTED The socket is not configured.\r
646 @retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.\r
647\r
648**/\r
83cbd279 649EFI_STATUS\r
650SockSend (\r
651 IN SOCKET *Sock,\r
652 IN VOID *Token\r
653 );\r
654\r
dfc1f033 655/**\r
656 Issue a token to get data from the socket.\r
657\r
658 @param Sock Pointer to the socket to get data from.\r
659 @param Token The token to store the received data from the\r
660 socket.\r
661\r
662 @retval EFI_SUCCESS The token is processed successfully.\r
663 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
664 socket is closed, or the socket is not in a\r
665 synchronized state , or the token is already in one\r
666 of this socket's lists.\r
667 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
668 finished.\r
669 @retval EFI_NOT_STARTED The socket is not configured.\r
670 @retval EFI_CONNECTION_FIN The connection is closed and there is no more data.\r
671 @retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.\r
672\r
673**/\r
83cbd279 674EFI_STATUS\r
675SockRcv (\r
676 IN SOCKET *Sock,\r
677 IN VOID *Token\r
678 );\r
679\r
dfc1f033 680/**\r
681 Reset the socket and its associated protocol control block.\r
682\r
683 @param Sock Pointer to the socket to be flushed.\r
684\r
685 @retval EFI_SUCCESS The socket is flushed successfully.\r
686 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
687\r
688**/\r
83cbd279 689EFI_STATUS\r
690SockFlush (\r
691 IN SOCKET *Sock\r
692 );\r
693\r
dfc1f033 694/**\r
695 Close or abort the socket associated connection.\r
696\r
697 @param Sock Pointer to the socket of the connection to close or\r
698 abort.\r
699 @param Token The token for close operation.\r
700 @param OnAbort TRUE for aborting the connection, FALSE to close it.\r
701\r
702 @retval EFI_SUCCESS The close or abort operation is initialized\r
703 successfully.\r
704 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
705 socket is closed, or the socket is not in a\r
706 synchronized state , or the token is already in one\r
707 of this socket's lists.\r
708 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
709 finished.\r
710 @retval EFI_NOT_STARTED The socket is not configured.\r
711\r
712**/\r
83cbd279 713EFI_STATUS\r
714SockClose (\r
715 IN SOCKET *Sock,\r
716 IN VOID *Token,\r
717 IN BOOLEAN OnAbort\r
718 );\r
719\r
dfc1f033 720/**\r
721 Get the mode data of the low layer protocol.\r
722\r
723 @param Sock Pointer to the socket to get mode data from.\r
724 @param Mode Pointer to the data to store the low layer mode\r
725 information.\r
726\r
727 @retval EFI_SUCCESS The mode data is got successfully.\r
728 @retval EFI_NOT_STARTED The socket is not configured.\r
729\r
730**/\r
83cbd279 731EFI_STATUS\r
732SockGetMode (\r
276dcc1b 733 IN SOCKET *Sock,\r
734 IN OUT VOID *Mode\r
83cbd279 735 );\r
736\r
dfc1f033 737/**\r
738 Configure the low level protocol to join a multicast group for\r
739 this socket's connection.\r
740\r
741 @param Sock Pointer to the socket of the connection to join the\r
742 specific multicast group.\r
743 @param GroupInfo Pointer to the multicast group info.\r
744\r
745 @retval EFI_SUCCESS The configuration is done successfully.\r
746 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
747 @retval EFI_NOT_STARTED The socket is not configured.\r
748\r
749**/\r
83cbd279 750EFI_STATUS\r
751SockGroup (\r
752 IN SOCKET *Sock,\r
753 IN VOID *GroupInfo\r
754 );\r
755\r
dfc1f033 756/**\r
757 Add or remove route information in IP route table associated\r
758 with this socket.\r
759\r
760 @param Sock Pointer to the socket associated with the IP route\r
761 table to operate on.\r
762 @param RouteInfo Pointer to the route information to be processed.\r
763\r
764 @retval EFI_SUCCESS The route table is updated successfully.\r
765 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
766 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
767 finished.\r
768 @retval EFI_NOT_STARTED The socket is not configured.\r
769\r
770**/\r
83cbd279 771EFI_STATUS\r
772SockRoute (\r
773 IN SOCKET *Sock,\r
774 IN VOID *RouteInfo\r
775 );\r
776\r
777//\r
778// Supporting function to operate on socket buffer\r
779//\r
dfc1f033 780\r
781/**\r
782 Get the first buffer block in the specific socket buffer.\r
783\r
784 @param Sockbuf Pointer to the socket buffer.\r
785\r
786 @return Pointer to the first buffer in the queue. NULL if the queue is empty.\r
787\r
788**/\r
83cbd279 789NET_BUF *\r
790SockBufFirst (\r
791 IN SOCK_BUFFER *Sockbuf\r
792 );\r
793\r
dfc1f033 794/**\r
795 Get the next buffer block in the specific socket buffer.\r
796\r
797 @param Sockbuf Pointer to the socket buffer.\r
798 @param SockEntry Pointer to the buffer block prior to the required\r
799 one.\r
800\r
801 @return Pointer to the buffer block next to SockEntry. NULL if SockEntry is \r
802 the tail or head entry.\r
803\r
804**/\r
83cbd279 805NET_BUF *\r
806SockBufNext (\r
807 IN SOCK_BUFFER *Sockbuf,\r
808 IN NET_BUF *SockEntry\r
809 );\r
810\r
811#endif\r