+++ /dev/null
-/** @file\r
- Definitions for the socket library.\r
-\r
- Copyright (c) 2011, Intel Corporation\r
- All rights reserved. This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _SOCKET_INTERNALS_H_\r
-#define _SOCKET_INTERNALS_H_\r
-\r
-#include <Uefi.h>\r
-\r
-//----------------------------------------------------------------------\r
-//\r
-// The following private files are required to support file descriptors\r
-//\r
-\r
-#include <kfile.h>\r
-#include <MainData.h>\r
-\r
-#include <Efi/SysEfi.h>\r
-\r
-//\r
-// End of private files\r
-//\r
-//----------------------------------------------------------------------\r
-\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-#include <Protocol/EfiSocket.h>\r
-#include <Protocol/ServiceBinding.h>\r
-\r
-#include <sys/errno.h>\r
-#include <sys/poll.h>\r
-#include <sys/EfiSysCall.h>\r
-#include <sys/socket.h>\r
-\r
-//------------------------------------------------------------------------------\r
-// Support Routines\r
-//------------------------------------------------------------------------------\r
-\r
-/**\r
- Translate from the socket file descriptor to the socket protocol.\r
-\r
- @param [in] s Socket file descriptor returned from ::socket.\r
-\r
- @param [in] ppDescriptor Address to receive the descriptor structure\r
- address for the file\r
- @param [in] pErrno Address of the errno variable\r
-\r
- @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if\r
- an invalid file descriptor was passed in.\r
-\r
- **/\r
-EFI_SOCKET_PROTOCOL *\r
-BslFdToSocketProtocol (\r
- int s,\r
- struct __filedes ** ppDescriptor,\r
- int * pErrno\r
- );\r
-\r
-/**\r
- Close the socket\r
-\r
- The BslSocketClose routine is called indirectly from the close file\r
- system routine. This routine closes the socket and returns the\r
- status to the caller.\r
-\r
- @param[in] pDescriptor Descriptor address for the file\r
-\r
- @return This routine returns 0 upon success and -1 upon failure.\r
- In the case of failure, ::errno contains more information.\r
-\r
-**/\r
-int\r
-EFIAPI\r
-BslSocketClose (\r
- struct __filedes * pDescriptor\r
- );\r
-\r
-/**\r
- Worker routine to close the socket.\r
-\r
- @param[in] pSocketProtocol Socket protocol structure address\r
-\r
- @param[in] pErrno Address of the ::errno variable\r
-\r
- @retval EFI_SUCCESS Successfully closed the socket\r
-\r
-**/\r
-EFI_STATUS\r
-BslSocketCloseWork (\r
- IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
- IN int * pErrno\r
- );\r
-\r
-/**\r
- Poll the socket for activity\r
-\r
- @param [in] pDescriptor Descriptor address for the file\r
-\r
- @param [in] Events Mask of events to detect\r
-\r
- @return Detected events for the socket\r
-\r
- **/\r
-short\r
-EFIAPI\r
-BslSocketPoll (\r
- IN struct __filedes * pDescriptor,\r
- IN short Events\r
- );\r
-\r
-/**\r
- Build a file descriptor for a socket.\r
-\r
- @param [in] pSocketProtocol Socket protocol structure address\r
-\r
- @param [in] pErrno Address of the errno variable\r
-\r
- @return The file descriptor for the socket or -1 if an error occurs.\r
-\r
- **/\r
-int\r
-BslSocketProtocolToFd (\r
- IN EFI_SOCKET_PROTOCOL * pSocketProtocol,\r
- IN int * pErrno\r
- );\r
-\r
-/**\r
- Read support routine for sockets\r
-\r
- The BslSocketRead routine is called indirectly by the read file\r
- system routine. This routine is typically used for SOCK_STREAM\r
- because it waits for receive data from the target system specified\r
- in the ::connect call.\r
-\r
- @param [in] pDescriptor Descriptor address for the file\r
- @param [in] pOffset File offset\r
- @param [in] LengthInBytes Number of bytes to read\r
- @param [in] pBuffer Address of the buffer to receive the data\r
-\r
- @return The number of bytes read or -1 if an error occurs.\r
- In the case of an error, ::errno contains more details.\r
-\r
-**/\r
-ssize_t\r
-EFIAPI\r
-BslSocketRead (\r
- struct __filedes *pDescriptor,\r
- off_t * pOffset,\r
- size_t LengthInBytes,\r
- void * pBuffer\r
- );\r
-\r
-/**\r
- Write support routine for sockets\r
-\r
- @param [in] pDescriptor Descriptor address for the file\r
- @param [in] pOffset File offset\r
- @param [in] LengthInBytes Number of bytes to write\r
- @param [in] pBuffer Address of the data\r
-\r
- @return The number of bytes written or -1 if an error occurs.\r
- In the case of an error, ::errno contains more details.\r
-\r
-**/\r
-ssize_t\r
-EFIAPI\r
-BslSocketWrite (\r
- struct __filedes *pDescriptor,\r
- off_t * pOffset,\r
- size_t LengthInBytes,\r
- const void * pBuffer\r
- );\r
-\r
-/**\r
- Validate the socket's file descriptor\r
-\r
- @param [in] pDescriptor Descriptor for the file\r
-\r
- @param [in] pErrno Address of the errno variable\r
-\r
- @return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if\r
- an invalid file descriptor was passed in.\r
-\r
- **/\r
-EFI_SOCKET_PROTOCOL *\r
-BslValidateSocketFd (\r
- struct __filedes * pDescriptor,\r
- int * pErrno\r
- );\r
-\r
-//------------------------------------------------------------------------------\r
-\r
-#endif // _SOCKET_INTERNALS_H_\r