Blame src/socket/ntapi_sc_setsockopt.c

830346
/********************************************************/
830346
/*  ntapi: Native API core library                      */
830346
/*  Copyright (C) 2013--2016  Z. Gilboa                 */
830346
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
830346
/********************************************************/
830346
830346
#include <psxtypes/psxtypes.h>
830346
#include <ntapi/nt_object.h>
830346
#include <ntapi/nt_file.h>
830346
#include <ntapi/nt_socket.h>
830346
#include <ntapi/ntapi.h>
830346
#include "ntapi_impl.h"
830346
830346
int32_t __cdecl __ntapi_sc_setsockopt(
830346
	__in	nt_socket *		hssocket,
830346
	__in	int32_t			level,
830346
	__in	int32_t			optname,
830346
	__in	const void *		optval,
830346
	__in	uint32_t		optlen,
830346
	__out	nt_io_status_block *	iosb)
830346
{
830346
	nt_afd_sockopt_info	afd_sockopt;
830346
	nt_io_status_block	siosb;
830346
830346
	iosb = iosb ? iosb : &siosb;
830346
830346
	/* afd_sockopt */
830346
	afd_sockopt.mode    = NT_AFD_SOCKOPT_SET;
830346
	afd_sockopt.level   = level;
830346
	afd_sockopt.optname = optname;
830346
	afd_sockopt.optval  = optval;
830346
	afd_sockopt.optlen  = optlen;
830346
	afd_sockopt.ding    = 1;
830346
830346
	hssocket->iostatus = __ntapi->zw_device_io_control_file(
830346
			hssocket->hsocket,
830346
			hssocket->hevent,
830346
			0,
830346
			0,
830346
			iosb,
830346
			NT_AFD_IOCTL_SOCKOPT,
830346
			&afd_sockopt,
830346
			sizeof(afd_sockopt),
830346
			0,
830346
			0);
830346
830346
	return hssocket->iostatus
830346
		? __ntapi->sc_wait(hssocket,iosb,0)
830346
		: NT_STATUS_SUCCESS;
830346
}