summaryrefslogtreecommitdiffstats
path: root/tapset/inet.stp
blob: 9df5ea660d1be44cb90043199beea32b69016964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
%{
#include <net/sock.h>
#include <net/inet_hashtables.h>
#include <linux/in.h>
%}

function _inet_ntoa:string (_uaddr:long) %{
	struct sockaddr_in *addr;
	unsigned char *bytes;

	addr = (struct sockaddr_in *)(long)kread(&THIS->_uaddr);
	bytes = (unsigned char *)&addr->sin_addr.s_addr;

	snprintf(THIS->__retvalue, MAXSTRINGLEN, 
		"%d.%d.%d.%d:%d", bytes[0], bytes[1], bytes[2], bytes[3],
		addr->sin_port);

	CATCH_DEREF_FAULT();
%}