summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r--src/ipcpd/normal/comp.h (renamed from src/ipcpd/normal/ae.h)18
-rw-r--r--src/ipcpd/normal/connmgr.c154
-rw-r--r--src/ipcpd/normal/connmgr.h14
-rw-r--r--src/ipcpd/normal/dht.c2
-rw-r--r--src/ipcpd/normal/dir.c2
-rw-r--r--src/ipcpd/normal/dir.h2
-rw-r--r--src/ipcpd/normal/dt.c59
-rw-r--r--src/ipcpd/normal/dt.h12
-rw-r--r--src/ipcpd/normal/dt_pci.c59
-rw-r--r--src/ipcpd/normal/dt_pci.h22
-rw-r--r--src/ipcpd/normal/enroll.c59
-rw-r--r--src/ipcpd/normal/enroll.h2
-rw-r--r--src/ipcpd/normal/fa.c8
-rw-r--r--src/ipcpd/normal/main.c32
-rw-r--r--src/ipcpd/normal/pol/link_state.c16
-rw-r--r--src/ipcpd/normal/pol/link_state.h2
-rw-r--r--src/ipcpd/normal/tests/dht_test.c2
17 files changed, 228 insertions, 237 deletions
diff --git a/src/ipcpd/normal/ae.h b/src/ipcpd/normal/comp.h
index 527748d1..bdfba353 100644
--- a/src/ipcpd/normal/ae.h
+++ b/src/ipcpd/normal/comp.h
@@ -1,7 +1,7 @@
/*
* Ouroboros - Copyright (C) 2016 - 2018
*
- * Application Entities for the normal IPC process
+ * Components for the normal IPC process
*
* Dimitri Staessens <[email protected]>
* Sander Vrijders <[email protected]>
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef OUROBOROS_IPCPD_NORMAL_AE_H
-#define OUROBOROS_IPCPD_NORMAL_AE_H
+#ifndef OUROBOROS_IPCPD_NORMAL_COMP_H
+#define OUROBOROS_IPCPD_NORMAL_COMP_H
#include <ouroboros/cacep.h>
@@ -29,11 +29,11 @@
#define DST_MAX_STRLEN 64
-enum ae_id {
- AEID_DT = 0,
- AEID_ENROLL,
- AEID_MGMT,
- AEID_MAX
+enum comp_id {
+ COMPID_DT = 0,
+ COMPID_ENROLL,
+ COMPID_MGMT,
+ COMPID_MAX
};
struct conn {
@@ -45,4 +45,4 @@ struct conn {
} flow_info;
};
-#endif /* OUROBOROS_IPCPD_NORMAL_AE_H */
+#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 <[email protected]>
* Sander Vrijders <[email protected]>
@@ -31,7 +31,7 @@
#include <ouroboros/logs.h>
#include <ouroboros/notifier.h>
-#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 <ouroboros/cacep.h>
#include <ouroboros/qos.h>
-#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 <[email protected]>
* Sander Vrijders <[email protected]>
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 <[email protected]>
* Sander Vrijders <[email protected]>
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 <[email protected]>
* Sander Vrijders <[email protected]>
@@ -24,7 +24,7 @@
#include "config.h"
-#define OUROBOROS_PREFIX "dt-ae"
+#define OUROBOROS_PREFIX "dt"
#include <ouroboros/bitmap.h>
#include <ouroboros/errno.h>
@@ -39,7 +39,7 @@
#include "pff.h"
#include "routing.h"
#include "sdu_sched.h"
-#include "ae.h"
+#include "comp.h"
#include "fa.h"
#include <stdlib.h>
@@ -49,9 +49,9 @@
#include <inttypes.h>
#include <assert.h>
-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 <[email protected]>
* Sander Vrijders <[email protected]>
@@ -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 <[email protected]>
* Sander Vrijders <[email protected]>
@@ -28,36 +28,32 @@
#include <string.h>
#include <assert.h>
-#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 <[email protected]>
* Sander Vrijders <[email protected]>
@@ -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 <ouroboros/ipcp.h>
-#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 <ouroboros/rib.h>
#include <ouroboros/utils.h>
-#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 <[email protected]>
* Sander Vrijders <[email protected]>