]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/TcpDxe/SockImpl.h
NetworkPkg: Fix potential ASSERT if NetIp4IsUnicast is called
[mirror_edk2.git] / NetworkPkg / TcpDxe / SockImpl.h
1 /** @file
2 The function declaration that provided for Socket Interface.
3
4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _SOCK_IMPL_H_
17 #define _SOCK_IMPL_H_
18
19 #include "Socket.h"
20 #include "TcpMain.h"
21
22 /**
23 Signal a event with the given status.
24
25 @param[in] Token The token's event is to be signaled.
26 @param[in] TokenStatus The status to be sent with the event.
27
28 **/
29 #define SIGNAL_TOKEN(Token, TokenStatus) \
30 do { \
31 (Token)->Status = (TokenStatus); \
32 gBS->SignalEvent ((Token)->Event); \
33 } while (0)
34
35 #define SOCK_HEADER_SPACE (60 + 60 + 72)
36
37 /**
38 Process the TCP send data, buffer the tcp txdata and append
39 the buffer to socket send buffer, then try to send it.
40
41 @param[in] Sock Pointer to the socket.
42 @param[in] TcpTxData Pointer to the application provided send buffer.
43
44 @retval EFI_SUCCESS The operation completed successfully.
45 @retval EFI_OUT_OF_RESOURCES Failed due to resource limits.
46
47 **/
48 EFI_STATUS
49 SockProcessTcpSndData (
50 IN SOCKET *Sock,
51 IN VOID *TcpTxData
52 );
53
54 /**
55 Get received data from the socket layer to the receive token.
56
57 @param[in, out] Sock Pointer to the socket.
58 @param[in, out] RcvToken Pointer to the application provided receive token.
59
60 @return The length of data received in this token.
61
62 **/
63 UINT32
64 SockProcessRcvToken (
65 IN OUT SOCKET *Sock,
66 IN OUT SOCK_IO_TOKEN *RcvToken
67 );
68
69 /**
70 Flush the sndBuffer and rcvBuffer of socket.
71
72 @param[in, out] Sock Pointer to the socket.
73
74 **/
75 VOID
76 SockConnFlush (
77 IN OUT SOCKET *Sock
78 );
79
80 /**
81 Cancel the tokens in the specific token list.
82
83 @param[in] Token Pointer to the Token. If NULL, all tokens
84 in SpecifiedTokenList will be canceled.
85 @param[in, out] SpecifiedTokenList Pointer to the token list to be checked.
86
87 @retval EFI_SUCCESS Cancel the tokens in the specific token listsuccessfully.
88 @retval EFI_NOT_FOUND The Token is not found in SpecifiedTokenList.
89
90 **/
91 EFI_STATUS
92 SockCancelToken (
93 IN SOCK_COMPLETION_TOKEN *Token,
94 IN OUT LIST_ENTRY *SpecifiedTokenList
95 );
96
97 /**
98 Create a socket with initial data SockInitData.
99
100 @param[in] SockInitData Pointer to the initial data of the socket.
101
102 @return Pointer to the newly created socket, return NULL when exception occured.
103
104 **/
105 SOCKET *
106 SockCreate (
107 IN SOCK_INIT_DATA *SockInitData
108 );
109
110 /**
111 Destroy a socket.
112
113 @param[in, out] Sock Pointer to the socket.
114
115 **/
116 VOID
117 SockDestroy (
118 IN OUT SOCKET *Sock
119 );
120
121 #endif