summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-03-25 04:53:13 -0400
committermidipix <writeonce@midipix.org>2016-03-27 10:54:31 -0400
commitf6c77ac338e5e7a913404658b765936782776869 (patch)
tree82a494545d0586ab3219a7ad656a3d3c40bac9fa
parenteb53e602bc5289b3702dd4a711ff1054da7b1086 (diff)
downloadntapi-f6c77ac338e5e7a913404658b765936782776869.tar.bz2
ntapi-f6c77ac338e5e7a913404658b765936782776869.tar.xz
socket interfaces: __ntapi_sc_recv(): added connectionless datagram support.
-rw-r--r--include/ntapi/nt_socket.h8
-rw-r--r--src/socket/ntapi_sc_recv.c31
2 files changed, 31 insertions, 8 deletions
diff --git a/include/ntapi/nt_socket.h b/include/ntapi/nt_socket.h
index 55b2bb1..00ce144 100644
--- a/include/ntapi/nt_socket.h
+++ b/include/ntapi/nt_socket.h
@@ -179,6 +179,7 @@
#define NT_AFD_IOCTL_SEND (0x1201Fu)
#define NT_AFD_IOCTL_UDP_SEND (0x12023u)
#define NT_AFD_IOCTL_RECV (0x12017u)
+#define NT_AFD_IOCTL_UDP_RECV (0x1201bu)
#define NT_AFD_IOCTL_DISCONNECT (0x1202Bu)
#define NT_AFD_IOCTL_SELECT (0x12024u)
#define NT_AFD_IOCTL_GET_SOCK_NAME (0x1202Fu)
@@ -283,6 +284,12 @@ typedef union _nt_sockaddr {
} nt_sockaddr;
+typedef struct _nt_sockaddr_reply {
+ uint32_t addrlen;
+ nt_sockaddr addr;
+} nt_sockaddr_reply;
+
+
typedef struct _nt_afd_buffer {
size_t length;
char * buffer;
@@ -393,6 +400,7 @@ typedef int32_t __cdecl ntapi_sc_recv(
__in const void * buffer,
__in size_t len,
__out ssize_t * bytes_received __optional,
+ __in nt_sockaddr_reply * raddr __optional,
__in uintptr_t afdflags __optional,
__in uintptr_t tdiflags __optional,
__out nt_io_status_block * iosb __optional);
diff --git a/src/socket/ntapi_sc_recv.c b/src/socket/ntapi_sc_recv.c
index 2c969af..bdc6165 100644
--- a/src/socket/ntapi_sc_recv.c
+++ b/src/socket/ntapi_sc_recv.c
@@ -11,21 +11,36 @@
#include <ntapi/ntapi.h>
#include "ntapi_impl.h"
+typedef struct _nt_afd_recv_udp_info {
+ nt_afd_recv_info afd_recv;
+ nt_sockaddr * addr;
+ nt_sockaddr_reply * raddr;
+} nt_afd_recv_udp_info;
+
int32_t __cdecl __ntapi_sc_recv(
__in nt_socket * hssocket,
__in const void * buffer,
__in size_t len,
__out ssize_t * bytes_received __optional,
+ __in nt_sockaddr_reply * raddr __optional,
__in uintptr_t afdflags __optional,
__in uintptr_t tdiflags __optional,
__out nt_io_status_block * iosb __optional)
{
nt_afd_buffer afd_buffer;
- nt_afd_recv_info afd_recv;
+ nt_afd_recv_udp_info afd_recv;
nt_io_status_block siosb;
iosb = iosb ? iosb : &siosb;
+ /* conditional connect */
+ if (raddr && (hssocket->protocol == NT_IPPROTO_UDP)) {
+ afd_recv.raddr = raddr;
+ raddr->addrlen = sizeof(raddr->addr);
+ afd_recv.addr = &raddr->addr;
+ } else
+ raddr = 0;
+
/* tdiflags */
if (tdiflags == 0)
tdiflags = NT_TDI_RECEIVE_NORMAL;
@@ -34,12 +49,12 @@ int32_t __cdecl __ntapi_sc_recv(
afd_buffer.length = len;
afd_buffer.buffer = (char *)buffer;
- /* afd_recv */
- afd_recv.afd_buffer_array = &afd_buffer;
- afd_recv.buffer_count = 1;
+ /* afd_recv.afd_recv */
+ afd_recv.afd_recv.afd_buffer_array = &afd_buffer;
+ afd_recv.afd_recv.buffer_count = 1;
- afd_recv.afd_flags = (uint32_t)afdflags;
- afd_recv.tdi_flags = (uint32_t)tdiflags;
+ afd_recv.afd_recv.afd_flags = (uint32_t)afdflags;
+ afd_recv.afd_recv.tdi_flags = (uint32_t)tdiflags;
hssocket->iostatus = __ntapi->zw_device_io_control_file(
hssocket->hsocket,
@@ -47,9 +62,9 @@ int32_t __cdecl __ntapi_sc_recv(
0,
0,
iosb,
- NT_AFD_IOCTL_RECV,
+ raddr ? NT_AFD_IOCTL_UDP_RECV : NT_AFD_IOCTL_RECV,
&afd_recv,
- sizeof(afd_recv),
+ raddr ? sizeof(afd_recv) : sizeof(afd_recv.afd_recv),
0,
0);