[PSDK]
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 27 Mar 2010 22:06:39 +0000 (22:06 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 27 Mar 2010 22:06:39 +0000 (22:06 +0000)
- Add several missing mswsockdef.h definitions.
- mswsock.h : Introduce pragma once, apply consistent formatting, improve several existing definitions, remove some unrelated ones and add several missing ones.

svn path=/branches/header-work/; revision=46501

include/psdk/mswsock.h
include/psdk/mswsockdef.h [new file with mode: 0644]

index b84f043..988fb9f 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  */
 
-#ifndef _MSWSOCK_H
-#define _MSWSOCK_H
+#pragma once
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define SO_CONNDATA    0x7000
-#define SO_CONNOPT     0x7001
-#define SO_DISCDATA    0x7002
-#define SO_DISCOPT     0x7003
-#define SO_CONNDATALEN 0x7004
-#define SO_CONNOPTLEN  0x7005
-#define SO_DISCDATALEN 0x7006
-#define SO_DISCOPTLEN  0x7007
-#define SO_OPENTYPE    0x7008
-#define SO_SYNCHRONOUS_ALERT   0x10
-#define SO_SYNCHRONOUS_NONALERT        0x20
-#define SO_MAXDG       0x7009
-#define SO_MAXPATHDG   0x700A
-#define SO_UPDATE_ACCEPT_CONTEXT       0x700B
-#define SO_CONNECT_TIME        0x700C
-#define TCP_BSDURGENT  0x7000
-
-#define TF_DISCONNECT   1
-#define TF_REUSE_SOCKET 2
-#define TF_WRITE_BEHIND 4
-#define TF_USE_DEFAULT_WORKER   0
-#define TF_USE_SYSTEM_THREAD    16
-#define TF_USE_KERNEL_APC   32
+#include <mswsockdef.h>
 
-typedef struct _TRANSMIT_FILE_BUFFERS {
-       PVOID Head;
-       DWORD HeadLength;
-       PVOID Tail;
-       DWORD TailLength;
-} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, *LPTRANSMIT_FILE_BUFFERS;
+#define SO_CONNDATA               0x7000
+#define SO_CONNOPT                0x7001
+#define SO_DISCDATA               0x7002
+#define SO_DISCOPT                0x7003
+#define SO_CONNDATALEN            0x7004
+#define SO_CONNOPTLEN             0x7005
+#define SO_DISCDATALEN            0x7006
+#define SO_DISCOPTLEN             0x7007
+#define SO_OPENTYPE               0x7008
+#define SO_SYNCHRONOUS_ALERT      0x10
+#define SO_SYNCHRONOUS_NONALERT   0x20
+#define SO_MAXDG                  0x7009
+#define SO_MAXPATHDG              0x700A
+#define SO_UPDATE_ACCEPT_CONTEXT  0x700B
+#define SO_CONNECT_TIME           0x700C
+#if(_WIN32_WINNT >= 0x0501)
+#define SO_UPDATE_CONNECT_CONTEXT 0x7010
+#endif
 
-int PASCAL WSARecvEx(SOCKET,char*,int,int*);
-BOOL PASCAL TransmitFile(SOCKET,HANDLE,DWORD,DWORD,LPOVERLAPPED,LPTRANSMIT_FILE_BUFFERS,DWORD);
-BOOL PASCAL AcceptEx(SOCKET,SOCKET,PVOID,DWORD,DWORD,DWORD,LPDWORD,LPOVERLAPPED);
-VOID PASCAL GetAcceptExSockaddrs(PVOID,DWORD,DWORD,DWORD,struct sockaddr**, LPINT, struct sockaddr**, LPINT);
+#define TCP_BSDURGENT            0x7000
 
-#define WSAID_ACCEPTEX             { 0xB5367DF0, 0xCBAC, 0x11CF, { 0x95, 0xCA, 0x00, 0x80, 0x5F, 0x48, 0xA1, 0x92 } }
-#define WSAID_TRANSMITFILE         { 0xB5367DF1, 0xCBAC, 0x11CF, { 0x95, 0xCA, 0x00, 0x80, 0x5F, 0x48, 0xA1, 0x92 } }
-#define WSAID_GETACCEPTEXSOCKADDRS { 0xB5367DF2, 0xCBAC, 0x11CF, { 0x95, 0xCA, 0x00, 0x80, 0x5F, 0x48, 0xA1, 0x92 } }
+#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
 
-#define NLA_NAMESPACE_GUID         { 0x6642243A, 0x3BA8, 0x4AA6, { 0xBA, 0xA5, 0x2E, 0xB, 0xD7, 0x1F, 0xDD, 0x83 } }
+#if((_WIN32_WINNT < 0x0600) && (_WIN32_WINNT >= 0x0501))
+#define SIO_SOCKET_CLOSE_NOTIFY _WSAIOW(IOC_VENDOR,13)
+#endif
 
-typedef BOOL (PASCAL *LPFN_TRANSMITFILE)(SOCKET,HANDLE,DWORD,DWORD,LPOVERLAPPED,LPTRANSMIT_FILE_BUFFERS,DWORD);
-typedef BOOL (PASCAL *LPFN_ACCEPTEX)(SOCKET,SOCKET,PVOID,DWORD,DWORD,DWORD,LPDWORD,LPOVERLAPPED);
-typedef VOID (PASCAL *LPFN_GETACCEPTEXSOCKADDRS)(PVOID,DWORD,DWORD,DWORD,struct sockaddr**, LPINT, struct sockaddr**, LPINT);
+#define SIO_UDP_NETRESET _WSAIOW(IOC_VENDOR,15)
 
-#ifdef _WINSOCK2_H /* These require the winsock2 interface.  */
+#define TF_DISCONNECT            1
+#define TF_REUSE_SOCKET          2
+#define TF_WRITE_BEHIND          4
 
-#define TP_ELEMENT_FILE                1
-#define TP_ELEMENT_MEMORY      2
-#define TP_ELEMENT_EOP         4
+#define TF_USE_DEFAULT_WORKER    0
+#define TF_USE_SYSTEM_THREAD     16
+#define TF_USE_KERNEL_APC        32
 
-typedef struct _TRANSMIT_PACKETS_ELEMENT {
-       ULONG dwElFlags;
-       ULONG cLength;
-       _ANONYMOUS_UNION
-       union {
-               struct {
-                       LARGE_INTEGER   nFileOffset;
-                       HANDLE          hFile;
-               };
-               PVOID   pBuffer;
-       };
-} TRANSMIT_PACKETS_ELEMENT;
-
-typedef struct _WSAMSG {
-       LPSOCKADDR      name;
-       INT             namelen;
-       LPWSABUF        lpBuffers;
-       DWORD           dwBufferCount;
-       WSABUF          Control;
-       DWORD           dwFlags;
-} WSAMSG, *PWSAMSG, *LPWSAMSG;
-
-
-/* According to MSDN docs, the WSAMSG.Control buffer starts with a
-   cmsghdr header of the following form.  See also RFC 2292. */
-
-typedef struct wsacmsghdr {
-       UINT    cmsg_len;
-       INT     cmsg_level;
-       INT     cmsg_type;
-       /* followed by UCHAR cmsg_data[]; */
-} WSACMSGHDR;
-
-/* TODO: Standard Posix.1g macros as per RFC 2292, with WSA_uglification. */
-#if 0
-#define WSA_CMSG_FIRSTHDR(mhdr)
-#define WSA_CMSG_NXTHDR(mhdr, cmsg)
-#define WSA_CMSG_SPACE(length)
-#define WSA_CMSG_LEN(length)
+#if(_WIN32_WINNT >= 0x0501)
+#define TP_ELEMENT_MEMORY        1
+#define TP_ELEMENT_FILE          2
+#define TP_ELEMENT_EOP           4
 #endif
 
-BOOL PASCAL DisconnectEx(SOCKET,LPOVERLAPPED,DWORD,DWORD);
-int PASCAL WSARecvMsg(SOCKET,LPWSAMSG,LPDWORD,LPWSAOVERLAPPED,LPWSAOVERLAPPED_COMPLETION_ROUTINE);
+#define TP_DISCONNECT            TF_DISCONNECT
+#define TP_REUSE_SOCKET          TF_REUSE_SOCKET
+#define TP_USE_DEFAULT_WORKER    TF_USE_DEFAULT_WORKER
+#define TP_USE_SYSTEM_THREAD     TF_USE_SYSTEM_THREAD
+#define TP_USE_KERNEL_APC        TF_USE_KERNEL_APC
+
+#define WSAID_TRANSMITFILE \
+  {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
+
+#define WSAID_ACCEPTEX \
+  {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
+
+#define WSAID_GETACCEPTEXSOCKADDRS \
+  {0xb5367df2,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
+
+typedef struct _TRANSMIT_FILE_BUFFERS {
+  LPVOID Head;
+  DWORD HeadLength;
+  LPVOID Tail;
+  DWORD TailLength;
+} TRANSMIT_FILE_BUFFERS, *PTRANSMIT_FILE_BUFFERS, FAR *LPTRANSMIT_FILE_BUFFERS;
+
+typedef BOOL
+(PASCAL FAR *LPFN_TRANSMITFILE)(
+  IN SOCKET hSocket,
+  IN HANDLE hFile,
+  IN DWORD nNumberOfBytesToWrite,
+  IN DWORD nNumberOfBytesPerSend,
+  IN OUT LPOVERLAPPED lpOverlapped OPTIONAL,
+  IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers OPTIONAL,
+  IN DWORD dwReserved);
+
+typedef BOOL
+(PASCAL FAR *LPFN_ACCEPTEX)(
+  IN SOCKET sListenSocket,
+  IN SOCKET sAcceptSocket,
+  IN PVOID lpOutputBuffer,
+  IN DWORD dwReceiveDataLength,
+  IN DWORD dwLocalAddressLength,
+  IN DWORD dwRemoteAddressLength,
+  OUT LPDWORD lpdwBytesReceived,
+  IN OUT LPOVERLAPPED lpOverlapped);
+
+typedef VOID
+(PASCAL FAR *LPFN_GETACCEPTEXSOCKADDRS)(
+  IN PVOID lpOutputBuffer,
+  IN DWORD dwReceiveDataLength,
+  IN DWORD dwLocalAddressLength,
+  IN DWORD dwRemoteAddressLength,
+  OUT struct sockaddr **LocalSockaddr,
+  OUT LPINT LocalSockaddrLength,
+  OUT struct sockaddr **RemoteSockaddr,
+  OUT LPINT RemoteSockaddrLength);
+
+#if(_WIN32_WINNT >= 0x0501)
+
+typedef struct _TRANSMIT_PACKETS_ELEMENT {
+  ULONG dwElFlags;
+  ULONG cLength;
+  union {
+    struct {
+      LARGE_INTEGER nFileOffset;
+      HANDLE hFile;
+    };
+    PVOID pBuffer;
+  };
+} TRANSMIT_PACKETS_ELEMENT, *PTRANSMIT_PACKETS_ELEMENT, FAR *LPTRANSMIT_PACKETS_ELEMENT;
+
+typedef BOOL
+(PASCAL FAR *LPFN_TRANSMITPACKETS)(
+  IN SOCKET hSocket,
+  IN LPTRANSMIT_PACKETS_ELEMENT lpPacketArray OPTIONAL,
+  IN DWORD nElementCount,
+  IN DWORD nSendSize,
+  IN OUT LPOVERLAPPED lpOverlapped OPTIONAL,
+  IN DWORD dwFlags);
+
+#define WSAID_TRANSMITPACKETS \
+  {0xd9689da0,0x1f90,0x11d3,{0x99,0x71,0x00,0xc0,0x4f,0x68,0xc8,0x76}}
+
+typedef BOOL
+(PASCAL FAR *LPFN_CONNECTEX)(
+  IN SOCKET s,
+  IN const struct sockaddr FAR *name,
+  IN int namelen,
+  IN PVOID lpSendBuffer OPTIONAL,
+  IN DWORD dwSendDataLength,
+  OUT LPDWORD lpdwBytesSent,
+  IN OUT LPOVERLAPPED lpOverlapped);
+
+#define WSAID_CONNECTEX \
+  {0x25a207b9,0xddf3,0x4660,{0x8e,0xe9,0x76,0xe5,0x8c,0x74,0x06,0x3e}}
+
+typedef BOOL
+(PASCAL FAR *LPFN_DISCONNECTEX)(
+  IN SOCKET s,
+  IN OUT LPOVERLAPPED lpOverlapped OPTIONAL,
+  IN DWORD dwFlags,
+  IN DWORD dwReserved);
+
+#define WSAID_DISCONNECTEX \
+  {0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
+
+#define DE_REUSE_SOCKET TF_REUSE_SOCKET
+
+#define NLA_NAMESPACE_GUID \
+  {0x6642243a,0x3ba8,0x4aa6,{0xba,0xa5,0x2e,0xb,0xd7,0x1f,0xdd,0x83}}
+
+#define NLA_SERVICE_CLASS_GUID \
+  {0x37e515,0xb5c9,0x4a43,{0xba,0xda,0x8b,0x48,0xa8,0x7a,0xd2,0x39}}
 
-#endif /* _WINSOCK2_H */
+#define NLA_ALLUSERS_NETWORK     0x00000001
+#define NLA_FRIENDLY_NAME        0x00000002
+
+typedef enum _NLA_BLOB_DATA_TYPE {
+  NLA_RAW_DATA = 0,
+  NLA_INTERFACE = 1,
+  NLA_802_1X_LOCATION = 2,
+  NLA_CONNECTIVITY = 3,
+  NLA_ICS = 4,
+} NLA_BLOB_DATA_TYPE, *PNLA_BLOB_DATA_TYPE;
+
+typedef enum _NLA_CONNECTIVITY_TYPE {
+  NLA_NETWORK_AD_HOC = 0,
+  NLA_NETWORK_MANAGED = 1,
+  NLA_NETWORK_UNMANAGED = 2,
+  NLA_NETWORK_UNKNOWN = 3,
+} NLA_CONNECTIVITY_TYPE, *PNLA_CONNECTIVITY_TYPE;
+
+typedef enum _NLA_INTERNET {
+  NLA_INTERNET_UNKNOWN = 0,
+  NLA_INTERNET_NO = 1,
+  NLA_INTERNET_YES = 2,
+} NLA_INTERNET, *PNLA_INTERNET;
+
+typedef struct _NLA_BLOB {
+  struct {
+    NLA_BLOB_DATA_TYPE type;
+    DWORD dwSize;
+    DWORD nextOffset;
+  } header;
+  union {
+    CHAR rawData[1];
+    struct {
+      DWORD dwType;
+      DWORD dwSpeed;
+      CHAR adapterName[1];
+    } interfaceData;
+    struct {
+      CHAR information[1];
+    } locationData;
+    struct {
+      NLA_CONNECTIVITY_TYPE type;
+      NLA_INTERNET internet;
+    } connectivity;
+    struct {
+      struct {
+        DWORD speed;
+        DWORD type;
+        DWORD state;
+        WCHAR machineName[256];
+        WCHAR sharedAdapterName[256];
+      } remote;
+    } ICS;
+  } data;
+} NLA_BLOB, *PNLA_BLOB, * FAR LPNLA_BLOB;
+
+typedef INT
+(PASCAL FAR *LPFN_WSARECVMSG)(
+  IN SOCKET s,
+  IN OUT LPWSAMSG lpMsg,
+  OUT LPDWORD lpdwNumberOfBytesRecvd OPTIONAL,
+  IN OUT LPWSAOVERLAPPED lpOverlapped OPTIONAL,
+  IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine OPTIONAL);
+
+#define WSAID_WSARECVMSG \
+  {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}
+
+#endif /* (_WIN32_WINNT >= 0x0501) */
+
+#if(_WIN32_WINNT >= 0x0600)
+
+#define SIO_BSP_HANDLE          _WSAIOR(IOC_WS2,27)
+#define SIO_BSP_HANDLE_SELECT   _WSAIOR(IOC_WS2,28)
+#define SIO_BSP_HANDLE_POLL     _WSAIOR(IOC_WS2,29)
+
+#define SIO_BASE_HANDLE         _WSAIOR(IOC_WS2,34)
+
+#define SIO_EXT_SELECT          _WSAIORW(IOC_WS2,30)
+#define SIO_EXT_POLL            _WSAIORW(IOC_WS2,31)
+#define SIO_EXT_SENDMSG         _WSAIORW(IOC_WS2,32)
+
+typedef struct {
+  int result;
+  ULONG fds;
+  INT timeout;
+  WSAPOLLFD fdArray[0];
+} WSAPOLLDATA, *LPWSAPOLLDATA;
+
+typedef struct {
+  LPWSAMSG lpMsg;
+  DWORD dwFlags;
+  LPDWORD lpNumberOfBytesSent;
+  LPWSAOVERLAPPED lpOverlapped;
+  LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine;
+} WSASENDMSG, *LPWSASENDMSG;
+
+typedef INT
+(PASCAL FAR *LPFN_WSASENDMSG)(
+  IN SOCKET s,
+  IN LPWSAMSG lpMsg,
+  IN DWORD dwFlags,
+  OUT LPDWORD lpNumberOfBytesSent OPTIONAL,
+  IN OUT LPWSAOVERLAPPED lpOverlapped OPTIONAL,
+  IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine OPTIONAL);
+
+#define WSAID_WSASENDMSG
+  {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}}
+
+typedef INT
+(WSAAPI *LPFN_WSAPOLL)(
+  IN OUT LPWSAPOLLFD fdarray,
+  IN ULONG nfds,
+  IN INT timeout);
+
+#define WSAID_WSAPOLL \
+  {0x18C76F85,0xDC66,0x4964,{0x97,0x2E,0x23,0xC2,0x72,0x38,0x31,0x2B}}
+
+#endif /* (_WIN32_WINNT >= 0x0600) */
+
+#if(_WIN32_WINNT < 0x0600)
+int
+PASCAL
+FAR
+WSARecvEx(
+  IN SOCKET s,
+  OUT char FAR *buf,
+  IN int len,
+  IN OUT int FAR *flags);
+#else //(_WIN32_WINNT < 0x0600)
+INT
+PASCAL
+FAR
+WSARecvEx(
+  IN SOCKET s,
+  OUT CHAR FAR *buf,
+  IN INT len,
+  IN OUT INT FAR *flags);
+#endif //(_WIN32_WINNT < 0x0600)
+
+BOOL
+PASCAL
+FAR
+TransmitFile(
+  IN SOCKET hSocket,
+  IN HANDLE hFile,
+  IN DWORD nNumberOfBytesToWrite,
+  IN DWORD nNumberOfBytesPerSend,
+  IN OUT LPOVERLAPPED lpOverlapped OPTIONAL,
+  IN LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers OPTIONAL,
+  IN DWORD dwReserved);
+
+BOOL
+PASCAL
+FAR
+AcceptEx(
+  IN SOCKET sListenSocket,
+  IN SOCKET sAcceptSocket,
+  OUT PVOID lpOutputBuffer,
+  IN DWORD dwReceiveDataLength,
+  IN DWORD dwLocalAddressLength,
+  IN DWORD dwRemoteAddressLength,
+  OUT LPDWORD lpdwBytesReceived,
+  IN OUT LPOVERLAPPED lpOverlapped);
+
+VOID
+PASCAL
+FAR
+GetAcceptExSockaddrs(
+  IN PVOID lpOutputBuffer,
+  IN DWORD dwReceiveDataLength,
+  IN DWORD dwLocalAddressLength,
+  IN DWORD dwRemoteAddressLength,
+  OUT struct sockaddr **LocalSockaddr,
+  OUT LPINT LocalSockaddrLength,
+  OUT struct sockaddr **RemoteSockaddr,
+  OUT LPINT RemoteSockaddrLength);
 
 #ifdef __cplusplus
 }
 #endif
-#endif  /*  _MSWSOCK_H */
-
diff --git a/include/psdk/mswsockdef.h b/include/psdk/mswsockdef.h
new file mode 100644 (file)
index 0000000..6303cf4
--- /dev/null
@@ -0,0 +1,66 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if(_WIN32_WINNT >= 0x0600)
+#ifdef _MSC_VER
+#define MSWSOCKDEF_INLINE __inline
+#else
+#define MSWSOCKDEF_INLINE extern inline
+#endif
+#endif /* (_WIN32_WINNT>=0x0600) */
+
+#ifndef ASSERT
+#define MSWSOCKDEF_ASSERT_UNDEFINED
+#define ASSERT(exp) ((VOID) 0)
+#endif
+
+#if(_WIN32_WINNT >= 0x0600)
+
+#ifdef _WS2DEF_
+
+extern CONST UCHAR sockaddr_size[AF_MAX];
+
+MSWSOCKDEF_INLINE
+UCHAR
+SOCKADDR_SIZE(
+  IN ADDRESS_FAMILY af)
+{
+  return (UCHAR)((af < AF_MAX) ? sockaddr_size[af]
+                               : sockaddr_size[AF_UNSPEC]);
+}
+
+MSWSOCKDEF_INLINE
+SCOPE_LEVEL
+ScopeLevel(
+  IN SCOPE_ID ScopeId)
+{
+  return (SCOPE_LEVEL)ScopeId.Level;
+}
+
+#endif /* _WS2DEF_ */
+
+#define SIO_SET_COMPATIBILITY_MODE _WSAIOW(IOC_VENDOR,300)
+
+typedef enum _WSA_COMPATIBILITY_BEHAVIOR_ID {
+  WsaBehaviorAll = 0,
+  WsaBehaviorReceiveBuffering,
+  WsaBehaviorAutoTuning
+} WSA_COMPATIBILITY_BEHAVIOR_ID, *PWSA_COMPATIBILITY_BEHAVIOR_ID;
+
+typedef struct _WSA_COMPATIBILITY_MODE {
+  WSA_COMPATIBILITY_BEHAVIOR_ID BehaviorId;
+  ULONG TargetOsVersion;
+} WSA_COMPATIBILITY_MODE, *PWSA_COMPATIBILITY_MODE;   
+
+#endif /* (_WIN32_WINNT>=0x0600) */
+
+#ifdef MSWSOCKDEF_ASSERT_UNDEFINED
+#undef ASSERT
+#endif
+
+#ifdef __cplusplus
+}
+#endif