ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ioctl.c
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS WinSock 2 API
00004  * FILE:        ioctl.c
00005  * PURPOSE:     Socket I/O Control Code support.
00006  * PROGRAMMER:  Alex Ionescu (alex@relsoft.net)
00007  */
00008 
00009 /* INCLUDES ******************************************************************/
00010 #include "ws2_32.h"
00011 
00012 //#define NDEBUG
00013 #include <debug.h>
00014 
00015 /* DATA **********************************************************************/
00016 
00017 /* FUNCTIONS *****************************************************************/
00018 
00019 /*
00020  * @implemented
00021  */
00022 INT
00023 WSAAPI
00024 ioctlsocket(IN SOCKET s,
00025             IN LONG cmd,
00026             IN OUT ULONG FAR* argp)
00027 {
00028     DWORD Dummy;
00029 
00030     /* Let WSA do it */
00031     return WSAIoctl(s,
00032                     cmd,
00033                     argp,
00034                     sizeof(ULONG),
00035                     argp,
00036                     sizeof(ULONG),
00037                     &Dummy,
00038                     NULL,
00039                     NULL);
00040 }
00041 
00042 /*
00043  * @implemented
00044  */
00045 INT
00046 WSAAPI
00047 WSAIoctl(IN SOCKET s,
00048          IN DWORD dwIoControlCode,
00049          IN LPVOID lpvInBuffer,
00050          IN DWORD cbInBuffer,
00051          OUT LPVOID lpvOutBuffer,
00052          IN DWORD cbOutBuffer,
00053          OUT LPDWORD lpcbBytesReturned,
00054          IN LPWSAOVERLAPPED lpOverlapped,
00055          IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
00056 {
00057     PWSSOCKET Socket;
00058     INT Status;
00059     INT ErrorCode;
00060     LPWSATHREADID ThreadId;
00061     DPRINT("WSAIoctl: %lx, %lx\n", s, dwIoControlCode);
00062 
00063     /* Check for WSAStartup */
00064     if ((ErrorCode = WsQuickPrologTid(&ThreadId)) == ERROR_SUCCESS)
00065     {
00066         /* Get the Socket Context */
00067         if ((Socket = WsSockGetSocket(s)))
00068         {
00069             /* Make the call */
00070             Status = Socket->Provider->Service.lpWSPIoctl(s,
00071                                                   dwIoControlCode,
00072                                                   lpvInBuffer,
00073                                                   cbInBuffer,
00074                                                   lpvOutBuffer,
00075                                                   cbOutBuffer,
00076                                                   lpcbBytesReturned,
00077                                                   lpOverlapped,
00078                                                   lpCompletionRoutine,
00079                                                   ThreadId,
00080                                                   &ErrorCode);
00081 
00082             /* Deference the Socket Context */
00083             WsSockDereference(Socket);
00084 
00085             /* Return Provider Value */
00086             if (Status == ERROR_SUCCESS) return Status;
00087         }
00088         else
00089         {
00090             /* No Socket Context Found */
00091             ErrorCode = WSAENOTSOCK;
00092         }
00093     }
00094 
00095     /* Return with an Error */
00096     SetLastError(ErrorCode);
00097     return SOCKET_ERROR;
00098 }

Generated on Fri May 25 2012 04:25:10 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.