]>
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 socket protocol structure or NULL if
61 an invalid file descriptor was passed in.
65 BslFdToSocketProtocol (
67 struct __filedes
** ppDescriptor
,
74 @param [in] pDescriptor Descriptor address for the file
76 @return This routine returns 0 upon success and -1 upon failure.
77 In the case of failure, errno contains more information.
82 struct __filedes
* pDescriptor
86 Worker routine to close the socket.
88 @param [in] pSocketProtocol Socket protocol structure address
90 @param [in] pErrno Address of the errno variable
92 @retval EFI_SUCCESS Successfully closed the socket
97 IN EFI_SOCKET_PROTOCOL
* pSocketProtocol
,
102 Poll the socket for activity
104 @param [in] pDescriptor Descriptor address for the file
106 @param [in] Events Mask of events to detect
108 @return Detected events for the socket
113 IN
struct __filedes
* pDescriptor
,
118 Build a file descriptor for a socket.
120 @param [in] pSocketProtocol Socket protocol structure address
122 @param [in] pErrno Address of the errno variable
124 @return The file descriptor for the socket or -1 if an error occurs.
128 BslSocketProtocolToFd (
129 IN EFI_SOCKET_PROTOCOL
* pSocketProtocol
,
134 Read support routine for sockets
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
141 @return The number of bytes read or -1 if an error occurs.
146 struct __filedes
*pDescriptor
,
148 size_t LengthInBytes
,
153 Write support routine for sockets
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
160 @return The number of bytes written or -1 if an error occurs.
165 struct __filedes
*pDescriptor
,
167 size_t LengthInBytes
,
172 Validate the socket's file descriptor
174 @param [in] pDescriptor Descriptor for the file
176 @param [in] pErrno Address of the errno variable
178 @return A pointer to the socket protocol structure or NULL if
179 an invalid file descriptor was passed in.
182 EFI_SOCKET_PROTOCOL
*
183 BslValidateSocketFd (
184 struct __filedes
* pDescriptor
,
188 //------------------------------------------------------------------------------
190 #endif // _SOCKET_INTERNALS_H_