summaryrefslogtreecommitdiffhomepage
path: root/src/socket/ntapi_sc_getsockname_v2.c
blob: 25d867fa839ab8c199a9f95fae304978d71c5612 (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--2017  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;
}