summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2017-04-26 20:31:39 +0200
committerdimitri staessens <[email protected]>2017-04-27 17:59:01 +0200
commitb398dbe5cfd12b928e00f9a22cd6826bbdfb18d7 (patch)
tree137c34f79897b5f371a65dd14208b77201d1e907 /src/ipcpd
parent6d6a4a488d7b631f519b1cf462ffbb44d399e1ce (diff)
downloadouroboros-b398dbe5cfd12b928e00f9a22cd6826bbdfb18d7.tar.gz
ouroboros-b398dbe5cfd12b928e00f9a22cd6826bbdfb18d7.zip
ipcpd: Add capability reporting
The IPCP will now report the DIF name and the hash value to the IRMd as a dif_info struct. This can later be extended to add further capability reporting. Some bugfixes in normal. Fixes #24
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/ipcp.c12
-rw-r--r--src/ipcpd/ipcp.h3
-rw-r--r--src/ipcpd/normal/main.c29
3 files changed, 29 insertions, 15 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index d682309d..7f3ebc73 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -143,9 +143,10 @@ static void * ipcp_main_loop(void * o)
ipcp_config_msg_t * conf_msg;
struct ipcp_config conf;
+ struct dif_info info;
struct timeval ltv = {(SOCKET_TIMEOUT / 1000),
- (SOCKET_TIMEOUT % 1000) * 1000};
+ (SOCKET_TIMEOUT % 1000) * 1000};
ssize_t id = (ssize_t) o;
@@ -259,7 +260,14 @@ static void * ipcp_main_loop(void * o)
break;
}
- ret_msg.result = ipcpi.ops->ipcp_enroll(msg->dst_name);
+ ret_msg.result = ipcpi.ops->ipcp_enroll(msg->dst_name,
+ &info);
+
+ if (ret_msg.result == 0) {
+ ret_msg.has_dir_hash_algo = true;
+ ret_msg.dir_hash_algo = info.algo;
+ ret_msg.dif_name = info.dif_name;
+ }
break;
case IPCP_MSG_CODE__IPCP_REG:
ret_msg.has_result = true;
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index c78aa5a6..3f5e1bd6 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -43,7 +43,8 @@ enum ipcp_state {
struct ipcp_ops {
int (* ipcp_bootstrap)(const struct ipcp_config * conf);
- int (* ipcp_enroll)(const char * dst);
+ int (* ipcp_enroll)(const char * dst,
+ struct dif_info * info);
int (* ipcp_reg)(const uint8_t * hash);
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index ab8cf387..9228f36b 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -116,21 +116,21 @@ static int boot_components(void)
log_dbg("Starting ribmgr.");
- if (ribmgr_init()) {
- log_err("Failed to initialize RIB manager.");
+ if (dir_init()) {
+ log_err("Failed to initialize directory.");
goto fail_addr_auth;
}
- if (dir_init()) {
- log_err("Failed to initialize directory.");
- goto fail_ribmgr;
+ if (ribmgr_init()) {
+ log_err("Failed to initialize RIB manager.");
+ goto fail_dir;
}
log_dbg("Ribmgr started.");
if (frct_init()) {
log_err("Failed to initialize FRCT.");
- goto fail_dir;
+ goto fail_ribmgr;
}
if (fa_init()) {
@@ -180,10 +180,10 @@ static int boot_components(void)
fa_fini();
fail_frct:
frct_fini();
- fail_dir:
- dir_fini();
fail_ribmgr:
ribmgr_fini();
+ fail_dir:
+ dir_fini();
fail_addr_auth:
addr_auth_fini();
fail_name:
@@ -208,16 +208,17 @@ void shutdown_components(void)
frct_fini();
- dir_fini();
-
ribmgr_fini();
+ dir_fini();
+
addr_auth_fini();
free(ipcpi.dif_name);
}
-static int normal_ipcp_enroll(const char * dst)
+static int normal_ipcp_enroll(const char * dst,
+ struct dif_info * info)
{
if (rib_add(RIB_ROOT, MEMBERS_NAME)) {
log_err("Failed to create members.");
@@ -237,7 +238,11 @@ static int normal_ipcp_enroll(const char * dst)
log_dbg("Enrolled with " HASH_FMT, HASH_VAL(dst));
- return ipcpi.dir_hash_algo;
+ info->algo = ipcpi.dir_hash_algo;
+
+ strcpy(info->dif_name, ipcpi.dif_name);
+
+ return 0;
}
const struct ros {