From 0b6a6d6445b5addcf38eb67a001b792456242481 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 9 Jan 2017 16:05:57 +0100 Subject: lib: Add Common Application Connection Establishment Phase This adds CACEP to the library, which can be used for authenticating the other party after flow allocation and for obtaining other relevant information. --- include/ouroboros/cacep.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 include/ouroboros/cacep.h (limited to 'include') diff --git a/include/ouroboros/cacep.h b/include/ouroboros/cacep.h new file mode 100644 index 00000000..7b22b4a2 --- /dev/null +++ b/include/ouroboros/cacep.h @@ -0,0 +1,47 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * The Common Application Connection Establishment Phase + * + * Sander Vrijders + * Dimitri Staessens + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef OUROBOROS_CACEP_H +#define OUROBOROS_CACEP_H + +#include +#include + +struct cacep; + +struct cacep_info { + char * name; + uint64_t addr; +}; + +struct cacep * cacep_create(int fd, + char * name, + uint64_t address); + +int cacep_destroy(struct cacep * instance); + +struct cacep_info * cacep_auth(struct cacep * instance); + +struct cacep_info * cacep_auth_wait(struct cacep * instance); + +#endif /* OUROBOROS_CACEP_H */ -- cgit v1.2.3 From 747cde06887cc6893f650f52abcf1c9a08627d52 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 11 Jan 2017 12:06:53 +0100 Subject: lib: Fix Python wrapping Since Python 3.6, the headers are no longer C89 compliant, since they introduced C++ style comments. This sets the compiler flag to std99 instead of std89 to allow wrapping of headers. It also adds a missing header to the wrapping file. --- include/ouroboros/wrap/CMakeLists.txt | 3 +++ include/ouroboros/wrap/ouroboros.i | 2 ++ 2 files changed, 5 insertions(+) (limited to 'include') diff --git a/include/ouroboros/wrap/CMakeLists.txt b/include/ouroboros/wrap/CMakeLists.txt index 16c86611..7753ca02 100644 --- a/include/ouroboros/wrap/CMakeLists.txt +++ b/include/ouroboros/wrap/CMakeLists.txt @@ -16,6 +16,9 @@ else () else () include_directories(${PYTHON_INCLUDE_PATH}) + # Python assumes C99 since Python 3.6 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + swig_add_module(ouroboros python ouroboros.i) swig_link_libraries(ouroboros ${PYTHON_LIBRARIES} ouroboros) diff --git a/include/ouroboros/wrap/ouroboros.i b/include/ouroboros/wrap/ouroboros.i index 23d05f7b..b156eb36 100644 --- a/include/ouroboros/wrap/ouroboros.i +++ b/include/ouroboros/wrap/ouroboros.i @@ -22,6 +22,7 @@ %module ouroboros %{ +#include "ouroboros/cacep.h" #include "ouroboros/cdap.h" #include "ouroboros/dev.h" #include "ouroboros/errno.h" @@ -35,6 +36,7 @@ typedef int pid_t; +#include "ouroboros/cacep.h" %include "ouroboros/cdap.h" %include "ouroboros/dev.h" %include "ouroboros/errno.h" -- cgit v1.2.3 From 15e9b779385c71d366776b83540e19e0735c4e66 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Wed, 11 Jan 2017 18:59:11 +0100 Subject: ipcpd: normal: Create policies for GAM This allows the selection of a policy for the graph adjacency manager. Currently we only support constructing a complete graph. --- include/ouroboros/cacep.h | 6 +- include/ouroboros/irm.h | 4 +- include/ouroboros/irm_config.h | 32 +++--- src/ipcpd/ipcp.c | 1 + src/ipcpd/normal/CMakeLists.txt | 1 + src/ipcpd/normal/fmgr.c | 4 +- src/ipcpd/normal/gam.c | 136 ++++++++---------------- src/ipcpd/normal/gam.h | 8 +- src/ipcpd/normal/pol-gam-ops.h | 40 +++++++ src/ipcpd/normal/pol/complete.c | 208 +++++++++++++++++++++++++++++++++++++ src/ipcpd/normal/pol/complete.h | 46 ++++++++ src/ipcpd/normal/ribmgr.c | 13 ++- src/ipcpd/normal/ribmgr.h | 2 + src/ipcpd/normal/static_info.proto | 19 ++-- src/lib/cacep.c | 6 +- src/lib/dif_config.proto | 7 +- src/lib/irm.c | 2 + src/tools/irm/irm_ipcp_bootstrap.c | 13 ++- 18 files changed, 410 insertions(+), 138 deletions(-) create mode 100644 src/ipcpd/normal/pol-gam-ops.h create mode 100644 src/ipcpd/normal/pol/complete.c create mode 100644 src/ipcpd/normal/pol/complete.h (limited to 'include') diff --git a/include/ouroboros/cacep.h b/include/ouroboros/cacep.h index 7b22b4a2..ae615e6e 100644 --- a/include/ouroboros/cacep.h +++ b/include/ouroboros/cacep.h @@ -34,9 +34,9 @@ struct cacep_info { uint64_t addr; }; -struct cacep * cacep_create(int fd, - char * name, - uint64_t address); +struct cacep * cacep_create(int fd, + const char * name, + uint64_t address); int cacep_destroy(struct cacep * instance); diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h index b281d4c5..79e3e7c9 100644 --- a/include/ouroboros/irm.h +++ b/include/ouroboros/irm.h @@ -50,10 +50,10 @@ int irm_bind_ap(char * ap, int irm_unbind_ap(char * ap, char * name); -int irm_bind_api(pid_t api, +int irm_bind_api(pid_t api, char * name); -int irm_unbind_api(pid_t api, +int irm_unbind_api(pid_t api, char * name); int irm_reg(char * name, diff --git a/include/ouroboros/irm_config.h b/include/ouroboros/irm_config.h index ac94e9c8..c4a81c23 100644 --- a/include/ouroboros/irm_config.h +++ b/include/ouroboros/irm_config.h @@ -43,36 +43,40 @@ enum pol_addr_auth { FLAT_RANDOM = 0 }; +enum pol_gam { + COMPLETE = 0 +}; + struct dif_config { - char * dif_name; + 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; + 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 */ - bool has_ttl; - bool has_chk; + bool has_ttl; + bool has_chk; - uint32_t min_pdu_size; - uint32_t max_pdu_size; + uint32_t min_pdu_size; + uint32_t max_pdu_size; enum pol_addr_auth addr_auth_type; + enum pol_gam dt_gam_type; }; /* Shim UDP */ struct { - uint32_t ip_addr; - uint32_t dns_addr; + uint32_t ip_addr; + uint32_t dns_addr; }; /* Shim Ethernet LLC */ struct { - char * if_name; + char * if_name; }; }; }; diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 96f00dc0..a94e268d 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -128,6 +128,7 @@ static void * ipcp_main_loop(void * o) conf.min_pdu_size = conf_msg->min_pdu_size; conf.max_pdu_size = conf_msg->max_pdu_size; conf.addr_auth_type = conf_msg->addr_auth_type; + conf.dt_gam_type = conf_msg->dt_gam_type; } if (conf_msg->ipcp_type == IPCP_SHIM_UDP) { conf.ip_addr = conf_msg->ip_addr; diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt index 43059c3e..157baa9e 100644 --- a/src/ipcpd/normal/CMakeLists.txt +++ b/src/ipcpd/normal/CMakeLists.txt @@ -36,6 +36,7 @@ set(SOURCE_FILES ribmgr.c shm_pci.c # Add policies last + pol/complete.c pol/flat.c ) diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index 33ac83c9..6fe6fb60 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -305,7 +305,7 @@ int fmgr_init() } } - fmgr.gam = gam_create(DT_AE); + fmgr.gam = gam_create(ribmgr_dt_gam(), DT_AE); if (fmgr.gam == NULL) { LOG_ERR("Failed to create graph adjacency manager."); fmgr_destroy_flows(); @@ -617,7 +617,7 @@ int fmgr_nm1_flow_arr(int fd, assert(fmgr.gam); if (gam_flow_arr(fmgr.gam, fd, qs)) { - LOG_ERR("Failed to hand to connectivy manager."); + LOG_ERR("Failed to hand to graph adjacency manager."); return -1; } diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c index 34db87e3..0e626115 100644 --- a/src/ipcpd/normal/gam.c +++ b/src/ipcpd/normal/gam.c @@ -3,7 +3,7 @@ * * Graph adjacency manager for IPC Process components * - * Dimitri Staeesens + * Dimitri Staessens * Sander Vrijders * * This program is free software; you can redistribute it and/or modify @@ -25,23 +25,20 @@ #include #include #include -#include #include #include #include "ribmgr.h" #include "ipcp.h" -#include "ro.h" -#include "pathname.h" #include "gam.h" +#include "pol-gam-ops.h" +#include "pol/complete.h" #include #include #include #include -#define RO_DIR "neighbors" - struct ga { struct list_head next; @@ -51,59 +48,34 @@ struct ga { }; struct gam { - struct list_head gas; - pthread_mutex_t gas_lock; - pthread_cond_t gas_cond; - - char * ae_name; + struct list_head gas; + pthread_mutex_t gas_lock; + pthread_cond_t gas_cond; - /* FIXME: Keep a list of known members */ + char * ae_name; - pthread_t allocator; + struct pol_gam_ops * ops; + void * ops_o; }; -static void * allocator(void * o) +struct gam * gam_create(enum pol_gam gam_type, + const char * ae_name) { - qosspec_t qs; - ssize_t len; - char ** children; - struct gam * instance; - int i; - char * ro_name; - - instance = (struct gam *) o; - - qs.delay = 0; - qs.jitter = 0; - - ro_name = pathname_create(RO_DIR); - if (ro_name == NULL) - return (void *) -1; - - len = ro_children(ro_name, &children); - if (len > 0) { - for (i = 0; i < len; i++) { - if (strcmp(children[i], ipcpi.name) == 0) - continue; - gam_flow_alloc(instance, children[i], qs); - } - } - - pathname_destroy(ro_name); - - return (void *) 0; -} - -struct gam * gam_create(char * ae_name) -{ - struct gam * tmp; - struct ro_attr attr; - char * ro_name; + struct gam * tmp; tmp = malloc(sizeof(*tmp)); if (tmp == NULL) return NULL; + switch (gam_type) { + case COMPLETE: + tmp->ops = &complete_ops; + break; + default: + free(tmp); + return NULL; + } + list_head_init(&tmp->gas); tmp->ae_name = strdup(ae_name); @@ -125,47 +97,8 @@ struct gam * gam_create(char * ae_name) return NULL; } - ro_attr_init(&attr); - attr.enrol_sync = true; - attr.recv_set = ALL_MEMBERS; - - ro_name = pathname_create(RO_DIR); - if (ro_name == NULL) { - pthread_mutex_destroy(&tmp->gas_lock); - free(tmp->ae_name); - free(tmp); - return NULL; - } - - if (!ro_exists(RO_DIR)) { - if (ro_create(ro_name, &attr, NULL, 0)) { - pathname_destroy(ro_name); - pthread_mutex_destroy(&tmp->gas_lock); - free(tmp->ae_name); - free(tmp); - return NULL; - } - } - - ro_name = pathname_append(ro_name, ipcpi.name); - if (ro_name == NULL) { - pathname_destroy(ro_name); - pthread_mutex_destroy(&tmp->gas_lock); - free(tmp->ae_name); - free(tmp); - return NULL; - } - - if (ro_create(ro_name, &attr, NULL, 0)) { - pathname_destroy(ro_name); - pthread_mutex_destroy(&tmp->gas_lock); - free(tmp->ae_name); - free(tmp); - return NULL; - } - pathname_destroy(ro_name); - - if (pthread_create(&tmp->allocator, NULL, allocator, (void *) tmp)) { + tmp->ops_o = tmp->ops->create(tmp); + if (tmp->ops_o == NULL) { pthread_cond_destroy(&tmp->gas_cond); pthread_mutex_destroy(&tmp->gas_lock); free(tmp->ae_name); @@ -183,8 +116,7 @@ void gam_destroy(struct gam * instance) assert(instance); - pthread_cancel(instance->allocator); - pthread_join(instance->allocator, NULL); + instance->ops->destroy(instance->ops_o); pthread_mutex_destroy(&instance->gas_lock); pthread_cond_destroy(&instance->gas_cond); @@ -232,7 +164,8 @@ int gam_flow_arr(struct gam * instance, struct cacep * cacep; struct cacep_info * info; - if (flow_alloc_resp(fd, 0) < 0) { + if (flow_alloc_resp(fd, instance->ops->accept_new_flow(instance->ops_o)) + < 0) { LOG_ERR("Could not respond to new flow."); return -1; } @@ -249,8 +182,15 @@ int gam_flow_arr(struct gam * instance, cacep_destroy(cacep); return -1; } + cacep_destroy(cacep); + if (instance->ops->accept_flow(instance->ops_o, qs, info)) { + flow_dealloc(fd); + free(info); + return 0; + } + if (add_ga(instance, fd, qs, info)) { LOG_ERR("Failed to add ga to graph adjacency manager list."); free(info); @@ -292,10 +232,17 @@ int gam_flow_alloc(struct gam * instance, cacep_destroy(cacep); return -1; } + cacep_destroy(cacep); + if (instance->ops->accept_flow(instance->ops_o, qs, info)) { + flow_dealloc(fd); + free(info); + return 0; + } + if (add_ga(instance, fd, qs, info)) { - LOG_ERR("Failed to add ga to graph adjacency manager list."); + LOG_ERR("Failed to add GA to graph adjacency manager list."); free(info); return -1; } @@ -322,7 +269,6 @@ int gam_flow_wait(struct gam * instance, ga = list_first_entry((&instance->gas), struct ga, next); if (ga == NULL) { pthread_mutex_unlock(&instance->gas_lock); - LOG_ERR("Ga was NULL."); return -1; } diff --git a/src/ipcpd/normal/gam.h b/src/ipcpd/normal/gam.h index 309cb46d..e858114c 100644 --- a/src/ipcpd/normal/gam.h +++ b/src/ipcpd/normal/gam.h @@ -23,8 +23,10 @@ #ifndef OUROBOROS_IPCPD_NORMAL_GAM_H #define OUROBOROS_IPCPD_NORMAL_GAM_H -/* FIXME: Will take a policy */ -struct gam * gam_create(char * ae_name); +#include + +struct gam * gam_create(enum pol_gam gam_type, + const char * ae_name); void gam_destroy(struct gam * instance); @@ -41,4 +43,4 @@ int gam_flow_wait(struct gam * instance, struct cacep_info ** info, qosspec_t * qs); -#endif +#endif /* OUROBOROS_IPCPD_NORMAL_GAM_H */ diff --git a/src/ipcpd/normal/pol-gam-ops.h b/src/ipcpd/normal/pol-gam-ops.h new file mode 100644 index 00000000..eeece8d9 --- /dev/null +++ b/src/ipcpd/normal/pol-gam-ops.h @@ -0,0 +1,40 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Graph adjacency manager policy ops + * + * 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_POL_GAM_OPS_H +#define OUROBOROS_IPCPD_NORMAL_POL_GAM_OPS_H + +#include + +struct pol_gam_ops { + void * (* create)(struct gam * instance); + + void (* destroy)(void * o); + + int (* accept_new_flow)(void * o); + + int (* accept_flow)(void * o, + qosspec_t qs, + const struct cacep_info * info); +}; + +#endif /* OUROBOROS_IPCPD_NORMAL_POL_GAM_OPS_H */ diff --git a/src/ipcpd/normal/pol/complete.c b/src/ipcpd/normal/pol/complete.c new file mode 100644 index 00000000..89e1b91f --- /dev/null +++ b/src/ipcpd/normal/pol/complete.c @@ -0,0 +1,208 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Graph adjacency manager for IPC Process components + * + * 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. + */ + +#define OUROBOROS_PREFIX "complete-graph-adjacency-manager" + +#include +#include +#include +#include + +#include "pathname.h" +#include "ro.h" +#include "ipcp.h" +#include "gam.h" + +#include +#include + +#define RO_DIR "neighbors" + +struct neighbor { + struct list_head next; + char * neighbor; +}; + +struct complete { + struct list_head neighbors; + pthread_mutex_t neighbors_lock; + + pthread_t allocator; + + struct gam * gam; +}; + +static void * allocator(void * o) +{ + qosspec_t qs; + ssize_t len; + char ** children; + int i; + char * ro_name; + struct complete * complete = (struct complete *) o; + + qs.delay = 0; + qs.jitter = 0; + + ro_name = pathname_create(RO_DIR); + if (ro_name == NULL) + return (void *) -1; + + len = ro_children(ro_name, &children); + if (len > 0) { + for (i = 0; i < len; i++) { + if (strcmp(children[i], ipcpi.name) == 0) + continue; + gam_flow_alloc(complete->gam, children[i], qs); + } + } + + pathname_destroy(ro_name); + + return (void *) 0; +} + +void * complete_create(struct gam * gam) +{ + struct ro_attr attr; + char * ro_name; + struct complete * complete; + + ro_attr_init(&attr); + attr.enrol_sync = true; + attr.recv_set = ALL_MEMBERS; + + complete = malloc(sizeof(*complete)); + if (complete == NULL) + return NULL; + + ro_name = pathname_create(RO_DIR); + if (ro_name == NULL) { + free(complete); + return NULL; + } + + if (!ro_exists(RO_DIR)) { + if (ro_create(ro_name, &attr, NULL, 0)) { + free(complete); + pathname_destroy(ro_name); + return NULL; + } + } + + ro_name = pathname_append(ro_name, ipcpi.name); + if (ro_name == NULL) { + free(complete); + pathname_destroy(ro_name); + return NULL; + } + + if (ro_create(ro_name, &attr, NULL, 0)) { + free(complete); + pathname_destroy(ro_name); + return NULL; + } + pathname_destroy(ro_name); + + list_head_init(&complete->neighbors); + complete->gam = gam; + + if (pthread_mutex_init(&complete->neighbors_lock, NULL)) { + free(complete); + return NULL; + } + + if (pthread_create(&complete->allocator, NULL, + allocator, (void *) complete)) { + free(complete); + pthread_mutex_destroy(&complete->neighbors_lock); + return NULL; + } + + return (void *) complete; +} + +void complete_destroy(void * o) +{ + struct list_head * p = NULL; + struct list_head * n = NULL; + struct complete * complete = (struct complete *) o; + + pthread_cancel(complete->allocator); + pthread_join(complete->allocator, NULL); + + list_for_each_safe(p, n, &complete->neighbors) { + struct neighbor * e = list_entry(p, struct neighbor, next); + list_del(&e->next); + free(e->neighbor); + free(e); + } +} + +int complete_accept_new_flow(void * o) +{ + (void) o; + + return 0; +} + +int complete_accept_flow(void * o, + qosspec_t qs, + const struct cacep_info * info) +{ + struct list_head * pos = NULL; + struct neighbor * n; + struct complete * complete = (struct complete *) o; + + (void) qs; + + pthread_mutex_lock(&complete->neighbors_lock); + + list_for_each(pos, &complete->neighbors) { + struct neighbor * e = list_entry(pos, struct neighbor, next); + if (strcmp(e->neighbor, info->name) == 0) { + pthread_mutex_unlock(&complete->neighbors_lock); + return -1; + } + } + + n = malloc(sizeof(*n)); + if (n == NULL) { + pthread_mutex_unlock(&complete->neighbors_lock); + return -1; + } + + list_head_init(&n->next); + + n->neighbor = strdup(info->name); + if (n->neighbor == NULL) { + pthread_mutex_unlock(&complete->neighbors_lock); + free(n); + return -1; + } + + list_add(&n->next, &complete->neighbors); + + pthread_mutex_unlock(&complete->neighbors_lock); + + return 0; +} diff --git a/src/ipcpd/normal/pol/complete.h b/src/ipcpd/normal/pol/complete.h new file mode 100644 index 00000000..8fcc87ba --- /dev/null +++ b/src/ipcpd/normal/pol/complete.h @@ -0,0 +1,46 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Graph adjacency manager for IPC Process components + * + * 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_POL_COMPLETE_H +#define OUROBOROS_IPCPD_NORMAL_POL_COMPLETE_H + +#include "gam.h" +#include "pol-gam-ops.h" + +void * complete_create(struct gam * instance); + +void complete_destroy(void * o); + +int complete_accept_new_flow(void * o); + +int complete_accept_flow(void * o, + qosspec_t qs, + const struct cacep_info * info); + +struct pol_gam_ops complete_ops = { + .create = complete_create, + .destroy = complete_destroy, + .accept_new_flow = complete_accept_new_flow, + .accept_flow = complete_accept_flow +}; + +#endif /* OUROBOROS_IPCPD_NORMAL_POL_COMPLETE_H */ diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c index c780bf50..993fe62a 100644 --- a/src/ipcpd/normal/ribmgr.c +++ b/src/ipcpd/normal/ribmgr.c @@ -139,6 +139,8 @@ struct { struct addr_auth * addr_auth; enum pol_addr_auth addr_auth_type; + enum pol_gam dt_gam_type; + enum ribmgr_state state; pthread_cond_t state_cond; pthread_mutex_t state_lock; @@ -168,6 +170,7 @@ void ribmgr_ro_created(const char * name, rib.dtc.min_pdu_size = stat_msg->min_pdu_size; rib.dtc.max_pdu_size = stat_msg->max_pdu_size; rib.addr_auth_type = stat_msg->addr_auth_type; + rib.dt_gam_type = stat_msg->dt_gam_type; static_info_msg__free_unpacked(stat_msg, NULL); } @@ -1262,6 +1265,7 @@ int ribmgr_bootstrap(struct dif_config * conf) stat_info.min_pdu_size = rib.dtc.min_pdu_size = conf->min_pdu_size; stat_info.max_pdu_size = rib.dtc.max_pdu_size = conf->max_pdu_size; stat_info.addr_auth_type = rib.addr_auth_type = conf->addr_auth_type; + stat_info.dt_gam_type = rib.dt_gam_type = conf->dt_gam_type; len = static_info_msg__get_packed_size(&stat_info); if (len == 0) { @@ -1354,16 +1358,21 @@ int ribmgr_start_policies(void) return 0; } -struct dt_const * ribmgr_dt_const() +struct dt_const * ribmgr_dt_const(void) { return &(rib.dtc); } -uint64_t ribmgr_address() +uint64_t ribmgr_address(void) { return rib.address; } +enum pol_gam ribmgr_dt_gam(void) +{ + return rib.dt_gam_type; +} + static int send_neighbors_ro(char * name, ro_msg_t * msg, enum cdap_opcode code) { struct list_head * p = NULL; diff --git a/src/ipcpd/normal/ribmgr.h b/src/ipcpd/normal/ribmgr.h index ddc98e6e..22212de9 100644 --- a/src/ipcpd/normal/ribmgr.h +++ b/src/ipcpd/normal/ribmgr.h @@ -45,4 +45,6 @@ struct dt_const * ribmgr_dt_const(void); uint64_t ribmgr_address(void); +enum pol_gam ribmgr_dt_gam(void); + #endif /* OUROBOROS_IPCPD_NORMAL_RIBMGR_H */ diff --git a/src/ipcpd/normal/static_info.proto b/src/ipcpd/normal/static_info.proto index 18f02e36..bb6f8c4e 100644 --- a/src/ipcpd/normal/static_info.proto +++ b/src/ipcpd/normal/static_info.proto @@ -23,13 +23,14 @@ syntax = "proto2"; message static_info_msg { - required uint32 addr_size = 1; - required uint32 cep_id_size = 2; - required uint32 pdu_length_size = 3; - required uint32 seqno_size = 4; - required bool has_ttl = 5; - required bool has_chk = 6; - required uint32 min_pdu_size = 7; - required uint32 max_pdu_size = 8; - required uint32 addr_auth_type = 9; + required uint32 addr_size = 1; + required uint32 cep_id_size = 2; + required uint32 pdu_length_size = 3; + required uint32 seqno_size = 4; + required bool has_ttl = 5; + required bool has_chk = 6; + required uint32 min_pdu_size = 7; + required uint32 max_pdu_size = 8; + required uint32 addr_auth_type = 9; + required uint32 dt_gam_type = 10; } \ No newline at end of file diff --git a/src/lib/cacep.c b/src/lib/cacep.c index 90994c04..22c6137f 100644 --- a/src/lib/cacep.c +++ b/src/lib/cacep.c @@ -39,9 +39,9 @@ struct cacep { uint64_t address; }; -struct cacep * cacep_create(int fd, - char * name, - uint64_t address) +struct cacep * cacep_create(int fd, + const char * name, + uint64_t address) { struct cacep * tmp; diff --git a/src/lib/dif_config.proto b/src/lib/dif_config.proto index 8a1d329e..f1f8747b 100644 --- a/src/lib/dif_config.proto +++ b/src/lib/dif_config.proto @@ -37,9 +37,10 @@ message dif_config_msg { optional uint32 min_pdu_size = 10; optional uint32 max_pdu_size = 11; optional uint32 addr_auth_type = 12; + optional uint32 dt_gam_type = 13; // Config for shim UDP - optional uint32 ip_addr = 13; - optional uint32 dns_addr = 14; + optional uint32 ip_addr = 14; + optional uint32 dns_addr = 15; // Config for the shim Ethernet LLC - optional string if_name = 15; + optional string if_name = 16; } \ No newline at end of file diff --git a/src/lib/irm.c b/src/lib/irm.c index 635c8f9b..ade38b6f 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -120,6 +120,7 @@ int irm_bootstrap_ipcp(pid_t api, config.has_min_pdu_size = true; config.has_max_pdu_size = true; config.has_addr_auth_type = true; + config.has_dt_gam_type = true; config.addr_size = conf->addr_size; config.cep_id_size = conf->cep_id_size; @@ -131,6 +132,7 @@ int irm_bootstrap_ipcp(pid_t api, config.min_pdu_size = conf->min_pdu_size; config.max_pdu_size = conf->max_pdu_size; config.addr_auth_type = conf->addr_auth_type; + config.dt_gam_type = conf->dt_gam_type; break; case IPCP_SHIM_UDP: config.has_ip_addr = true; diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c index 10e53294..4c7f2168 100644 --- a/src/tools/irm/irm_ipcp_bootstrap.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -45,8 +45,10 @@ #define DEFAULT_MAX_PDU_SIZE 9000 #define DEFAULT_DDNS 0 #define DEFAULT_ADDR_AUTH FLAT_RANDOM +#define DEFAULT_DT_GAM COMPLETE -#define ADDR_AUTH_FLAT "flat" +#define ADDR_AUTH_FLAT "flat" +#define DT_GAM_COMPLETE "complete" static void usage(void) { @@ -67,6 +69,8 @@ static void usage(void) " [min_pdu (default: %d)]\n" " [max_pdu (default: %d)]\n" " [addr_auth
(default: %s)]\n" + " [dt_gam " + "(default: %s)]\n" "if TYPE == " SHIM_UDP "\n" " ip \n" " [dns " @@ -76,7 +80,7 @@ static void usage(void) DEFAULT_ADDR_SIZE, DEFAULT_CEP_ID_SIZE, DEFAULT_PDU_LEN_SIZE, DEFAULT_SEQ_NO_SIZE, DEFAULT_MIN_PDU_SIZE, DEFAULT_MAX_PDU_SIZE, - ADDR_AUTH_FLAT, DEFAULT_DDNS); + ADDR_AUTH_FLAT, DT_GAM_COMPLETE, DEFAULT_DDNS); } int do_bootstrap_ipcp(int argc, char ** argv) @@ -93,6 +97,7 @@ int do_bootstrap_ipcp(int argc, char ** argv) uint32_t min_pdu_size = DEFAULT_MIN_PDU_SIZE; uint32_t max_pdu_size = DEFAULT_MAX_PDU_SIZE; enum pol_addr_auth addr_auth_type = DEFAULT_ADDR_AUTH; + enum pol_gam dt_gam_type = DEFAULT_DT_GAM; uint32_t ip_addr = 0; uint32_t dns_addr = DEFAULT_DDNS; char * ipcp_type = NULL; @@ -144,6 +149,9 @@ int do_bootstrap_ipcp(int argc, char ** argv) } else if (matches(*argv, "addr_auth") == 0) { if (strcmp(ADDR_AUTH_FLAT, *(argv + 1)) == 0) addr_auth_type = FLAT_RANDOM; + } else if (matches(*argv, "dt_gam") == 0) { + if (strcmp(DT_GAM_COMPLETE, *(argv + 1)) == 0) + dt_gam_type = COMPLETE; } else { printf("\"%s\" is unknown, try \"irm " "ipcp bootstrap\".\n", *argv); @@ -172,6 +180,7 @@ int do_bootstrap_ipcp(int argc, char ** argv) conf.min_pdu_size = min_pdu_size; conf.max_pdu_size = max_pdu_size; conf.addr_auth_type = addr_auth_type; + conf.dt_gam_type = dt_gam_type; } else if (strcmp(ipcp_type, SHIM_UDP) == 0) { conf.type = IPCP_SHIM_UDP; if (ip_addr == 0) { -- cgit v1.2.3