summaryrefslogtreecommitdiffstats
path: root/library/Native_FunctionDefs.cc
diff options
context:
space:
mode:
Diffstat (limited to 'library/Native_FunctionDefs.cc')
-rw-r--r--library/Native_FunctionDefs.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/library/Native_FunctionDefs.cc b/library/Native_FunctionDefs.cc
new file mode 100644
index 0000000..446d86b
--- /dev/null
+++ b/library/Native_FunctionDefs.cc
@@ -0,0 +1,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