summaryrefslogtreecommitdiff
path: root/src/ipcpd
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-05-12 13:05:47 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-05-15 12:06:09 +0200
commit9903b8a2f9a7dc8ebac6928dcf2d2b5593ea0615 (patch)
treeea16469c2d8fbcb417ed89e0bbd550834d0602a6 /src/ipcpd
parentb36acfd93b1dc16a153ca9b9077d113732accb4e (diff)
downloadouroboros-9903b8a2f9a7dc8ebac6928dcf2d2b5593ea0615.tar.gz
ouroboros-9903b8a2f9a7dc8ebac6928dcf2d2b5593ea0615.zip
ipcpd: Allow specifying fixed syntax
This commits adds the functions and messages to specify a fixed protocol syntax during CACEP. It also revises the messages for specifying the DT protocol syntax from the irm tool.
Diffstat (limited to 'src/ipcpd')
-rw-r--r--src/ipcpd/ipcp.c45
-rw-r--r--src/ipcpd/local/main.c2
-rw-r--r--src/ipcpd/normal/dt.h6
-rw-r--r--src/ipcpd/normal/dt_pci.c70
-rw-r--r--src/ipcpd/normal/dt_pci.h23
-rw-r--r--src/ipcpd/normal/main.c34
-rw-r--r--src/ipcpd/shim-eth-llc/main.c2
-rw-r--r--src/ipcpd/shim-udp/main.c2
8 files changed, 81 insertions, 103 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 7f3ebc73..4737b1cd 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -133,22 +133,21 @@ static void thread_exit(ssize_t id)
static void * ipcp_main_loop(void * o)
{
- int lsockfd;
- uint8_t buf[IPCP_MSG_BUF_SIZE];
-
- ipcp_msg_t * msg;
- ssize_t count;
- buffer_t buffer;
- ipcp_msg_t ret_msg = IPCP_MSG__INIT;
-
- ipcp_config_msg_t * conf_msg;
+ int lsockfd;
+ uint8_t buf[IPCP_MSG_BUF_SIZE];
+ ssize_t count;
+ buffer_t buffer;
struct ipcp_config conf;
struct dif_info info;
- struct timeval ltv = {(SOCKET_TIMEOUT / 1000),
- (SOCKET_TIMEOUT % 1000) * 1000};
+ ipcp_config_msg_t * conf_msg;
+ ipcp_msg_t * msg;
+ ipcp_msg_t ret_msg = IPCP_MSG__INIT;
+ dif_info_msg_t dif_info = DIF_INFO_MSG__INIT;
+ struct timeval ltv = {(SOCKET_TIMEOUT / 1000),
+ (SOCKET_TIMEOUT % 1000) * 1000};
- ssize_t id = (ssize_t) o;
+ ssize_t id = (ssize_t) o;
while (true) {
#ifdef __FreeBSD__
@@ -213,23 +212,19 @@ static void * ipcp_main_loop(void * o)
conf_msg = msg->conf;
conf.type = conf_msg->ipcp_type;
- conf.dir_hash_algo = conf_msg->dir_hash_algo;
- conf.dif_name = conf_msg->dif_name;
- if (conf.dif_name == NULL) {
+ conf.dif_info.dir_hash_algo =
+ conf_msg->dif_info->dir_hash_algo;
+ strcpy(conf.dif_info.dif_name,
+ conf_msg->dif_info->dif_name);
+ if (conf.dif_info.dif_name == NULL) {
ret_msg.has_result = true;
ret_msg.result = -1;
break;
}
if (conf_msg->ipcp_type == IPCP_NORMAL) {
conf.addr_size = conf_msg->addr_size;
- conf.cep_id_size = conf_msg->cep_id_size;
- conf.pdu_length_size =
- conf_msg->pdu_length_size;
- conf.seqno_size = conf_msg->seqno_size;
+ conf.fd_size = conf_msg->fd_size;
conf.has_ttl = conf_msg->has_ttl;
- conf.has_chk = conf_msg->has_chk;
- conf.min_pdu_size = conf_msg->min_pdu_size;
- conf.max_pdu_size = conf_msg->max_pdu_size;
conf.addr_auth_type = conf_msg->addr_auth_type;
conf.dt_gam_type = conf_msg->dt_gam_type;
conf.rm_gam_type = conf_msg->rm_gam_type;
@@ -264,9 +259,9 @@ static void * ipcp_main_loop(void * o)
&info);
if (ret_msg.result == 0) {
- ret_msg.has_dir_hash_algo = true;
- ret_msg.dir_hash_algo = info.algo;
- ret_msg.dif_name = info.dif_name;
+ ret_msg.dif_info = &dif_info;
+ dif_info.dir_hash_algo = info.dir_hash_algo;
+ dif_info.dif_name = info.dif_name;
}
break;
case IPCP_MSG_CODE__IPCP_REG:
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 162ce4d9..6d89045c 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -119,7 +119,7 @@ static int ipcp_local_bootstrap(const struct ipcp_config * conf)
assert(conf);
assert(conf->type == THIS_TYPE);
- ipcpi.dir_hash_algo = conf->dir_hash_algo;
+ ipcpi.dir_hash_algo = conf->dif_info.dir_hash_algo;
ipcp_set_state(IPCP_OPERATIONAL);
diff --git a/src/ipcpd/normal/dt.h b/src/ipcpd/normal/dt.h
index b7b3f7c6..52760154 100644
--- a/src/ipcpd/normal/dt.h
+++ b/src/ipcpd/normal/dt.h
@@ -29,12 +29,6 @@
#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);
diff --git a/src/ipcpd/normal/dt_pci.c b/src/ipcpd/normal/dt_pci.c
index 9f3b9a91..a4f99142 100644
--- a/src/ipcpd/normal/dt_pci.c
+++ b/src/ipcpd/normal/dt_pci.c
@@ -25,7 +25,6 @@
#include <ouroboros/crc32.h>
#include <ouroboros/rib.h>
-#include "dt_const.h"
#include "dt_pci.h"
#include "ribconfig.h"
@@ -33,16 +32,13 @@
#include <string.h>
#include <assert.h>
-#define PDU_TYPE_SIZE 1
-#define QC_SIZE 1
#define DEFAULT_TTL 60
-#define TTL_SIZE 1
-#define CHK_SIZE 4
struct {
- struct dt_const dtc;
+ uint8_t addr_size;
+ uint8_t fd_size;
+ bool has_ttl;
size_t head_size;
- size_t tail_size;
/* offsets */
size_t qc_o;
@@ -50,29 +46,28 @@ struct {
size_t fd_o;
} dt_pci_info;
-int dt_pci_init(void)
+int dt_pci_init()
{
/* read dt constants from the RIB */
if (rib_read(BOOT_PATH "/dt/const/addr_size",
- &dt_pci_info.dtc.addr_size,
- sizeof(dt_pci_info.dtc.addr_size)) < 0 ||
+ &dt_pci_info.addr_size,
+ sizeof(dt_pci_info.addr_size)) < 0 ||
+ rib_read(BOOT_PATH "/dt/const/fd_size",
+ &dt_pci_info.fd_size,
+ sizeof(dt_pci_info.fd_size)) < 0 ||
rib_read(BOOT_PATH "/dt/const/has_ttl",
- &dt_pci_info.dtc.has_ttl,
- sizeof(dt_pci_info.dtc.has_ttl)) < 0 ||
- rib_read(BOOT_PATH "/dt/const/has_chk",
- &dt_pci_info.dtc.has_chk,
- sizeof(dt_pci_info.dtc.has_chk)) < 0)
+ &dt_pci_info.has_ttl,
+ sizeof(dt_pci_info.has_ttl)) < 0)
return -1;
- 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.fd_o = dt_pci_info.ttl_o + TTL_SIZE;
+ 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.head_size = dt_pci_info.fd_o + PDU_TYPE_SIZE;
- dt_pci_info.tail_size = dt_pci_info.dtc.has_chk ? CHK_SIZE : 0;
+ dt_pci_info.head_size = dt_pci_info.fd_o + dt_pci_info.fd_size;
return 0;
}
@@ -85,7 +80,6 @@ int dt_pci_ser(struct shm_du_buff * sdb,
struct dt_pci * dt_pci)
{
uint8_t * head;
- uint8_t * tail;
uint8_t ttl = DEFAULT_TTL;
assert(sdb);
@@ -96,22 +90,11 @@ int dt_pci_ser(struct shm_du_buff * sdb,
return -EPERM;
/* FIXME: Add check and operations for Big Endian machines */
- memcpy(head, &dt_pci->dst_addr, dt_pci_info.dtc.addr_size);
- 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.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);
- if (tail == NULL) {
- shm_du_buff_head_release(sdb, dt_pci_info.head_size);
- return -EPERM;
- }
-
- *((uint32_t *) tail) = 0;
- crc32((uint32_t *) tail, head, tail - head);
- }
+ 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);
return 0;
}
@@ -127,17 +110,17 @@ void dt_pci_des(struct shm_du_buff * sdb,
head = shm_du_buff_head(sdb);
/* FIXME: Add check and operations for Big Endian machines */
- memcpy(&dt_pci->dst_addr, head, dt_pci_info.dtc.addr_size);
- memcpy(&dt_pci->qc, head + dt_pci_info.qc_o, QC_SIZE);
+ 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.dtc.has_ttl) {
+ 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_SIZE);
+ 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, PDU_TYPE_SIZE);
+ memcpy(&dt_pci->fd, head + dt_pci_info.fd_o, dt_pci_info.fd_size);
}
void dt_pci_shrink(struct shm_du_buff * sdb)
@@ -145,5 +128,4 @@ void dt_pci_shrink(struct shm_du_buff * sdb)
assert(sdb);
shm_du_buff_head_release(sdb, dt_pci_info.head_size);
- shm_du_buff_tail_release(sdb, dt_pci_info.tail_size);
}
diff --git a/src/ipcpd/normal/dt_pci.h b/src/ipcpd/normal/dt_pci.h
index 280956f4..13f782a4 100644
--- a/src/ipcpd/normal/dt_pci.h
+++ b/src/ipcpd/normal/dt_pci.h
@@ -24,8 +24,31 @@
#define OUROBOROS_IPCPD_NORMAL_DT_PCI_H
#include <ouroboros/shm_du_buff.h>
+#include <ouroboros/proto.h>
#include <ouroboros/shared.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#define DT_PROTO "dt"
+#define FD_FA 1
+#define FD_DHT 2
+
+/* 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 */
+};
+
+/* Default 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;
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index d103b339..f9718041 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -229,7 +229,7 @@ static int normal_ipcp_enroll(const char * dst,
log_dbg("Enrolled with " HASH_FMT, HASH_VAL(dst));
- info->algo = ipcpi.dir_hash_algo;
+ info->dir_hash_algo = ipcpi.dir_hash_algo;
strcpy(info->dif_name, ipcpi.dif_name);
@@ -259,12 +259,8 @@ const struct ros {
{BOOT_PATH "/dt/gam", "cacep"},
{BOOT_PATH "/dt", "const"},
{BOOT_PATH "/dt/const", "addr_size"},
- {BOOT_PATH "/dt/const", "cep_id_size"},
- {BOOT_PATH "/dt/const", "seqno_size"},
+ {BOOT_PATH "/dt/const", "fd_size"},
{BOOT_PATH "/dt/const", "has_ttl"},
- {BOOT_PATH "/dt/const", "has_chk"},
- {BOOT_PATH "/dt/const", "min_pdu_size"},
- {BOOT_PATH "/dt/const", "max_pdu_size"},
/* RIB MGR COMPONENT */
{BOOT_PATH, "rm"},
@@ -301,7 +297,7 @@ static int normal_ipcp_bootstrap(const struct ipcp_config * conf)
assert(conf);
assert(conf->type == THIS_TYPE);
- hash_algo = hton32((uint32_t) conf->dir_hash_algo);
+ hash_algo = hton32((uint32_t) conf->dif_info.dir_hash_algo);
assert(ntoh32(hash_algo) != 0);
@@ -311,32 +307,20 @@ static int normal_ipcp_bootstrap(const struct ipcp_config * conf)
}
if (rib_write(BOOT_PATH "/general/dif_name",
- conf->dif_name,
- strlen(conf->dif_name) + 1) ||
+ conf->dif_info.dif_name,
+ strlen(conf->dif_info.dif_name) + 1) ||
rib_write(BOOT_PATH "/general/dir_hash_algo",
&hash_algo,
sizeof(hash_algo)) ||
rib_write(BOOT_PATH "/dt/const/addr_size",
&conf->addr_size,
sizeof(conf->addr_size)) ||
- rib_write(BOOT_PATH "/dt/const/cep_id_size",
- &conf->cep_id_size,
- sizeof(conf->cep_id_size)) ||
- rib_write(BOOT_PATH "/dt/const/seqno_size",
- &conf->seqno_size,
- sizeof(conf->seqno_size)) ||
+ rib_write(BOOT_PATH "/dt/const/fd_size",
+ &conf->fd_size,
+ sizeof(conf->fd_size)) ||
rib_write(BOOT_PATH "/dt/const/has_ttl",
&conf->has_ttl,
sizeof(conf->has_ttl)) ||
- rib_write(BOOT_PATH "/dt/const/has_chk",
- &conf->has_chk,
- sizeof(conf->has_chk)) ||
- rib_write(BOOT_PATH "/dt/const/min_pdu_size",
- &conf->min_pdu_size,
- sizeof(conf->min_pdu_size)) ||
- rib_write(BOOT_PATH "/dt/const/max_pdu_size",
- &conf->max_pdu_size,
- sizeof(conf->max_pdu_size)) ||
rib_write(BOOT_PATH "/dt/gam/type",
&conf->dt_gam_type,
sizeof(conf->dt_gam_type)) ||
@@ -355,7 +339,7 @@ static int normal_ipcp_bootstrap(const struct ipcp_config * conf)
return -1;
}
- log_dbg("Bootstrapped in DIF %s.", conf->dif_name);
+ log_dbg("Bootstrapped in DIF %s.", conf->dif_info.dif_name);
return 0;
}
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 72889236..1696d0ad 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -758,7 +758,7 @@ static int eth_llc_ipcp_bootstrap(const struct ipcp_config * conf)
assert(conf);
assert(conf->type == THIS_TYPE);
- ipcpi.dir_hash_algo = conf->dir_hash_algo;
+ ipcpi.dir_hash_algo = conf->dif_info.dir_hash_algo;
if (conf->if_name == NULL) {
log_err("Interface name is NULL.");
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index a3e87b86..4ea0ad3d 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -534,7 +534,7 @@ static int ipcp_udp_bootstrap(const struct ipcp_config * conf)
assert(conf);
assert(conf->type == THIS_TYPE);
- ipcpi.dir_hash_algo = conf->dir_hash_algo;
+ ipcpi.dir_hash_algo = conf->dif_info.dir_hash_algo;
if (inet_ntop(AF_INET,
&conf->ip_addr,