Add Native_Functions module for inet_addr / inet_ntoa
diff --git a/ggsn_tests/gen_links.sh b/ggsn_tests/gen_links.sh
index d0f410a..573e263 100755
--- a/ggsn_tests/gen_links.sh
+++ b/ggsn_tests/gen_links.sh
@@ -16,7 +16,7 @@
 #gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
-FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h Native_Functions.ttcn Native_FunctionDefs.cc"
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCConversion.hh TCCInterface.cc TCCInterface_ip.h"
 gen_links $DIR $FILES
 
 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
@@ -40,5 +40,5 @@
 gen_links $DIR $FILES
 
 DIR=../library
-FILES="General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn"
+FILES="General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc"
 gen_links $DIR $FILES
diff --git a/library/Native_FunctionDefs.cc b/library/Native_FunctionDefs.cc
index 446d86b..5dda08c 100644
--- a/library/Native_FunctionDefs.cc
+++ b/library/Native_FunctionDefs.cc
@@ -1,3 +1,4 @@
+
 /* 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>
@@ -22,4 +23,35 @@
 	return OCTETSTRING(4, (const unsigned char *)&ia);
 }
 
+OCTETSTRING f__inet__haddr(const CHARSTRING& in)
+{
+	TTCN_Buffer ttcn_buffer(in);
+	in_addr_t ia;
+
+	ia = inet_addr((const char *)ttcn_buffer.get_data());
+	ia = ntohl(ia);
+
+	return OCTETSTRING(4, (const unsigned char *)&ia);
+}
+
+CHARSTRING f__inet__ntoa(const OCTETSTRING& in)
+{
+	TTCN_Buffer ttcn_buffer(in);
+	const struct in_addr ia = *(const struct in_addr *)ttcn_buffer.get_data();
+	const char *str = inet_ntoa(ia);
+
+	return CHARSTRING(str);
+}
+
+CHARSTRING f__inet__hntoa(const OCTETSTRING& in)
+{
+	TTCN_Buffer ttcn_buffer(in);
+	struct in_addr ia = *(const in_addr *)ttcn_buffer.get_data();
+	ia.s_addr = htonl(ia.s_addr);
+	const char *str = inet_ntoa(ia);
+
+	return CHARSTRING(str);
+}
+
+
 } // namespace
diff --git a/library/Native_Functions.ttcn b/library/Native_Functions.ttcn
index ac62161..31bc767 100644
--- a/library/Native_Functions.ttcn
+++ b/library/Native_Functions.ttcn
@@ -1,4 +1,12 @@
 module Native_Functions {
 
+	/* direct import of inet_addr() C function, returns net byte order */
 	external function f_inet_addr(in charstring ch) return octetstring;
+	/* like inet_addr() but return is host byte order */
+	external function f_inet_haddr(in charstring ch) return octetstring;
+
+	/* direct import of inet_ntoa() C function, input net byte order */
+	external function f_inet_ntoa(in octetstring oct) return charstring;
+	/* like inet_ntoa() but input is host byte order */
+	external function f_inet_hntoa(in octetstring oct) return charstring;
 }