aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/salticidae/msg.h4
-rw-r--r--include/salticidae/network.h21
-rw-r--r--src/msg.cpp4
-rw-r--r--src/network.cpp48
4 files changed, 68 insertions, 9 deletions
diff --git a/include/salticidae/msg.h b/include/salticidae/msg.h
index 7e8032b..2f597fc 100644
--- a/include/salticidae/msg.h
+++ b/include/salticidae/msg.h
@@ -285,9 +285,9 @@ typedef struct msg_t msg_t;
extern "C" {
#endif
-msg_t *msg_new(_opcode_t opcode, bytearray_t *_moved_payload);
+msg_t *msg_new_moved_from_bytearray(_opcode_t opcode, bytearray_t *_moved_payload);
void msg_free(msg_t *msg);
-datastream_t *msg_get_payload(const msg_t *msg);
+datastream_t *msg_consume_payload(const msg_t *msg);
_opcode_t msg_get_opcode(const msg_t *msg);
#ifdef __cplusplus
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index 4c5b6d0..98bd1e4 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -819,6 +819,11 @@ typedef enum msgnetwork_conn_mode_t {
CONN_MODE_DEAD
} msgnetwork_conn_mode_t;
+typedef enum peernetwork_id_mode_t {
+ ID_MODE_IP_BASED,
+ ID_MODE_IP_PORT_BASED
+} peernetwork_id_mode_t;
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -828,6 +833,12 @@ void salticidae_injected_msg_callback(const msg_t *msg, msgnetwork_conn_t *conn)
// MsgNetwork
msgnetwork_config_t *msgnetwork_config_new();
void msgnetwork_config_free(const msgnetwork_config_t *self);
+void msgnetwork_config_burst_size(msgnetwork_config_t *self, size_t burst_size);
+void msgnetwork_config_max_listen_backlog(msgnetwork_config_t *self, int backlog);
+void msgnetwork_config_conn_server_timeout(msgnetwork_config_t *self, double timeout);
+void msgnetwork_config_seg_buff_size(msgnetwork_config_t *self, size_t size);
+void msgnetwork_config_nworker(msgnetwork_config_t *self, size_t nworker);
+void msgnetwork_config_queue_capacity(msgnetwork_config_t *self, size_t cap);
msgnetwork_t *msgnetwork_new(const eventcontext_t *ec, const msgnetwork_config_t *config);
void msgnetwork_free(const msgnetwork_t *self);
@@ -851,6 +862,12 @@ netaddr_t *msgnetwork_conn_get_addr(const msgnetwork_conn_t *conn);
peernetwork_config_t *peernetwork_config_new();
void peernetwork_config_free(const peernetwork_config_t *self);
+void peernetwork_config_retry_conn_delay(peernetwork_config_t *self, double t);
+void peernetwork_config_ping_period(peernetwork_config_t *self, double t);
+void peernetwork_config_conn_timeout(peernetwork_config_t *self, double t);
+void peernetwork_config_id_mode(peernetwork_config_t *self, peernetwork_id_mode_t mode);
+msgnetwork_config_t *peernetwork_config_as_msgnetwork_config(peernetwork_config_t *self);
+
peernetwork_t *peernetwork_new(const eventcontext_t *ec, const peernetwork_config_t *config);
void peernetwork_free(const peernetwork_t *self);
void peernetwork_add_peer(peernetwork_t *self, const netaddr_t *paddr);
@@ -858,8 +875,8 @@ bool peernetwork_has_peer(const peernetwork_t *self, const netaddr_t *paddr);
const peernetwork_conn_t *peernetwork_get_peer_conn(const peernetwork_t *self, const netaddr_t *paddr);
msgnetwork_t *peernetwork_as_msgnetwork(peernetwork_t *self);
msgnetwork_conn_t *msgnetwork_conn_new_from_peernetwork_conn(const peernetwork_conn_t *conn);
-void peernetwork_send_msg(peernetwork_t *self, msg_t * _moved_msg, const netaddr_t *paddr);
-void peernetwork_multicast_msg(peernetwork_t *self, msg_t *_moved_msg, const netaddr_array_t *paddrs);
+void peernetwork_send_msg_by_move(peernetwork_t *self, msg_t * _moved_msg, const netaddr_t *paddr);
+void peernetwork_multicast_msg_by_move(peernetwork_t *self, msg_t *_moved_msg, const netaddr_array_t *paddrs);
void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr);
#ifdef __cplusplus
diff --git a/src/msg.cpp b/src/msg.cpp
index 33dc31c..d525cd5 100644
--- a/src/msg.cpp
+++ b/src/msg.cpp
@@ -4,7 +4,7 @@
extern "C" {
-msg_t *msg_new(_opcode_t opcode, bytearray_t *_moved_payload) {
+msg_t *msg_new_moved_from_bytearray(_opcode_t opcode, bytearray_t *_moved_payload) {
auto res = new msg_t(opcode, std::move(*_moved_payload));
bytearray_free(_moved_payload);
return res;
@@ -12,7 +12,7 @@ msg_t *msg_new(_opcode_t opcode, bytearray_t *_moved_payload) {
void msg_free(msg_t *msg) { delete msg; }
-datastream_t *msg_get_payload(const msg_t *msg) {
+datastream_t *msg_consume_payload(const msg_t *msg) {
return new datastream_t(msg->get_payload());
}
diff --git a/src/network.cpp b/src/network.cpp
index 39eec4c..42496e8 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -20,6 +20,30 @@ msgnetwork_t *msgnetwork_new(const eventcontext_t *ec, const msgnetwork_config_t
void msgnetwork_free(const msgnetwork_t *self) { delete self; }
+void msgnetwork_config_burst_size(msgnetwork_config_t *self, size_t burst_size) {
+ self->burst_size(burst_size);
+}
+
+void msgnetwork_config_max_listen_backlog(msgnetwork_config_t *self, int backlog) {
+ self->max_listen_backlog(backlog);
+}
+
+void msgnetwork_config_conn_server_timeout(msgnetwork_config_t *self, double timeout) {
+ self->conn_server_timeout(timeout);
+}
+
+void msgnetwork_config_seg_buff_size(msgnetwork_config_t *self, size_t size) {
+ self->seg_buff_size(size);
+}
+
+void msgnetwork_config_nworker(msgnetwork_config_t *self, size_t nworker) {
+ self->nworker(nworker);
+}
+
+void msgnetwork_config_queue_capacity(msgnetwork_config_t *self, size_t cap) {
+ self->queue_capacity(cap);
+}
+
bool msgnetwork_send_msg(msgnetwork_t *self,
const msg_t *msg, const msgnetwork_conn_t *conn) {
return self->_send_msg(*msg, *conn);
@@ -78,6 +102,24 @@ peernetwork_config_t *peernetwork_config_new() {
void peernetwork_config_free(const peernetwork_config_t *self) { delete self; }
+void peernetwork_config_retry_conn_delay(peernetwork_config_t *self, double t) {
+ self->retry_conn_delay(t);
+}
+
+void peernetwork_config_ping_period(peernetwork_config_t *self, double t) {
+ self->ping_period(t);
+}
+
+void peernetwork_config_conn_timeout(peernetwork_config_t *self, double t) {
+ self->conn_timeout(t);
+}
+
+void peernetwork_config_id_mode(peernetwork_config_t *self, peernetwork_id_mode_t mode) {
+ self->id_mode(peernetwork_t::IdentityMode(mode));
+}
+
+msgnetwork_config_t *peernetwork_config_as_msgnetwork_config(peernetwork_config_t *self) { return self; }
+
peernetwork_t *peernetwork_new(const eventcontext_t *ec, const peernetwork_config_t *config) {
return new peernetwork_t(*ec, *config);
}
@@ -103,13 +145,13 @@ msgnetwork_conn_t *msgnetwork_conn_new_from_peernetwork_conn(const peernetwork_c
return new msgnetwork_conn_t(*conn);
}
-void peernetwork_send_msg(peernetwork_t *self,
- msg_t * _moved_msg, const netaddr_t *paddr) {
+void peernetwork_send_msg_by_move(peernetwork_t *self,
+ msg_t * _moved_msg, const netaddr_t *paddr) {
self->_send_msg(std::move(*_moved_msg), *paddr);
delete _moved_msg;
}
-void peernetwork_multicast_msg(peernetwork_t *self,
+void peernetwork_multicast_msg_by_move(peernetwork_t *self,
msg_t *_moved_msg,
const netaddr_array_t *paddrs) {
self->multicast_msg(std::move(*_moved_msg), *paddrs);