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