summaryrefslogtreecommitdiff
path: root/src/ipcpd/unicast/main.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2023-02-12 21:05:40 +0100
committerSander Vrijders <sander@ouroboros.rocks>2023-02-13 21:10:11 +0100
commit269f25d3bac5ab871d8044935eacc15cfeadeec6 (patch)
treed68cba31a7a4b941658836d0c0d616fc7ec6400b /src/ipcpd/unicast/main.c
parentc3814fa77eb7afbe6e798ded0fdff2df74ad8642 (diff)
downloadouroboros-269f25d3bac5ab871d8044935eacc15cfeadeec6.tar.gz
ouroboros-269f25d3bac5ab871d8044935eacc15cfeadeec6.zip
ipcpd: refactor IPCP configuration
The ipcp configuration struct now has internal structures for the different IPCPs and for IPCP components of the unicast IPCP. Split the very long IPCP main loop into individual handler functions. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/ipcpd/unicast/main.c')
-rw-r--r--src/ipcpd/unicast/main.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/src/ipcpd/unicast/main.c b/src/ipcpd/unicast/main.c
index 4d2ef1f2..1318ec2f 100644
--- a/src/ipcpd/unicast/main.c
+++ b/src/ipcpd/unicast/main.c
@@ -59,18 +59,13 @@ struct ipcp ipcpi;
static int initialize_components(const struct ipcp_config * conf)
{
- ipcpi.layer_name = strdup(conf->layer_info.layer_name);
- if (ipcpi.layer_name == NULL) {
- log_err("Failed to set layer name.");
- goto fail_layer_name;
- }
-
+ strcpy(ipcpi.layer_name, conf->layer_info.layer_name);
ipcpi.dir_hash_algo = conf->layer_info.dir_hash_algo;
assert(ipcp_dir_hash_len() != 0);
- if (addr_auth_init(conf->addr_auth_type,
- &conf->addr_size)) {
+ if (addr_auth_init(conf->unicast.addr_auth_type,
+ &conf->unicast.dt.addr_size)) {
log_err("Failed to init address authority.");
goto fail_addr_auth;
}
@@ -83,15 +78,12 @@ static int initialize_components(const struct ipcp_config * conf)
log_dbg("IPCP got address %" PRIu64 ".", ipcpi.dt_addr);
- if (ca_init(conf->cong_avoid)) {
+ if (ca_init(conf->unicast.cong_avoid)) {
log_err("Failed to initialize congestion avoidance.");
goto fail_ca;
}
- if (dt_init(conf->routing_type,
- conf->addr_size,
- conf->eid_size,
- conf->max_ttl)) {
+ if (dt_init(conf->unicast.dt)) {
log_err("Failed to initialize data transfer component.");
goto fail_dt;
}
@@ -119,8 +111,6 @@ static int initialize_components(const struct ipcp_config * conf)
fail_ca:
addr_auth_fini();
fail_addr_auth:
- free(ipcpi.layer_name);
- fail_layer_name:
return -1;
}
@@ -135,8 +125,6 @@ static void finalize_components(void)
ca_fini();
addr_auth_fini();
-
- free(ipcpi.layer_name);
}
static int start_components(void)