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