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