]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/SocketInternals.h
2 Definitions for the socket library.
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
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.
15 #ifndef _SOCKET_INTERNALS_H_
16 #define _SOCKET_INTERNALS_H_
20 //----------------------------------------------------------------------
22 // The following private files are required to support file descriptors
28 #include <Efi/SysEfi.h>
31 // End of private files
33 //----------------------------------------------------------------------
35 #include <Library/DebugLib.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/UefiLib.h>
39 #include <Protocol/EfiSocket.h>
40 #include <Protocol/ServiceBinding.h>
42 #include <sys/errno.h>
44 #include <sys/EfiSysCall.h>
45 #include <sys/socket.h>
47 //------------------------------------------------------------------------------
49 //------------------------------------------------------------------------------
52 Translate from the socket file descriptor to the socket protocol.
54 @param [in] s Socket file descriptor returned from ::socket.
56 @param [in] ppDescriptor Address to receive the descriptor structure
58 @param [in] pErrno Address of the errno variable
60 @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if
61 an invalid file descriptor was passed in.
65 BslFdToSocketProtocol (
67 struct __filedes
** ppDescriptor
,
74 The BslSocketClose routine is called indirectly from the close file
75 system routine. This routine closes the socket and returns the
78 @param[in] pDescriptor Descriptor address for the file
80 @return This routine returns 0 upon success and -1 upon failure.
81 In the case of failure, ::errno contains more information.
87 struct __filedes
* pDescriptor
91 Worker routine to close the socket.
93 @param[in] pSocketProtocol Socket protocol structure address
95 @param[in] pErrno Address of the ::errno variable
97 @retval EFI_SUCCESS Successfully closed the socket
102 IN EFI_SOCKET_PROTOCOL
* pSocketProtocol
,
107 Poll the socket for activity
109 @param [in] pDescriptor Descriptor address for the file
111 @param [in] Events Mask of events to detect
113 @return Detected events for the socket
119 IN
struct __filedes
* pDescriptor
,
124 Build a file descriptor for a socket.
126 @param [in] pSocketProtocol Socket protocol structure address
128 @param [in] pErrno Address of the errno variable
130 @return The file descriptor for the socket or -1 if an error occurs.
134 BslSocketProtocolToFd (
135 IN EFI_SOCKET_PROTOCOL
* pSocketProtocol
,
140 Read support routine for sockets
142 The BslSocketRead routine is called indirectly by the read file
143 system routine. This routine is typically used for SOCK_STREAM
144 because it waits for receive data from the target system specified
145 in the ::connect call.
147 @param [in] pDescriptor Descriptor address for the file
148 @param [in] pOffset File offset
149 @param [in] LengthInBytes Number of bytes to read
150 @param [in] pBuffer Address of the buffer to receive the data
152 @return The number of bytes read or -1 if an error occurs.
153 In the case of an error, ::errno contains more details.
159 struct __filedes
*pDescriptor
,
161 size_t LengthInBytes
,
166 Write support routine for sockets
168 @param [in] pDescriptor Descriptor address for the file
169 @param [in] pOffset File offset
170 @param [in] LengthInBytes Number of bytes to write
171 @param [in] pBuffer Address of the data
173 @return The number of bytes written or -1 if an error occurs.
174 In the case of an error, ::errno contains more details.
180 struct __filedes
*pDescriptor
,
182 size_t LengthInBytes
,
187 Validate the socket's file descriptor
189 @param [in] pDescriptor Descriptor for the file
191 @param [in] pErrno Address of the errno variable
193 @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if
194 an invalid file descriptor was passed in.
197 EFI_SOCKET_PROTOCOL
*
198 BslValidateSocketFd (
199 struct __filedes
* pDescriptor
,
203 //------------------------------------------------------------------------------
205 #endif // _SOCKET_INTERNALS_H_