diff options
author | midipix <writeonce@midipix.org> | 2016-06-16 13:22:38 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-06-16 13:22:38 -0400 |
commit | 830346bf1600a38dbbacc569599da55895cfd033 (patch) | |
tree | a64218ef4b7fdbac932516a636f70e5078af180a /src/socket | |
parent | a867b08c1bdfa631cd117be7d23a4ad90246d27e (diff) | |
download | ntapi-830346bf1600a38dbbacc569599da55895cfd033.tar.bz2 ntapi-830346bf1600a38dbbacc569599da55895cfd033.tar.xz |
__ntapi_sc_setsockopt(): initial implementation and integration.
Diffstat (limited to 'src/socket')
-rw-r--r-- | src/socket/ntapi_sc_setsockopt.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/socket/ntapi_sc_setsockopt.c b/src/socket/ntapi_sc_setsockopt.c new file mode 100644 index 0000000..4989e54 --- /dev/null +++ b/src/socket/ntapi_sc_setsockopt.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_setsockopt( + __in nt_socket * hssocket, + __in int32_t level, + __in int32_t optname, + __in const void * optval, + __in uint32_t optlen, + __out nt_io_status_block * iosb) +{ + nt_afd_sockopt_info afd_sockopt; + nt_io_status_block siosb; + + iosb = iosb ? iosb : &siosb; + + /* afd_sockopt */ + afd_sockopt.mode = NT_AFD_SOCKOPT_SET; + afd_sockopt.level = level; + afd_sockopt.optname = optname; + afd_sockopt.optval = optval; + afd_sockopt.optlen = optlen; + 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), + 0, + 0); + + return hssocket->iostatus + ? __ntapi->sc_wait(hssocket,iosb,0) + : NT_STATUS_SUCCESS; +} |