ReactOS 0.4.16-dev-122-g325d74c
protocol.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winsock2.h>
#include "wine/test.h"
Include dependency graph for protocol.c:

Go to the source code of this file.

Macros

#define TCPIP_SERVICE_FLAGS
 
#define UDPIP_SERVICE_FLAGS
 

Functions

static void test_service_flags (int family, int version, int socktype, int protocol, DWORD testflags)
 
static void test_WSAEnumProtocolsA (void)
 
static void test_WSAEnumProtocolsW (void)
 
 START_TEST (protocol)
 

Macro Definition Documentation

◆ TCPIP_SERVICE_FLAGS

#define TCPIP_SERVICE_FLAGS
Value:
#define XP1_EXPEDITED_DATA
Definition: winsock2.h:442
#define XP1_GUARANTEED_ORDER
Definition: winsock2.h:438
#define XP1_GRACEFUL_CLOSE
Definition: winsock2.h:441
#define XP1_GUARANTEED_DELIVERY
Definition: winsock2.h:437
#define XP1_IFS_HANDLES
Definition: winsock2.h:453

Definition at line 30 of file protocol.c.

◆ UDPIP_SERVICE_FLAGS

#define UDPIP_SERVICE_FLAGS
Value:
#define XP1_SUPPORT_BROADCAST
Definition: winsock2.h:445
#define XP1_CONNECTIONLESS
Definition: winsock2.h:436
#define XP1_SUPPORT_MULTIPOINT
Definition: winsock2.h:446
#define XP1_MESSAGE_ORIENTED
Definition: winsock2.h:439

Definition at line 36 of file protocol.c.

Function Documentation

◆ START_TEST()

START_TEST ( protocol  )

Definition at line 195 of file protocol.c.

196{
198 WORD version = MAKEWORD( 2, 2 );
199
200 if (WSAStartup( version, &data )) return;
201
204}
static const WCHAR version[]
Definition: asmname.c:66
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void test_WSAEnumProtocolsW(void)
Definition: protocol.c:128
static void test_WSAEnumProtocolsA(void)
Definition: protocol.c:61
#define MAKEWORD(a, b)
Definition: typedefs.h:248

◆ test_service_flags()

static void test_service_flags ( int  family,
int  version,
int  socktype,
int  protocol,
DWORD  testflags 
)
static

Definition at line 42 of file protocol.c.

43{
44 DWORD expectedflags = 0;
45 if (socktype == SOCK_STREAM && protocol == IPPROTO_TCP)
46 expectedflags = TCPIP_SERVICE_FLAGS;
47 if (socktype == SOCK_DGRAM && protocol == IPPROTO_UDP)
48 expectedflags = UDPIP_SERVICE_FLAGS;
49
50 /* check if standard TCP and UDP protocols are offering the correct service flags */
51 if ((family == AF_INET || family == AF_INET6) && version == 2 && expectedflags)
52 {
53 /* QOS may or may not be installed */
54 testflags &= ~XP1_QOS_SUPPORTED;
55 ok(expectedflags == testflags,
56 "Incorrect flags, expected 0x%x, received 0x%x\n",
57 expectedflags, testflags);
58 }
59}
#define ok(value,...)
Definition: atltest.h:57
#define IPPROTO_TCP
Definition: ip.h:196
#define IPPROTO_UDP
Definition: ip.h:197
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TCPIP_SERVICE_FLAGS
Definition: protocol.c:30
#define UDPIP_SERVICE_FLAGS
Definition: protocol.c:36
#define SOCK_DGRAM
Definition: winsock.h:336
#define AF_INET6
Definition: winsock.h:369

Referenced by test_WSAEnumProtocolsA(), and test_WSAEnumProtocolsW().

◆ test_WSAEnumProtocolsA()

static void test_WSAEnumProtocolsA ( void  )
static

Definition at line 61 of file protocol.c.

