]> git.proxmox.com Git - mirror_edk2.git/blame - StdLib/BsdSocketLib/SocketInternals.h
Don't install FV protocol on the corrupt FV image.
[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
39f4382a 28#include <Efi/SysEfi.h>\r
d7ce7006 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
a88c3163 60 @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if\r
d7ce7006 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
a88c3163 74 The BslSocketClose routine is called indirectly from the close file\r
75 system routine. This routine closes the socket and returns the\r
76 status to the caller.\r
77\r
78 @param[in] pDescriptor Descriptor address for the file\r
d7ce7006 79\r
7dc13291 80 @return This routine returns 0 upon success and -1 upon failure.\r
a88c3163 81 In the case of failure, ::errno contains more information.\r
d7ce7006 82\r
83**/\r
a88c3163 84int\r
d7ce7006 85BslSocketClose (\r
86 struct __filedes * pDescriptor\r
87 );\r
88\r
89/**\r
90 Worker routine to close the socket.\r
91\r
a88c3163 92 @param[in] pSocketProtocol Socket protocol structure address\r
d7ce7006 93\r
a88c3163 94 @param[in] pErrno Address of the ::errno variable\r
d7ce7006 95\r
96 @retval EFI_SUCCESS Successfully closed the socket\r
97\r
98**/\r
99EFI_STATUS\r
100BslSocketCloseWork (\r
101 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
102 IN int * pErrno\r
103 );\r
104\r
105/**\r
106 Poll the socket for activity\r
107\r
108 @param [in] pDescriptor Descriptor address for the file\r
109\r
110 @param [in] Events Mask of events to detect\r
111\r
7dc13291 112 @return Detected events for the socket\r
d7ce7006 113\r
114 **/\r
115short\r
116BslSocketPoll (\r
117 IN struct __filedes * pDescriptor,\r
118 IN short Events\r
119 );\r
120\r
121/**\r
122 Build a file descriptor for a socket.\r
123\r
124 @param [in] pSocketProtocol Socket protocol structure address\r
39f4382a 125\r
d7ce7006 126 @param [in] pErrno Address of the errno variable\r
127\r
7dc13291 128 @return The file descriptor for the socket or -1 if an error occurs.\r
d7ce7006 129\r
130 **/\r
131int\r
132BslSocketProtocolToFd (\r
133 IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
134 IN int * pErrno\r
135 );\r
136\r
137/**\r
138 Read support routine for sockets\r
139\r
a88c3163 140 The BslSocketRead routine is called indirectly by the read file\r
141 system routine. This routine is typically used for SOCK_STREAM\r
142 because it waits for receive data from the target system specified\r
143 in the ::connect call.\r
144\r
d7ce7006 145 @param [in] pDescriptor Descriptor address for the file\r
146 @param [in] pOffset File offset\r
147 @param [in] LengthInBytes Number of bytes to read\r
148 @param [in] pBuffer Address of the buffer to receive the data\r
149\r
7dc13291 150 @return The number of bytes read or -1 if an error occurs.\r
a88c3163 151 In the case of an error, ::errno contains more details.\r
d7ce7006 152\r
153**/\r
154ssize_t\r
155BslSocketRead (\r
156 struct __filedes *pDescriptor,\r
157 off_t * pOffset,\r
158 size_t LengthInBytes,\r
159 void * pBuffer\r
160 );\r
161\r
162/**\r
163 Write support routine for sockets\r
164\r
165 @param [in] pDescriptor Descriptor address for the file\r
166 @param [in] pOffset File offset\r
167 @param [in] LengthInBytes Number of bytes to write\r
168 @param [in] pBuffer Address of the data\r
169\r
7dc13291 170 @return The number of bytes written or -1 if an error occurs.\r
a88c3163 171 In the case of an error, ::errno contains more details.\r
d7ce7006 172\r
173**/\r
174ssize_t\r
175BslSocketWrite (\r
176 struct __filedes *pDescriptor,\r
177 off_t * pOffset,\r
178 size_t LengthInBytes,\r
179 const void * pBuffer\r
180 );\r
181\r
182/**\r
183 Validate the socket's file descriptor\r
184\r
185 @param [in] pDescriptor Descriptor for the file\r
186\r
187 @param [in] pErrno Address of the errno variable\r
188\r
a88c3163 189 @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if\r
d7ce7006 190 an invalid file descriptor was passed in.\r
191\r
192 **/\r
193EFI_SOCKET_PROTOCOL *\r
194BslValidateSocketFd (\r
195 struct __filedes * pDescriptor,\r
196 int * pErrno\r
197 );\r
198\r
199//------------------------------------------------------------------------------\r
200\r
201#endif // _SOCKET_INTERNALS_H_\r