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