62{
63 INT ret, i, j, found;
64 DWORD len = 0, error;
66 INT ptest[] = {0xdead, IPPROTO_TCP, 0xcafe, IPPROTO_UDP, 0xbeef, 0};
67
69 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsA() succeeded unexpectedly\n");
71 ok( error == WSAENOBUFS, "Expected 10055, received %d\n", error);
72
73 len = 0;
74
76 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsA() succeeded unexpectedly\n");
78 ok( error == WSAENOBUFS, "Expected 10055, received %d\n", error);
79
81
82 if (buffer)
83 {
85 ok( ret != SOCKET_ERROR, "WSAEnumProtocolsA() failed unexpectedly: %d\n",
87
88 for (i = 0; i < ret; i++)
89 {
90 ok( strlen( buffer[i].szProtocol ), "No protocol name found\n" );
91 test_service_flags( buffer[i].iAddressFamily, buffer[i].iVersion,
92 buffer[i].iSocketType, buffer[i].iProtocol,
93 buffer[i].dwServiceFlags1);
94 }
95
97 }
98
99 /* Test invalid protocols in the list */
100 ret = WSAEnumProtocolsA( ptest, NULL, &len );
101 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsA() succeeded unexpectedly\n");
103 ok( error == WSAENOBUFS || broken(error == WSAEFAULT) /* NT4 */,
104 "Expected 10055, received %d\n", error);
105
107
108 if (buffer)
109 {
110 ret = WSAEnumProtocolsA( ptest, buffer, &len );
111 ok( ret != SOCKET_ERROR, "WSAEnumProtocolsA() failed unexpectedly: %d\n",
112 WSAGetLastError() );
113 ok( ret >= 2, "Expected at least 2 items, received %d\n", ret);
114
115 for (i = found = 0; i < ret; i++)
116 for (j = 0; j < sizeof(ptest) / sizeof(ptest[0]); j++)
117 if (buffer[i].iProtocol == ptest[j])
118 {
119 found |= 1 << j;
120 break;
121 }
122 ok(found == 0x0A, "Expected 2 bits represented as 0xA, received 0x%x\n", found);
123
125 }
126}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define broken(x)
Definition: atltest.h:178
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
INT WSAAPI WSAEnumProtocolsA(IN LPINT lpiProtocols, OUT LPWSAPROTOCOL_INFOA lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength)
Definition: enumprot.c:229
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define error(str)
Definition: mkdosfs.c:1605
static void test_service_flags(int family, int version, int socktype, int protocol, DWORD testflags)
Definition: protocol.c:42
int32_t INT
Definition: typedefs.h:58
int ret
#define WSAENOBUFS
Definition: winerror.h:1968
#define WSAEFAULT
Definition: winerror.h:1945
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
#define SOCKET_ERROR
Definition: winsock.h:333

Referenced by START_TEST().

◆ test_WSAEnumProtocolsW()

static void test_WSAEnumProtocolsW ( void  )
static

Definition at line 128 of file protocol.c.

129{
130 INT ret, i, j, found;
131 DWORD len = 0, error;
133 INT ptest[] = {0xdead, IPPROTO_TCP, 0xcafe, IPPROTO_UDP, 0xbeef, 0};
134
136 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsW() succeeded unexpectedly\n");
138 ok( error == WSAENOBUFS, "Expected 10055, received %d\n", error);
139
140 len = 0;
141
143 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsW() succeeded unexpectedly\n");
145 ok( error == WSAENOBUFS, "Expected 10055, received %d\n", error);
146
148
149 if (buffer)
150 {
152 ok( ret != SOCKET_ERROR, "WSAEnumProtocolsW() failed unexpectedly: %d\n",
153 WSAGetLastError() );
154
155 for (i = 0; i < ret; i++)
156 {
157 ok( lstrlenW( buffer[i].szProtocol ), "No protocol name found\n" );
158 test_service_flags( buffer[i].iAddressFamily, buffer[i].iVersion,
159 buffer[i].iSocketType, buffer[i].iProtocol,
160 buffer[i].dwServiceFlags1);
161 }
162
164 }
165
166 /* Test invalid protocols in the list */
167 ret = WSAEnumProtocolsW( ptest, NULL, &len );
168 ok( ret == SOCKET_ERROR, "WSAEnumProtocolsW() succeeded unexpectedly\n");
170 ok( error == WSAENOBUFS || broken(error == WSAEFAULT) /* NT4 */,
171 "Expected 10055, received %d\n", error);
172
174
175 if (buffer)
176 {
177 ret = WSAEnumProtocolsW( ptest, buffer, &len );
178 ok( ret != SOCKET_ERROR, "WSAEnumProtocolsW() failed unexpectedly: %d\n",
179 WSAGetLastError() );
180 ok( ret >= 2, "Expected at least 2 items, received %d\n", ret);
181
182 for (i = found = 0; i < ret; i++)
183 for (j = 0; j < sizeof(ptest) / sizeof(ptest[0]); j++)
184 if (buffer[i].iProtocol == ptest[j])
185 {
186 found |= 1 << j;
187 break;
188 }
189 ok(found == 0x0A, "Expected 2 bits represented as 0xA, received 0x%x\n", found);
190
192 }
193}
#define lstrlenW
Definition: compat.h:750
INT WSAAPI WSAEnumProtocolsW(IN LPINT lpiProtocols, OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer, IN OUT LPDWORD lpdwBufferLength)
Definition: enumprot.c:276

Referenced by START_TEST().