aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-10 21:32:45 -0400
committerDeterminant <[email protected]>2019-06-10 21:32:45 -0400
commit299d1a3cf7f7ab2465dccc87dde578044c9b040b (patch)
treeaaf7d58d929fdc564b94dccc6a22576d58bf822f
parent66c711cf653b082ae07e1119417dcb3461039c80 (diff)
...
-rw-r--r--include/salticidae/event.h6
-rw-r--r--include/salticidae/netaddr.h2
-rw-r--r--include/salticidae/network.h1
-rw-r--r--src/event.cpp12
-rw-r--r--src/netaddr.cpp4
-rw-r--r--src/network.cpp4
6 files changed, 20 insertions, 9 deletions
diff --git a/include/salticidae/event.h b/include/salticidae/event.h
index c82d54f..c54b69d 100644
--- a/include/salticidae/event.h
+++ b/include/salticidae/event.h
@@ -686,9 +686,9 @@ sigev_t *sigev_new(const eventcontext_t *ec, sigev_callback_t cb);
void sigev_free(sigev_t *self);
void sigev_add(sigev_t *self, int sig);
-typedef void (*timerev_callback_t)(timerev_t *);
-timerev_t *timerev_new(const eventcontext_t *ec, timerev_callback_t callback);
-void timerev_set_callback(timerev_t *self, timerev_callback_t callback);
+typedef void (*timerev_callback_t)(timerev_t *, void *);
+timerev_t *timerev_new(const eventcontext_t *ec, timerev_callback_t callback, void *);
+void timerev_set_callback(timerev_t *self, timerev_callback_t callback, void *);
void timerev_free(timerev_t *self);
void timerev_add(timerev_t *self, double t_sec);
void timerev_del(timerev_t *self);
diff --git a/include/salticidae/netaddr.h b/include/salticidae/netaddr.h
index 4edf926..01510e0 100644
--- a/include/salticidae/netaddr.h
+++ b/include/salticidae/netaddr.h
@@ -141,6 +141,8 @@ netaddr_t *netaddr_new_from_sip_port(const char *ip, uint16_t port);
netaddr_t *netaddr_new_from_sipport(const char *ip_port_addr);
bool netaddr_is_eq(const netaddr_t *a, const netaddr_t *b);
bool netaddr_is_null(const netaddr_t *self);
+uint32_t netaddr_get_ip(const netaddr_t *self);
+uint16_t netaddr_get_port(const netaddr_t *self);
#ifdef __cplusplus
}
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index 3b53f26..32d638a 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -841,6 +841,7 @@ bool msgnetwork_send_msg(msgnetwork_t *self, const msg_t *msg, const msgnetwork_
msgnetwork_conn_t *msgnetwork_connect(msgnetwork_t *self, const netaddr_t *addr);
void msgnetwork_listen(msgnetwork_t *self, const netaddr_t *listen_addr);
void msgnetwork_start(msgnetwork_t *self);
+void msgnetwork_terminate(msgnetwork_t *self, const msgnetwork_conn_t *conn);
typedef void (*msgnetwork_msg_callback_t)(const msg_t *, const msgnetwork_conn_t *, void *userdata);
void msgnetwork_reg_handler(msgnetwork_t *self, _opcode_t opcode, msgnetwork_msg_callback_t cb, void *userdata);
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();
}