aboutsummaryrefslogtreecommitdiff
path: root/src/netaddr.cpp
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-03 17:30:01 -0400
committerDeterminant <[email protected]>2019-06-03 17:30:01 -0400
commit9f294eb2e0ae0bed8120fc34fd9782f2f0a9ac74 (patch)
treed5005c9888874bd2b169fcd51418a3fab36fe631 /src/netaddr.cpp
parent9ec5a371f5c05fda8ddeac3470be6fc5c67d44e9 (diff)
WIP: C bindings
Diffstat (limited to 'src/netaddr.cpp')
-rw-r--r--src/netaddr.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/netaddr.cpp b/src/netaddr.cpp
new file mode 100644
index 0000000..a3a54bf
--- /dev/null
+++ b/src/netaddr.cpp
@@ -0,0 +1,30 @@
+#include "salticidae/netaddr.h"
+
+using namespace salticidae;
+
+#ifdef __cplusplus
+
+extern "C" {
+
+netaddr_t *netaddr_new() { return new NetAddr(); }
+netaddr_t *netaddr_new_from_ip_port(uint32_t ip, uint16_t port) {
+ return new NetAddr(ip, port);
+}
+
+netaddr_t *netaddr_new_from_sip_port(const char *ip, uint16_t port) {
+ return new NetAddr(ip, port);
+}
+
+netaddr_t *netaddr_new_from_sipport(const char *ip_port_addr) {
+ return new NetAddr(ip_port_addr);
+}
+
+bool netaddr_is_eq(const netaddr_t *a, const netaddr_t *b) {
+ return *a == *b;
+}
+
+bool netaddr_is_null(const netaddr_t *self) { return self->is_null(); }
+
+}
+
+#endif