From 269f25d3bac5ab871d8044935eacc15cfeadeec6 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 12 Feb 2023 21:05:40 +0100 Subject: 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 Signed-off-by: Sander Vrijders --- src/tools/irm/irm_ipcp_bootstrap.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src/tools/irm') diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c index 32b3cea3..2e90b82c 100644 --- a/src/tools/irm/irm_ipcp_bootstrap.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -292,6 +292,7 @@ int do_bootstrap_ipcp(int argc, printf("Types do not match.\n\n"); goto fail; } + conf.type = ipcps[i].type; if (autobind && (conf.type != IPCP_UNICAST && @@ -302,40 +303,36 @@ int do_bootstrap_ipcp(int argc, } if (strlen(layer) > LAYER_NAME_SIZE) { - printf("Layer name too big.\n\n"); + printf("Layer name too long.\n\n"); goto fail_usage; } strcpy(conf.layer_info.layer_name, layer); - if (conf.type != IPCP_UDP) - conf.layer_info.dir_hash_algo = hash_algo; + conf.layer_info.dir_hash_algo = hash_algo; switch (conf.type) { case IPCP_UNICAST: - conf.addr_size = addr_size; - conf.eid_size = eid_size; - conf.max_ttl = max_ttl; - conf.addr_auth_type = addr_auth_type; - conf.routing_type = routing_type; - conf.cong_avoid = cong_avoid; + conf.unicast.dt.addr_size = addr_size; + conf.unicast.dt.eid_size = eid_size; + conf.unicast.dt.max_ttl = max_ttl; + conf.unicast.dt.routing_type = routing_type; + conf.unicast.addr_auth_type = addr_auth_type; + conf.unicast.cong_avoid = cong_avoid; break; case IPCP_UDP: if (ip_addr == 0) goto fail_usage; - conf.ip_addr = ip_addr; - conf.dns_addr = dns_addr; - conf.port = port; - break; - case IPCP_ETH_LLC: - if (dev == NULL) - goto fail_usage; - conf.dev = dev; + conf.udp.ip_addr = ip_addr; + conf.udp.dns_addr = dns_addr; + conf.udp.port = port; break; case IPCP_ETH_DIX: + conf.eth.ethertype = ethertype; + /* FALLTHRU */ + case IPCP_ETH_LLC: if (dev == NULL) goto fail_usage; - conf.dev = dev; - conf.ethertype = ethertype; + conf.eth.dev = dev; break; case IPCP_BROADCAST: /* FALLTHRU */ -- cgit v1.2.3