summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/common/enroll.c1
-rw-r--r--src/ipcpd/unicast/CMakeLists.txt4
-rw-r--r--src/ipcpd/unicast/dir/dht.c62
-rw-r--r--src/ipcpd/unicast/dir/dht.proto (renamed from src/ipcpd/unicast/dir/kademlia.proto)8
-rw-r--r--src/ipcpd/unicast/dir/tests/CMakeLists.txt5
-rw-r--r--src/lib/CMakeLists.txt12
-rw-r--r--src/lib/pb/cacep.proto (renamed from src/lib/cacep.proto)0
-rw-r--r--src/lib/pb/enroll.proto (renamed from src/lib/enroll.proto)0
-rw-r--r--src/lib/pb/ipcp.proto (renamed from src/lib/ipcpd_messages.proto)2
-rw-r--r--src/lib/pb/ipcp_config.proto (renamed from src/lib/ipcp_config.proto)0
-rw-r--r--src/lib/pb/irm.proto (renamed from src/lib/irmd_messages.proto)2
-rw-r--r--src/lib/pb/qos.proto (renamed from src/lib/qosspec.proto)0
12 files changed, 47 insertions, 49 deletions
diff --git a/src/ipcpd/common/enroll.c b/src/ipcpd/common/enroll.c
index 4cc2fa42..eeff391a 100644
--- a/src/ipcpd/common/enroll.c
+++ b/src/ipcpd/common/enroll.c
@@ -133,7 +133,6 @@ static void * enroll_handle(void * o)
if (len < 0) {
log_err_id(req.id, "Failed to read from flow.");
goto finish_enroll;
-
}
msg.data = buf.data;
diff --git a/src/ipcpd/unicast/CMakeLists.txt b/src/ipcpd/unicast/CMakeLists.txt
index c87a58c4..ca742871 100644
--- a/src/ipcpd/unicast/CMakeLists.txt
+++ b/src/ipcpd/unicast/CMakeLists.txt
@@ -16,7 +16,7 @@ set(IPCP_UNICAST_TARGET ipcpd-unicast CACHE INTERNAL "")
set(IPCP_UNICAST_MPL 60 CACHE STRING
"Default maximum packet lifetime for the unicast IPCP, in seconds")
-protobuf_generate_c(KAD_PROTO_SRCS KAD_PROTO_HDRS dir/kademlia.proto)
+protobuf_generate_c(DHT_PROTO_SRCS DHT_PROTO_HDRS dir/dht.proto)
math(EXPR PFT_EXPR "1 << 12")
set(PFT_SIZE ${PFT_EXPR} CACHE STRING
@@ -57,7 +57,7 @@ set(SOURCE_FILES
)
add_executable(ipcpd-unicast ${SOURCE_FILES} ${IPCP_SOURCES} ${COMMON_SOURCES}
- ${KAD_PROTO_SRCS} ${LAYER_CONFIG_PROTO_SRCS})
+ ${DHT_PROTO_SRCS} ${LAYER_CONFIG_PROTO_SRCS})
target_link_libraries(ipcpd-unicast LINK_PUBLIC ouroboros-dev)
include(AddCompileFlags)
diff --git a/src/ipcpd/unicast/dir/dht.c b/src/ipcpd/unicast/dir/dht.c
index adc6feb2..7e4bd474 100644
--- a/src/ipcpd/unicast/dir/dht.c
+++ b/src/ipcpd/unicast/dir/dht.c
@@ -57,9 +57,9 @@
#include <inttypes.h>
#include <limits.h>
-#include "kademlia.pb-c.h"
-typedef KadMsg kad_msg_t;
-typedef KadContactMsg kad_contact_msg_t;
+#include "dht.pb-c.h"
+typedef DhtMsg dht_msg_t;
+typedef DhtContactMsg dht_contact_msg_t;
#ifndef CLOCK_REALTIME_COARSE
#define CLOCK_REALTIME_COARSE CLOCK_REALTIME
@@ -354,7 +354,7 @@ static uint8_t * create_id(size_t len)
}
static void kad_req_create(struct dht * dht,
- kad_msg_t * msg,
+ dht_msg_t * msg,
uint64_t addr)
{
struct kad_req * req;
@@ -793,7 +793,7 @@ static void lookup_destroy(struct lookup * lu)
static void lookup_update(struct dht * dht,
struct lookup * lu,
- kad_msg_t * msg)
+ dht_msg_t * msg)
{
struct list_head * p = NULL;
struct list_head * h;
@@ -1027,7 +1027,7 @@ static enum lookup_state lookup_wait(struct lookup * lu)
}
static struct kad_req * dht_find_request(struct dht * dht,
- kad_msg_t * msg)
+ dht_msg_t * msg)
{
struct list_head * p;
@@ -1464,7 +1464,7 @@ static int dht_update_bucket(struct dht * dht,
}
static int send_msg(struct dht * dht,
- kad_msg_t * msg,
+ dht_msg_t * msg,
uint64_t addr)
{
#ifndef __DHT_TEST__
@@ -1497,7 +1497,7 @@ static int send_msg(struct dht * dht,
pthread_rwlock_unlock(&dht->lock);
#ifndef __DHT_TEST__
- len = kad_msg__get_packed_size(msg);
+ len = dht_msg__get_packed_size(msg);
if (len == 0)
goto fail_msg;
@@ -1505,7 +1505,7 @@ static int send_msg(struct dht * dht,
if (ipcp_sdb_reserve(&sdb, len))
goto fail_msg;
- kad_msg__pack(msg, shm_du_buff_head(sdb));
+ dht_msg__pack(msg, shm_du_buff_head(sdb));
if (dt_write_packet(addr, QOS_CUBE_BE, dht->eid, sdb) == 0)
break;
@@ -1552,7 +1552,7 @@ static struct dht_entry * dht_find_entry(struct dht * dht,
}
static int kad_add(struct dht * dht,
- const kad_contact_msg_t * contacts,
+ const dht_contact_msg_t * contacts,
ssize_t n,
time_t exp)
{
@@ -1591,7 +1591,7 @@ static int kad_add(struct dht * dht,
}
static int wait_resp(struct dht * dht,
- kad_msg_t * msg,
+ dht_msg_t * msg,
time_t timeo)
{
struct kad_req * req;
@@ -1618,9 +1618,9 @@ static int kad_store(struct dht * dht,
uint64_t r_addr,
time_t ttl)
{
- kad_msg_t msg = KAD_MSG__INIT;
- kad_contact_msg_t cmsg = KAD_CONTACT_MSG__INIT;
- kad_contact_msg_t * cmsgp[1];
+ dht_msg_t msg = DHT_MSG__INIT;
+ dht_contact_msg_t cmsg = DHT_CONTACT_MSG__INIT;
+ dht_contact_msg_t * cmsgp[1];
cmsg.id.data = (uint8_t *) key;
cmsg.addr = addr;
@@ -1650,7 +1650,7 @@ static ssize_t kad_find(struct dht * dht,
const uint64_t * addrs,
enum kad_code code)
{
- kad_msg_t msg = KAD_MSG__INIT;
+ dht_msg_t msg = DHT_MSG__INIT;
ssize_t sent = 0;
assert(dht);
@@ -1790,7 +1790,7 @@ static void kad_publish(struct dht * dht,
while (n-- > 0) {
if (addrs[n] == dht->addr) {
- kad_contact_msg_t msg = KAD_CONTACT_MSG__INIT;
+ dht_contact_msg_t msg = DHT_CONTACT_MSG__INIT;
msg.id.data = (uint8_t *) key;
msg.id.len = dht->b;
msg.addr = addr;
@@ -1809,7 +1809,7 @@ static void kad_publish(struct dht * dht,
static int kad_join(struct dht * dht,
uint64_t addr)
{
- kad_msg_t msg = KAD_MSG__INIT;
+ dht_msg_t msg = DHT_MSG__INIT;
msg.code = KAD_JOIN;
@@ -1944,7 +1944,7 @@ static buffer_t dht_retrieve(struct dht * dht,
static ssize_t dht_get_contacts(struct dht * dht,
const uint8_t * key,
- kad_contact_msg_t *** msgs)
+ dht_contact_msg_t *** msgs)
{
struct list_head l;
struct list_head * p;
@@ -1981,7 +1981,7 @@ static ssize_t dht_get_contacts(struct dht * dht,
return 0;
}
- kad_contact_msg__init((*msgs)[i]);
+ dht_contact_msg__init((*msgs)[i]);
(*msgs)[i]->id.data = c->id;
(*msgs)[i]->id.len = dht->b;
@@ -2118,7 +2118,7 @@ static void * work(void * o)
static int kad_handle_join_resp(struct dht * dht,
struct kad_req * req,
- kad_msg_t * msg)
+ dht_msg_t * msg)
{
assert(dht);
assert(req);
@@ -2178,7 +2178,7 @@ static int kad_handle_join_resp(struct dht * dht,
static int kad_handle_find_resp(struct dht * dht,
struct kad_req * req,
- kad_msg_t * msg)
+ dht_msg_t * msg)
{
struct lookup * lu;
@@ -2202,7 +2202,7 @@ static int kad_handle_find_resp(struct dht * dht,
}
static void kad_handle_response(struct dht * dht,
- kad_msg_t * msg)
+ dht_msg_t * msg)
{
struct kad_req * req;
@@ -2440,9 +2440,9 @@ static void * dht_handle_packet(void * o)
assert(dht);
while (true) {
- kad_msg_t * msg;
- kad_contact_msg_t ** cmsgs;
- kad_msg_t resp_msg = KAD_MSG__INIT;
+ dht_msg_t * msg;
+ dht_contact_msg_t ** cmsgs;
+ dht_msg_t resp_msg = DHT_MSG__INIT;
uint64_t addr;
buffer_t buf;
size_t i;
@@ -2464,7 +2464,7 @@ static void * dht_handle_packet(void * o)
i = shm_du_buff_len(cmd->sdb);
- msg = kad_msg__unpack(NULL, i, shm_du_buff_head(cmd->sdb));
+ msg = dht_msg__unpack(NULL, i, shm_du_buff_head(cmd->sdb));
#ifndef __DHT_TEST__
ipcp_sdb_release(cmd->sdb);
#endif
@@ -2476,7 +2476,7 @@ static void * dht_handle_packet(void * o)
}
if (msg->code != KAD_RESPONSE && dht_wait_running(dht)) {
- kad_msg__free_unpacked(msg, NULL);
+ dht_msg__free_unpacked(msg, NULL);
log_dbg("Got a request message when not running.");
continue;
}
@@ -2489,13 +2489,13 @@ static void * dht_handle_packet(void * o)
pthread_rwlock_unlock(&dht->lock);
if (msg->has_key && msg->key.len != b) {
- kad_msg__free_unpacked(msg, NULL);
+ dht_msg__free_unpacked(msg, NULL);
log_warn("Bad key in message.");
continue;
}
if (msg->has_s_id && !msg->has_b && msg->s_id.len != b) {
- kad_msg__free_unpacked(msg, NULL);
+ dht_msg__free_unpacked(msg, NULL);
log_warn("Bad source ID in message of type %d.",
msg->code);
continue;
@@ -2596,7 +2596,7 @@ static void * dht_handle_packet(void * o)
log_warn("Failed to send response.");
finish:
- kad_msg__free_unpacked(msg, NULL);
+ dht_msg__free_unpacked(msg, NULL);
if (resp_msg.n_addrs > 0)
free(resp_msg.addrs);
@@ -2607,7 +2607,7 @@ static void * dht_handle_packet(void * o)
}
for (i = 0; i < resp_msg.n_contacts; ++i)
- kad_contact_msg__free_unpacked(resp_msg.contacts[i],
+ dht_contact_msg__free_unpacked(resp_msg.contacts[i],
NULL);
free(resp_msg.contacts);
diff --git a/src/ipcpd/unicast/dir/kademlia.proto b/src/ipcpd/unicast/dir/dht.proto
index 1cd890af..e1063384 100644
--- a/src/ipcpd/unicast/dir/kademlia.proto
+++ b/src/ipcpd/unicast/dir/dht.proto
@@ -1,7 +1,7 @@
/*
* Ouroboros - Copyright (C) 2016 - 2023
*
- * KAD protocol
+ * DHT protocol, based on Kademlia
*
* Dimitri Staessens <dimitri@ouroboros.rocks>
* Sander Vrijders <sander@ouroboros.rocks>
@@ -22,19 +22,19 @@
syntax = "proto2";
-message kad_contact_msg {
+message dht_contact_msg {
required bytes id = 1;
required uint64 addr = 2;
}
-message kad_msg {
+message dht_msg {
required uint32 code = 1;
required uint32 cookie = 2;
required uint64 s_addr = 3;
optional bytes s_id = 4;
optional bytes key = 5;
repeated uint64 addrs = 6;
- repeated kad_contact_msg contacts = 7;
+ repeated dht_contact_msg contacts = 7;
// enrolment parameters
optional uint32 alpha = 8;
optional uint32 b = 9;
diff --git a/src/ipcpd/unicast/dir/tests/CMakeLists.txt b/src/ipcpd/unicast/dir/tests/CMakeLists.txt
index 482711d5..c850e41d 100644
--- a/src/ipcpd/unicast/dir/tests/CMakeLists.txt
+++ b/src/ipcpd/unicast/dir/tests/CMakeLists.txt
@@ -20,10 +20,9 @@ create_test_sourcelist(${PARENT_DIR}_tests test_suite.c
dht_test.c
)
-protobuf_generate_c(KAD_PROTO_SRCS KAD_PROTO_HDRS ../kademlia.proto)
-
+protobuf_generate_c(DHT_PROTO_SRCS KAD_PROTO_HDRS ../dht.proto)
add_executable(${PARENT_DIR}_test EXCLUDE_FROM_ALL ${${PARENT_DIR}_tests}
- ${KAD_PROTO_SRCS})
+ ${DHT_PROTO_SRCS})
target_link_libraries(${PARENT_DIR}_test ouroboros-common)
add_dependencies(check ${PARENT_DIR}_test)
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index ac5367ab..b75fd0e0 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -5,17 +5,17 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
protobuf_generate_c(QOSSPEC_PROTO_SRCS QOSSPEC_PROTO_HDRS
- qosspec.proto)
+ pb/qos.proto)
protobuf_generate_c(IPCP_CONFIG_PROTO_SRCS IPCP_CONFIG_PROTO_HDRS
- ipcp_config.proto)
+ pb/ipcp_config.proto)
protobuf_generate_c(ENROLL_PROTO_SRCS ENROLL_PROTO_HDRS
- enroll.proto)
+ pb/enroll.proto)
protobuf_generate_c(CACEP_PROTO_SRCS CACEP_PROTO_HDRS
- cacep.proto)
+ pb/cacep.proto)
protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS
- irmd_messages.proto)
+ pb/irm.proto)
protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS
- ipcpd_messages.proto)
+ pb/ipcp.proto)
if (NOT APPLE)
find_library(LIBRT_LIBRARIES rt)
diff --git a/src/lib/cacep.proto b/src/lib/pb/cacep.proto
index 5d735e33..5d735e33 100644
--- a/src/lib/cacep.proto
+++ b/src/lib/pb/cacep.proto
diff --git a/src/lib/enroll.proto b/src/lib/pb/enroll.proto
index 3b22ac17..3b22ac17 100644
--- a/src/lib/enroll.proto
+++ b/src/lib/pb/enroll.proto
diff --git a/src/lib/ipcpd_messages.proto b/src/lib/pb/ipcp.proto
index c985b752..f3eca0b8 100644
--- a/src/lib/ipcpd_messages.proto
+++ b/src/lib/pb/ipcp.proto
@@ -23,7 +23,7 @@
syntax = "proto2";
import "ipcp_config.proto";
-import "qosspec.proto";
+import "qos.proto";
enum ipcp_msg_code {
IPCP_BOOTSTRAP = 1;
diff --git a/src/lib/ipcp_config.proto b/src/lib/pb/ipcp_config.proto
index 1ff304f1..1ff304f1 100644
--- a/src/lib/ipcp_config.proto
+++ b/src/lib/pb/ipcp_config.proto
diff --git a/src/lib/irmd_messages.proto b/src/lib/pb/irm.proto
index 41ef8595..49afa2e4 100644
--- a/src/lib/irmd_messages.proto
+++ b/src/lib/pb/irm.proto
@@ -23,7 +23,7 @@
syntax = "proto2";
import "ipcp_config.proto";
-import "qosspec.proto";
+import "qos.proto";
enum irm_msg_code {
IRM_CREATE_IPCP = 1;
diff --git a/src/lib/qosspec.proto b/src/lib/pb/qos.proto
index 81d0e4a0..81d0e4a0 100644
--- a/src/lib/qosspec.proto
+++ b/src/lib/pb/qos.proto