summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-06-16 13:23:50 -0400
committermidipix <writeonce@midipix.org>2016-06-16 13:23:50 -0400
commit4192289efd809a11ae1d29a1e31a0b55930ace8b (patch)
tree67a679d33136113e6d8d53223caf22a9dcd496cb /src
parent830346bf1600a38dbbacc569599da55895cfd033 (diff)
downloadntapi-4192289efd809a11ae1d29a1e31a0b55930ace8b.tar.bz2
ntapi-4192289efd809a11ae1d29a1e31a0b55930ace8b.tar.xz
__ntapi_sc_getsockopt(): initial implementation and integration.
Diffstat (limited to 'src')
-rw-r--r--src/internal/ntapi.c1
-rw-r--r--src/internal/ntapi_fnapi.h1
-rw-r--r--src/socket/ntapi_sc_getsockopt.c50
3 files changed, 52 insertions, 0 deletions
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index 451ccd7..07f0da7 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -309,6 +309,7 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
__ntapi->sc_shutdown = __ntapi_sc_shutdown;
__ntapi->sc_server_duplicate_socket = __ntapi_sc_server_duplicate_socket;
__ntapi->sc_setsockopt = __ntapi_sc_setsockopt;
+ __ntapi->sc_getsockopt = __ntapi_sc_getsockopt;
__ntapi->sc_wait = __ntapi_sc_wait;
/* nt_mount.h */
diff --git a/src/internal/ntapi_fnapi.h b/src/internal/ntapi_fnapi.h
index 05f4707..396fb59 100644
--- a/src/internal/ntapi_fnapi.h
+++ b/src/internal/ntapi_fnapi.h
@@ -204,6 +204,7 @@ ntapi_sc_server_accept_connection __ntapi_sc_server_accept_connection_v1;
ntapi_sc_server_accept_connection __ntapi_sc_server_accept_connection_v2;
ntapi_sc_server_duplicate_socket __ntapi_sc_server_duplicate_socket;
ntapi_sc_setsockopt __ntapi_sc_setsockopt;
+ntapi_sc_getsockopt __ntapi_sc_getsockopt;
ntapi_sc_listen __ntapi_sc_listen;
ntapi_sc_accept __ntapi_sc_accept;
ntapi_sc_send __ntapi_sc_send;
diff --git a/src/socket/ntapi_sc_getsockopt.c b/src/socket/ntapi_sc_getsockopt.c
new file mode 100644
index 0000000..3fa59d4
--- /dev/null
+++ b/src/socket/ntapi_sc_getsockopt.c
@@ -0,0 +1,50 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013--2016 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <psxtypes/psxtypes.h>
+#include <ntapi/nt_object.h>
+#include <ntapi/nt_file.h>
+#include <ntapi/nt_socket.h>
+#include <ntapi/ntapi.h>
+#include "ntapi_impl.h"
+
+int32_t __cdecl __ntapi_sc_getsockopt(
+ __in nt_socket * hssocket,
+ __in int32_t level,
+ __in int32_t optname,
+ __out void * optval,
+ __in uint32_t optlen,
+ __out nt_io_status_block * iosb)
+{
+ nt_afd_sockopt_info afd_sockopt;
+
+ if (!iosb)
+ return NT_STATUS_INVALID_PARAMETER_6;
+
+ /* afd_sockopt */
+ afd_sockopt.mode = NT_AFD_SOCKOPT_GET;
+ afd_sockopt.level = level;
+ afd_sockopt.optname = optname;
+ afd_sockopt.optval = 0;
+ afd_sockopt.optlen = 0;
+ afd_sockopt.ding = 1;
+
+ hssocket->iostatus = __ntapi->zw_device_io_control_file(
+ hssocket->hsocket,
+ hssocket->hevent,
+ 0,
+ 0,
+ iosb,
+ NT_AFD_IOCTL_SOCKOPT,
+ &afd_sockopt,
+ sizeof(afd_sockopt),
+ optval,
+ optlen);
+
+ return hssocket->iostatus
+ ? __ntapi->sc_wait(hssocket,iosb,0)
+ : NT_STATUS_SUCCESS;
+}