summaryrefslogtreecommitdiffstats
path: root/library/Native_FunctionDefs.cc
blob: 446d86bb109643ba82158a2c39fd1c0f581c9e0f (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
/* Utility functions that I'm used to from C but for which I couldn't find TTCN-3 implementations
 *
 * (C) 2017 by Harald Welte <laforge@gnumonks.org>
 */

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#include <Charstring.hh>
#include <Octetstring.hh>

namespace Native__Functions {

OCTETSTRING f__inet__addr(const CHARSTRING& in)
{
	TTCN_Buffer ttcn_buffer(in);
	in_addr_t ia;

	ia = inet_addr((const char *)ttcn_buffer.get_data());

	return OCTETSTRING(4, (const unsigned char *)&ia);
}

} // namespace