From 299d1a3cf7f7ab2465dccc87dde578044c9b040b Mon Sep 17 00:00:00 2001 From: Determinant Date: Mon, 10 Jun 2019 21:32:45 -0400 Subject: ... --- src/event.cpp | 12 ++++++------ src/netaddr.cpp | 4 ++++ src/network.cpp | 4 ++++ 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/event.cpp b/src/event.cpp index 2e38e5f..9b6f432 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -34,15 +34,15 @@ void sigev_free(sigev_t *self) { delete self; } void sigev_add(sigev_t *self, int sig) { self->add(sig); } -timerev_t *timerev_new(const eventcontext_t *ec, timerev_callback_t callback) { - return new timerev_t(*ec, [callback](salticidae::TimerEvent &ev) { - callback(&ev); +timerev_t *timerev_new(const eventcontext_t *ec, timerev_callback_t callback, void *userdata) { + return new timerev_t(*ec, [=](salticidae::TimerEvent &ev) { + callback(&ev, userdata); }); } -void timerev_set_callback(timerev_t *self, timerev_callback_t callback) { - self->set_callback([callback](salticidae::TimerEvent &ev) { - callback(&ev); +void timerev_set_callback(timerev_t *self, timerev_callback_t callback, void *userdata) { + self->set_callback([=](salticidae::TimerEvent &ev) { + callback(&ev, userdata); }); } diff --git a/src/netaddr.cpp b/src/netaddr.cpp index 3c2618a..109a6ac 100644 --- a/src/netaddr.cpp +++ b/src/netaddr.cpp @@ -26,6 +26,10 @@ bool netaddr_is_eq(const netaddr_t *a, const netaddr_t *b) { bool netaddr_is_null(const netaddr_t *self) { return self->is_null(); } +uint32_t netaddr_get_ip(const netaddr_t *self) { return self->ip; } + +uint16_t netaddr_get_port(const netaddr_t *self) { return self->port; } + } #endif diff --git a/src/network.cpp b/src/network.cpp index c14531c..673cc24 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -54,6 +54,10 @@ void msgnetwork_reg_conn_handler(msgnetwork_t *self, void msgnetwork_start(msgnetwork_t *self) { self->start(); } +void msgnetwork_terminate(msgnetwork_t *self, const msgnetwork_conn_t *conn) { + self->terminate(*conn); +} + msgnetwork_t *msgnetwork_conn_get_net(const msgnetwork_conn_t *conn) { return (*conn)->get_net(); } -- cgit v1.2.3-70-g09d2