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. --- include/ouroboros/CMakeLists.txt | 1 + include/ouroboros/common.h | 24 ---------------- include/ouroboros/dif_config.h | 61 ++++++++++++++++++++++++++++++++++++++++ include/ouroboros/ipcp.h | 10 +++++-- include/ouroboros/irm.h | 12 ++++---- include/ouroboros/sockets.h | 3 ++ include/ouroboros/utils.h | 2 ++ 7 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 include/ouroboros/dif_config.h (limited to 'include') diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index 0b52a2bc..fb4884b7 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -8,6 +8,7 @@ set(HEADER_FILES common.h da.h dev.h + dif_config.h du_buff.h flow.h instance_name.h diff --git a/include/ouroboros/common.h b/include/ouroboros/common.h index 658c3618..971a382a 100644 --- a/include/ouroboros/common.h +++ b/include/ouroboros/common.h @@ -42,28 +42,4 @@ struct qos_spec { uint32_t jitter; }; -/* FIXME: What should be configurable in the DIF? */ -struct dif_config { - /* general data */ - char * dif_name; - - /* TODO: efficient policies */ - - /* dt field sizes in octets */ - uint8_t addr_size; - uint8_t cep_id_size; - uint8_t pdu_length_size; - uint8_t qos_id_size; - uint8_t seqno_size; - - /* constants for dup */ - uint8_t ttl_size; - uint8_t chk_size; - - /* values, octets */ - uint32_t min_pdu_size; - uint32_t max_pdu_size; - -}; - #endif /* OUROBOROS_COMMON_H */ diff --git a/include/ouroboros/dif_config.h b/include/ouroboros/dif_config.h new file mode 100644 index 00000000..5443085e --- /dev/null +++ b/include/ouroboros/dif_config.h @@ -0,0 +1,61 @@ +/* + * Ouroboros - Copyright (C) 2016 + * + * DIF configurations for each IPCP type + * + * Sander Vrijders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include + +#ifndef OUROBOROS_DIF_CONFIG_H +#define OUROBOROS_DIF_CONFIG_H + +enum ipcp_type { + NORMAL_IPCP = 1, + SHIM_UDP_IPCP +}; + +struct dif_config { + char * dif_name; + enum ipcp_type type; + + union { + /* Normal DIF */ + struct { + uint8_t addr_size; + uint8_t cep_id_size; + uint8_t pdu_length_size; + uint8_t qos_id_size; + uint8_t seqno_size; + + /* DUP constants */ + uint8_t ttl_size; + uint8_t chk_size; + + uint32_t min_pdu_size; + uint32_t max_pdu_size; + }; + /* Shim UDP */ + struct { + uint32_t ip_addr; + }; + }; +}; + + +#endif /* OUROBOROS_DIF_CONFIG_H */ diff --git a/include/ouroboros/ipcp.h b/include/ouroboros/ipcp.h index fdaf5c4a..3198a882 100644 --- a/include/ouroboros/ipcp.h +++ b/include/ouroboros/ipcp.h @@ -24,7 +24,9 @@ #define OUROBOROS_IPCP_H #include +#include #include +#include #include @@ -32,7 +34,8 @@ struct ipcp; /* Returns the process id */ pid_t ipcp_create(instance_name_t * api, - char * ipcp_type); + enum ipcp_type ipcp_type); + int ipcp_destroy(pid_t pid); int ipcp_reg(pid_t pid, @@ -42,12 +45,13 @@ int ipcp_unreg(pid_t pid, char ** difs, size_t difs_size); -int ipcp_bootstrap(pid_t pid, - struct dif_config * conf); int ipcp_enroll(pid_t pid, char * member_name, char * n_1_dif); +int ipcp_bootstrap(pid_t pid, + dif_config_msg_t * conf); + /* Flow related ops, these go from IRMd to IPCP */ int ipcp_ap_reg(pid_t pid, diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h index 780bf77b..24bb2c42 100644 --- a/include/ouroboros/irm.h +++ b/include/ouroboros/irm.h @@ -23,18 +23,20 @@ #ifndef OUROBOROS_IRM_H #define OUROBOROS_IRM_H -#include "common.h" -#include "instance_name.h" +#include +#include int irm_create_ipcp(instance_name_t * api, - char * ipcp_type); + enum ipcp_type ipcp_type); + int irm_destroy_ipcp(instance_name_t * api); -int irm_bootstrap_ipcp(instance_name_t * api, - struct dif_config * conf); int irm_enroll_ipcp(instance_name_t * api, char * dif_name); +int irm_bootstrap_ipcp(instance_name_t * api, + struct dif_config * conf); + int irm_reg_ipcp(instance_name_t * api, char ** difs, size_t difs_size); diff --git a/include/ouroboros/sockets.h b/include/ouroboros/sockets.h index 0c517bd4..be5ae651 100644 --- a/include/ouroboros/sockets.h +++ b/include/ouroboros/sockets.h @@ -27,6 +27,9 @@ #include +#include "dif_config.pb-c.h" +typedef DifConfigMsg dif_config_msg_t; + #include "irmd_messages.pb-c.h" typedef IrmMsg irm_msg_t; diff --git a/include/ouroboros/utils.h b/include/ouroboros/utils.h index 2eaccae9..2e5a4944 100644 --- a/include/ouroboros/utils.h +++ b/include/ouroboros/utils.h @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#define MAX(a,b) (a > b ? a : b) + /* * Returns the number of characters a uint would * need when represented as a string -- 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 'include') 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