]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h
Fixing function headers.
[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 buffer structure of rcvd data and send data used by socket.\r
202///\r
203typedef struct _SOCK_BUFFER {\r
204 UINT32 HighWater; ///< The buffersize upper limit of sock_buffer\r
205 UINT32 LowWater; ///< The low warter mark of sock_buffer\r
206 NET_BUF_QUEUE *DataQueue; ///< The queue to buffer data\r
207} SOCK_BUFFER;\r
208\r
209/**\r
210 The handler of protocol for request from socket.\r
211 \r
212 @param Socket The socket issuing the request to protocol\r
213 @param Request The request issued by socket\r
214 @param RequestData The request related data\r
215 \r
216 @retval EFI_SUCCESS The socket request is completed successfully.\r
217 @retval other The error status returned by the corresponding TCP\r
218 layer function.\r
219 \r
220**/\r
221typedef\r
222EFI_STATUS\r
223(*SOCK_PROTO_HANDLER) (\r
224 IN SOCKET *Socket,\r
225 IN SOCK_REQUEST Request,\r
226 IN VOID *RequestData\r
227 );\r
228 \r
229 \r
230//\r
231// Socket provided oprerations for low layer protocol\r
232//\r
233\r
234//\r
235// Socket provided operations for user interface\r
236//\r
237\r
238/**\r
239 Set the state of the socket.\r
240\r
241 @param Sock Pointer to the socket.\r
242 @param State The new state to be set.\r
243\r
244**/\r
245VOID\r
246SockSetState (\r
247 IN SOCKET *Sock,\r
248 IN SOCK_STATE State\r
249 );\r
250\r
251/**\r
252 Called by the low layer protocol to indicate the socket a connection is \r
253 established. \r
254 \r
255 This function just changes the socket's state to SO_CONNECTED \r
256 and signals the token used for connection establishment.\r
257\r
258 @param Sock Pointer to the socket associated with the\r
259 established connection.\r
260 \r
261**/\r
262VOID\r
263SockConnEstablished (\r
264 IN SOCKET *Sock\r
265 );\r
266\r
267/**\r
268 Called by the low layer protocol to indicate the connection is closed.\r
269 \r
270 This function flushes the socket, sets the state to SO_CLOSED and signals \r
271 the close token.\r
272\r
273 @param Sock Pointer to the socket associated with the closed\r
274 connection.\r
275 \r
276**/\r
277VOID\r
278SockConnClosed (\r
279 IN SOCKET *Sock\r
280 );\r
281\r
282/**\r
283 Called by low layer protocol to indicate that some data is sent or processed.\r
284 \r
285 This function trims the sent data in the socket send buffer, signals the data \r
286 token if proper.\r
287\r
288 @param Sock Pointer to the socket.\r
289 @param Count The length of the data processed or sent, in bytes.\r
290\r
291**/\r
292VOID\r
293SockDataSent (\r
294 IN SOCKET *Sock,\r
295 IN UINT32 Count\r
296 );\r
297\r
298/**\r
299 Called by the low layer protocol to copy some data in socket send\r
300 buffer starting from the specific offset to a buffer provided by\r
301 the caller.\r
302\r
303 @param Sock Pointer to the socket.\r
304 @param Offset The start point of the data to be copied.\r
305 @param Len The length of the data to be copied.\r
306 @param Dest Pointer to the destination to copy the data.\r
307\r
308 @return The data size copied.\r
309\r
310**/\r
311UINT32\r
312SockGetDataToSend (\r
313 IN SOCKET *Sock,\r
314 IN UINT32 Offset,\r
315 IN UINT32 Len,\r
316 IN UINT8 *Dest\r
317 );\r
318\r
319/**\r
320 Called by the low layer protocol to indicate that there\r
321 will be no more data from the communication peer.\r
322 \r
323 This function set the socket's state to SO_NO_MORE_DATA and\r
324 signal all queued IO tokens with the error status EFI_CONNECTION_FIN.\r
325\r
326 @param Sock Pointer to the socket.\r
327\r
328**/\r
329VOID\r
330SockNoMoreData (\r
331 IN SOCKET *Sock\r
332 );\r
333\r
334/**\r
335 Called by the low layer protocol to deliver received data to socket layer.\r
336 \r
337 This function will append the data to the socket receive buffer, set ther \r
338 urgent data length and then check if any receive token can be signaled.\r
339\r
340 @param Sock Pointer to the socket.\r
341 @param NetBuffer Pointer to the buffer that contains the received\r
342 data.\r
343 @param UrgLen The length of the urgent data in the received data.\r
344\r
345**/\r
346VOID\r
347SockDataRcvd (\r
348 IN SOCKET *Sock,\r
349 IN NET_BUF *NetBuffer,\r
350 IN UINT32 UrgLen\r
351 );\r
352\r
353/**\r
354 Get the length of the free space of the specific socket buffer.\r
355\r
356 @param Sock Pointer to the socket.\r
357 @param Which Flag to indicate which socket buffer to check,\r
358 either send buffer or receive buffer.\r
359\r
360 @return The length of the free space, in bytes.\r
361\r
362**/\r
363UINT32\r
364SockGetFreeSpace (\r
365 IN SOCKET *Sock,\r
366 IN UINT32 Which\r
367 );\r
368\r
369/**\r
370 Clone a new socket including its associated protocol control block.\r
371\r
372 @param Sock Pointer to the socket to be cloned.\r
373\r
374 @return Pointer to the newly cloned socket. If NULL, error condition occurred.\r
375\r
376**/\r
377SOCKET *\r
378SockClone (\r
379 IN SOCKET *Sock\r
380 );\r
381\r
382/**\r
383 Signal the receive token with the specific error or\r
384 set socket error code after error is received.\r
385\r
386 @param Sock Pointer to the socket.\r
387 @param Error The error code received.\r
388\r
389**/\r
390VOID\r
391SockRcvdErr (\r
392 IN SOCKET *Sock,\r
393 IN EFI_STATUS Error\r
394 );\r
395\r
396///\r
397/// Proto type of the create callback\r
398///\r
399typedef\r
400EFI_STATUS\r
401(*SOCK_CREATE_CALLBACK) (\r
402 IN SOCKET *This,\r
403 IN VOID *Context\r
404 );\r
405 \r
406///\r
407/// Proto type of the destroy callback \r
408///\r
409typedef\r
410VOID\r
411(*SOCK_DESTROY_CALLBACK) (\r
412 IN SOCKET *This,\r
413 IN VOID *Context\r
414 );\r
415\r
416///\r
417/// The initialize data for create a new socket.\r
418///\r
419typedef struct _SOCK_INIT_DATA {\r
420 SOCK_TYPE Type;\r
421 SOCK_STATE State;\r
422\r
423 SOCKET *Parent; ///< The parent of this socket\r
424 UINT32 BackLog; ///< The connection limit for listening socket\r
425 UINT32 SndBufferSize; ///< The high warter mark of send buffer\r
426 UINT32 RcvBufferSize; ///< The high warter mark of receive buffer\r
427 VOID *Protocol; ///< The pointer to protocol function template\r
428 ///< wanted to install on socket\r
429\r
430 //\r
431 // Callbacks after socket is created and before socket is to be destroyed.\r
432 //\r
433 SOCK_CREATE_CALLBACK CreateCallback; ///< Callback after created\r
434 SOCK_DESTROY_CALLBACK DestroyCallback; ///< Callback before destroied\r
435 VOID *Context; ///< The context of the callback\r
436\r
437 //\r
438 // Opaque protocol data.\r
439 //\r
440 VOID *ProtoData;\r
441 UINT32 DataSize;\r
442\r
443 SOCK_PROTO_HANDLER ProtoHandler; ///< The handler of protocol for socket request\r
444\r
445 EFI_HANDLE DriverBinding; ///< The driver binding handle\r
446} SOCK_INIT_DATA;\r
447\r
448///\r
449/// The union type of TCP and UDP protocol.\r
450/// \r
451typedef union _NET_PROTOCOL {\r
452 EFI_TCP4_PROTOCOL TcpProtocol; ///< Tcp protocol\r
453 EFI_UDP4_PROTOCOL UdpProtocol; ///< Udp protocol\r
454} NET_PROTOCOL;\r
455\r
456///\r
457/// The socket structure representing a network service access point\r
458///\r
459struct _SOCKET {\r
460\r
461 //\r
462 // Socket description information\r
463 //\r
464 UINT32 Signature; ///< Signature of the socket\r
465 EFI_HANDLE SockHandle; ///< The virtual handle of the socket\r
466 EFI_HANDLE DriverBinding; ///< Socket's driver binding protocol\r
467 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
468 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
469 LIST_ENTRY Link; \r
470 SOCK_CONFIGURE_STATE ConfigureState;\r
471 SOCK_TYPE Type;\r
472 SOCK_STATE State;\r
473 UINT16 Flag;\r
474 EFI_LOCK Lock; ///< The lock of socket\r
475 SOCK_BUFFER SndBuffer; ///< Send buffer of application's data\r
476 SOCK_BUFFER RcvBuffer; ///< Receive buffer of received data\r
477 EFI_STATUS SockError; ///< The error returned by low layer protocol\r
478 BOOLEAN IsDestroyed;\r
479\r
480 //\r
481 // Fields used to manage the connection request\r
482 //\r
483 UINT32 BackLog; ///< the limit of connection to this socket\r
484 UINT32 ConnCnt; ///< the current count of connections to it\r
485 SOCKET *Parent; ///< listening parent that accept the connection\r
486 LIST_ENTRY ConnectionList; ///< the connections maintained by this socket\r
487 \r
488 //\r
489 // The queue to buffer application's asynchronous token\r
490 //\r
491 LIST_ENTRY ListenTokenList;\r
492 LIST_ENTRY RcvTokenList;\r
493 LIST_ENTRY SndTokenList;\r
494 LIST_ENTRY ProcessingSndTokenList;\r
495\r
496 SOCK_COMPLETION_TOKEN *ConnectionToken; ///< app's token to signal if connected\r
497 SOCK_COMPLETION_TOKEN *CloseToken; ///< app's token to signal if closed\r
498\r
499 //\r
500 // Interface for low level protocol\r
501 //\r
502 SOCK_PROTO_HANDLER ProtoHandler; ///< The request handler of protocol\r
503 UINT8 ProtoReserved[PROTO_RESERVED_LEN]; ///< Data fields reserved for protocol\r
504 NET_PROTOCOL NetProtocol; ///< TCP or UDP protocol socket used\r
505\r
506 //\r
507 // Callbacks after socket is created and before socket is to be destroyed.\r
508 //\r
509 SOCK_CREATE_CALLBACK CreateCallback; ///< Callback after created\r
510 SOCK_DESTROY_CALLBACK DestroyCallback; ///< Callback before destroied\r
511 VOID *Context; ///< The context of the callback\r
512};\r
513\r
514///\r
515/// The token structure buffered in socket layer.\r
516///\r
517typedef struct _SOCK_TOKEN {\r
518 LIST_ENTRY TokenList; ///< The entry to add in the token list\r
519 SOCK_COMPLETION_TOKEN *Token; ///< The application's token\r
520 UINT32 RemainDataLen; ///< Unprocessed data length\r
521 SOCKET *Sock; ///< The poninter to the socket this token\r
522 ///< belongs to\r
523} SOCK_TOKEN;\r
524\r
525///\r
526/// Reserved data to access the NET_BUF delivered by UDP driver.\r
527///\r
528typedef struct _UDP_RSV_DATA {\r
529 EFI_TIME TimeStamp;\r
530 EFI_UDP4_SESSION_DATA Session;\r
531} UDP_RSV_DATA;\r
532\r
533///\r
534/// Reserved data to access the NET_BUF delivered by TCP driver.\r
535///\r
536typedef struct _TCP_RSV_DATA {\r
537 UINT32 UrgLen;\r
538} TCP_RSV_DATA;\r
539\r
540/**\r
541 Create a socket and its associated protocol control block\r
542 with the intial data SockInitData and protocol specific\r
543 data ProtoData.\r
544\r
545 @param SockInitData Inital data to setting the socket.\r
546 \r
547 @return Pointer to the newly created socket. If NULL, error condition occured.\r
548\r
549**/\r
550SOCKET *\r
551SockCreateChild (\r
552 IN SOCK_INIT_DATA *SockInitData\r
553 );\r
554\r
555/**\r
556 Destory the socket Sock and its associated protocol control block.\r
557\r
558 @param Sock The socket to be destroyed.\r
559\r
560 @retval EFI_SUCCESS The socket Sock is destroyed successfully.\r
561 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
562\r
563**/\r
564EFI_STATUS\r
565SockDestroyChild (\r
566 IN SOCKET *Sock\r
567 );\r
568\r
569/**\r
570 Configure the specific socket Sock using configuration data ConfigData.\r
571\r
572 @param Sock Pointer to the socket to be configured.\r
573 @param ConfigData Pointer to the configuration data.\r
574\r
575 @retval EFI_SUCCESS The socket is configured successfully.\r
576 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket or the\r
577 socket is already configured.\r
578\r
579**/\r
580EFI_STATUS\r
581SockConfigure (\r
582 IN SOCKET *Sock,\r
583 IN VOID *ConfigData\r
584 );\r
585\r
586/**\r
587 Initiate a connection establishment process.\r
588\r
589 @param Sock Pointer to the socket to initiate the initate the\r
590 connection.\r
591 @param Token Pointer to the token used for the connection\r
592 operation.\r
593\r
594 @retval EFI_SUCCESS The connection is initialized successfully.\r
595 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
596 socket is closed, or the socket is not configured to\r
597 be an active one, or the token is already in one of\r
598 this socket's lists.\r
599 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
600 finished.\r
601 @retval EFI_NOT_STARTED The socket is not configured.\r
602\r
603**/\r
604EFI_STATUS\r
605SockConnect (\r
606 IN SOCKET *Sock,\r
607 IN VOID *Token\r
608 );\r
609\r
610/**\r
611 Issue a listen token to get an existed connected network instance\r
612 or wait for a connection if there is none.\r
613\r
614 @param Sock Pointer to the socket to accept connections.\r
615 @param Token The token to accept a connection.\r
616\r
617 @retval EFI_SUCCESS Either a connection is accpeted or the Token is\r
618 buffered for further acception.\r
619 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
620 socket is closed, or the socket is not configured to\r
621 be a passive one, or the token is already in one of\r
622 this socket's lists.\r
623 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
624 finished.\r
625 @retval EFI_NOT_STARTED The socket is not configured.\r
626 @retval EFI_OUT_OF_RESOURCE Failed to buffer the Token due to memory limit.\r
627\r
628**/\r
629EFI_STATUS\r
630SockAccept (\r
631 IN SOCKET *Sock,\r
632 IN VOID *Token\r
633 );\r
634\r
635/**\r
636 Issue a token with data to the socket to send out.\r
637\r
638 @param Sock Pointer to the socket to process the token with\r
639 data.\r
640 @param Token The token with data that needs to send out.\r
641\r
642 @retval EFI_SUCCESS The token is processed successfully.\r
643 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
644 socket is closed, or the socket is not in a\r
645 synchronized state , or the token is already in one\r
646 of this socket's lists.\r
647 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
648 finished.\r
649 @retval EFI_NOT_STARTED The socket is not configured.\r
650 @retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.\r
651\r
652**/\r
653EFI_STATUS\r
654SockSend (\r
655 IN SOCKET *Sock,\r
656 IN VOID *Token\r
657 );\r
658\r
659/**\r
660 Issue a token to get data from the socket.\r
661\r
662 @param Sock Pointer to the socket to get data from.\r
663 @param Token The token to store the received data from the\r
664 socket.\r
665\r
666 @retval EFI_SUCCESS The token is processed successfully.\r
667 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
668 socket is closed, or the socket is not in a\r
669 synchronized state , or the token is already in one\r
670 of this socket's lists.\r
671 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
672 finished.\r
673 @retval EFI_NOT_STARTED The socket is not configured.\r
674 @retval EFI_CONNECTION_FIN The connection is closed and there is no more data.\r
675 @retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.\r
676\r
677**/\r
678EFI_STATUS\r
679SockRcv (\r
680 IN SOCKET *Sock,\r
681 IN VOID *Token\r
682 );\r
683\r
684/**\r
685 Reset the socket and its associated protocol control block.\r
686\r
687 @param Sock Pointer to the socket to be flushed.\r
688\r
689 @retval EFI_SUCCESS The socket is flushed successfully.\r
690 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
691\r
692**/\r
693EFI_STATUS\r
694SockFlush (\r
695 IN SOCKET *Sock\r
696 );\r
697\r
698/**\r
699 Close or abort the socket associated connection.\r
700\r
701 @param Sock Pointer to the socket of the connection to close or\r
702 abort.\r
703 @param Token The token for close operation.\r
704 @param OnAbort TRUE for aborting the connection, FALSE to close it.\r
705\r
706 @retval EFI_SUCCESS The close or abort operation is initialized\r
707 successfully.\r
708 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the\r
709 socket is closed, or the socket is not in a\r
710 synchronized state , or the token is already in one\r
711 of this socket's lists.\r
712 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
713 finished.\r
714 @retval EFI_NOT_STARTED The socket is not configured.\r
715\r
716**/\r
717EFI_STATUS\r
718SockClose (\r
719 IN SOCKET *Sock,\r
720 IN VOID *Token,\r
721 IN BOOLEAN OnAbort\r
722 );\r
723\r
724/**\r
725 Get the mode data of the low layer protocol.\r
726\r
727 @param Sock Pointer to the socket to get mode data from.\r
728 @param Mode Pointer to the data to store the low layer mode\r
729 information.\r
730\r
731 @retval EFI_SUCCESS The mode data is got successfully.\r
732 @retval EFI_NOT_STARTED The socket is not configured.\r
733\r
734**/\r
735EFI_STATUS\r
736SockGetMode (\r
737 IN SOCKET *Sock,\r
738 IN OUT VOID *Mode\r
739 );\r
740\r
741/**\r
742 Configure the low level protocol to join a multicast group for\r
743 this socket's connection.\r
744\r
745 @param Sock Pointer to the socket of the connection to join the\r
746 specific multicast group.\r
747 @param GroupInfo Pointer to the multicast group info.\r
748\r
749 @retval EFI_SUCCESS The configuration is done successfully.\r
750 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
751 @retval EFI_NOT_STARTED The socket is not configured.\r
752\r
753**/\r
754EFI_STATUS\r
755SockGroup (\r
756 IN SOCKET *Sock,\r
757 IN VOID *GroupInfo\r
758 );\r
759\r
760/**\r
761 Add or remove route information in IP route table associated\r
762 with this socket.\r
763\r
764 @param Sock Pointer to the socket associated with the IP route\r
765 table to operate on.\r
766 @param RouteInfo Pointer to the route information to be processed.\r
767\r
768 @retval EFI_SUCCESS The route table is updated successfully.\r
769 @retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.\r
770 @retval EFI_NO_MAPPING The IP address configuration operation is not\r
771 finished.\r
772 @retval EFI_NOT_STARTED The socket is not configured.\r
773\r
774**/\r
775EFI_STATUS\r
776SockRoute (\r
777 IN SOCKET *Sock,\r
778 IN VOID *RouteInfo\r
779 );\r
780\r
781//\r
782// Supporting function to operate on socket buffer\r
783//\r
784\r
785/**\r
786 Get the first buffer block in the specific socket buffer.\r
787\r
788 @param Sockbuf Pointer to the socket buffer.\r
789\r
790 @return Pointer to the first buffer in the queue. NULL if the queue is empty.\r
791\r
792**/\r
793NET_BUF *\r
794SockBufFirst (\r
795 IN SOCK_BUFFER *Sockbuf\r
796 );\r
797\r
798/**\r
799 Get the next buffer block in the specific socket buffer.\r
800\r
801 @param Sockbuf Pointer to the socket buffer.\r
802 @param SockEntry Pointer to the buffer block prior to the required\r
803 one.\r
804\r
805 @return Pointer to the buffer block next to SockEntry. NULL if SockEntry is \r
806 the tail or head entry.\r
807\r
808**/\r
809NET_BUF *\r
810SockBufNext (\r
811 IN SOCK_BUFFER *Sockbuf,\r
812 IN NET_BUF *SockEntry\r
813 );\r
814\r
815#endif\r