diff options
| author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-05-12 13:05:47 +0200 | 
|---|---|---|
| committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-05-15 12:06:09 +0200 | 
| commit | 9903b8a2f9a7dc8ebac6928dcf2d2b5593ea0615 (patch) | |
| tree | ea16469c2d8fbcb417ed89e0bbd550834d0602a6 /src/ipcpd/normal | |
| parent | b36acfd93b1dc16a153ca9b9077d113732accb4e (diff) | |
| download | ouroboros-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/normal')
| -rw-r--r-- | src/ipcpd/normal/dt.h | 6 | ||||
| -rw-r--r-- | src/ipcpd/normal/dt_pci.c | 70 | ||||
| -rw-r--r-- | src/ipcpd/normal/dt_pci.h | 23 | ||||
| -rw-r--r-- | src/ipcpd/normal/main.c | 34 | 
4 files changed, 58 insertions, 75 deletions
| 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;  } | 
