ReactOS  0.4.14-dev-317-g96040ec
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 }
#define STATUS_INVALID_CONNECTION
Definition: ntstatus.h:542
#define inet_addr(cp)
Definition: inet.h:98
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS AfdSend(_In_ HANDLE SocketHandle, _In_ const void *Buffer, _In_ ULONG BufferLength)
Definition: AfdHelpers.c:264
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
NTSTATUS AfdBind(_In_ HANDLE SocketHandle, _In_ const struct sockaddr *Address, _In_ ULONG AddressLength)
Definition: AfdHelpers.c:134
static NTSTATUS NTAPI AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:302
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
NTSTATUS AfdConnect(_In_ HANDLE SocketHandle, _In_ const struct sockaddr *Address, _In_ ULONG AddressLength)
Definition: AfdHelpers.c:197
GLenum const GLvoid * addr
Definition: glext.h:9621
Status
Definition: gdiplustypes.h:24
#define ok(value,...)
Definition: atltest.h:57
#define AF_INET
Definition: tcpip.h:117
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define SOCK_STREAM
Definition: tcpip.h:118
#define htons(x)
Definition: module.h:213
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define memset(x, y, z)
Definition: compat.h:39

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 }
#define inet_addr(cp)
Definition: inet.h:98
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS AfdSendTo(_In_ HANDLE SocketHandle, _In_ const void *Buffer, _In_ ULONG BufferLength, _In_ const struct sockaddr *Address, _In_ ULONG AddressLength)
Definition: AfdHelpers.c:314
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
NTSTATUS AfdBind(_In_ HANDLE SocketHandle, _In_ const struct sockaddr *Address, _In_ ULONG AddressLength)
Definition: AfdHelpers.c:134
static NTSTATUS NTAPI AfdCreateSocket(PDEVICE_OBJECT DeviceObject, PIRP Irp, PIO_STACK_LOCATION IrpSp)
Definition: main.c:302
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
GLenum const GLvoid * addr
Definition: glext.h:9621
Status
Definition: gdiplustypes.h:24
#define ok(value,...)
Definition: atltest.h:57
#define AF_INET
Definition: tcpip.h:117
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define htons(x)
Definition: module.h:213
#define SOCK_DGRAM
Definition: winsock.h:336
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define memset(x, y, z)
Definition: compat.h:39

Referenced by START_TEST().