From 6ad0fcf2f32f412091d0dfd58da1d8f5dc474809 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 8 Apr 2016 16:32:35 +0200 Subject: lib, irmd, irm: Add dif_config This adds dif_config to the prototype, in which one is able to specify the parameters a DIF should have. The bootstrap operation of an IPCP takes this as parameter and is oblivious to whether it is a shim or a normal IPCP. The dif_config struct is also correctly serialized and deserialized and passed opaquely to the correct IPCP. This IPCP is in charge of deserializing it correctly. --- src/tools/irm/irm_create_ipcp.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/tools/irm/irm_create_ipcp.c') diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c index 73d20dce..e4a0f22f 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_create_ipcp.c @@ -20,10 +20,11 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include #include #include #include + +#include #include #include #include @@ -31,18 +32,23 @@ #include "irm_ops.h" #include "irm_utils.h" +#define NORMAL "normal" +#define SHIM_UDP "shim-udp" + static void usage() { printf("Usage: irm create_ipcp\n" " ap \n" " [api ]\n" - " type \n"); + " type [TYPE]\n\n" + "where TYPE = {" NORMAL " " SHIM_UDP "}\n"); } int do_create_ipcp(int argc, char ** argv) { char * ipcp_type = NULL; instance_name_t api = {NULL, 0}; + enum ipcp_type type = 0; while (argc > 0) { if (matches(*argv, "type") == 0) { @@ -66,5 +72,14 @@ int do_create_ipcp(int argc, char ** argv) return -1; } - return irm_create_ipcp(&api, ipcp_type); + if (strcmp(ipcp_type, NORMAL) == 0) + type = NORMAL_IPCP; + else if (strcmp(ipcp_type, SHIM_UDP) == 0) + type = SHIM_UDP_IPCP; + else { + usage(); + return -1; + } + + return irm_create_ipcp(&api, type); } -- cgit v1.2.3 From 9906ac98c45530e530d7aa439937aedf526c3508 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 11 Apr 2016 17:01:47 +0200 Subject: lib: Change ipcp types This changes the name of the IPCP types after discussions with Dimitri. --- include/ouroboros/dif_config.h | 4 ++-- src/lib/irm.c | 4 ++-- src/tools/irm/irm_bootstrap_ipcp.c | 6 ++---- src/tools/irm/irm_create_ipcp.c | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src/tools/irm/irm_create_ipcp.c') diff --git a/include/ouroboros/dif_config.h b/include/ouroboros/dif_config.h index 5443085e..91b44cb1 100644 --- a/include/ouroboros/dif_config.h +++ b/include/ouroboros/dif_config.h @@ -26,8 +26,8 @@ #define OUROBOROS_DIF_CONFIG_H enum ipcp_type { - NORMAL_IPCP = 1, - SHIM_UDP_IPCP + IPCP_NORMAL = 1, + IPCP_SHIM_UDP }; struct dif_config { diff --git a/src/lib/irm.c b/src/lib/irm.c index 3078e158..70b7b3a5 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -111,7 +111,7 @@ int irm_bootstrap_ipcp(instance_name_t * api, config.ipcp_type = conf->type; switch (conf->type) { - case NORMAL_IPCP: + case IPCP_NORMAL: config.has_addr_size = true; config.has_cep_id_size = true; config.has_pdu_length_size = true; @@ -132,7 +132,7 @@ int irm_bootstrap_ipcp(instance_name_t * api, config.min_pdu_size = conf->min_pdu_size; config.max_pdu_size = conf->max_pdu_size; break; - case SHIM_UDP_IPCP: + case IPCP_SHIM_UDP: config.has_ip_addr = true; config.ip_addr = conf->ip_addr; diff --git a/src/tools/irm/irm_bootstrap_ipcp.c b/src/tools/irm/irm_bootstrap_ipcp.c index 7e7b6e05..78a09362 100644 --- a/src/tools/irm/irm_bootstrap_ipcp.c +++ b/src/tools/irm/irm_bootstrap_ipcp.c @@ -139,7 +139,7 @@ int do_bootstrap_ipcp(int argc, char ** argv) conf.dif_name = dif_name; if (strcmp(ipcp_type, NORMAL) == 0) { - conf.type = NORMAL_IPCP; + conf.type = IPCP_NORMAL; conf.addr_size = addr_size; conf.cep_id_size = cep_id_size; conf.pdu_length_size = pdu_length_size; @@ -150,13 +150,11 @@ int do_bootstrap_ipcp(int argc, char ** argv) conf.min_pdu_size = min_pdu_size; conf.max_pdu_size = max_pdu_size; } else if (strcmp(ipcp_type, SHIM_UDP) == 0) { - conf.type = SHIM_UDP_IPCP; - + conf.type = IPCP_SHIM_UDP; if (ip_addr == 0) { usage(); return -1; } - conf.ip_addr = ip_addr; } else { usage(); diff --git a/src/tools/irm/irm_create_ipcp.c b/src/tools/irm/irm_create_ipcp.c index e4a0f22f..08b55259 100644 --- a/src/tools/irm/irm_create_ipcp.c +++ b/src/tools/irm/irm_create_ipcp.c @@ -73,9 +73,9 @@ int do_create_ipcp(int argc, char ** argv) } if (strcmp(ipcp_type, NORMAL) == 0) - type = NORMAL_IPCP; + type = IPCP_NORMAL; else if (strcmp(ipcp_type, SHIM_UDP) == 0) - type = SHIM_UDP_IPCP; + type = IPCP_SHIM_UDP; else { usage(); return -1; -- cgit v1.2.3