summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/dt.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-07-13 09:43:09 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-07-18 13:03:05 +0200
commit6e739b09bef860a4830328630ea07622bdd79d79 (patch)
tree205ea90bd2f59a0a707c7b4a14df2a54fd7b4a50 /src/ipcpd/normal/dt.c
parent0bcb3ab0804bbfd31d056c08548cb40591598f4b (diff)
downloadouroboros-6e739b09bef860a4830328630ea07622bdd79d79.tar.gz
ouroboros-6e739b09bef860a4830328630ea07622bdd79d79.zip
ipcpd: Add DHT as directory in normal IPCP
This implements a Distributed Hash Table (DHT) based on the Kademlia protocol, with default parameters set as used in the BitTorrent Mainline DHT. This initial implementation is almost feature complete, except for some things to be done after a testing period: caching and stale peer bumping, and setting the expiration timeout via the IRM tool.
Diffstat (limited to 'src/ipcpd/normal/dt.c')
-rw-r--r--src/ipcpd/normal/dt.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c
index 1867c13b..5fcc5865 100644
--- a/src/ipcpd/normal/dt.c
+++ b/src/ipcpd/normal/dt.c
@@ -50,7 +50,7 @@
#include <assert.h>
struct ae_info {
- int (*post_sdu)(void * ae, struct shm_du_buff * sdb);
+ void (* post_sdu)(void * ae, struct shm_du_buff * sdb);
void * ae;
};
@@ -131,11 +131,14 @@ static int sdu_handler(int fd,
return 0;
}
- if (dt.aes[dt_pci.fd].post_sdu(dt.aes[dt_pci.fd].ae, sdb)) {
+ if (dt.aes[dt_pci.fd].post_sdu == NULL) {
+ log_err("No registered AE on fd %d.", dt_pci.fd);
ipcp_sdb_release(sdb);
- return -1;
+ return -EPERM;
}
+ dt.aes[dt_pci.fd].post_sdu(dt.aes[dt_pci.fd].ae, sdb);
+
return 0;
}
@@ -295,7 +298,7 @@ void dt_stop(void)
}
int dt_reg_ae(void * ae,
- int (* func)(void * func, struct shm_du_buff *))
+ void (* func)(void * func, struct shm_du_buff *))
{
int res_fd;
@@ -330,10 +333,11 @@ int dt_write_sdu(uint64_t dst_addr,
struct dt_pci dt_pci;
assert(sdb);
+ assert(dst_addr != ipcpi.dt_addr);
fd = pff_nhop(dt.pff[qc], dst_addr);
if (fd < 0) {
- log_err("Could not get nhop for addr %" PRIu64 ".", dst_addr);
+ log_dbg("Could not get nhop for addr %" PRIu64 ".", dst_addr);
return -1;
}