From 645cf66af11ac36b81648f2e1eb3b1f5aeb7b544 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 16 Feb 2017 19:22:50 +0100 Subject: ipcpd: Move RIB configuration to common header Moves the definitions of paths in the RIB for the normal IPCP to a header ribconfig.h to avoid repetition. --- include/ouroboros/config.h.in | 6 ------ src/ipcpd/normal/dir.c | 3 +-- src/ipcpd/normal/enroll.c | 8 ++------ src/ipcpd/normal/fmgr.c | 7 ++++--- src/ipcpd/normal/gam.h | 1 + src/ipcpd/normal/main.c | 6 +----- src/ipcpd/normal/pol/complete.c | 1 + src/ipcpd/normal/pol/flat.c | 1 + src/ipcpd/normal/ribconfig.h | 39 +++++++++++++++++++++++++++++++++++++++ src/ipcpd/normal/ribmgr.c | 12 +++++------- src/ipcpd/normal/shm_pci.c | 5 ++--- src/lib/tests/rib_test.c | 2 ++ 12 files changed, 59 insertions(+), 32 deletions(-) create mode 100644 src/ipcpd/normal/ribconfig.h diff --git a/include/ouroboros/config.h.in b/include/ouroboros/config.h.in index 517eee45..7616961c 100644 --- a/include/ouroboros/config.h.in +++ b/include/ouroboros/config.h.in @@ -60,11 +60,5 @@ #define SOCKET_TIMEOUT 4000 #define CDAP_REPLY_TIMEOUT 1000 #define ENROLL_TIMEOUT 2000 -/* RIB configuration for normal */ -#define RIB_MAX_PATH_LEN 256 -#define BOOT_NAME "boot" -#define MEMBERS_NAME "members" -#define DIF_NAME "dif_name" -#define DIR_NAME "directory" #endif /* OUROBOROS_CONFIG */ diff --git a/src/ipcpd/normal/dir.c b/src/ipcpd/normal/dir.c index c67d303f..55d6e3f6 100644 --- a/src/ipcpd/normal/dir.c +++ b/src/ipcpd/normal/dir.c @@ -26,13 +26,12 @@ #include "dir.h" #include "ipcp.h" +#include "ribconfig.h" #include #include #include -#define DIR_PATH "/" DIR_NAME - static char dir_path[RIB_MAX_PATH_LEN + 1]; static void dir_path_reset(void) { diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c index a0d28598..bc5d2a20 100644 --- a/src/ipcpd/normal/enroll.c +++ b/src/ipcpd/normal/enroll.c @@ -29,6 +29,7 @@ #include #include "ae.h" +#include "ribconfig.h" #include #include @@ -36,14 +37,9 @@ /* Symbolic, will return current time */ #define TIME_NAME "localtime" +#define TIME_PATH DLR TIME_NAME #define ENROLL_WARN_TIME_OFFSET 20 -#define DLR "/" -#define DIF_PATH DLR DIF_NAME -#define BOOT_PATH DLR BOOT_NAME -#define MEMBERS_PATH DLR MEMBERS_NAME -#define TIME_PATH DLR TIME_NAME - int enroll_handle(int fd) { struct cdap * ci; diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index 31c83ac5..c2b53abf 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -36,6 +36,7 @@ #include "ipcp.h" #include "shm_pci.h" #include "gam.h" +#include "ribconfig.h" #include #include @@ -285,13 +286,13 @@ int fmgr_init(void) } } - if (rib_read("/" BOOT_NAME "/dt/gam/type", &pg, sizeof(pg)) + if (rib_read(BOOT_PATH "/dt/gam/type", &pg, sizeof(pg)) != sizeof(pg)) { log_err("Failed to read policy for ribmgr gam."); return -1; } - if (rib_read("/" BOOT_NAME "/dt/gam/cacep", &pc, sizeof(pc)) + if (rib_read(BOOT_PATH "/dt/gam/cacep", &pc, sizeof(pc)) != sizeof(pc)) { log_err("Failed to read CACEP policy for ribmgr gam."); return -1; @@ -375,7 +376,7 @@ int fmgr_np1_alloc(int fd, assert(strlen(dst_ap_name) + strlen("/" DIR_NAME) + 1 < RIB_MAX_PATH_LEN); - strcpy(path, "/" DIR_NAME); + strcpy(path, DIR_PATH); rib_path_append(path, dst_ap_name); diff --git a/src/ipcpd/normal/gam.h b/src/ipcpd/normal/gam.h index e858114c..50f83df9 100644 --- a/src/ipcpd/normal/gam.h +++ b/src/ipcpd/normal/gam.h @@ -24,6 +24,7 @@ #define OUROBOROS_IPCPD_NORMAL_GAM_H #include +#include struct gam * gam_create(enum pol_gam gam_type, const char * ae_name); diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 11ec0938..e3955ff2 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -39,6 +39,7 @@ #include "fmgr.h" #include "frct.h" #include "ipcp.h" +#include "ribconfig.h" #include "ribmgr.h" #include @@ -49,11 +50,6 @@ #include #include -#define DLR "/" -#define DIF_PATH DLR DIF_NAME -#define BOOT_PATH DLR BOOT_NAME -#define MEMBERS_PATH DLR MEMBERS_NAME - #define THIS_TYPE IPCP_NORMAL struct { diff --git a/src/ipcpd/normal/pol/complete.c b/src/ipcpd/normal/pol/complete.c index f85fd749..5faa1ae8 100644 --- a/src/ipcpd/normal/pol/complete.c +++ b/src/ipcpd/normal/pol/complete.c @@ -30,6 +30,7 @@ #include "ipcp.h" #include "gam.h" +#include "ribconfig.h" #include #include diff --git a/src/ipcpd/normal/pol/flat.c b/src/ipcpd/normal/pol/flat.c index 61b0110c..d982f5ac 100644 --- a/src/ipcpd/normal/pol/flat.c +++ b/src/ipcpd/normal/pol/flat.c @@ -30,6 +30,7 @@ #include #include "ipcp.h" +#include "ribconfig.h" #include #include diff --git a/src/ipcpd/normal/ribconfig.h b/src/ipcpd/normal/ribconfig.h new file mode 100644 index 00000000..15b65ce2 --- /dev/null +++ b/src/ipcpd/normal/ribconfig.h @@ -0,0 +1,39 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Normal IPC Process - RIB configuration + * + * Dimitri Staessens + * Sander Vrijders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + */ + +#ifndef OUROBOROS_IPCPD_NORMAL_RIB_CONFIG_H +#define OUROBOROS_IPCPD_NORMAL_RIB_CONFIG_H + +/* RIB configuration for normal */ +#define RIB_MAX_PATH_LEN 256 + +#define DLR "/" +#define BOOT_NAME "boot" +#define MEMBERS_NAME "members" +#define DIF_NAME "dif_name" +#define DIR_NAME "directory" +#define DIF_PATH DLR DIF_NAME +#define DIR_PATH DLR DIR_NAME +#define BOOT_PATH DLR BOOT_NAME +#define MEMBERS_PATH DLR MEMBERS_NAME + +#endif /* OUROBOROS_IPCPD_NORMAL_RIB_CONFIG_H */ diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c index 05d881ea..f254bd50 100644 --- a/src/ipcpd/normal/ribmgr.c +++ b/src/ipcpd/normal/ribmgr.c @@ -3,7 +3,8 @@ * * RIB manager of the IPC Process * - * Sander Vrijders + * Dimitri Staessens + * Sander Vrijders * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -32,11 +33,10 @@ #include #include -#include "timerwheel.h" -#include "addr_auth.h" -#include "ribmgr.h" -#include "gam.h" #include "ae.h" +#include "gam.h" +#include "ribconfig.h" +#include "ribmgr.h" #include #include @@ -44,8 +44,6 @@ #include #include -#define BOOT_PATH "/" BOOT_NAME - struct { flow_set_t * fs; fqueue_t * fq; diff --git a/src/ipcpd/normal/shm_pci.c b/src/ipcpd/normal/shm_pci.c index 1c2cee54..0807a24f 100644 --- a/src/ipcpd/normal/shm_pci.c +++ b/src/ipcpd/normal/shm_pci.c @@ -25,8 +25,9 @@ #include #include -#include "shm_pci.h" #include "dt_const.h" +#include "shm_pci.h" +#include "ribconfig.h" #include #include @@ -38,8 +39,6 @@ #define TTL_SIZE 1 #define CHK_SIZE 4 -#define BOOT_PATH "/" BOOT_NAME - struct { struct dt_const dtc; size_t head_size; diff --git a/src/lib/tests/rib_test.c b/src/lib/tests/rib_test.c index a7ae7311..8996c379 100644 --- a/src/lib/tests/rib_test.c +++ b/src/lib/tests/rib_test.c @@ -29,6 +29,8 @@ #include #include +#define RIB_MAX_PATH_LEN 256 + int rib_test(int argc, char ** argv) { -- cgit v1.2.3