summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ipcpd/normal/CMakeLists.txt2
-rw-r--r--src/ipcpd/normal/connmgr.c1
-rw-r--r--src/ipcpd/normal/dt.c24
-rw-r--r--src/ipcpd/normal/dt.h10
-rw-r--r--src/ipcpd/normal/dt_pci.c12
-rw-r--r--src/ipcpd/normal/dt_pci.h7
-rw-r--r--src/ipcpd/normal/fa.c134
-rw-r--r--src/ipcpd/normal/fa.h5
-rw-r--r--src/ipcpd/normal/flow_alloc.proto4
-rw-r--r--src/ipcpd/normal/frct.c340
-rw-r--r--src/ipcpd/normal/frct.h56
-rw-r--r--src/ipcpd/normal/frct_pci.c102
-rw-r--r--src/ipcpd/normal/frct_pci.h47
-rw-r--r--src/ipcpd/normal/main.c55
-rw-r--r--src/ipcpd/normal/pol/complete.c1
-rw-r--r--src/lib/dev.c2
16 files changed, 92 insertions, 710 deletions
diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt
index 3f0f2612..984ebd3d 100644
--- a/src/ipcpd/normal/CMakeLists.txt
+++ b/src/ipcpd/normal/CMakeLists.txt
@@ -26,8 +26,6 @@ set(SOURCE_FILES
dt_pci.c
enroll.c
fa.c
- frct.c
- frct_pci.c
gam.c
graph.c
main.c
diff --git a/src/ipcpd/normal/connmgr.c b/src/ipcpd/normal/connmgr.c
index 56fe9164..00af3db4 100644
--- a/src/ipcpd/normal/connmgr.c
+++ b/src/ipcpd/normal/connmgr.c
@@ -32,7 +32,6 @@
#include "ae.h"
#include "connmgr.h"
#include "enroll.h"
-#include "frct.h"
#include "ipcp.h"
#include "ribmgr.h"
diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c
index 4e0ba51d..33070fa2 100644
--- a/src/ipcpd/normal/dt.c
+++ b/src/ipcpd/normal/dt.c
@@ -36,7 +36,6 @@
#include "gam.h"
#include "routing.h"
#include "sdu_sched.h"
-#include "frct.h"
#include "ae.h"
#include "ribconfig.h"
#include "fa.h"
@@ -113,19 +112,21 @@ static int sdu_handler(int fd,
} else {
dt_pci_shrink(sdb);
- switch (dt_pci.pdu_type) {
- case PDU_TYPE_FRCT:
- if (frct_post_sdu(sdb)) {
+ if (dt_pci.fd > AP_RES_FDS) {
+ if (ipcp_flow_write(dt_pci.fd, sdb)) {
ipcp_sdb_release(sdb);
return -1;
}
- break;
- case PDU_TYPE_FA:
+ return 0;
+ }
+
+ switch (dt_pci.fd) {
+ case FD_FA:
if (fa_post_sdu(sdb)) {
ipcp_sdb_release(sdb);
return -1;
}
- break;
+ return 0;
default:
log_err("Unknown PDU type received.");
ipcp_sdb_release(sdb);
@@ -133,6 +134,7 @@ static int sdu_handler(int fd,
}
}
+ /* silence compiler */
return 0;
}
@@ -150,7 +152,7 @@ int dt_init(void)
memset(&info, 0, sizeof(info));
strcpy(info.ae_name, DT_AE);
- strcpy(info.protocol, FRCT_PROTO);
+ strcpy(info.protocol, DT_PROTO);
info.pref_version = 1;
info.pref_syntax = PROTO_FIXED;
info.addr = ipcpi.dt_addr;
@@ -265,7 +267,7 @@ void dt_stop(void)
int dt_write_sdu(uint64_t dst_addr,
qoscube_t qc,
- uint8_t pdu_type,
+ int np1_fd,
struct shm_du_buff * sdb)
{
int fd;
@@ -280,8 +282,8 @@ int dt_write_sdu(uint64_t dst_addr,
}
dt_pci.dst_addr = dst_addr;
- dt_pci.qc = qc;
- dt_pci.pdu_type = pdu_type;
+ dt_pci.qc = qc;
+ dt_pci.fd = 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 ec59d592..b7b3f7c6 100644
--- a/src/ipcpd/normal/dt.h
+++ b/src/ipcpd/normal/dt.h
@@ -27,6 +27,14 @@
#include "dt_pci.h"
+#define INVALID_ADDR 0
+
+#define DT_PROTO "dt"
+#define FD_FA 1
+#define FD_DHT 2
+
+typedef uint32_t dt_cep_id_t;
+
int dt_init(void);
void dt_fini(void);
@@ -37,7 +45,7 @@ void dt_stop(void);
int dt_write_sdu(uint64_t dst_addr,
qoscube_t qc,
- uint8_t pdu_type,
+ int np1_fd,
struct shm_du_buff * sdb);
#endif /* OUROBOROS_IPCPD_NORMAL_DT_H */
diff --git a/src/ipcpd/normal/dt_pci.c b/src/ipcpd/normal/dt_pci.c
index 39dde46b..9f3b9a91 100644
--- a/src/ipcpd/normal/dt_pci.c
+++ b/src/ipcpd/normal/dt_pci.c
@@ -47,7 +47,7 @@ struct {
/* offsets */
size_t qc_o;
size_t ttl_o;
- size_t type_o;
+ size_t fd_o;
} dt_pci_info;
int dt_pci_init(void)
@@ -67,11 +67,11 @@ int dt_pci_init(void)
dt_pci_info.qc_o = dt_pci_info.dtc.addr_size;
dt_pci_info.ttl_o = dt_pci_info.qc_o + QC_SIZE;
if (dt_pci_info.dtc.has_ttl)
- dt_pci_info.type_o = dt_pci_info.ttl_o + TTL_SIZE;
+ dt_pci_info.fd_o = dt_pci_info.ttl_o + TTL_SIZE;
else
- dt_pci_info.type_o = dt_pci_info.ttl_o;
+ dt_pci_info.fd_o = dt_pci_info.ttl_o;
- dt_pci_info.head_size = dt_pci_info.type_o + PDU_TYPE_SIZE;
+ dt_pci_info.head_size = dt_pci_info.fd_o + PDU_TYPE_SIZE;
dt_pci_info.tail_size = dt_pci_info.dtc.has_chk ? CHK_SIZE : 0;
return 0;
@@ -100,7 +100,7 @@ int dt_pci_ser(struct shm_du_buff * sdb,
memcpy(head + dt_pci_info.qc_o, &dt_pci->qc, QC_SIZE);
if (dt_pci_info.dtc.has_ttl)
memcpy(head + dt_pci_info.ttl_o, &ttl, TTL_SIZE);
- memcpy(head + dt_pci_info.type_o, &dt_pci->pdu_type, PDU_TYPE_SIZE);
+ memcpy(head + dt_pci_info.fd_o, &dt_pci->fd, PDU_TYPE_SIZE);
if (dt_pci_info.dtc.has_chk) {
tail = shm_du_buff_tail_alloc(sdb, dt_pci_info.tail_size);
@@ -137,7 +137,7 @@ void dt_pci_des(struct shm_du_buff * sdb,
dt_pci->ttl = 1;
}
- memcpy(&dt_pci->pdu_type, head + dt_pci_info.type_o, PDU_TYPE_SIZE);
+ memcpy(&dt_pci->fd, head + dt_pci_info.fd_o, PDU_TYPE_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 bec21188..280956f4 100644
--- a/src/ipcpd/normal/dt_pci.h
+++ b/src/ipcpd/normal/dt_pci.h
@@ -26,16 +26,11 @@
#include <ouroboros/shm_du_buff.h>
#include <ouroboros/shared.h>
-#define PDU_TYPE_FA 0x40
-#define PDU_TYPE_FRCT 0x80
-
-#define INVALID_ADDR 0
-
struct dt_pci {
uint64_t dst_addr;
qoscube_t qc;
uint8_t ttl;
- uint8_t pdu_type;
+ uint32_t fd;
};
int dt_pci_init(void);
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c
index 3aa2634a..d6c36a17 100644
--- a/src/ipcpd/normal/fa.c
+++ b/src/ipcpd/normal/fa.c
@@ -48,8 +48,8 @@ typedef FlowAllocMsg flow_alloc_msg_t;
struct {
pthread_rwlock_t flows_lock;
- cep_id_t fd_to_cep_id[AP_MAX_FLOWS];
- int cep_id_to_fd[IPCPD_MAX_CONNS];
+ int r_fd[AP_MAX_FLOWS];
+ uint64_t r_addr[AP_MAX_FLOWS];
struct sdu_sched * sdu_sched;
} fa;
@@ -58,14 +58,12 @@ static int sdu_handler(int fd,
qoscube_t qc,
struct shm_du_buff * sdb)
{
- (void) qc;
-
pthread_rwlock_rdlock(&fa.flows_lock);
- if (frct_i_write_sdu(fa.fd_to_cep_id[fd], sdb)) {
+ if (dt_write_sdu(fa.r_addr[fd], qc, fa.r_fd[fd], sdb)) {
pthread_rwlock_unlock(&fa.flows_lock);
ipcp_sdb_release(sdb);
- log_warn("Failed to hand SDU to FRCT.");
+ log_warn("Failed to forward SDU.");
return -1;
}
@@ -74,15 +72,18 @@ static int sdu_handler(int fd,
return 0;
}
+static void destroy_conn(int fd)
+{
+ fa.r_fd[fd] = -1;
+ fa.r_addr[fd] = INVALID_ADDR;
+}
+
int fa_init(void)
{
int i;
for (i = 0; i < AP_MAX_FLOWS; ++i)
- fa.fd_to_cep_id[i] = INVALID_CEP_ID;
-
- for (i = 0; i < IPCPD_MAX_CONNS; ++i)
- fa.cep_id_to_fd[i] = -1;
+ destroy_conn(i);
if (pthread_rwlock_init(&fa.flows_lock, NULL))
return -1;
@@ -128,20 +129,10 @@ static struct shm_du_buff * create_fa_sdb(flow_alloc_msg_t * msg)
return sdb;
}
-/* FIXME: Revise when Delta-t is fully implemented */
-static void destroy_conn(int fd,
- cep_id_t cep_id)
-{
- fa.fd_to_cep_id[fd] = INVALID_CEP_ID;
- fa.cep_id_to_fd[cep_id] = -1;
- frct_i_destroy(cep_id);
-}
-
int fa_alloc(int fd,
const uint8_t * dst,
qoscube_t qc)
{
- cep_id_t cep_id;
flow_alloc_msg_t msg = FLOW_ALLOC_MSG__INIT;
char path[RIB_MAX_PATH_LEN + 1];
uint64_t addr;
@@ -185,38 +176,30 @@ int fa_alloc(int fd,
if (rib_read(path, &addr, sizeof(addr)) != sizeof(addr))
return -1;
- cep_id = frct_i_create(addr, qc);
- if (cep_id == INVALID_CEP_ID)
- return -1;
-
msg.code = FLOW_ALLOC_CODE__FLOW_REQ;
msg.has_hash = true;
msg.hash.len = ipcp_dir_hash_len();
msg.hash.data = (uint8_t *) dst;
msg.has_qc = true;
msg.qc = qc;
- msg.has_s_cep_id = true;
- msg.s_cep_id = cep_id;
+ msg.has_s_fd = true;
+ msg.s_fd = fd;
msg.has_s_addr = true;
msg.s_addr = ipcpi.dt_addr;
sdb = create_fa_sdb(&msg);
- if (sdb == NULL) {
- frct_i_destroy(cep_id);
+ if (sdb == NULL)
return -1;
- }
- pthread_rwlock_wrlock(&fa.flows_lock);
-
- if (dt_write_sdu(addr, qc, PDU_TYPE_FA, sdb)) {
- frct_i_destroy(cep_id);
- pthread_rwlock_unlock(&fa.flows_lock);
+ if (dt_write_sdu(addr, qc, FD_FA, sdb)) {
ipcp_sdb_release(sdb);
return -1;
}
- fa.fd_to_cep_id[fd] = cep_id;
- fa.cep_id_to_fd[cep_id] = fd;
+ pthread_rwlock_wrlock(&fa.flows_lock);
+
+ fa.r_fd[fd] = fd;
+ fa.r_addr[fd] = addr;
pthread_rwlock_unlock(&fa.flows_lock);
@@ -251,22 +234,22 @@ int fa_alloc_resp(int fd,
pthread_rwlock_wrlock(&fa.flows_lock);
msg.code = FLOW_ALLOC_CODE__FLOW_REPLY;
- msg.has_cep_id = true;
- msg.cep_id = frct_i_get_id(fa.fd_to_cep_id[fd]);
- msg.s_cep_id = fa.fd_to_cep_id[fd];
- msg.has_s_cep_id = true;
+ msg.has_r_fd = true;
+ msg.r_fd = fa.r_fd[fd];
+ msg.has_s_fd = true;
+ msg.s_fd = fd;
msg.response = response;
msg.has_response = true;
sdb = create_fa_sdb(&msg);
if (sdb == NULL) {
- destroy_conn(fd, fa.fd_to_cep_id[fd]);
+ destroy_conn(fd);
pthread_rwlock_unlock(&fa.flows_lock);
return -1;
}
if (response < 0) {
- destroy_conn(fd, fa.fd_to_cep_id[fd]);
+ destroy_conn(fd);
ipcp_sdb_release(sdb);
} else {
sdu_sched_add(fa.sdu_sched, fd);
@@ -276,11 +259,8 @@ int fa_alloc_resp(int fd,
assert(qc >= 0 && qc < QOS_CUBE_MAX);
- if (dt_write_sdu(frct_i_get_addr(fa.fd_to_cep_id[fd]),
- qc,
- PDU_TYPE_FA,
- sdb)) {
- destroy_conn(fd, fa.fd_to_cep_id[fd]);
+ if (dt_write_sdu(fa.r_addr[fd], qc, FD_FA, sdb)) {
+ destroy_conn(fd);
pthread_rwlock_unlock(&fa.flows_lock);
ipcp_sdb_release(sdb);
return -1;
@@ -299,7 +279,7 @@ int fa_dealloc(int fd)
sdu_sched_del(fa.sdu_sched, fd);
- destroy_conn(fd, fa.fd_to_cep_id[fd]);
+ destroy_conn(fd);
pthread_rwlock_unlock(&fa.flows_lock);
@@ -313,7 +293,6 @@ int fa_post_sdu(struct shm_du_buff * sdb)
struct timespec ts = {0, TIMEOUT * 1000};
int fd;
flow_alloc_msg_t * msg;
- cep_id_t cep_id;
assert(sdb);
@@ -332,7 +311,7 @@ int fa_post_sdu(struct shm_du_buff * sdb)
case FLOW_ALLOC_CODE__FLOW_REQ:
pthread_mutex_lock(&ipcpi.alloc_lock);
- if (!msg->has_hash) {
+ if (!msg->has_hash || !msg->has_s_fd || !msg->has_s_addr) {
log_err("Bad flow request.");
pthread_mutex_unlock(&ipcpi.alloc_lock);
flow_alloc_msg__free_unpacked(msg, NULL);
@@ -354,27 +333,12 @@ int fa_post_sdu(struct shm_du_buff * sdb)
assert(ipcpi.alloc_id == -1);
- cep_id = frct_i_create(msg->s_addr, msg->qc);
- if (cep_id == INVALID_CEP_ID) {
- pthread_mutex_unlock(&ipcpi.alloc_lock);
- flow_alloc_msg__free_unpacked(msg, NULL);
- return -1;
- }
-
- if (frct_i_set_id(cep_id, msg->s_cep_id)) {
- pthread_mutex_unlock(&ipcpi.alloc_lock);
- frct_i_destroy(cep_id);
- flow_alloc_msg__free_unpacked(msg, NULL);
- return -1;
- }
-
fd = ipcp_flow_req_arr(getpid(),
msg->hash.data,
ipcp_dir_hash_len(),
msg->qc);
if (fd < 0) {
pthread_mutex_unlock(&ipcpi.alloc_lock);
- frct_i_destroy(cep_id);
flow_alloc_msg__free_unpacked(msg, NULL);
log_err("Failed to get fd for flow.");
return -1;
@@ -382,8 +346,8 @@ int fa_post_sdu(struct shm_du_buff * sdb)
pthread_rwlock_wrlock(&fa.flows_lock);
- fa.fd_to_cep_id[fd] = cep_id;
- fa.cep_id_to_fd[cep_id] = fd;
+ fa.r_fd[fd] = msg->s_fd;
+ fa.r_addr[fd] = msg->s_addr;
pthread_rwlock_unlock(&fa.flows_lock);
@@ -396,15 +360,12 @@ int fa_post_sdu(struct shm_du_buff * sdb)
case FLOW_ALLOC_CODE__FLOW_REPLY:
pthread_rwlock_wrlock(&fa.flows_lock);
- fd = fa.cep_id_to_fd[msg->cep_id];
- ipcp_flow_alloc_reply(fd, msg->response);
- if (msg->response < 0) {
- destroy_conn(fd, msg->cep_id);
- } else {
- frct_i_set_id(msg->cep_id, msg->s_cep_id);
- sdu_sched_add(fa.sdu_sched,
- fa.cep_id_to_fd[msg->cep_id]);
- }
+ ipcp_flow_alloc_reply(msg->r_fd, msg->response);
+
+ if (msg->response < 0)
+ destroy_conn(msg->r_fd);
+ else
+ sdu_sched_add(fa.sdu_sched, fa.r_fd[msg->r_fd]);
pthread_rwlock_unlock(&fa.flows_lock);
@@ -420,24 +381,3 @@ int fa_post_sdu(struct shm_du_buff * sdb)
return 0;
}
-
-int fa_post_sdu_user(cep_id_t cep_id,
- struct shm_du_buff * sdb)
-{
- int fd;
-
- assert(sdb);
-
- pthread_rwlock_rdlock(&fa.flows_lock);
-
- fd = fa.cep_id_to_fd[cep_id];
- if (ipcp_flow_write(fd, sdb)) {
- pthread_rwlock_unlock(&fa.flows_lock);
- log_err("Failed to hand SDU to N flow.");
- return -1;
- }
-
- pthread_rwlock_unlock(&fa.flows_lock);
-
- return 0;
-}
diff --git a/src/ipcpd/normal/fa.h b/src/ipcpd/normal/fa.h
index 6ca705e4..264d45ea 100644
--- a/src/ipcpd/normal/fa.h
+++ b/src/ipcpd/normal/fa.h
@@ -26,8 +26,6 @@
#include <ouroboros/shared.h>
#include <ouroboros/utils.h>
-#include "frct.h"
-
int fa_init(void);
void fa_fini(void);
@@ -47,7 +45,4 @@ int fa_dealloc(int fd);
int fa_post_sdu(struct shm_du_buff * sdb);
-int fa_post_sdu_user(cep_id_t cep_id,
- struct shm_du_buff * sdb);
-
#endif /* OUROBOROS_IPCPD_NORMAL_FA_H */
diff --git a/src/ipcpd/normal/flow_alloc.proto b/src/ipcpd/normal/flow_alloc.proto
index 947ce86b..78505761 100644
--- a/src/ipcpd/normal/flow_alloc.proto
+++ b/src/ipcpd/normal/flow_alloc.proto
@@ -32,7 +32,7 @@ message flow_alloc_msg {
optional bytes hash = 2;
optional uint32 qc = 3;
optional sint32 response = 4;
- optional uint32 cep_id = 5;
- optional uint32 s_cep_id = 6;
+ optional uint32 r_fd = 5;
+ optional uint32 s_fd = 6;
optional uint64 s_addr = 7;
};
diff --git a/src/ipcpd/normal/frct.c b/src/ipcpd/normal/frct.c
deleted file mode 100644
index 010b9761..00000000
--- a/src/ipcpd/normal/frct.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * The Flow and Retransmission control component
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#define OUROBOROS_PREFIX "flow-rtx-control"
-
-#include <ouroboros/config.h>
-#include <ouroboros/logs.h>
-#include <ouroboros/bitmap.h>
-#include <ouroboros/list.h>
-#include <ouroboros/ipcp-dev.h>
-#include <ouroboros/errno.h>
-
-#include "frct.h"
-#include "ipcp.h"
-#include "dt.h"
-#include "fa.h"
-
-#include <stdlib.h>
-#include <stdbool.h>
-#include <pthread.h>
-#include <string.h>
-#include <assert.h>
-
-enum conn_state {
- CONN_PENDING = 0,
- CONN_ESTABLISHED
-};
-
-struct frct_i {
- uint32_t cep_id;
- uint64_t r_address;
- uint32_t r_cep_id;
- qoscube_t cube;
- uint64_t seqno;
-
- enum conn_state state;
-};
-
-struct {
- struct frct_i ** instances;
- pthread_mutex_t instances_lock;
-
- struct bmp * cep_ids;
- pthread_mutex_t cep_ids_lock;
-} frct;
-
-static cep_id_t next_cep_id(void)
-{
- cep_id_t ret;
-
- pthread_mutex_lock(&frct.cep_ids_lock);
-
- ret = bmp_allocate(frct.cep_ids);
- if (!bmp_is_id_valid(frct.cep_ids, ret))
- ret = INVALID_CEP_ID;
-
- pthread_mutex_unlock(&frct.cep_ids_lock);
-
- return ret;
-}
-
-static int release_cep_id(cep_id_t id)
-{
- int ret;
-
- pthread_mutex_lock(&frct.cep_ids_lock);
-
- ret = bmp_release(frct.cep_ids, id);
-
- pthread_mutex_unlock(&frct.cep_ids_lock);
-
- return ret;
-}
-
-int frct_init()
-{
- int i;
-
- if (frct_pci_init())
- return -1;
-
- if (pthread_mutex_init(&frct.cep_ids_lock, NULL))
- return -1;
-
- frct.cep_ids = bmp_create(IRMD_MAX_FLOWS, (INVALID_CEP_ID + 1));
- if (frct.cep_ids == NULL)
- goto fail_cep_ids_lock;
-
- if (pthread_mutex_init(&frct.instances_lock, NULL))
- goto fail_bmp;
-
- frct.instances = malloc(sizeof(*(frct.instances)) * IRMD_MAX_FLOWS);
- if (frct.instances == NULL)
- goto fail_instance_lock;
-
- for (i = 0; i < IRMD_MAX_FLOWS; i++)
- frct.instances[i] = NULL;
-
- return 0;
-
- fail_instance_lock:
- pthread_mutex_destroy(&frct.instances_lock);
- fail_bmp:
- bmp_destroy(frct.cep_ids);
- fail_cep_ids_lock:
- pthread_mutex_destroy(&frct.cep_ids_lock);
-
- return -1;
-}
-
-int frct_fini()
-{
- size_t len = IRMD_MAX_FLOWS;
-
- pthread_mutex_destroy(&frct.instances_lock);
-
- freepp(struct frct_i, frct.instances, len);
-
- bmp_destroy(frct.cep_ids);
-
- pthread_mutex_destroy(&frct.cep_ids_lock);
-
- return 0;
-}
-
-cep_id_t frct_i_create(uint64_t address,
- qoscube_t qc)
-{
- struct frct_i * instance;
- cep_id_t id;
-
- pthread_mutex_lock(&frct.instances_lock);
-
- instance = malloc(sizeof(*instance));
- if (instance == NULL)
- return INVALID_CEP_ID;
-
- id = next_cep_id();
- if (id == INVALID_CEP_ID) {
- free(instance);
- return INVALID_CEP_ID;
- }
-
- instance->r_address = address;
- instance->cep_id = id;
- instance->state = CONN_PENDING;
- instance->seqno = 0;
- instance->cube = qc;
-
- frct.instances[id] = instance;
-
- pthread_mutex_unlock(&frct.instances_lock);
-
- return id;
-}
-
-int frct_i_destroy(cep_id_t cep_id)
-{
- struct frct_i * instance;
-
- pthread_mutex_lock(&frct.instances_lock);
-
- instance = frct.instances[cep_id];
- if (instance == NULL) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Invalid instance.");
- return -1;
- }
-
- frct.instances[cep_id] = NULL;
-
- release_cep_id(instance->cep_id);
- free(instance);
-
- pthread_mutex_unlock(&frct.instances_lock);
-
- return 0;
-}
-
-int frct_i_set_id(cep_id_t cep_id,
- cep_id_t r_cep_id)
-{
- struct frct_i * instance;
-
- pthread_mutex_lock(&frct.instances_lock);
-
- instance = frct.instances[cep_id];
- if (instance == NULL) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Invalid instance.");
- return -1;
- }
-
- instance->r_cep_id = r_cep_id;
- instance->state = CONN_ESTABLISHED;
-
- pthread_mutex_unlock(&frct.instances_lock);
-
- return 0;
-}
-
-cep_id_t frct_i_get_id(cep_id_t cep_id)
-{
- struct frct_i * instance;
- cep_id_t r_cep_id;
-
- pthread_mutex_lock(&frct.instances_lock);
-
- instance = frct.instances[cep_id];
- if (instance == NULL) {
- pthread_mutex_unlock(&frct.instances_lock);
- return INVALID_CEP_ID;
- }
-
- r_cep_id = instance->r_cep_id;
-
- pthread_mutex_unlock(&frct.instances_lock);
-
- return r_cep_id;
-}
-
-uint64_t frct_i_get_addr(cep_id_t cep_id)
-{
- struct frct_i * instance;
- uint64_t r_addr;
-
- pthread_mutex_lock(&frct.instances_lock);
-
- instance = frct.instances[cep_id];
- if (instance == NULL) {
- pthread_mutex_unlock(&frct.instances_lock);
- return INVALID_ADDR;
- }
-
- r_addr = instance->r_address;
-
- pthread_mutex_unlock(&frct.instances_lock);
-
- return r_addr;
-}
-
-int frct_post_sdu(struct shm_du_buff * sdb)
-{
- struct frct_pci frct_pci;
- struct frct_i * instance;
-
- assert(sdb);
-
- memset(&frct_pci, 0, sizeof(frct_pci));
-
- frct_pci_des(sdb, &frct_pci);
-
- /* Known cep-ids are delivered to FA (minimal DTP) */
- pthread_mutex_lock(&frct.instances_lock);
-
- instance = frct.instances[frct_pci.dst_cep_id];
- if (instance == NULL) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Invalid instance.");
- return -1;
- }
-
- if (instance->state != CONN_ESTABLISHED) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Connection is not established.");
- return -1;
- }
-
- pthread_mutex_unlock(&frct.instances_lock);
-
- if (fa_post_sdu_user(frct_pci.dst_cep_id, sdb))
- return -1;
-
- return 0;
-}
-
-int frct_i_write_sdu(cep_id_t id,
- struct shm_du_buff * sdb)
-{
- struct frct_i * instance;
- struct frct_pci frct_pci;
-
- assert(sdb);
-
- pthread_mutex_lock(&frct.instances_lock);
-
- instance = frct.instances[id];
- if (instance == NULL) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Invalid instance.");
- return -1;
- }
-
- if (instance->state != CONN_ESTABLISHED) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Connection is not established.");
- return -1;
- }
-
- frct_pci.dst_cep_id = instance->r_cep_id;
- frct_pci.seqno = (instance->seqno)++;
-
- if (frct_pci_ser(sdb, &frct_pci)) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Failed to serialize.");
- return -1;
- }
-
- if (dt_write_sdu(instance->r_address,
- instance->cube,
- PDU_TYPE_FRCT,
- sdb)) {
- pthread_mutex_unlock(&frct.instances_lock);
- log_err("Failed to hand SDU to DT.");
- return -1;
- }
-
- pthread_mutex_unlock(&frct.instances_lock);
-
- return 0;
-}
diff --git a/src/ipcpd/normal/frct.h b/src/ipcpd/normal/frct.h
deleted file mode 100644
index 03dec672..00000000
--- a/src/ipcpd/normal/frct.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * The Flow and Retransmission control component
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef OUROBOROS_IPCPD_NORMAL_FRCT_H
-#define OUROBOROS_IPCPD_NORMAL_FRCT_H
-
-#include <ouroboros/shared.h>
-#include <ouroboros/utils.h>
-
-#include "frct_pci.h"
-
-#define FRCT_PROTO "FRCT"
-
-struct frct_i;
-
-int frct_init(void);
-
-int frct_fini(void);
-
-cep_id_t frct_i_create(uint64_t address,
- qoscube_t cube);
-
-int frct_i_destroy(cep_id_t cep_id);
-
-int frct_i_set_id(cep_id_t cep_id,
- cep_id_t r_cep_id);
-
-cep_id_t frct_i_get_id(cep_id_t cep_id);
-
-uint64_t frct_i_get_addr(cep_id_t cep_id);
-
-int frct_i_write_sdu(cep_id_t id,
- struct shm_du_buff * sdb);
-
-int frct_post_sdu(struct shm_du_buff * sdb);
-
-#endif /* OUROBOROS_IPCPD_NORMAL_FRCT_H */
diff --git a/src/ipcpd/normal/frct_pci.c b/src/ipcpd/normal/frct_pci.c
deleted file mode 100644
index a13df2f4..00000000
--- a/src/ipcpd/normal/frct_pci.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * Protocol Control Information for FRCT
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <ouroboros/config.h>
-#include <ouroboros/errno.h>
-#include <ouroboros/rib.h>
-
-#include "dt_const.h"
-#include "frct_pci.h"
-#include "ribconfig.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-struct {
- struct dt_const dtc;
- size_t head_size;
-
- /* offsets */
- size_t seqno_o;
-} frct_pci_info;
-
-int frct_pci_init(void)
-{
- /* read dt constants from the RIB */
- if (rib_read(BOOT_PATH "/dt/const/cep_id_size",
- &frct_pci_info.dtc.cep_id_size,
- sizeof(frct_pci_info.dtc.cep_id_size)) < 0 ||
- rib_read(BOOT_PATH "/dt/const/seqno_size",
- &frct_pci_info.dtc.seqno_size,
- sizeof(frct_pci_info.dtc.seqno_size)) < 0)
- return -1;
-
- frct_pci_info.seqno_o = frct_pci_info.dtc.cep_id_size;
-
- frct_pci_info.head_size = frct_pci_info.seqno_o +
- frct_pci_info.dtc.seqno_size;
-
- return 0;
-}
-
-void frct_pci_fini(void) {
- return;
-}
-
-int frct_pci_ser(struct shm_du_buff * sdb,
- struct frct_pci * frct_pci)
-{
- uint8_t * head;
-
- assert(sdb);
- assert(frct_pci);
-
- head = shm_du_buff_head_alloc(sdb, frct_pci_info.head_size);
- if (head == NULL)
- return -EPERM;
-
- /* FIXME: Add check and operations for Big Endian machines */
- memcpy(head, &frct_pci->dst_cep_id, frct_pci_info.dtc.cep_id_size);
- memcpy(head + frct_pci_info.seqno_o, &frct_pci->seqno,
- frct_pci_info.dtc.seqno_size);
-
- return 0;
-}
-
-void frct_pci_des(struct shm_du_buff * sdb,
- struct frct_pci * frct_pci)
-{
- uint8_t * head;
-
- assert(sdb);
- assert(frct_pci);
-
- head = shm_du_buff_head(sdb);
-
- /* FIXME: Add check and operations for Big Endian machines */
- memcpy(&frct_pci->dst_cep_id, head, frct_pci_info.dtc.cep_id_size);
- memcpy(&frct_pci->seqno, head + frct_pci_info.seqno_o,
- frct_pci_info.dtc.seqno_size);
-
- shm_du_buff_head_release(sdb, frct_pci_info.head_size);
-}
diff --git a/src/ipcpd/normal/frct_pci.h b/src/ipcpd/normal/frct_pci.h
deleted file mode 100644
index 006fe8e7..00000000
--- a/src/ipcpd/normal/frct_pci.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * Protocol Control Information for FRCT
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef OUROBOROS_IPCPD_NORMAL_FRCT_PCI_H
-#define OUROBOROS_IPCPD_NORMAL_FRCT_PCI_H
-
-#include <ouroboros/shm_du_buff.h>
-
-typedef uint32_t cep_id_t;
-
-#define INVALID_CEP_ID 0
-
-struct frct_pci {
- cep_id_t dst_cep_id;
- uint64_t seqno;
-};
-
-int frct_pci_init(void);
-
-void frct_pci_fini(void);
-
-int frct_pci_ser(struct shm_du_buff * sdb,
- struct frct_pci * frct_pci);
-
-void frct_pci_des(struct shm_du_buff * sdb,
- struct frct_pci * frct_pci);
-
-#endif /* OUROBOROS_IPCPD_NORMAL_FRCT_PCI_H */
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 42516efd..d103b339 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -74,7 +74,7 @@ static int boot_components(void)
&ipcpi.dir_hash_algo, sizeof(ipcpi.dir_hash_algo));
if (len < 0) {
log_err("Failed to read hash length: %zd.", len);
- goto fail_name;
+ goto fail_addr_auth;
}
ipcpi.dir_hash_algo = ntoh32(ipcpi.dir_hash_algo);
@@ -83,7 +83,7 @@ static int boot_components(void)
if (rib_add(MEMBERS_PATH, ipcpi.name)) {
log_err("Failed to add name to " MEMBERS_PATH);
- goto fail_name;
+ goto fail_addr_auth;
}
log_dbg("Starting components.");
@@ -91,25 +91,25 @@ static int boot_components(void)
if (rib_read(BOOT_PATH "/addr_auth/type", &pa, sizeof(pa))
!= sizeof(pa)) {
log_err("Failed to read policy for address authority.");
- goto fail_name;
+ goto fail_addr_auth;
}
if (addr_auth_init(pa)) {
log_err("Failed to init address authority.");
- goto fail_name;
+ goto fail_addr_auth;
}
ipcpi.dt_addr = addr_auth_address();
if (ipcpi.dt_addr == 0) {
log_err("Failed to get a valid address.");
- goto fail_addr_auth;
+ goto fail_dir;
}
path[0] = '\0';
rib_path_append(rib_path_append(path, MEMBERS_NAME), ipcpi.name);
if (rib_write(path, &ipcpi.dt_addr, sizeof(&ipcpi.dt_addr))) {
log_err("Failed to write address to member object.");
- goto fail_addr_auth;
+ goto fail_dir;
}
log_dbg("IPCP got address %" PRIu64 ".", ipcpi.dt_addr);
@@ -118,75 +118,68 @@ static int boot_components(void)
if (dir_init()) {
log_err("Failed to initialize directory.");
- goto fail_addr_auth;
+ goto fail_dir;
}
if (ribmgr_init()) {
log_err("Failed to initialize RIB manager.");
- goto fail_dir;
+ goto fail_ribmgr;
}
log_dbg("Ribmgr started.");
- if (frct_init()) {
- log_err("Failed to initialize FRCT.");
- goto fail_ribmgr;
- }
-
if (fa_init()) {
log_err("Failed to initialize flow allocator ae.");
- goto fail_frct;
+ goto fail_fa;
}
if (dt_init()) {
log_err("Failed to initialize data transfer ae.");
- goto fail_fa;
+ goto fail_dt;
}
if (fa_start()) {
log_err("Failed to start flow allocator.");
- goto fail_dt;
+ goto fail_fa_start;
}
if (dt_start()) {
log_err("Failed to start data transfer ae.");
- goto fail_fa_start;
+ goto fail_dt_start;
}
if (enroll_start()) {
log_err("Failed to start enroll.");
- goto fail_dt_start;
+ goto fail_enroll_start;
}
ipcp_set_state(IPCP_OPERATIONAL);
if (connmgr_start()) {
log_err("Failed to start AP connection manager.");
- goto fail_enroll;
+ goto fail_connmgr_start;
}
return 0;
- fail_enroll:
+ fail_connmgr_start:
ipcp_set_state(IPCP_INIT);
enroll_stop();
- fail_dt_start:
+ fail_enroll_start:
dt_stop();
- fail_fa_start:
+ fail_dt_start:
fa_stop();
- fail_dt:
+ fail_fa_start:
dt_fini();
- fail_fa:
+ fail_dt:
fa_fini();
- fail_frct:
- frct_fini();
- fail_ribmgr:
+ fail_fa:
ribmgr_fini();
- fail_dir:
+ fail_ribmgr:
dir_fini();
- fail_addr_auth:
+ fail_dir:
addr_auth_fini();
- fail_name:
+ fail_addr_auth:
free(ipcpi.dif_name);
return -1;
@@ -206,8 +199,6 @@ void shutdown_components(void)
fa_fini();
- frct_fini();
-
ribmgr_fini();
dir_fini();
diff --git a/src/ipcpd/normal/pol/complete.c b/src/ipcpd/normal/pol/complete.c
index 20a2dafb..732556c6 100644
--- a/src/ipcpd/normal/pol/complete.c
+++ b/src/ipcpd/normal/pol/complete.c
@@ -31,7 +31,6 @@
#include <ouroboros/cacep.h>
#include "neighbors.h"
-#include "frct.h"
#include "ribconfig.h"
#include "ipcp.h"
#include "ae.h"
diff --git a/src/lib/dev.c b/src/lib/dev.c
index f5315cf5..306fd008 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -249,7 +249,7 @@ int ouroboros_init(const char * ap_name)
ai.api = getpid();
ai.daf_name = NULL;
- ai.fds = bmp_create(AP_MAX_FLOWS, 0);
+ ai.fds = bmp_create(AP_MAX_FLOWS, AP_RES_FDS + 1);
if (ai.fds == NULL)
return -ENOMEM;