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