aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2019-06-04 18:59:00 -0400
committerDeterminant <[email protected]>2019-06-04 18:59:00 -0400
commitda42ddf96c78a73b4cf5f8854e98e009f4f174a4 (patch)
tree2435817585507cbc2a158fd84996884263dcc8ec /src
parentebada91a1327da99f1827c7e4c15fc3bee527d58 (diff)
...
Diffstat (limited to 'src')
-rw-r--r--src/msg.cpp2
-rw-r--r--src/network.cpp8
-rw-r--r--src/stream.cpp10
-rw-r--r--src/type.cpp4
4 files changed, 22 insertions, 2 deletions
diff --git a/src/msg.cpp b/src/msg.cpp
index e75d7d4..d395d2b 100644
--- a/src/msg.cpp
+++ b/src/msg.cpp
@@ -8,7 +8,7 @@ msg_t *msg_new(_opcode_t opcode, bytearray_t *_moved_payload) {
bytearray_free(payload);
}
-datastream_t *msg_get_payload(msg_t *msg) {
+datastream_t *msg_get_payload(const msg_t *msg) {
return new datastream_t(msg->get_payload());
}
diff --git a/src/network.cpp b/src/network.cpp
index 0b12131..d2d9615 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -55,6 +55,14 @@ msgnetwork_t *msgnetwork_conn_get_net(const msgnetwork_conn_t *conn) {
void msgnetwork_start(msgnetwork_t *self) { self->start(); }
+msgnetwork_conn_mode_t msgnetwork_conn_get_mode(const msgnetwork_conn_t *conn) {
+ return conn->get_mode();
+}
+
+netaddr_t msgnetwork_conn_get_addr(const msgnetwork_conn_t *conn) {
+ return new netaddr_t(conn->get_addr());
+}
+
}
#endif
diff --git a/src/stream.cpp b/src/stream.cpp
index f3dd322..ec1d5da 100644
--- a/src/stream.cpp
+++ b/src/stream.cpp
@@ -51,7 +51,7 @@ void datastream_put_i16(datastream_t *self, int16_t val) { *self << val; }
void datastream_put_i32(datastream_t *self, int32_t val) { *self << val; }
void datastream_put_data(datastream_t *self,
- uint8_t *begin, uint8_t *end) {
+ const uint8_t *begin, const uint8_t *end) {
self->put_data(begin, end);
}
@@ -87,6 +87,14 @@ uint256_t *datastream_get_hash(const datastream_t *self) {
return new uint256_t(self->get_hash());
}
+void datastream_free(const datastream_t *self) { delete self; }
+
+bytearray_t *datastream_to_bytearray(datastream_t *self) {
+ auto res = new bytearray_t(std::move(*self));
+ delete self;
+ return res;
+}
+
}
#endif
diff --git a/src/type.cpp b/src/type.cpp
index 8290a07..1b02933 100644
--- a/src/type.cpp
+++ b/src/type.cpp
@@ -3,6 +3,10 @@
extern "C" {
+bytearray_t *bytearray_new() {
+ return new bytearray_t();
+}
+
uint8_t *bytearray_data(bytearray_t *arr) {
return &(*arr)[0];
}