summaryrefslogtreecommitdiffhomepage
path: root/src/socket/ntapi_sc_getsockname_v2.c
blob: 07313ac3552a3ed9182687cac3e8db289f1d48fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013,2014,2015  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_getsockname_v2(
	__in	nt_socket *		hssocket,
	__in	nt_sockaddr *		addr,
	__in	uint16_t *		addrlen,
	__out	nt_io_status_block *	iosb	__optional)
{
	nt_iosb siosb;

	iosb = iosb ? iosb : &siosb;

	hssocket->iostatus = __ntapi->zw_device_io_control_file(
			hssocket->hsocket,
			hssocket->hevent,
			0,
			0,
			iosb,
			NT_AFD_IOCTL_GET_SOCK_NAME,
			0,
			0,
			addr,
			sizeof(*addr));

	__ntapi->sc_wait(hssocket,iosb,0);

	if (!hssocket->iostatus)
		*addrlen = (uint16_t)iosb->info;

	return hssocket->iostatus;
}