]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/SocketInternals.h
Fix send to properly wait while long transmits are in progress
[mirror_edk2.git] / StdLib / BsdSocketLib / SocketInternals.h
CommitLineData
d7ce7006 1/** @file\r
2 Definitions for the socket library.\r
3\r
4 Copyright (c) 2011, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _SOCKET_INTERNALS_H_\r
16#define _SOCKET_INTERNALS_H_\r
17\r
18#include <Uefi.h>\r
19\r
20//----------------------------------------------------------------------\r
21//\r
22// The following private files are required to support file descriptors\r
23//\r
24\r
25#include <kfile.h>\r
26#include <MainData.h>\r
27\r
28#include <efi/SysEfi.h>\r
29\r
30//\r
31// End of private files\r
32//\r
33//----------------------------------------------------------------------\r
34\r
35#include <Library/DebugLib.h>\r
36#include <Library/UefiBootServicesTableLib.h>\r
37#include <Library/UefiLib.h>\r
38\r
39#include <Protocol/EfiSocket.h>\r
40#include <Protocol/ServiceBinding.h>\r
41\r
42#include <sys/errno.h>\r
43#include <sys/poll.h>\r
44#include <sys/EfiSysCall.h>\r
45#include <sys/socket.h>\r
46\r
47//------------------------------------------------------------------------------\r
48// Support Routines\r
49//------------------------------------------------------------------------------\r
50\r
51/**\r
52 Translate from the socket file descriptor to the socket protocol.\r
53\r
54 @param [in] s Socket file descriptor returned from ::socket.\r
55\r
56 @param [in] ppDescriptor Address to receive the descriptor structure\r
57 address for the file\r
58 @param [in] pErrno Address of the errno variable\r
59\r
60 @returns A pointer to the socket protocol structure or NULL if\r
61 an invalid file descriptor was passed in.\r
62\r
63 **/\r
64EFI_SOCKET_PROTOCOL *\r
65BslFdToSocketProtocol (\r
66 int s,\r
67 struct __filedes ** ppDescriptor,\r
68 int * pErrno\r
69 );\r
70\r
71/**\r
72 Close the socket\r
73\r
74 @param [in] pDescriptor Descriptor address for the file\r
75\r
76 @returns This routine returns 0 upon success and -1 upon failure.\r
77 In the case of failure, errno contains more information.\r
78\r
79**/\r
80INT32\r
81BslSocketClose (\r
82 struct __filedes * pDescriptor\r
83 );\r
84\r
85/**\r
86 Worker routine to close the socket.\r
87\r
88 @param [in] pSocketProtocol Socket protocol structure address\r
89\r
90 @param [in] pErrno Address of the errno variable\r
91\r
92 @retval EFI_SUCCESS Successfully closed the socket\r
93\r
94**/\r
95EFI_STATUS\r
96BslSocketCloseWork (\r
97 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
98 IN int * pErrno\r
99 );\r
100\r
101/**\r
102 Poll the socket for activity\r
103\r
104 @param [in] pDescriptor Descriptor address for the file\r
105\r
106 @param [in] Events Mask of events to detect\r
107\r
108 @returns Detected events for the socket\r
109\r
110 **/\r
111short\r
112BslSocketPoll (\r
113 IN struct __filedes * pDescriptor,\r
114 IN short Events\r
115 );\r
116\r
117/**\r
118 Build a file descriptor for a socket.\r
119\r
120 @param [in] pSocketProtocol Socket protocol structure address\r
121 \r
122 @param [in] pErrno Address of the errno variable\r
123\r
124 @returns The file descriptor for the socket or -1 if an error occurs.\r
125\r
126 **/\r
127int\r
128BslSocketProtocolToFd (\r
129 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
130 IN int * pErrno\r
131 );\r
132\r
133/**\r
134 Read support routine for sockets\r
135\r
136 @param [in] pDescriptor Descriptor address for the file\r
137 @param [in] pOffset File offset\r
138 @param [in] LengthInBytes Number of bytes to read\r
139 @param [in] pBuffer Address of the buffer to receive the data\r
140\r
141 @returns The number of bytes read or -1 if an error occurs.\r
142\r
143**/\r
144ssize_t\r
145BslSocketRead (\r
146 struct __filedes *pDescriptor,\r
147 off_t * pOffset,\r
148 size_t LengthInBytes,\r
149 void * pBuffer\r
150 );\r
151\r
152/**\r
153 Write support routine for sockets\r
154\r
155 @param [in] pDescriptor Descriptor address for the file\r
156 @param [in] pOffset File offset\r
157 @param [in] LengthInBytes Number of bytes to write\r
158 @param [in] pBuffer Address of the data\r
159\r
160 @returns The number of bytes written or -1 if an error occurs.\r
161\r
162**/\r
163ssize_t\r
164BslSocketWrite (\r
165 struct __filedes *pDescriptor,\r
166 off_t * pOffset,\r
167 size_t LengthInBytes,\r
168 const void * pBuffer\r
169 );\r
170\r
171/**\r
172 Validate the socket's file descriptor\r
173\r
174 @param [in] pDescriptor Descriptor for the file\r
175\r
176 @param [in] pErrno Address of the errno variable\r
177\r
178 @returns A pointer to the socket protocol structure or NULL if\r
179 an invalid file descriptor was passed in.\r
180\r
181 **/\r
182EFI_SOCKET_PROTOCOL *\r
183BslValidateSocketFd (\r
184 struct __filedes * pDescriptor,\r
185 int * pErrno\r
186 );\r
187\r
188//------------------------------------------------------------------------------\r
189\r
190#endif // _SOCKET_INTERNALS_H_\r