From e095d0ade3035c714768266755c9c61acfc2ad0f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 13 Feb 2018 18:16:28 +0100 Subject: ipcpd: Revise Data Transfer component This makes the TTL non-optional and allows the maximum (initial) value of the TTL to be specified at bootstrap (the default is set to 60). The fd in the DT PCI is now called EID (Endpoint ID). The names "dif" and "ae" have been replaced by "layer" and "component" respectively in all sources. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/ipcp.c | 47 +++++------ src/ipcpd/ipcp.h | 6 +- src/ipcpd/normal/ae.h | 48 ----------- src/ipcpd/normal/comp.h | 48 +++++++++++ src/ipcpd/normal/connmgr.c | 154 ++++++++++++++++++------------------ src/ipcpd/normal/connmgr.h | 14 ++-- src/ipcpd/normal/dht.c | 2 +- src/ipcpd/normal/dir.c | 2 +- src/ipcpd/normal/dir.h | 2 +- src/ipcpd/normal/dt.c | 59 +++++++------- src/ipcpd/normal/dt.h | 12 +-- src/ipcpd/normal/dt_pci.c | 59 ++++++-------- src/ipcpd/normal/dt_pci.h | 22 +++--- src/ipcpd/normal/enroll.c | 59 +++++++------- src/ipcpd/normal/enroll.h | 2 +- src/ipcpd/normal/fa.c | 8 +- src/ipcpd/normal/main.c | 32 ++++---- src/ipcpd/normal/pol/link_state.c | 16 ++-- src/ipcpd/normal/pol/link_state.h | 2 +- src/ipcpd/normal/tests/dht_test.c | 2 +- src/irmd/ipcp.c | 20 ++--- src/irmd/ipcp.h | 8 +- src/irmd/main.c | 82 +++++++++---------- src/irmd/registry.c | 68 ++++++++-------- src/irmd/registry.h | 16 ++-- src/lib/CMakeLists.txt | 4 +- src/lib/cacep.c | 4 +- src/lib/cacep.proto | 2 +- src/lib/ipcp_config.proto | 28 +++---- src/lib/ipcpd_messages.proto | 24 +++--- src/lib/irm.c | 73 +++++++++-------- src/lib/irmd_messages.proto | 2 +- src/tools/irm/irm_ipcp_bootstrap.c | 55 ++++++------- src/tools/irm/irm_ipcp_connect.c | 4 +- src/tools/irm/irm_ipcp_disconnect.c | 4 +- src/tools/irm/irm_ipcp_enroll.c | 23 +++--- src/tools/irm/irm_register.c | 12 +-- src/tools/irm/irm_unregister.c | 14 ++-- 38 files changed, 516 insertions(+), 523 deletions(-) delete mode 100644 src/ipcpd/normal/ae.h create mode 100644 src/ipcpd/normal/comp.h (limited to 'src') diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 6a1cde40..4900ec03 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -174,16 +174,16 @@ static void * mainloop(void * o) int sfd; buffer_t buffer; struct ipcp_config conf; - struct dif_info info; + struct layer_info info; ipcp_config_msg_t * conf_msg; ipcp_msg_t * msg; (void) o; while (true) { - ipcp_msg_t ret_msg = IPCP_MSG__INIT; - dif_info_msg_t dif_info = DIF_INFO_MSG__INIT; - int fd = -1; + ipcp_msg_t ret_msg = IPCP_MSG__INIT; + layer_info_msg_t layer_info = LAYER_INFO_MSG__INIT; + int fd = -1; struct cmd * cmd; ret_msg.code = IPCP_MSG_CODE__IPCP_REPLY; @@ -234,12 +234,12 @@ static void * mainloop(void * o) conf_msg = msg->conf; conf.type = conf_msg->ipcp_type; - strcpy(conf.dif_info.dif_name, - conf_msg->dif_info->dif_name); + strcpy(conf.layer_info.layer_name, + conf_msg->layer_info->layer_name); if (conf_msg->ipcp_type == IPCP_NORMAL) { conf.addr_size = conf_msg->addr_size; - conf.fd_size = conf_msg->fd_size; - conf.has_ttl = conf_msg->has_ttl; + conf.eid_size = conf_msg->eid_size; + conf.max_ttl = conf_msg->max_ttl; conf.addr_auth_type = conf_msg->addr_auth_type; conf.routing_type = conf_msg->routing_type; conf.pff_type = conf_msg->pff_type; @@ -252,43 +252,44 @@ static void * mainloop(void * o) conf.ip_addr = conf_msg->ip_addr; conf.dns_addr = conf_msg->dns_addr; - conf.dif_info.dir_hash_algo = HASH_MD5; - dif_info.dir_hash_algo = HASH_MD5; + conf.layer_info.dir_hash_algo = HASH_MD5; + layer_info.dir_hash_algo = HASH_MD5; } /* Only udp needs a fixed hash algorithm */ if (conf_msg->ipcp_type != IPCP_UDP) { - switch(conf_msg->dif_info->dir_hash_algo) { + switch(conf_msg->layer_info->dir_hash_algo) { case DIR_HASH_SHA3_224: - conf.dif_info.dir_hash_algo = + conf.layer_info.dir_hash_algo = HASH_SHA3_224; break; case DIR_HASH_SHA3_256: - conf.dif_info.dir_hash_algo = + conf.layer_info.dir_hash_algo = HASH_SHA3_256; break; case DIR_HASH_SHA3_384: - conf.dif_info.dir_hash_algo = + conf.layer_info.dir_hash_algo = HASH_SHA3_384; break; case DIR_HASH_SHA3_512: - conf.dif_info.dir_hash_algo = + conf.layer_info.dir_hash_algo = HASH_SHA3_512; break; default: assert(false); } - dif_info.dir_hash_algo = - conf.dif_info.dir_hash_algo; + layer_info.dir_hash_algo = + conf.layer_info.dir_hash_algo; } - ipcpi.dir_hash_algo = conf.dif_info.dir_hash_algo; + ipcpi.dir_hash_algo = conf.layer_info.dir_hash_algo; ret_msg.result = ipcpi.ops->ipcp_bootstrap(&conf); if (ret_msg.result == 0) { - ret_msg.dif_info = &dif_info; - dif_info.dif_name = conf.dif_info.dif_name; + ret_msg.layer_info = &layer_info; + layer_info.layer_name = + conf.layer_info.layer_name; } break; case IPCP_MSG_CODE__IPCP_ENROLL: @@ -309,9 +310,9 @@ static void * mainloop(void * o) ret_msg.result = ipcpi.ops->ipcp_enroll(msg->dst_name, &info); if (ret_msg.result == 0) { - ret_msg.dif_info = &dif_info; - dif_info.dir_hash_algo = info.dir_hash_algo; - dif_info.dif_name = info.dif_name; + ret_msg.layer_info = &layer_info; + layer_info.dir_hash_algo = info.dir_hash_algo; + layer_info.layer_name = info.layer_name; } break; case IPCP_MSG_CODE__IPCP_CONNECT: diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h index d53a9d7c..c81ea1aa 100644 --- a/src/ipcpd/ipcp.h +++ b/src/ipcpd/ipcp.h @@ -44,8 +44,8 @@ enum ipcp_state { struct ipcp_ops { int (* ipcp_bootstrap)(const struct ipcp_config * conf); - int (* ipcp_enroll)(const char * dst, - struct dif_info * info); + int (* ipcp_enroll)(const char * dst, + struct layer_info * info); int (* ipcp_connect)(const char * dst, const char * component); @@ -77,7 +77,7 @@ struct ipcp { char * name; enum ipcp_type type; - char * dif_name; + char * layer_name; uint64_t dt_addr; diff --git a/src/ipcpd/normal/ae.h b/src/ipcpd/normal/ae.h deleted file mode 100644 index 527748d1..00000000 --- a/src/ipcpd/normal/ae.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2018 - * - * Application Entities for the normal IPC process - * - * 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., http://www.fsf.org/about/contact/. - */ - -#ifndef OUROBOROS_IPCPD_NORMAL_AE_H -#define OUROBOROS_IPCPD_NORMAL_AE_H - -#include - -#include "dt.h" - -#define DST_MAX_STRLEN 64 - -enum ae_id { - AEID_DT = 0, - AEID_ENROLL, - AEID_MGMT, - AEID_MAX -}; - -struct conn { - struct conn_info conn_info; - struct { - char dst[DST_MAX_STRLEN + 1]; - int fd; - qosspec_t qs; - } flow_info; -}; - -#endif /* OUROBOROS_IPCPD_NORMAL_AE_H */ diff --git a/src/ipcpd/normal/comp.h b/src/ipcpd/normal/comp.h new file mode 100644 index 00000000..bdfba353 --- /dev/null +++ b/src/ipcpd/normal/comp.h @@ -0,0 +1,48 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2018 + * + * Components for the normal IPC process + * + * 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., http://www.fsf.org/about/contact/. + */ + +#ifndef OUROBOROS_IPCPD_NORMAL_COMP_H +#define OUROBOROS_IPCPD_NORMAL_COMP_H + +#include + +#include "dt.h" + +#define DST_MAX_STRLEN 64 + +enum comp_id { + COMPID_DT = 0, + COMPID_ENROLL, + COMPID_MGMT, + COMPID_MAX +}; + +struct conn { + struct conn_info conn_info; + struct { + char dst[DST_MAX_STRLEN + 1]; + int fd; + qosspec_t qs; + } flow_info; +}; + +#endif /* OUROBOROS_IPCPD_NORMAL_COMP_H */ diff --git a/src/ipcpd/normal/connmgr.c b/src/ipcpd/normal/connmgr.c index 7a6f252e..843eb280 100644 --- a/src/ipcpd/normal/connmgr.c +++ b/src/ipcpd/normal/connmgr.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * Handles AE connections + * Handles connections between components * * Dimitri Staessens * Sander Vrijders @@ -31,7 +31,7 @@ #include #include -#include "ae.h" +#include "comp.h" #include "connmgr.h" #include "enroll.h" #include "ipcp.h" @@ -52,7 +52,7 @@ struct conn_el { struct conn conn; }; -struct ae { +struct comp { struct nbs * nbs; struct conn_info info; @@ -64,7 +64,7 @@ struct ae { }; struct { - struct ae aes[AEID_MAX]; + struct comp comps[COMPID_MAX]; enum connmgr_state state; pthread_t acceptor; @@ -72,19 +72,19 @@ struct { static int get_id_by_name(const char * name) { - enum ae_id i; + enum comp_id i; - for (i = 0; i < AEID_MAX; ++i) - if (strcmp(name, connmgr.aes[i].info.ae_name) == 0) + for (i = 0; i < COMPID_MAX; ++i) + if (strcmp(name, connmgr.comps[i].info.comp_name) == 0) return i; return -1; } -static int add_ae_conn(enum ae_id id, - int fd, - qosspec_t qs, - struct conn_info * rcv_info) +static int add_comp_conn(enum comp_id id, + int fd, + qosspec_t qs, + struct conn_info * rcv_info) { struct conn_el * el; @@ -98,12 +98,12 @@ static int add_ae_conn(enum ae_id id, el->conn.flow_info.fd = fd; el->conn.flow_info.qs = qs; - pthread_mutex_lock(&connmgr.aes[id].lock); + pthread_mutex_lock(&connmgr.comps[id].lock); - list_add(&el->next, &connmgr.aes[id].pending); - pthread_cond_signal(&connmgr.aes[id].cond); + list_add(&el->next, &connmgr.comps[id].pending); + pthread_cond_signal(&connmgr.comps[id].cond); - pthread_mutex_unlock(&connmgr.aes[id].lock); + pthread_mutex_unlock(&connmgr.comps[id].lock); return 0; } @@ -135,24 +135,24 @@ static void * flow_acceptor(void * o) continue; } - id = get_id_by_name(rcv_info.ae_name); + id = get_id_by_name(rcv_info.comp_name); if (id < 0) { - log_dbg("Connection request for unknown AE %s.", - rcv_info.ae_name); + log_dbg("Connection request for unknown component %s.", + rcv_info.comp_name); cacep_snd(fd, &fail_info); flow_dealloc(fd); continue; } - assert(id < AEID_MAX); + assert(id < COMPID_MAX); - if (cacep_snd(fd, &connmgr.aes[id].info)) { + if (cacep_snd(fd, &connmgr.comps[id].info)) { log_dbg("Failed to respond to request."); flow_dealloc(fd); continue; } - if (add_ae_conn(id, fd, qs, &rcv_info)) { + if (add_comp_conn(id, fd, qs, &rcv_info)) { log_dbg("Failed to add new connection."); flow_dealloc(fd); continue; @@ -176,8 +176,8 @@ void connmgr_fini(void) if (connmgr.state == CONNMGR_RUNNING) pthread_join(connmgr.acceptor, NULL); - for (i = 0; i < AEID_MAX; ++i) - connmgr_ae_fini(i); + for (i = 0; i < COMPID_MAX; ++i) + connmgr_comp_fini(i); } int connmgr_start(void) @@ -196,64 +196,64 @@ void connmgr_stop(void) pthread_cancel(connmgr.acceptor); } -int connmgr_ae_init(enum ae_id id, - const struct conn_info * info) +int connmgr_comp_init(enum comp_id id, + const struct conn_info * info) { - struct ae * ae; + struct comp * comp; - assert(id >= 0 && id < AEID_MAX); + assert(id >= 0 && id < COMPID_MAX); - ae = connmgr.aes + id; + comp = connmgr.comps + id; - if (pthread_mutex_init(&ae->lock, NULL)) + if (pthread_mutex_init(&comp->lock, NULL)) return -1; - if (pthread_cond_init(&ae->cond, NULL)) { - pthread_mutex_destroy(&ae->lock); + if (pthread_cond_init(&comp->cond, NULL)) { + pthread_mutex_destroy(&comp->lock); return -1; } - list_head_init(&ae->conns); - list_head_init(&ae->pending); + list_head_init(&comp->conns); + list_head_init(&comp->pending); - memcpy(&connmgr.aes[id].info, info, sizeof(connmgr.aes[id].info)); + memcpy(&connmgr.comps[id].info, info, sizeof(connmgr.comps[id].info)); return 0; } -void connmgr_ae_fini(enum ae_id id) +void connmgr_comp_fini(enum comp_id id) { struct list_head * p; struct list_head * h; - struct ae * ae; + struct comp * comp; - assert(id >= 0 && id < AEID_MAX); + assert(id >= 0 && id < COMPID_MAX); - if (strlen(connmgr.aes[id].info.ae_name) == 0) + if (strlen(connmgr.comps[id].info.comp_name) == 0) return; - ae = connmgr.aes + id; + comp = connmgr.comps + id; - pthread_mutex_lock(&ae->lock); + pthread_mutex_lock(&comp->lock); - list_for_each_safe(p, h, &ae->conns) { + list_for_each_safe(p, h, &comp->conns) { struct conn_el * e = list_entry(p, struct conn_el, next); list_del(&e->next); free(e); } - list_for_each_safe(p, h, &ae->pending) { + list_for_each_safe(p, h, &comp->pending) { struct conn_el * e = list_entry(p, struct conn_el, next); list_del(&e->next); free(e); } - pthread_mutex_unlock(&ae->lock); + pthread_mutex_unlock(&comp->lock); - pthread_cond_destroy(&ae->cond); - pthread_mutex_destroy(&ae->lock); + pthread_cond_destroy(&comp->cond); + pthread_mutex_destroy(&comp->lock); - memset(&connmgr.aes[id].info, 0, sizeof(connmgr.aes[id].info)); + memset(&connmgr.comps[id].info, 0, sizeof(connmgr.comps[id].info)); } int connmgr_ipcp_connect(const char * dst, @@ -292,11 +292,11 @@ int connmgr_ipcp_connect(const char * dst, strcpy(ce->conn.flow_info.dst, dst); } - pthread_mutex_lock(&connmgr.aes[id].lock); + pthread_mutex_lock(&connmgr.comps[id].lock); - list_add(&ce->next, &connmgr.aes[id].conns); + list_add(&ce->next, &connmgr.comps[id].conns); - pthread_mutex_unlock(&connmgr.aes[id].lock); + pthread_mutex_unlock(&connmgr.comps[id].lock); return 0; } @@ -315,13 +315,13 @@ int connmgr_ipcp_disconnect(const char * dst, if (id < 0) return -1; - pthread_mutex_lock(&connmgr.aes[id].lock); + pthread_mutex_lock(&connmgr.comps[id].lock); - list_for_each_safe(p,h, &connmgr.aes[id].conns) { + list_for_each_safe(p,h, &connmgr.comps[id].conns) { struct conn_el * el = list_entry(p, struct conn_el, next); if (strcmp(el->conn.flow_info.dst, dst) == 0) { int ret; - pthread_mutex_unlock(&connmgr.aes[id].lock); + pthread_mutex_unlock(&connmgr.comps[id].lock); list_del(&el->next); ret = connmgr_dealloc(id, &el->conn); free(el); @@ -329,17 +329,17 @@ int connmgr_ipcp_disconnect(const char * dst, } } - pthread_mutex_unlock(&connmgr.aes[id].lock); + pthread_mutex_unlock(&connmgr.comps[id].lock); return 0; } -int connmgr_alloc(enum ae_id id, +int connmgr_alloc(enum comp_id id, const char * dst, qosspec_t * qs, struct conn * conn) { - assert(id >= 0 && id < AEID_MAX); + assert(id >= 0 && id < COMPID_MAX); assert(dst); conn->flow_info.fd = flow_alloc(dst, qs, NULL); @@ -354,9 +354,9 @@ int connmgr_alloc(enum ae_id id, memset(&conn->flow_info.qs, 0, sizeof(conn->flow_info.qs)); log_dbg("Sending cacep info for protocol %s to fd %d.", - connmgr.aes[id].info.protocol, conn->flow_info.fd); + connmgr.comps[id].info.protocol, conn->flow_info.fd); - if (cacep_snd(conn->flow_info.fd, &connmgr.aes[id].info)) { + if (cacep_snd(conn->flow_info.fd, &connmgr.comps[id].info)) { log_dbg("Failed to create application connection."); flow_dealloc(conn->flow_info.fd); return -1; @@ -368,31 +368,31 @@ int connmgr_alloc(enum ae_id id, return -1; } - if (strcmp(connmgr.aes[id].info.protocol, conn->conn_info.protocol)) { + if (strcmp(connmgr.comps[id].info.protocol, conn->conn_info.protocol)) { log_dbg("Unknown protocol (requested %s, got %s).", - connmgr.aes[id].info.protocol, + connmgr.comps[id].info.protocol, conn->conn_info.protocol); flow_dealloc(conn->flow_info.fd); return -1; } - if (connmgr.aes[id].info.pref_version != conn->conn_info.pref_version) { + if (connmgr.comps[id].info.pref_version != conn->conn_info.pref_version) { log_dbg("Unknown protocol version."); flow_dealloc(conn->flow_info.fd); return -1; } - if (connmgr.aes[id].info.pref_syntax != conn->conn_info.pref_syntax) { + if (connmgr.comps[id].info.pref_syntax != conn->conn_info.pref_syntax) { log_dbg("Unknown protocol syntax."); flow_dealloc(conn->flow_info.fd); return -1; } switch (id) { - case AEID_DT: + case COMPID_DT: notifier_event(NOTIFY_DT_CONN_ADD, conn); break; - case AEID_MGMT: + case COMPID_MGMT: notifier_event(NOTIFY_MGMT_CONN_ADD, conn); break; default: @@ -402,14 +402,14 @@ int connmgr_alloc(enum ae_id id, return 0; } -int connmgr_dealloc(enum ae_id id, +int connmgr_dealloc(enum comp_id id, struct conn * conn) { switch (id) { - case AEID_DT: + case COMPID_DT: notifier_event(NOTIFY_DT_CONN_DEL, conn); break; - case AEID_MGMT: + case COMPID_MGMT: notifier_event(NOTIFY_MGMT_CONN_DEL, conn); break; default: @@ -420,30 +420,30 @@ int connmgr_dealloc(enum ae_id id, } -int connmgr_wait(enum ae_id id, +int connmgr_wait(enum comp_id id, struct conn * conn) { struct conn_el * el; - struct ae * ae; + struct comp * comp; - assert(id >= 0 && id < AEID_MAX); + assert(id >= 0 && id < COMPID_MAX); assert(conn); - ae = connmgr.aes + id; + comp = connmgr.comps + id; - pthread_mutex_lock(&ae->lock); + pthread_mutex_lock(&comp->lock); pthread_cleanup_push((void(*)(void *))pthread_mutex_unlock, - (void *) &ae->lock); + (void *) &comp->lock); - while (list_is_empty(&ae->pending)) - pthread_cond_wait(&ae->cond, &ae->lock); + while (list_is_empty(&comp->pending)) + pthread_cond_wait(&comp->cond, &comp->lock); pthread_cleanup_pop(false); - el = list_first_entry((&ae->pending), struct conn_el, next); + el = list_first_entry((&comp->pending), struct conn_el, next); if (el == NULL) { - pthread_mutex_unlock(&ae->lock); + pthread_mutex_unlock(&comp->lock); return -1; } @@ -452,7 +452,7 @@ int connmgr_wait(enum ae_id id, list_del(&el->next); free(el); - pthread_mutex_unlock(&ae->lock); + pthread_mutex_unlock(&comp->lock); return 0; } diff --git a/src/ipcpd/normal/connmgr.h b/src/ipcpd/normal/connmgr.h index 0efeae89..cf627d60 100644 --- a/src/ipcpd/normal/connmgr.h +++ b/src/ipcpd/normal/connmgr.h @@ -26,7 +26,7 @@ #include #include -#include "ae.h" +#include "comp.h" #define NOTIFY_DT_CONN_ADD 0x00D0 #define NOTIFY_DT_CONN_DEL 0x00D1 @@ -45,10 +45,10 @@ int connmgr_start(void); void connmgr_stop(void); -int connmgr_ae_init(enum ae_id id, - const struct conn_info * info); +int connmgr_comp_init(enum comp_id id, + const struct conn_info * info); -void connmgr_ae_fini(enum ae_id id); +void connmgr_comp_fini(enum comp_id id); int connmgr_ipcp_connect(const char * dst, const char * component); @@ -56,15 +56,15 @@ int connmgr_ipcp_connect(const char * dst, int connmgr_ipcp_disconnect(const char * dst, const char * component); -int connmgr_alloc(enum ae_id id, +int connmgr_alloc(enum comp_id id, const char * dst, qosspec_t * qs, struct conn * conn); -int connmgr_dealloc(enum ae_id id, +int connmgr_dealloc(enum comp_id id, struct conn * conn); -int connmgr_wait(enum ae_id id, +int connmgr_wait(enum comp_id id, struct conn * conn); #endif /* OUROBOROS_IPCPD_NORMAL_CONNMGR_H */ diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c index d2ea9985..ebed4068 100644 --- a/src/ipcpd/normal/dht.c +++ b/src/ipcpd/normal/dht.c @@ -2767,7 +2767,7 @@ struct dht * dht_create(uint64_t addr) if (tpm_start(dht->tpm)) goto fail_tpm_start; - dht->fd = dt_reg_ae(dht, &dht_post_sdu); + dht->fd = dt_reg_comp(dht, &dht_post_sdu); notifier_reg(handle_event, dht); #else (void) handle_event; diff --git a/src/ipcpd/normal/dir.c b/src/ipcpd/normal/dir.c index 1d0a5270..2428e1b6 100644 --- a/src/ipcpd/normal/dir.c +++ b/src/ipcpd/normal/dir.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * DIF directory + * Directory * * Dimitri Staessens * Sander Vrijders diff --git a/src/ipcpd/normal/dir.h b/src/ipcpd/normal/dir.h index 916088e8..365341ad 100644 --- a/src/ipcpd/normal/dir.h +++ b/src/ipcpd/normal/dir.h @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * DIF directory + * Directory * * Dimitri Staessens * Sander Vrijders diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c index 1bc9031e..0df68dd4 100644 --- a/src/ipcpd/normal/dt.c +++ b/src/ipcpd/normal/dt.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * Data Transfer AE + * Data Transfer Component * * Dimitri Staessens * Sander Vrijders @@ -24,7 +24,7 @@ #include "config.h" -#define OUROBOROS_PREFIX "dt-ae" +#define OUROBOROS_PREFIX "dt" #include #include @@ -39,7 +39,7 @@ #include "pff.h" #include "routing.h" #include "sdu_sched.h" -#include "ae.h" +#include "comp.h" #include "fa.h" #include @@ -49,9 +49,9 @@ #include #include -struct ae_info { - void (* post_sdu)(void * ae, struct shm_du_buff * sdb); - void * ae; +struct comp_info { + void (* post_sdu)(void * comp, struct shm_du_buff * sdb); + void * comp; }; struct { @@ -61,7 +61,7 @@ struct { struct routing_i * routing[QOS_CUBE_MAX]; struct bmp * res_fds; - struct ae_info aes[PROG_RES_FDS]; + struct comp_info comps[PROG_RES_FDS]; pthread_rwlock_t lock; pthread_t listener; @@ -127,19 +127,20 @@ static void sdu_handler(int fd, } else { dt_pci_shrink(sdb); - if (dt_pci.fd > PROG_RES_FDS) { - if (ipcp_flow_write(dt_pci.fd, sdb)) + if (dt_pci.eid > PROG_RES_FDS) { + if (ipcp_flow_write(dt_pci.eid, sdb)) ipcp_sdb_release(sdb); return; } - if (dt.aes[dt_pci.fd].post_sdu == NULL) { - log_err("No registered AE on fd %d.", dt_pci.fd); + if (dt.comps[dt_pci.eid].post_sdu == NULL) { + log_err("No registered component on eid %d.", + dt_pci.eid); ipcp_sdb_release(sdb); return; } - dt.aes[dt_pci.fd].post_sdu(dt.aes[dt_pci.fd].ae, sdb); + dt.comps[dt_pci.eid].post_sdu(dt.comps[dt_pci.eid].comp, sdb); } } @@ -150,7 +151,7 @@ static void * dt_conn_handle(void * o) (void) o; while (true) { - if (connmgr_wait(AEID_DT, &conn)) { + if (connmgr_wait(COMPID_DT, &conn)) { log_err("Failed to get next DT connection."); continue; } @@ -166,8 +167,8 @@ static void * dt_conn_handle(void * o) int dt_init(enum pol_routing pr, enum pol_pff pp, uint8_t addr_size, - uint8_t fd_size, - bool has_ttl) + uint8_t eid_size, + uint8_t max_ttl) { int i; int j; @@ -175,13 +176,13 @@ int dt_init(enum pol_routing pr, memset(&info, 0, sizeof(info)); - strcpy(info.ae_name, DT_AE); + strcpy(info.comp_name, DT_COMP); strcpy(info.protocol, DT_PROTO); info.pref_version = 1; info.pref_syntax = PROTO_FIXED; info.addr = ipcpi.dt_addr; - if (dt_pci_init(addr_size, fd_size, has_ttl)) { + if (dt_pci_init(addr_size, eid_size, max_ttl)) { log_err("Failed to init shm dt_pci."); goto fail_pci_init; } @@ -191,9 +192,9 @@ int dt_init(enum pol_routing pr, goto fail_notifier_reg; } - if (connmgr_ae_init(AEID_DT, &info)) { + if (connmgr_comp_init(COMPID_DT, &info)) { log_err("Failed to register with connmgr."); - goto fail_connmgr_ae_init; + goto fail_connmgr_comp_init; } if (routing_init(pr)) { @@ -242,8 +243,8 @@ int dt_init(enum pol_routing pr, fail_pff: routing_fini(); fail_routing: - connmgr_ae_fini(AEID_DT); - fail_connmgr_ae_init: + connmgr_comp_fini(COMPID_DT); + fail_connmgr_comp_init: notifier_unreg(&handle_event); fail_notifier_reg: dt_pci_fini(); @@ -267,7 +268,7 @@ void dt_fini(void) routing_fini(); - connmgr_ae_fini(AEID_DT); + connmgr_comp_fini(COMPID_DT); notifier_unreg(&handle_event); @@ -298,8 +299,8 @@ void dt_stop(void) sdu_sched_destroy(dt.sdu_sched); } -int dt_reg_ae(void * ae, - void (* func)(void * func, struct shm_du_buff *)) +int dt_reg_comp(void * comp, + void (* func)(void * func, struct shm_du_buff *)) { int res_fd; @@ -314,11 +315,11 @@ int dt_reg_ae(void * ae, return -EBADF; } - assert(dt.aes[res_fd].post_sdu == NULL); - assert(dt.aes[res_fd].ae == NULL); + assert(dt.comps[res_fd].post_sdu == NULL); + assert(dt.comps[res_fd].comp == NULL); - dt.aes[res_fd].post_sdu = func; - dt.aes[res_fd].ae = ae; + dt.comps[res_fd].post_sdu = func; + dt.comps[res_fd].comp = comp; pthread_rwlock_unlock(&dt.lock); @@ -345,7 +346,7 @@ int dt_write_sdu(uint64_t dst_addr, dt_pci.dst_addr = dst_addr; dt_pci.qc = qc; - dt_pci.fd = np1_fd; + dt_pci.eid = np1_fd; if (dt_pci_ser(sdb, &dt_pci)) { log_err("Failed to serialize PDU."); diff --git a/src/ipcpd/normal/dt.h b/src/ipcpd/normal/dt.h index 9e8c0780..f3bfdc56 100644 --- a/src/ipcpd/normal/dt.h +++ b/src/ipcpd/normal/dt.h @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * Data Transfer AE + * Data Transfer component * * Dimitri Staessens * Sander Vrijders @@ -28,15 +28,15 @@ #include "dt_pci.h" -#define DT_AE "Data Transfer" +#define DT_COMP "Data Transfer" #define DT_PROTO "dtp" #define INVALID_ADDR 0 int dt_init(enum pol_routing pr, enum pol_pff pp, uint8_t addr_size, - uint8_t fd_size, - bool has_ttl + uint8_t eid_size, + uint8_t max_ttl ); void dt_fini(void); @@ -45,8 +45,8 @@ int dt_start(void); void dt_stop(void); -int dt_reg_ae(void * ae, - void (* func)(void * ae, struct shm_du_buff * sdb)); +int dt_reg_comp(void * comp, + void (* func)(void * comp, struct shm_du_buff * sdb)); int dt_write_sdu(uint64_t dst_addr, qoscube_t qc, diff --git a/src/ipcpd/normal/dt_pci.c b/src/ipcpd/normal/dt_pci.c index 77fa048e..76304668 100644 --- a/src/ipcpd/normal/dt_pci.c +++ b/src/ipcpd/normal/dt_pci.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * Protocol Control Information of Data Transfer AE + * Protocol Control Information of Data Transfer Component * * Dimitri Staessens * Sander Vrijders @@ -28,36 +28,32 @@ #include #include -#define DEFAULT_TTL 60 - struct { uint8_t addr_size; - uint8_t fd_size; - bool has_ttl; + uint8_t eid_size; size_t head_size; - /* offsets */ + /* Offsets */ size_t qc_o; size_t ttl_o; - size_t fd_o; + size_t eid_o; + + /* Initial TTL value */ + uint8_t max_ttl; } dt_pci_info; int dt_pci_init(uint8_t addr_size, - uint8_t fd_size, - bool has_ttl) + uint8_t eid_size, + uint8_t max_ttl) { dt_pci_info.addr_size = addr_size; - dt_pci_info.fd_size = fd_size; - dt_pci_info.has_ttl = has_ttl; - - dt_pci_info.qc_o = dt_pci_info.addr_size; - dt_pci_info.ttl_o = dt_pci_info.qc_o + QOS_LEN; - if (dt_pci_info.has_ttl) - dt_pci_info.fd_o = dt_pci_info.ttl_o + TTL_LEN; - else - dt_pci_info.fd_o = dt_pci_info.ttl_o; + dt_pci_info.eid_size = eid_size; + dt_pci_info.max_ttl = max_ttl; - dt_pci_info.head_size = dt_pci_info.fd_o + dt_pci_info.fd_size; + dt_pci_info.qc_o = dt_pci_info.addr_size; + dt_pci_info.ttl_o = dt_pci_info.qc_o + QOS_LEN; + dt_pci_info.eid_o = dt_pci_info.ttl_o + TTL_LEN; + dt_pci_info.head_size = dt_pci_info.eid_o + dt_pci_info.eid_size; return 0; } @@ -70,7 +66,7 @@ int dt_pci_ser(struct shm_du_buff * sdb, struct dt_pci * dt_pci) { uint8_t * head; - uint8_t ttl = DEFAULT_TTL; + uint8_t ttl = dt_pci_info.max_ttl; assert(sdb); assert(dt_pci); @@ -79,12 +75,11 @@ int dt_pci_ser(struct shm_du_buff * sdb, if (head == NULL) return -EPERM; - /* FIXME: Add check and operations for Big Endian machines */ + /* FIXME: Add check and operations for Big Endian machines. */ memcpy(head, &dt_pci->dst_addr, dt_pci_info.addr_size); memcpy(head + dt_pci_info.qc_o, &dt_pci->qc, QOS_LEN); - if (dt_pci_info.has_ttl) - memcpy(head + dt_pci_info.ttl_o, &ttl, TTL_LEN); - memcpy(head + dt_pci_info.fd_o, &dt_pci->fd, dt_pci_info.fd_size); + memcpy(head + dt_pci_info.ttl_o, &ttl, TTL_LEN); + memcpy(head + dt_pci_info.eid_o, &dt_pci->eid, dt_pci_info.eid_size); return 0; } @@ -99,18 +94,14 @@ void dt_pci_des(struct shm_du_buff * sdb, head = shm_du_buff_head(sdb); - /* FIXME: Add check and operations for Big Endian machines */ + /* Decrease TTL */ + --*(head + dt_pci_info.ttl_o); + + /* FIXME: Add check and operations for Big Endian machines. */ memcpy(&dt_pci->dst_addr, head, dt_pci_info.addr_size); memcpy(&dt_pci->qc, head + dt_pci_info.qc_o, QOS_LEN); - - if (dt_pci_info.has_ttl) { - --*(head + dt_pci_info.ttl_o); /* decrease TTL */ - memcpy(&dt_pci->ttl, head + dt_pci_info.ttl_o, TTL_LEN); - } else { - dt_pci->ttl = 1; - } - - memcpy(&dt_pci->fd, head + dt_pci_info.fd_o, dt_pci_info.fd_size); + memcpy(&dt_pci->ttl, head + dt_pci_info.ttl_o, TTL_LEN); + memcpy(&dt_pci->eid, head + dt_pci_info.eid_o, dt_pci_info.eid_size); } void dt_pci_shrink(struct shm_du_buff * sdb) diff --git a/src/ipcpd/normal/dt_pci.h b/src/ipcpd/normal/dt_pci.h index 34df9281..8022f84a 100644 --- a/src/ipcpd/normal/dt_pci.h +++ b/src/ipcpd/normal/dt_pci.h @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * Protocol Control Information of Data Transfer AE + * Protocol Control Information of Data Transfer Component * * Dimitri Staessens * Sander Vrijders @@ -32,29 +32,27 @@ /* Abstract syntax */ enum dtp_fields { - DTP_DST = 0, /* DST ADDRESS */ - DTP_QOS, /* QOS ID */ - DTP_DFD, /* DEST FD */ - DTP_TTL, /* TTL FIELD */ - DTP_NUM_FIELDS /* number of fields */ + DTP_DST = 0, /* DST ADDRESS */ + DTP_QOS, /* QOS ID */ + DTP_DEID, /* DST Endpoint ID */ + DTP_TTL, /* TTL FIELD */ + DTP_NUM_FIELDS /* Number of fields */ }; -/* Default field lengths */ +/* Fixed field lengths */ #define TTL_LEN 1 #define QOS_LEN 1 -#define DFD_LEN 1 -#define DST_LEN 2 struct dt_pci { uint64_t dst_addr; qoscube_t qc; uint8_t ttl; - uint32_t fd; + uint32_t eid; }; int dt_pci_init(uint8_t addr_size, - uint8_t fd_size, - bool has_ttl); + uint8_t eid_size, + uint8_t max_ttl); void dt_pci_fini(void); diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c index e8a75241..eaa87a42 100644 --- a/src/ipcpd/normal/enroll.c +++ b/src/ipcpd/normal/enroll.c @@ -44,7 +44,7 @@ #include "enroll.pb-c.h" typedef EnrollMsg enroll_msg_t; -#define ENROLL_AE "Enrollment" +#define ENROLL_COMP "Enrollment" #define ENROLL_PROTO "OEP" /* Ouroboros enrollment protocol */ #define ENROLL_WARN_TIME_OFFSET 20 #define ENROLL_BUF_LEN 1024 @@ -124,16 +124,17 @@ static int send_rcv_enroll_msg(int fd) if (labs(ts_diff_ms(&t0, &rtt)) - delta_t > ENROLL_WARN_TIME_OFFSET) log_warn("Clock offset above threshold."); - strcpy(enroll.conf.dif_info.dif_name, reply->conf->dif_info->dif_name); + strcpy(enroll.conf.layer_info.layer_name, + reply->conf->layer_info->layer_name); enroll.conf.type = reply->conf->ipcp_type; enroll.conf.addr_size = reply->conf->addr_size; - enroll.conf.fd_size = reply->conf->fd_size; - enroll.conf.has_ttl = reply->conf->has_ttl; + enroll.conf.eid_size = reply->conf->eid_size; + enroll.conf.max_ttl = reply->conf->max_ttl; enroll.conf.addr_auth_type = reply->conf->addr_auth_type; enroll.conf.routing_type = reply->conf->routing_type; enroll.conf.pff_type = reply->conf->pff_type; - enroll.conf.dif_info.dir_hash_algo - = reply->conf->dif_info->dir_hash_algo; + enroll.conf.layer_info.dir_hash_algo + = reply->conf->layer_info->dir_hash_algo; enroll_msg__free_unpacked(reply, NULL); @@ -142,9 +143,9 @@ static int send_rcv_enroll_msg(int fd) static ssize_t enroll_pack(uint8_t ** buf) { - enroll_msg_t msg = ENROLL_MSG__INIT; - ipcp_config_msg_t config = IPCP_CONFIG_MSG__INIT; - dif_info_msg_t dif_info = DIF_INFO_MSG__INIT; + enroll_msg_t msg = ENROLL_MSG__INIT; + ipcp_config_msg_t config = IPCP_CONFIG_MSG__INIT; + layer_info_msg_t layer_info = LAYER_INFO_MSG__INIT; struct timespec now; ssize_t len; @@ -160,20 +161,20 @@ static ssize_t enroll_pack(uint8_t ** buf) config.ipcp_type = enroll.conf.type; config.has_addr_size = true; config.addr_size = enroll.conf.addr_size; - config.has_fd_size = true; - config.fd_size = enroll.conf.fd_size; - config.has_has_ttl = true; - config.has_ttl = enroll.conf.has_ttl; + config.has_eid_size = true; + config.eid_size = enroll.conf.eid_size; + config.has_max_ttl = true; + config.max_ttl = enroll.conf.max_ttl; config.has_addr_auth_type = true; config.addr_auth_type = enroll.conf.addr_auth_type; config.has_routing_type = true; config.routing_type = enroll.conf.routing_type; config.has_pff_type = true; config.pff_type = enroll.conf.pff_type; - config.dif_info = &dif_info; + config.layer_info = &layer_info; - dif_info.dif_name = (char *) enroll.conf.dif_info.dif_name; - dif_info.dir_hash_algo = enroll.conf.dif_info.dir_hash_algo; + layer_info.layer_name = (char *) enroll.conf.layer_info.layer_name; + layer_info.dir_hash_algo = enroll.conf.layer_info.dir_hash_algo; len = enroll_msg__get_packed_size(&msg); @@ -197,7 +198,7 @@ static void * enroll_handle(void * o) (void) o; while (true) { - if (connmgr_wait(AEID_ENROLL, &conn)) { + if (connmgr_wait(COMPID_ENROLL, &conn)) { log_err("Failed to get next connection."); continue; } @@ -205,20 +206,20 @@ static void * enroll_handle(void * o) len = flow_read(conn.flow_info.fd, buf, ENROLL_BUF_LEN); if (len < 0) { log_err("Failed to read from flow."); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); continue; } msg = enroll_msg__unpack(NULL, len, buf); if (msg == NULL) { log_err("Failed to unpack message."); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); continue; } if (msg->code != ENROLL_CODE__ENROLL_REQ) { log_err("Wrong message type."); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); enroll_msg__free_unpacked(msg, NULL); continue; } @@ -230,7 +231,7 @@ static void * enroll_handle(void * o) len = enroll_pack(&reply); if (reply == NULL) { log_err("Failed to pack enrollment message."); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); continue; } @@ -238,7 +239,7 @@ static void * enroll_handle(void * o) if (flow_write(conn.flow_info.fd, reply, len)) { log_err("Failed respond to enrollment request."); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); free(reply); continue; } @@ -248,21 +249,21 @@ static void * enroll_handle(void * o) len = flow_read(conn.flow_info.fd, buf, ENROLL_BUF_LEN); if (len < 0) { log_err("Failed to read from flow."); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); continue; } msg = enroll_msg__unpack(NULL, len, buf); if (msg == NULL) { log_err("Failed to unpack message."); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); continue; } if (msg->code != ENROLL_CODE__ENROLL_DONE || !msg->has_result) { log_err("Wrong message type."); enroll_msg__free_unpacked(msg, NULL); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); continue; } @@ -273,7 +274,7 @@ static void * enroll_handle(void * o) enroll_msg__free_unpacked(msg, NULL); - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); } return 0; @@ -336,13 +337,13 @@ int enroll_init(void) memset(&info, 0, sizeof(info)); - strcpy(info.ae_name, ENROLL_AE); + strcpy(info.comp_name, ENROLL_COMP); strcpy(info.protocol, ENROLL_PROTO); info.pref_version = 1; info.pref_syntax = PROTO_GPB; info.addr = 0; - if (connmgr_ae_init(AEID_ENROLL, &info)) { + if (connmgr_comp_init(COMPID_ENROLL, &info)) { log_err("Failed to register with connmgr."); return -1; } @@ -357,7 +358,7 @@ void enroll_fini(void) if (enroll.state == ENROLL_RUNNING) pthread_join(enroll.listener, NULL); - connmgr_ae_fini(AEID_ENROLL); + connmgr_comp_fini(COMPID_ENROLL); } int enroll_start(void) diff --git a/src/ipcpd/normal/enroll.h b/src/ipcpd/normal/enroll.h index d5bfa71f..615b7025 100644 --- a/src/ipcpd/normal/enroll.h +++ b/src/ipcpd/normal/enroll.h @@ -25,7 +25,7 @@ #include -#include "ae.h" +#include "comp.h" int enroll_init(void); diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c index 2b3f5c2a..e7e5a786 100644 --- a/src/ipcpd/normal/fa.c +++ b/src/ipcpd/normal/fa.c @@ -88,7 +88,7 @@ static void destroy_conn(int fd) fa.r_addr[fd] = INVALID_ADDR; } -static void fa_post_sdu(void * ae, +static void fa_post_sdu(void * comp, struct shm_du_buff * sdb) { struct timespec ts = {0, TIMEOUT * 1000}; @@ -97,9 +97,9 @@ static void fa_post_sdu(void * ae, uint8_t * buf; struct fa_msg * msg; - (void) ae; + (void) comp; - assert(ae == &fa); + assert(comp == &fa); assert(sdb); buf = malloc(sizeof(*msg) + ipcp_dir_hash_len()); @@ -195,7 +195,7 @@ int fa_init(void) if (pthread_rwlock_init(&fa.flows_lock, NULL)) return -1; - fa.fd = dt_reg_ae(&fa, &fa_post_sdu); + fa.fd = dt_reg_comp(&fa, &fa_post_sdu); return 0; } diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 47192aa2..ba3fe33f 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -53,13 +53,13 @@ static int initialize_components(const struct ipcp_config * conf) { - ipcpi.dif_name = strdup(conf->dif_info.dif_name); - if (ipcpi.dif_name == NULL) { + ipcpi.layer_name = strdup(conf->layer_info.layer_name); + if (ipcpi.layer_name == NULL) { log_err("Failed to set layer name."); - goto fail_dif_name; + goto fail_layer_name; } - ipcpi.dir_hash_algo = conf->dif_info.dir_hash_algo; + ipcpi.dir_hash_algo = conf->layer_info.dir_hash_algo; assert(ipcp_dir_hash_len() != 0); @@ -80,8 +80,8 @@ static int initialize_components(const struct ipcp_config * conf) if (dt_init(conf->routing_type, conf->pff_type, conf->addr_size, - conf->fd_size, - conf->has_ttl)) { + conf->eid_size, + conf->max_ttl)) { log_err("Failed to initialize data transfer component."); goto fail_dt; } @@ -107,8 +107,8 @@ static int initialize_components(const struct ipcp_config * conf) fail_dt: addr_auth_fini(); fail_addr_auth: - free(ipcpi.dif_name); - fail_dif_name: + free(ipcpi.layer_name); + fail_layer_name: return -1; } @@ -122,7 +122,7 @@ static void finalize_components(void) addr_auth_fini(); - free(ipcpi.dif_name); + free(ipcpi.layer_name); } static int start_components(void) @@ -182,12 +182,12 @@ static int bootstrap_components(void) return 0; } -static int normal_ipcp_enroll(const char * dst, - struct dif_info * info) +static int normal_ipcp_enroll(const char * dst, + struct layer_info * info) { struct conn conn; - if (connmgr_alloc(AEID_ENROLL, dst, NULL, &conn)) { + if (connmgr_alloc(COMPID_ENROLL, dst, NULL, &conn)) { log_err("Failed to get connection."); goto fail_er_flow; } @@ -216,13 +216,13 @@ static int normal_ipcp_enroll(const char * dst, if (enroll_done(&conn, 0)) log_warn("Failed to confirm enrollment with peer."); - if (connmgr_dealloc(AEID_ENROLL, &conn)) + if (connmgr_dealloc(COMPID_ENROLL, &conn)) log_warn("Failed to deallocate enrollment flow."); log_info("Enrolled with %s.", dst); info->dir_hash_algo = ipcpi.dir_hash_algo; - strcpy(info->dif_name, ipcpi.dif_name); + strcpy(info->layer_name, ipcpi.layer_name); return 0; @@ -231,7 +231,7 @@ static int normal_ipcp_enroll(const char * dst, fail_dt_start: finalize_components(); fail_enroll_boot: - connmgr_dealloc(AEID_ENROLL, &conn); + connmgr_dealloc(COMPID_ENROLL, &conn); fail_er_flow: return -1; } @@ -263,7 +263,7 @@ static int normal_ipcp_bootstrap(const struct ipcp_config * conf) goto fail_bootstrap; } - log_dbg("Bootstrapped in layer %s.", conf->dif_info.dif_name); + log_dbg("Bootstrapped in layer %s.", conf->layer_info.layer_name); return 0; diff --git a/src/ipcpd/normal/pol/link_state.c b/src/ipcpd/normal/pol/link_state.c index a8a69259..520e2952 100644 --- a/src/ipcpd/normal/pol/link_state.c +++ b/src/ipcpd/normal/pol/link_state.c @@ -36,7 +36,7 @@ #include #include -#include "ae.h" +#include "comp.h" #include "connmgr.h" #include "graph.h" #include "ipcp.h" @@ -543,7 +543,7 @@ static void * ls_conn_handle(void * o) (void) o; while (true) { - if (connmgr_wait(AEID_MGMT, &conn)) { + if (connmgr_wait(COMPID_MGMT, &conn)) { log_err("Failed to get next MGMT connection."); continue; } @@ -751,7 +751,7 @@ int link_state_init(enum pol_routing pr) memset(&info, 0, sizeof(info)); - strcpy(info.ae_name, LS_AE); + strcpy(info.comp_name, LS_COMP); strcpy(info.protocol, LS_PROTO); info.pref_version = 1; info.pref_syntax = PROTO_GPB; @@ -781,8 +781,8 @@ int link_state_init(enum pol_routing pr) if (pthread_mutex_init(&ls.routing_i_lock, NULL)) goto fail_routing_i_lock_init; - if (connmgr_ae_init(AEID_MGMT, &info)) - goto fail_connmgr_ae_init; + if (connmgr_comp_init(COMPID_MGMT, &info)) + goto fail_connmgr_comp_init; ls.mgmt_set = fset_create(); if (ls.mgmt_set == NULL) @@ -817,8 +817,8 @@ int link_state_init(enum pol_routing pr) fail_pthread_create_lsupdate: fset_destroy(ls.mgmt_set); fail_fset_create: - connmgr_ae_fini(AEID_MGMT); - fail_connmgr_ae_init: + connmgr_comp_fini(COMPID_MGMT); + fail_connmgr_comp_init: pthread_mutex_destroy(&ls.routing_i_lock); fail_routing_i_lock_init: pthread_rwlock_destroy(&ls.db_lock); @@ -848,7 +848,7 @@ void link_state_fini(void) fset_destroy(ls.mgmt_set); - connmgr_ae_fini(AEID_MGMT); + connmgr_comp_fini(COMPID_MGMT); graph_destroy(ls.graph); diff --git a/src/ipcpd/normal/pol/link_state.h b/src/ipcpd/normal/pol/link_state.h index 70bebd26..b24716c2 100644 --- a/src/ipcpd/normal/pol/link_state.h +++ b/src/ipcpd/normal/pol/link_state.h @@ -23,7 +23,7 @@ #ifndef OUROBOROS_IPCPD_NORMAL_POL_LINK_STATE_H #define OUROBOROS_IPCPD_NORMAL_POL_LINK_STATE_H -#define LS_AE "Management" +#define LS_COMP "Management" #define LS_PROTO "LSP" #include "pol-routing-ops.h" diff --git a/src/ipcpd/normal/tests/dht_test.c b/src/ipcpd/normal/tests/dht_test.c index 81a6eb62..cd0a4445 100644 --- a/src/ipcpd/normal/tests/dht_test.c +++ b/src/ipcpd/normal/tests/dht_test.c @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * Unit tests of the DHT AE + * Unit tests of the DHT * * Dimitri Staessens * Sander Vrijders diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c index 1b28c325..87cbaca5 100644 --- a/src/irmd/ipcp.c +++ b/src/irmd/ipcp.c @@ -205,7 +205,7 @@ int ipcp_destroy(pid_t pid) int ipcp_bootstrap(pid_t pid, ipcp_config_msg_t * conf, - struct dif_info * info) + struct layer_info * info) { ipcp_msg_t msg = IPCP_MSG__INIT; ipcp_msg_t * recv_msg = NULL; @@ -232,13 +232,13 @@ int ipcp_bootstrap(pid_t pid, return ret; } - if (recv_msg->dif_info == NULL) { + if (recv_msg->layer_info == NULL) { ipcp_msg__free_unpacked(recv_msg, NULL); return -EIPCP; } - info->dir_hash_algo = recv_msg->dif_info->dir_hash_algo; - strcpy(info->dif_name, recv_msg->dif_info->dif_name); + info->dir_hash_algo = recv_msg->layer_info->dir_hash_algo; + strcpy(info->layer_name, recv_msg->layer_info->layer_name); ret = recv_msg->result; ipcp_msg__free_unpacked(recv_msg, NULL); @@ -246,9 +246,9 @@ int ipcp_bootstrap(pid_t pid, return ret; } -int ipcp_enroll(pid_t pid, - const char * dst, - struct dif_info * info) +int ipcp_enroll(pid_t pid, + const char * dst, + struct layer_info * info) { ipcp_msg_t msg = IPCP_MSG__INIT; ipcp_msg_t * recv_msg = NULL; @@ -275,13 +275,13 @@ int ipcp_enroll(pid_t pid, return ret; } - if (recv_msg->dif_info == NULL) { + if (recv_msg->layer_info == NULL) { ipcp_msg__free_unpacked(recv_msg, NULL); return -EIPCP; } - info->dir_hash_algo = recv_msg->dif_info->dir_hash_algo; - strcpy(info->dif_name, recv_msg->dif_info->dif_name); + info->dir_hash_algo = recv_msg->layer_info->dir_hash_algo; + strcpy(info->layer_name, recv_msg->layer_info->layer_name); ipcp_msg__free_unpacked(recv_msg, NULL); diff --git a/src/irmd/ipcp.h b/src/irmd/ipcp.h index 5a1c2fe4..8ff062b2 100644 --- a/src/irmd/ipcp.h +++ b/src/irmd/ipcp.h @@ -34,13 +34,13 @@ pid_t ipcp_create(const char * name, int ipcp_destroy(pid_t pid); -int ipcp_enroll(pid_t pid, - const char * dst, - struct dif_info * info); +int ipcp_enroll(pid_t pid, + const char * dst, + struct layer_info * info); int ipcp_bootstrap(pid_t pid, ipcp_config_msg_t * conf, - struct dif_info * info); + struct layer_info * info); int ipcp_connect(pid_t pid, const char * dst, diff --git a/src/irmd/main.c b/src/irmd/main.c index e9446ade..658811e2 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -82,7 +82,7 @@ struct ipcp_entry { pid_t pid; enum ipcp_type type; enum hash_algo dir_hash_algo; - char * dif_name; + char * layer_name; enum init_state init_state; pthread_cond_t init_cond; @@ -202,8 +202,8 @@ static struct ipcp_entry * ipcp_entry_create(void) if (e == NULL) return NULL; - e->name = NULL; - e->dif_name = NULL; + e->name = NULL; + e->layer_name = NULL; list_head_init(&e->next); @@ -224,8 +224,8 @@ static void ipcp_entry_destroy(struct ipcp_entry * e) if (e->name != NULL) free(e->name); - if (e->dif_name != NULL) - free(e->dif_name); + if (e->layer_name != NULL) + free(e->layer_name); free(e); } @@ -268,7 +268,7 @@ static struct ipcp_entry * get_ipcp_by_dst_name(const char * name, list_for_each_safe(p, h, &irmd.ipcps) { struct ipcp_entry * e = list_entry(p, struct ipcp_entry, next); - if (e->dif_name == NULL || e->pid == src) + if (e->layer_name == NULL || e->pid == src) continue; hash = malloc(IPCP_HASH_LEN(e)); @@ -361,7 +361,7 @@ static pid_t create_ipcp(char * name, pthread_mutex_init(&tmp->init_lock, NULL); tmp->pid = ppid->pid; - tmp->dif_name = NULL; + tmp->layer_name = NULL; tmp->type = ipcp_type; tmp->init_state = IPCP_BOOT; tmp->dir_hash_algo = -1; @@ -477,7 +477,7 @@ static int bootstrap_ipcp(pid_t pid, ipcp_config_msg_t * conf) { struct ipcp_entry * entry = NULL; - struct dif_info info; + struct layer_info info; pthread_rwlock_wrlock(&irmd.reg_lock); @@ -500,8 +500,8 @@ static int bootstrap_ipcp(pid_t pid, return -1; } - entry->dif_name = strdup(info.dif_name); - if (entry->dif_name == NULL) { + entry->layer_name = strdup(info.layer_name); + if (entry->layer_name == NULL) { pthread_rwlock_unlock(&irmd.reg_lock); log_warn("Failed to set name of layer."); return -ENOMEM; @@ -512,7 +512,7 @@ static int bootstrap_ipcp(pid_t pid, pthread_rwlock_unlock(&irmd.reg_lock); log_info("Bootstrapped IPCP %d in layer %s.", - pid, conf->dif_info->dif_name); + pid, conf->layer_info->layer_name); return 0; } @@ -521,7 +521,7 @@ static int enroll_ipcp(pid_t pid, char * dst_name) { struct ipcp_entry * entry = NULL; - struct dif_info info; + struct layer_info info; pthread_rwlock_wrlock(&irmd.reg_lock); @@ -532,7 +532,7 @@ static int enroll_ipcp(pid_t pid, return -1; } - if (entry->dif_name != NULL) { + if (entry->layer_name != NULL) { pthread_rwlock_unlock(&irmd.reg_lock); log_err("IPCP in wrong state"); return -1; @@ -554,10 +554,10 @@ static int enroll_ipcp(pid_t pid, return -1; } - entry->dif_name = strdup(info.dif_name); - if (entry->dif_name == NULL) { + entry->layer_name = strdup(info.layer_name); + if (entry->layer_name == NULL) { pthread_rwlock_unlock(&irmd.reg_lock); - log_err("Failed to strdup dif_name."); + log_err("Failed to strdup layer_name."); return -ENOMEM; } @@ -566,7 +566,7 @@ static int enroll_ipcp(pid_t pid, pthread_rwlock_unlock(&irmd.reg_lock); log_info("Enrolled IPCP %d in layer %s.", - pid, info.dif_name); + pid, info.layer_name); return 0; } @@ -873,7 +873,7 @@ static ssize_t list_ipcps(char * name, } static int name_reg(const char * name, - char ** difs, + char ** layers, size_t len) { size_t i; @@ -882,8 +882,8 @@ static int name_reg(const char * name, assert(name); assert(len); - assert(difs); - assert(difs[0]); + assert(layers); + assert(layers[0]); pthread_rwlock_wrlock(&irmd.reg_lock); @@ -929,7 +929,7 @@ static int name_reg(const char * name, list_for_each(p, &irmd.ipcps) { struct ipcp_entry * e = list_entry(p, struct ipcp_entry, next); - if (e->dif_name == NULL) + if (e->layer_name == NULL) continue; for (i = 0; i < len; ++i) { @@ -937,7 +937,7 @@ static int name_reg(const char * name, pid_t pid; size_t len; - if (wildcard_match(difs[i], e->dif_name)) + if (wildcard_match(layers[i], e->layer_name)) continue; hash = malloc(IPCP_HASH_LEN(e)); @@ -962,15 +962,15 @@ static int name_reg(const char * name, pthread_rwlock_wrlock(&irmd.reg_lock); - if (registry_add_name_to_dif(&irmd.registry, - name, - e->dif_name, - e->type) < 0) + if (registry_add_name_to_layer(&irmd.registry, + name, + e->layer_name, + e->type) < 0) log_warn("Registered unbound name %s. " "Registry may be corrupt.", name); log_info("Registered %s in %s as " HASH_FMT ".", - name, e->dif_name, HASH_VAL(hash)); + name, e->layer_name, HASH_VAL(hash)); ++ret; free(hash); @@ -983,7 +983,7 @@ static int name_reg(const char * name, } static int name_unreg(const char * name, - char ** difs, + char ** layers, size_t len) { size_t i; @@ -992,8 +992,8 @@ static int name_unreg(const char * name, assert(name); assert(len); - assert(difs); - assert(difs[0]); + assert(layers); + assert(layers[0]); pthread_rwlock_wrlock(&irmd.reg_lock); @@ -1001,7 +1001,7 @@ static int name_unreg(const char * name, struct ipcp_entry * e = list_entry(pos, struct ipcp_entry, next); - if (e->dif_name == NULL) + if (e->layer_name == NULL) continue; for (i = 0; i < len; ++i) { @@ -1009,7 +1009,7 @@ static int name_unreg(const char * name, pid_t pid; size_t len; - if (wildcard_match(difs[i], e->dif_name)) + if (wildcard_match(layers[i], e->layer_name)) continue; hash = malloc(IPCP_HASH_LEN(e)); @@ -1033,11 +1033,11 @@ static int name_unreg(const char * name, pthread_rwlock_wrlock(&irmd.reg_lock); - registry_del_name_from_dif(&irmd.registry, - name, - e->dif_name); + registry_del_name_from_layer(&irmd.registry, + name, + e->layer_name); log_info("Unregistered %s from %s.", - name, e->dif_name); + name, e->layer_name); ++ret; free(hash); @@ -1952,7 +1952,7 @@ static void * mainloop(void * o) case IRM_MSG_CODE__IRM_ENROLL_IPCP: ret_msg.has_result = true; ret_msg.result = enroll_ipcp(msg->pid, - msg->dif_name[0]); + msg->layer_name[0]); break; case IRM_MSG_CODE__IRM_CONNECT_IPCP: ret_msg.has_result = true; @@ -2001,14 +2001,14 @@ static void * mainloop(void * o) case IRM_MSG_CODE__IRM_REG: ret_msg.has_result = true; ret_msg.result = name_reg(msg->dst_name, - msg->dif_name, - msg->n_dif_name); + msg->layer_name, + msg->n_layer_name); break; case IRM_MSG_CODE__IRM_UNREG: ret_msg.has_result = true; ret_msg.result = name_unreg(msg->dst_name, - msg->dif_name, - msg->n_dif_name); + msg->layer_name, + msg->n_layer_name); break; case IRM_MSG_CODE__IRM_FLOW_ACCEPT: ret_msg.has_result = true; diff --git a/src/irmd/registry.c b/src/irmd/registry.c index 32975b03..ace9f225 100644 --- a/src/irmd/registry.c +++ b/src/irmd/registry.c @@ -42,9 +42,9 @@ #include #include -struct reg_dif { +struct reg_layer { struct list_head next; - char * dif_name; + char * layer_name; enum ipcp_type type; }; @@ -69,7 +69,7 @@ static int reg_entry_init(struct reg_entry * e, return -1; list_head_init(&e->next); - list_head_init(&e->difs); + list_head_init(&e->layers); list_head_init(&e->reg_progs); list_head_init(&e->reg_pids); @@ -121,10 +121,10 @@ static void cancel_reg_entry_destroy(void * o) free(a); } - list_for_each_safe(p, h, &e->difs) { - struct reg_dif * d = list_entry(p, struct reg_dif, next); + list_for_each_safe(p, h, &e->layers) { + struct reg_layer * d = list_entry(p, struct reg_layer, next); list_del(&d->next); - free(d->dif_name); + free(d->layer_name); free(d); } @@ -158,57 +158,57 @@ static void reg_entry_destroy(struct reg_entry * e) pthread_cleanup_pop(true); } -static bool reg_entry_is_local_in_dif(struct reg_entry * e, - const char * dif_name) +static bool reg_entry_is_local_in_layer(struct reg_entry * e, + const char * layer_name) { struct list_head * p = NULL; - list_for_each(p, &e->difs) { - struct reg_dif * d = list_entry(p, struct reg_dif, next); - if (!strcmp(dif_name, d->dif_name)) + list_for_each(p, &e->layers) { + struct reg_layer * d = list_entry(p, struct reg_layer, next); + if (!strcmp(layer_name, d->layer_name)) return true; } return false; } -static int reg_entry_add_local_in_dif(struct reg_entry * e, - const char * dif_name, - enum ipcp_type type) +static int reg_entry_add_local_in_layer(struct reg_entry * e, + const char * layer_name, + enum ipcp_type type) { - struct reg_dif * rdn; + struct reg_layer * rdn; /* already registered. Is ok */ - if (reg_entry_is_local_in_dif(e, dif_name)) + if (reg_entry_is_local_in_layer(e, layer_name)) return 0; rdn = malloc(sizeof(*rdn)); if (rdn == NULL) return -1; - rdn->dif_name = strdup(dif_name); - if (rdn->dif_name == NULL) { + rdn->layer_name = strdup(layer_name); + if (rdn->layer_name == NULL) { free(rdn); return -1; } rdn->type = type; - list_add(&rdn->next, &e->difs); + list_add(&rdn->next, &e->layers); return 0; } -static void reg_entry_del_local_from_dif(struct reg_entry * e, - const char * dif_name) +static void reg_entry_del_local_from_layer(struct reg_entry * e, + const char * layer_name) { struct list_head * p = NULL; struct list_head * h = NULL; - list_for_each_safe(p, h, &e->difs) { - struct reg_dif * d = list_entry(p, struct reg_dif, next); - if (!strcmp(dif_name, d->dif_name)) { + list_for_each_safe(p, h, &e->layers) { + struct reg_layer * d = list_entry(p, struct reg_layer, next); + if (!strcmp(layer_name, d->layer_name)) { list_del(&d->next); - free(d->dif_name); + free(d->layer_name); free(d); } } @@ -637,27 +637,27 @@ void registry_del_process(struct list_head * registry, return; } -int registry_add_name_to_dif(struct list_head * registry, - const char * name, - const char * dif_name, - enum ipcp_type type) +int registry_add_name_to_layer(struct list_head * registry, + const char * name, + const char * layer_name, + enum ipcp_type type) { struct reg_entry * re = registry_get_entry(registry, name); if (re == NULL) return -1; - return reg_entry_add_local_in_dif(re, dif_name, type); + return reg_entry_add_local_in_layer(re, layer_name, type); } -void registry_del_name_from_dif(struct list_head * registry, - const char * name, - const char * dif_name) +void registry_del_name_from_layer(struct list_head * registry, + const char * name, + const char * layer_name) { struct reg_entry * re = registry_get_entry(registry, name); if (re == NULL) return; - reg_entry_del_local_from_dif(re, dif_name); + reg_entry_del_local_from_layer(re, layer_name); } void registry_destroy(struct list_head * registry) diff --git a/src/irmd/registry.h b/src/irmd/registry.h index e4e0f6c9..08fa9f28 100644 --- a/src/irmd/registry.h +++ b/src/irmd/registry.h @@ -56,7 +56,7 @@ struct reg_entry { char * name; /* layers in which this name is registered */ - struct list_head difs; + struct list_head layers; /* Programs that can be instantiated by the irmd */ struct list_head reg_progs; /* Processes that are listening for this name */ @@ -119,14 +119,14 @@ struct reg_entry * registry_get_entry_by_hash(struct list_head * registry, const uint8_t * hash, size_t len); -int registry_add_name_to_dif(struct list_head * registry, - const char * name, - const char * dif_name, - enum ipcp_type type); - -void registry_del_name_from_dif(struct list_head * registry, +int registry_add_name_to_layer(struct list_head * registry, const char * name, - const char * dif_name); + const char * layer_name, + enum ipcp_type type); + +void registry_del_name_from_layer(struct list_head * registry, + const char * name, + const char * layer_name); void registry_destroy(struct list_head * registry); diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 2ee285f8..8e09c427 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -6,7 +6,7 @@ include_directories(${CMAKE_BINARY_DIR}/include) protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS irmd_messages.proto) protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS ipcpd_messages.proto) -protobuf_generate_c(DIF_CONFIG_PROTO_SRCS DIF_CONFIG_PROTO_HDRS +protobuf_generate_c(LAYER_CONFIG_PROTO_SRCS LAYER_CONFIG_PROTO_HDRS ipcp_config.proto) protobuf_generate_c(CACEP_PROTO_SRCS CACEP_PROTO_HDRS cacep.proto) @@ -217,7 +217,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY) add_library(ouroboros-common SHARED ${SOURCE_FILES_COMMON} ${IRM_PROTO_SRCS} - ${IPCP_PROTO_SRCS} ${DIF_CONFIG_PROTO_SRCS}) + ${IPCP_PROTO_SRCS} ${LAYER_CONFIG_PROTO_SRCS}) add_library(ouroboros-dev SHARED ${SOURCE_FILES_DEV} ${CACEP_PROTO_SRCS}) diff --git a/src/lib/cacep.c b/src/lib/cacep.c index fb1d4845..6efb7295 100644 --- a/src/lib/cacep.c +++ b/src/lib/cacep.c @@ -49,7 +49,7 @@ static int read_msg(int fd, if (msg == NULL) return -1; - strcpy(info->ae_name, msg->ae_name); + strcpy(info->comp_name, msg->comp_name); strcpy(info->protocol, msg->protocol); info->pref_version = msg->pref_version; @@ -68,7 +68,7 @@ static int send_msg(int fd, uint8_t * data = NULL; size_t len = 0; - msg.ae_name = (char *) info->ae_name; + msg.comp_name = (char *) info->comp_name; msg.protocol = (char *) info->protocol; msg.address = info->addr; msg.pref_version = info->pref_version; diff --git a/src/lib/cacep.proto b/src/lib/cacep.proto index 945ccccb..16c7a38a 100644 --- a/src/lib/cacep.proto +++ b/src/lib/cacep.proto @@ -28,7 +28,7 @@ message fixed_conc_syntax_msg { } message cacep_msg { - required string ae_name = 1; + required string comp_name = 1; required string protocol = 2; required int32 pref_version = 3; repeated int32 supp_version = 4; diff --git a/src/lib/ipcp_config.proto b/src/lib/ipcp_config.proto index 078c1491..92656f8d 100644 --- a/src/lib/ipcp_config.proto +++ b/src/lib/ipcp_config.proto @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2018 * - * DIF config message + * Layer configuration message * * Dimitri Staessens * Sander Vrijders @@ -22,24 +22,24 @@ syntax = "proto2"; -message dif_info_msg { - required string dif_name = 1; +message layer_info_msg { + required string layer_name = 1; required uint32 dir_hash_algo = 2; } message ipcp_config_msg { - required dif_info_msg dif_info = 1; - required int32 ipcp_type = 2; + required layer_info_msg layer_info = 1; + required int32 ipcp_type = 2; // Config for normal IPCP - optional uint32 addr_size = 3; - optional uint32 fd_size = 4; - optional bool has_ttl = 5; - optional uint32 addr_auth_type = 6; - optional uint32 routing_type = 7; - optional uint32 pff_type = 8; + optional uint32 addr_size = 3; + optional uint32 eid_size = 4; + optional uint32 max_ttl = 5; + optional uint32 addr_auth_type = 6; + optional uint32 routing_type = 7; + optional uint32 pff_type = 8; // Config for UDP - optional uint32 ip_addr = 9; - optional uint32 dns_addr = 10; + optional uint32 ip_addr = 9; + optional uint32 dns_addr = 10; // Config for the Ethernet LLC - optional string if_name = 11; + optional string if_name = 11; } diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto index af25189e..2d3bad7f 100644 --- a/src/lib/ipcpd_messages.proto +++ b/src/lib/ipcpd_messages.proto @@ -39,16 +39,16 @@ enum ipcp_msg_code { }; message ipcp_msg { - required ipcp_msg_code code = 1; - optional string name = 2; - optional bytes hash = 3; - optional int32 port_id = 4; - optional string dst_name = 5; - optional uint32 qoscube = 6; - optional ipcp_config_msg conf = 7; - optional int32 pid = 8; - optional dif_info_msg dif_info = 9; - optional int32 response = 10; - optional string comp_name = 11; - optional int32 result = 12; + required ipcp_msg_code code = 1; + optional string name = 2; + optional bytes hash = 3; + optional int32 port_id = 4; + optional string dst_name = 5; + optional uint32 qoscube = 6; + optional ipcp_config_msg conf = 7; + optional int32 pid = 8; + optional layer_info_msg layer_info = 9; + optional int32 response = 10; + optional string comp_name = 11; + optional int32 result = 12; }; diff --git a/src/lib/irm.c b/src/lib/irm.c index 8f5a5191..66b5c849 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -94,11 +94,11 @@ int irm_destroy_ipcp(pid_t pid) int irm_bootstrap_ipcp(pid_t pid, const struct ipcp_config * conf) { - irm_msg_t msg = IRM_MSG__INIT; - ipcp_config_msg_t config = IPCP_CONFIG_MSG__INIT; - dif_info_msg_t dif_info = DIF_INFO_MSG__INIT; - irm_msg_t * recv_msg = NULL; - int ret = -1; + irm_msg_t msg = IRM_MSG__INIT; + ipcp_config_msg_t config = IPCP_CONFIG_MSG__INIT; + layer_info_msg_t layer_info = LAYER_INFO_MSG__INIT; + irm_msg_t * recv_msg = NULL; + int ret = -1; if (pid == -1 || conf == NULL) return -EINVAL; @@ -107,10 +107,9 @@ int irm_bootstrap_ipcp(pid_t pid, msg.has_pid = true; msg.pid = pid; - config.dif_info = &dif_info; - msg.conf = &config; - - dif_info.dif_name = (char *) conf->dif_info.dif_name; + config.layer_info = &layer_info; + msg.conf = &config; + layer_info.layer_name = (char *) conf->layer_info.layer_name; config.ipcp_type = conf->type; @@ -118,17 +117,17 @@ int irm_bootstrap_ipcp(pid_t pid, case IPCP_NORMAL: config.has_addr_size = true; config.addr_size = conf->addr_size; - config.has_fd_size = true; - config.fd_size = conf->fd_size; - config.has_has_ttl = true; - config.has_ttl = conf->has_ttl; + config.has_eid_size = true; + config.eid_size = conf->eid_size; + config.has_max_ttl = true; + config.max_ttl = conf->max_ttl; config.has_addr_auth_type = true; config.addr_auth_type = conf->addr_auth_type; config.has_routing_type = true; config.routing_type = conf->routing_type; config.has_pff_type = true; config.pff_type = conf->pff_type; - dif_info.dir_hash_algo = conf->dif_info.dir_hash_algo; + layer_info.dir_hash_algo = conf->layer_info.dir_hash_algo; break; case IPCP_UDP: config.has_ip_addr = true; @@ -258,28 +257,28 @@ ssize_t irm_list_ipcps(const char * name, } int irm_enroll_ipcp(pid_t pid, - const char * dif_name) + const char * layer_name) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; int ret = -1; - if (pid == -1 || dif_name == NULL) + if (pid == -1 || layer_name == NULL) return -EINVAL; - msg.code = IRM_MSG_CODE__IRM_ENROLL_IPCP; - msg.has_pid = true; - msg.pid = pid; - msg.n_dif_name = 1; - msg.dif_name = malloc(sizeof(*(msg.dif_name))); - if (msg.dif_name == NULL) + msg.code = IRM_MSG_CODE__IRM_ENROLL_IPCP; + msg.has_pid = true; + msg.pid = pid; + msg.n_layer_name = 1; + msg.layer_name = malloc(sizeof(*(msg.layer_name))); + if (msg.layer_name == NULL) return -ENOMEM; - msg.dif_name[0] = (char *) dif_name; + msg.layer_name[0] = (char *) layer_name; recv_msg = send_recv_irm_msg(&msg); if (recv_msg == NULL) { - free(msg.dif_name); + free(msg.layer_name); return -EIRMD; } @@ -291,7 +290,7 @@ int irm_enroll_ipcp(pid_t pid, ret = recv_msg->result; irm_msg__free_unpacked(recv_msg, NULL); - free(msg.dif_name); + free(msg.layer_name); return ret; } @@ -519,22 +518,22 @@ int irm_unbind_process(pid_t pid, } int irm_reg(const char * name, - char ** difs, + char ** layers, size_t len) { - irm_msg_t msg = IRM_MSG__INIT; + irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; - int ret = -1; + int ret = -1; - if (name == NULL || difs == NULL || len == 0) + if (name == NULL || layers == NULL || len == 0) return -EINVAL; msg.code = IRM_MSG_CODE__IRM_REG; msg.dst_name = (char *) name; - msg.dif_name = difs; - msg.n_dif_name = len; + msg.layer_name = layers; + msg.n_layer_name = len; recv_msg = send_recv_irm_msg(&msg); if (recv_msg == NULL) @@ -553,22 +552,22 @@ int irm_reg(const char * name, int irm_unreg(const char * name, - char ** difs, + char ** layers, size_t len) { - irm_msg_t msg = IRM_MSG__INIT; + irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; - int ret = -1; + int ret = -1; - if (name == NULL || difs == NULL || len == 0) + if (name == NULL || layers == NULL || len == 0) return -EINVAL; msg.code = IRM_MSG_CODE__IRM_UNREG; msg.dst_name = (char *) name; - msg.dif_name = (char **) difs; - msg.n_dif_name = len; + msg.layer_name = (char **) layers; + msg.n_layer_name = len; recv_msg = send_recv_irm_msg(&msg); if (recv_msg == NULL) diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto index b4b28136..51b15023 100644 --- a/src/lib/irmd_messages.proto +++ b/src/lib/irmd_messages.proto @@ -53,7 +53,7 @@ message irm_msg { optional string prog_name = 2; optional sint32 pid = 3; optional uint32 ipcp_type = 4; - repeated string dif_name = 5; + repeated string layer_name = 5; repeated string args = 6; optional sint32 response = 7; optional string dst_name = 8; diff --git a/src/tools/irm/irm_ipcp_bootstrap.c b/src/tools/irm/irm_ipcp_bootstrap.c index 2acb6516..3cad072a 100644 --- a/src/tools/irm/irm_ipcp_bootstrap.c +++ b/src/tools/irm/irm_ipcp_bootstrap.c @@ -62,8 +62,9 @@ #define SHA3_512 "SHA3_512" #define DEFAULT_ADDR_SIZE 4 -#define DEFAULT_FD_SIZE 2 +#define DEFAULT_EID_SIZE 2 #define DEFAULT_DDNS 0 +#define DEFAULT_TTL 60 #define DEFAULT_ADDR_AUTH ADDR_AUTH_FLAT_RANDOM #define DEFAULT_ROUTING ROUTING_LINK_STATE #define DEFAULT_PFF PFF_SIMPLE @@ -76,7 +77,7 @@ static void usage(void) { - /* FIXME: Add ipcp_config stuff */ + /* FIXME: Add ipcp_config stuff. */ printf("Usage: irm ipcp bootstrap\n" " name \n" " layer \n" @@ -85,8 +86,8 @@ static void usage(void) UDP " " ETH_LLC " " RAPTOR "},\n\n" "if TYPE == " NORMAL "\n" " [addr
(default: %d)]\n" - " [fd (default: %d)]\n" - " [ttl (add time to live value in the PCI)]\n" + " [eid (default: %d)]\n" + " [ttl (max time-to-live value, default: %d)]\n" " [addr_auth (default: %s)]\n" " [routing (default: %s)]\n" " [pff [PFF_POLICY] (default: %s)]\n" @@ -115,9 +116,9 @@ static void usage(void) " [hash [ALGORITHM] (default: %s)]\n" "where ALGORITHM = {" SHA3_224 " " SHA3_256 " " SHA3_384 " " SHA3_512 "}\n\n", - DEFAULT_ADDR_SIZE, DEFAULT_FD_SIZE, FLAT_RANDOM_ADDR_AUTH, - LINK_STATE_ROUTING, SIMPLE_PFF, SHA3_256, SHA3_256, SHA3_256, - SHA3_256); + DEFAULT_ADDR_SIZE, DEFAULT_EID_SIZE, DEFAULT_TTL, + FLAT_RANDOM_ADDR_AUTH, LINK_STATE_ROUTING, SIMPLE_PFF, + SHA3_256, SHA3_256, SHA3_256, SHA3_256); } int do_bootstrap_ipcp(int argc, @@ -127,8 +128,8 @@ int do_bootstrap_ipcp(int argc, pid_t pid; struct ipcp_config conf; uint8_t addr_size = DEFAULT_ADDR_SIZE; - uint8_t fd_size = DEFAULT_FD_SIZE; - bool has_ttl = false; + uint8_t eid_size = DEFAULT_EID_SIZE; + uint8_t max_ttl = DEFAULT_TTL; enum pol_addr_auth addr_auth_type = DEFAULT_ADDR_AUTH; enum pol_routing routing_type = DEFAULT_ROUTING; enum pol_pff pff_type = DEFAULT_PFF; @@ -136,7 +137,7 @@ int do_bootstrap_ipcp(int argc, uint32_t ip_addr = 0; uint32_t dns_addr = DEFAULT_DDNS; char * ipcp_type = NULL; - char * dif_name = NULL; + char * layer_name = NULL; char * if_name = NULL; pid_t * pids = NULL; ssize_t len = 0; @@ -149,7 +150,7 @@ int do_bootstrap_ipcp(int argc, if (matches(*argv, "type") == 0) { ipcp_type = *(argv + 1); } else if (matches(*argv, "layer") == 0) { - dif_name = *(argv + 1); + layer_name = *(argv + 1); } else if (matches(*argv, "name") == 0) { name = *(argv + 1); } else if (matches(*argv, "hash") == 0) { @@ -173,11 +174,10 @@ int do_bootstrap_ipcp(int argc, if_name = *(argv + 1); } else if (matches(*argv, "addr") == 0) { addr_size = atoi(*(argv + 1)); - } else if (matches(*argv, "fd") == 0) { - fd_size = atoi(*(argv + 1)); + } else if (matches(*argv, "eid") == 0) { + eid_size = atoi(*(argv + 1)); } else if (matches(*argv, "ttl") == 0) { - has_ttl = true; - cargs = 1; + max_ttl = atoi(*(argv + 1)); } else if (matches(*argv, "autobind") == 0) { autobind = true; cargs = 1; @@ -210,23 +210,23 @@ int do_bootstrap_ipcp(int argc, argv += cargs; } - if (name == NULL || dif_name == NULL || ipcp_type == NULL) { + if (name == NULL || layer_name == NULL || ipcp_type == NULL) { usage(); return -1; } - strcpy(conf.dif_info.dif_name, dif_name); + strcpy(conf.layer_info.layer_name, layer_name); if (strcmp(ipcp_type, UDP) != 0) - conf.dif_info.dir_hash_algo = hash_algo; + conf.layer_info.dir_hash_algo = hash_algo; if (strcmp(ipcp_type, NORMAL) == 0) { - conf.type = IPCP_NORMAL; - conf.addr_size = addr_size; - conf.fd_size = fd_size; - conf.has_ttl = has_ttl; + conf.type = IPCP_NORMAL; + 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.pff_type = pff_type; + conf.routing_type = routing_type; + conf.pff_type = pff_type; } else if (strcmp(ipcp_type, UDP) == 0) { conf.type = IPCP_UDP; if (ip_addr == 0) { @@ -271,8 +271,9 @@ int do_bootstrap_ipcp(int argc, return -1; } - if (autobind && irm_bind_process(pids[i], dif_name)) { - printf("Failed to bind %d to %s.\n", pids[i], dif_name); + if (autobind && irm_bind_process(pids[i], layer_name)) { + printf("Failed to bind %d to %s.\n", + pids[i], layer_name); irm_unbind_process(pids[i], name); free(pids); return -1; @@ -281,7 +282,7 @@ int do_bootstrap_ipcp(int argc, if (irm_bootstrap_ipcp(pids[i], &conf)) { if (autobind) { irm_unbind_process(pids[i], name); - irm_unbind_process(pids[i], dif_name); + irm_unbind_process(pids[i], layer_name); } free(pids); return -1; diff --git a/src/tools/irm/irm_ipcp_connect.c b/src/tools/irm/irm_ipcp_connect.c index d58adb56..b9cad57d 100644 --- a/src/tools/irm/irm_ipcp_connect.c +++ b/src/tools/irm/irm_ipcp_connect.c @@ -93,10 +93,10 @@ int do_connect_ipcp(int argc, return -1; if (!strcmp(comp_name, DT)) - comp_name = DT_AE; + comp_name = DT_COMP; if (!strcmp(comp_name , MGMT)) - comp_name = MGMT_AE; + comp_name = MGMT_COMP; if (irm_connect_ipcp(pids[0], dst_name, comp_name)) { free(pids); diff --git a/src/tools/irm/irm_ipcp_disconnect.c b/src/tools/irm/irm_ipcp_disconnect.c index 64ca1ea8..8b5eb596 100644 --- a/src/tools/irm/irm_ipcp_disconnect.c +++ b/src/tools/irm/irm_ipcp_disconnect.c @@ -93,10 +93,10 @@ int do_disconnect_ipcp(int argc, return -1; if (!strcmp(comp_name, DT)) - comp_name = DT_AE; + comp_name = DT_COMP; if (!strcmp(comp_name , MGMT)) - comp_name = MGMT_AE; + comp_name = MGMT_COMP; if (irm_disconnect_ipcp(pids[0], dst_name, comp_name)) { free(pids); diff --git a/src/tools/irm/irm_ipcp_enroll.c b/src/tools/irm/irm_ipcp_enroll.c index e827dcf0..8b897096 100644 --- a/src/tools/irm/irm_ipcp_enroll.c +++ b/src/tools/irm/irm_ipcp_enroll.c @@ -54,13 +54,13 @@ static void usage(void) int do_enroll_ipcp(int argc, char ** argv) { - char * name = NULL; - char * dif_name = NULL; - pid_t * pids = NULL; + char * name = NULL; + char * layer_name = NULL; + pid_t * pids = NULL; pid_t pid; - ssize_t len = 0; - int i = 0; - bool autobind = false; + ssize_t len = 0; + int i = 0; + bool autobind = false; int cargs; while (argc > 0) { @@ -68,7 +68,7 @@ int do_enroll_ipcp(int argc, char ** argv) if (matches(*argv, "name") == 0) { name = *(argv + 1); } else if (matches(*argv, "layer") == 0) { - dif_name = *(argv + 1); + layer_name = *(argv + 1); } else if (matches(*argv, "autobind") == 0) { autobind = true; cargs = 1; @@ -82,7 +82,7 @@ int do_enroll_ipcp(int argc, char ** argv) argv += cargs; } - if (dif_name == NULL || name == NULL) { + if (layer_name == NULL || name == NULL) { usage(); return -1; } @@ -101,15 +101,16 @@ int do_enroll_ipcp(int argc, char ** argv) return -1; } - if (irm_enroll_ipcp(pids[i], dif_name)) { + if (irm_enroll_ipcp(pids[i], layer_name)) { if (autobind) irm_unbind_process(pids[i], name); free(pids); return -1; } - if (autobind && irm_bind_process(pids[i], dif_name)) { - printf("Failed to bind %d to %s.\n", pids[i], dif_name); + if (autobind && irm_bind_process(pids[i], layer_name)) { + printf("Failed to bind %d to %s.\n", + pids[i], layer_name); free(pids); return -1; } diff --git a/src/tools/irm/irm_register.c b/src/tools/irm/irm_register.c index f75220be..574c2224 100644 --- a/src/tools/irm/irm_register.c +++ b/src/tools/irm/irm_register.c @@ -59,15 +59,15 @@ static void usage(void) int do_register(int argc, char ** argv) { char * name = NULL; - char * difs[MAX_LAYERS]; - size_t difs_len = 0; + char * layers[MAX_LAYERS]; + size_t layers_len = 0; while (argc > 0) { if (matches(*argv, "name") == 0) { name = *(argv + 1); } else if (matches(*argv, "layer") == 0) { - difs[difs_len++] = *(argv + 1); - if (difs_len > MAX_LAYERS) { + layers[layers_len++] = *(argv + 1); + if (layers_len > MAX_LAYERS) { printf("Too many layers specified\n"); return -1; } @@ -81,10 +81,10 @@ int do_register(int argc, char ** argv) argv += 2; } - if (difs_len < 1 || name == NULL) { + if (layers_len < 1 || name == NULL) { usage(); return -1; } - return irm_reg(name, difs, difs_len); + return irm_reg(name, layers, layers_len); } diff --git a/src/tools/irm/irm_unregister.c b/src/tools/irm/irm_unregister.c index b6b3e242..3b161169 100644 --- a/src/tools/irm/irm_unregister.c +++ b/src/tools/irm/irm_unregister.c @@ -58,17 +58,17 @@ static void usage(void) int do_unregister(int argc, char ** argv) { - char * difs[MAX_LAYERS]; - size_t difs_len = 0; + char * layers[MAX_LAYERS]; + size_t layers_len = 0; char * name = NULL; while (argc > 0) { if (matches(*argv, "name") == 0) { name = *(argv + 1); } else if (matches(*argv, "layer") == 0) { - difs[difs_len++] = *(argv + 1); - if (difs_len > MAX_LAYERS) { - printf("Too many difs specified\n"); + layers[layers_len++] = *(argv + 1); + if (layers_len > MAX_LAYERS) { + printf("Too many layers specified\n"); return -1; } } else { @@ -81,10 +81,10 @@ int do_unregister(int argc, char ** argv) argv += 2; } - if (difs_len == 0 || name == NULL) { + if (layers_len == 0 || name == NULL) { usage(); return -1; } - return irm_unreg(name, difs, difs_len); + return irm_unreg(name, layers, layers_len); } -- cgit v1.2.3