ReactOS 0.4.16-dev-329-g9223134
send.c File Reference
#include "precomp.h"
Include dependency graph for send.c:

Go to the source code of this file.

Functions

static void TestSend (void)
 
static void TestSendTo (void)
 
 START_TEST (send)
 

Function Documentation

◆ START_TEST()

START_TEST ( send  )

Definition at line 91 of file send.c.

92{
93 TestSend();
94 TestSendTo();
95}
static void TestSend(void)
Definition: send.c:12
static void TestSendTo(void)
Definition: send.c:57

◆ TestSend()

static void TestSend ( void  )
static

Definition at line 12 of file send.c.

13{
15 HANDLE SocketHandle;
16 CHAR Buffer[32];
17 struct sockaddr_in addr;
18
19 RtlZeroMemory(Buffer, sizeof(Buffer));
20
22 ok(Status == STATUS_SUCCESS, "AfdCreateSocket failed with %lx\n", Status);
23
24 Status = AfdSend(SocketHandle, NULL, 0);
25 ok(Status == STATUS_INVALID_CONNECTION, "AfdSend failed with %lx\n", Status);
26
27 Status = AfdSend(SocketHandle, Buffer, sizeof(Buffer));
28 ok(Status == STATUS_INVALID_CONNECTION, "AfdSend failed with %lx\n", Status);
29
30 memset(&addr, 0, sizeof(addr));
31 addr.sin_family = AF_INET;
32 addr.sin_addr.s_addr = inet_addr("0.0.0.0");
33 addr.sin_port = htons(0);
34
35 Status = AfdBind(SocketHandle, (const struct sockaddr *)&addr, sizeof(addr));
36 ok(Status == STATUS_SUCCESS, "AfdBind failed with %lx\n", Status);
37
38 memset(&addr, 0, sizeof(addr));
39 addr.sin_family = AF_INET;
40 addr.sin_addr.s_addr = inet_addr("8.8.8.8");
41 addr.sin_port = htons(53);
42
43 Status = AfdConnect(SocketHandle, (const struct sockaddr *)&addr, sizeof(addr));
44 ok(Status == STATUS_SUCCESS, "AfdConnect failed with %lx\n", Status);
45
46 Status = AfdSend(SocketHandle, NULL, 0);
47 ok(Status == STATUS_SUCCESS, "AfdSend failed with %lx\n", Status);
48
49 Status = AfdSend(SocketHandle, Buffer, sizeof(Buffer));
50 ok(Status == STATUS_SUCCESS, "AfdSend failed with %lx\n", Status);
51
52 NtClose(SocketHandle);
53}
NTSTATUS AfdBind(_In_ HANDLE SocketHandle, _In_ const struct sockaddr *Address, _In_ ULONG AddressLength)
Definition: AfdHelpers.c:134
NTSTATUS AfdSend(_In_ HANDLE SocketHandle, _In_ const void *Buffer, _In_ ULONG BufferLength)
Definition: AfdHelpers.c:264
NTSTATUS AfdConnect(_In_ HANDLE SocketHandle, _In_ const struct sockaddr *Address, _In_ ULONG AddressLength)
Definition: AfdHelpers.c:197
ULONG WSAAPI inet_addr(IN CONST CHAR FAR *cp)
Definition: addrconv.c:71
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
#define NULL
Definition: types.h:112
static NTSTATUS NTAPI AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:302
#define IPPROTO_TCP
Definition: ip.h:196
#define SOCK_STREAM
Definition: tcpip.h:118
#define AF_INET
Definition: tcpip.h:117
Status
Definition: gdiplustypes.h:25
GLenum const GLvoid * addr
Definition: glext.h:9621
#define htons(x)
Definition: module.h:215
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define STATUS_INVALID_CONNECTION
Definition: ntstatus.h:556
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ TestSendTo()

static void TestSendTo ( void  )
static

Definition at line 57 of file send.c.

58{
60 HANDLE SocketHandle;
61 CHAR Buffer[32];
62 struct sockaddr_in addr;
63
64 RtlZeroMemory(Buffer, sizeof(Buffer));
65
67 ok(Status == STATUS_SUCCESS, "AfdCreateSocket failed with %lx\n", Status);
68
69 memset(&addr, 0, sizeof(addr));
70 addr.sin_family = AF_INET;
71 addr.sin_addr.s_addr = inet_addr("0.0.0.0");
72 addr.sin_port = htons(0);
73
74 Status = AfdBind(SocketHandle, (const struct sockaddr *)&addr, sizeof(addr));
75 ok(Status == STATUS_SUCCESS, "AfdBind failed with %lx\n", Status);
76
77 memset(&addr, 0, sizeof(addr));
78 addr.sin_family = AF_INET;
79 addr.sin_addr.s_addr = inet_addr("8.8.8.8");
80 addr.sin_port = htons(53);
81
82 Status = AfdSendTo(SocketHandle, NULL, 0, (const struct sockaddr *)&addr, sizeof(addr));
83 ok(Status == STATUS_SUCCESS, "AfdSendTo failed with %lx\n", Status);
84
85 Status = AfdSendTo(SocketHandle, Buffer, sizeof(Buffer), (const struct sockaddr *)&addr, sizeof(addr));
86 ok(Status == STATUS_SUCCESS, "AfdSendTo failed with %lx\n", Status);
87
88 NtClose(SocketHandle);
89}
NTSTATUS AfdSendTo(_In_ HANDLE SocketHandle, _In_ const void *Buffer, _In_ ULONG BufferLength, _In_ const struct sockaddr *Address, _In_ ULONG AddressLength)
Definition: AfdHelpers.c:314
#define IPPROTO_UDP
Definition: ip.h:197
#define SOCK_DGRAM
Definition: winsock.h:336

Referenced by START_TEST().