Blame src/socket/ntapi_sc_getsockname_v2.c

dd89bb
/********************************************************/
dd89bb
/*  ntapi: Native API core library                      */
64e606
/*  Copyright (C) 2013--2021  SysDeer Technologies, LLC */
dd89bb
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
dd89bb
/********************************************************/
dd89bb
dd89bb
#include <psxtypes/psxtypes.h>
dd89bb
#include <ntapi/nt_object.h>
dd89bb
#include <ntapi/nt_file.h>
dd89bb
#include <ntapi/nt_socket.h>
dd89bb
#include <ntapi/ntapi.h>
dd89bb
#include "ntapi_impl.h"
dd89bb
dd89bb
int32_t __cdecl __ntapi_sc_getsockname_v2(
dd89bb
	__in	nt_socket *		hssocket,
dd89bb
	__in	nt_sockaddr *		addr,
dd89bb
	__in	uint16_t *		addrlen,
2e04e9
	__out	nt_iosb volatile *	iosb	__optional)
dd89bb
{
2e04e9
	nt_iosb volatile siosb;
dd89bb
dd89bb
	iosb = iosb ? iosb : &siosb;
dd89bb
dd89bb
	hssocket->iostatus = __ntapi->zw_device_io_control_file(
dd89bb
			hssocket->hsocket,
dd89bb
			hssocket->hevent,
dd89bb
			0,
dd89bb
			0,
dd89bb
			iosb,
dd89bb
			NT_AFD_IOCTL_GET_SOCK_NAME,
dd89bb
			0,
dd89bb
			0,
dd89bb
			addr,
dd89bb
			sizeof(*addr));
dd89bb
dd89bb
	__ntapi->sc_wait(hssocket,iosb,0);
dd89bb
dd89bb
	if (!hssocket->iostatus)
dd89bb
		*addrlen = (uint16_t)iosb->info;
dd89bb
dd89bb
	return hssocket->iostatus;
dd89bb
}