]>
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.
86 struct __filedes
* pDescriptor
90 Worker routine to close the socket.
92 @param[in] pSocketProtocol Socket protocol structure address
94 @param[in] pErrno Address of the ::errno variable
96 @retval EFI_SUCCESS Successfully closed the socket
101 IN EFI_SOCKET_PROTOCOL
* pSocketProtocol
,
106 Poll the socket for activity
108 @param [in] pDescriptor Descriptor address for the file
110 @param [in] Events Mask of events to detect
112 @return Detected events for the socket
117 IN
struct __filedes
* pDescriptor
,
122 Build a file descriptor for a socket.
124 @param [in] pSocketProtocol Socket protocol structure address
126 @param [in] pErrno Address of the errno variable
128 @return The file descriptor for the socket or -1 if an error occurs.
132 BslSocketProtocolToFd (
133 IN EFI_SOCKET_PROTOCOL
* pSocketProtocol
,
138 Read support routine for sockets
140 The BslSocketRead routine is called indirectly by the read file
141 system routine. This routine is typically used for SOCK_STREAM
142 because it waits for receive data from the target system specified
143 in the ::connect call.
145 @param [in] pDescriptor Descriptor address for the file
146 @param [in] pOffset File offset
147 @param [in] LengthInBytes Number of bytes to read
148 @param [in] pBuffer Address of the buffer to receive the data
150 @return The number of bytes read or -1 if an error occurs.
151 In the case of an error, ::errno contains more details.
156 struct __filedes
*pDescriptor
,
158 size_t LengthInBytes
,
163 Write support routine for sockets
165 @param [in] pDescriptor Descriptor address for the file
166 @param [in] pOffset File offset
167 @param [in] LengthInBytes Number of bytes to write
168 @param [in] pBuffer Address of the data
170 @return The number of bytes written or -1 if an error occurs.
171 In the case of an error, ::errno contains more details.
176 struct __filedes
*pDescriptor
,
178 size_t LengthInBytes
,
183 Validate the socket's file descriptor
185 @param [in] pDescriptor Descriptor for the file
187 @param [in] pErrno Address of the errno variable
189 @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if
190 an invalid file descriptor was passed in.
193 EFI_SOCKET_PROTOCOL
*
194 BslValidateSocketFd (
195 struct __filedes
* pDescriptor
,
199 //------------------------------------------------------------------------------
201 #endif // _SOCKET_INTERNALS_H_