summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-09-06 10:29:02 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-09-07 13:58:21 +0200
commit2cf4f88fc8b957c15ae93a2eb3e56ebdb07a0381 (patch)
tree1b3bd39aa4b84132559cc8032024f44a1e9c8015 /src/ipcpd/normal
parentee2235c62cf0c51f7188fdeb6ac283c1e2ea0335 (diff)
downloadouroboros-2cf4f88fc8b957c15ae93a2eb3e56ebdb07a0381.tar.gz
ouroboros-2cf4f88fc8b957c15ae93a2eb3e56ebdb07a0381.zip
ipcpd: normal: Add operations to get and set the PCI
This adds the operations needed in the normal IPCP to get and set the Protocol Control Information. It allows to allocate or release space in the current DU. The struct pci can be serialized into newly allocate space. Vice versa, a struct pci can be deserialized given a DU. It allows for decreasing the TTL in the DU and for calculating the CRC32. The TTL and CRC32 can now be selected when creating a new DIF.
Diffstat (limited to 'src/ipcpd/normal')
-rw-r--r--src/ipcpd/normal/CMakeLists.txt6
-rw-r--r--src/ipcpd/normal/crc32.c83
-rw-r--r--src/ipcpd/normal/crc32.h30
-rw-r--r--src/ipcpd/normal/dt_const.h13
-rw-r--r--src/ipcpd/normal/frct.c8
-rw-r--r--src/ipcpd/normal/frct.h29
-rw-r--r--src/ipcpd/normal/ribmgr.c12
-rw-r--r--src/ipcpd/normal/shm_pci.c234
-rw-r--r--src/ipcpd/normal/shm_pci.h26
-rw-r--r--src/ipcpd/normal/static_info.proto4
10 files changed, 318 insertions, 127 deletions
diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt
index 68dca4b3..654bb127 100644
--- a/src/ipcpd/normal/CMakeLists.txt
+++ b/src/ipcpd/normal/CMakeLists.txt
@@ -22,12 +22,14 @@ protobuf_generate_c(FLOW_ALLOC_SRCS FLOW_ALLOC_HDRS
set(SOURCE_FILES
# Add source files here
- main.c
+ cdap_request.c
+ crc32.c
fmgr.c
frct.c
- cdap_request.c
+ main.c
ribmgr.c
rmt.c
+ shm_pci.c
)
add_executable (ipcpd-normal ${SOURCE_FILES} ${IPCP_SOURCES}
diff --git a/src/ipcpd/normal/crc32.c b/src/ipcpd/normal/crc32.c
new file mode 100644
index 00000000..ad3e2b35
--- /dev/null
+++ b/src/ipcpd/normal/crc32.c
@@ -0,0 +1,83 @@
+/*
+ * Ouroboros - Copyright (C) 2016
+ *
+ * 32-bit Cyclic Redundancy Check
+ *
+ * Sander Vrijders <sander.vrijders@intec.ugent.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 <stddef.h>
+
+#include "crc32.h"
+
+static const uint32_t crc32_table[256] = {
+ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
+ 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
+ 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
+ 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
+ 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
+ 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+ 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
+ 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
+ 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
+ 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
+ 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
+ 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
+ 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
+ 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
+ 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
+ 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+ 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
+ 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
+ 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
+ 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
+ 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
+ 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
+ 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
+ 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
+ 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
+ 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+ 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
+ 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
+ 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
+ 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
+ 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
+ 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
+ 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
+ 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
+ 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
+ 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+ 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
+ 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
+ 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
+ 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
+ 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
+ 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
+ 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
+};
+
+void crc32(uint32_t * crc, const uint8_t * buf, size_t len)
+{
+ size_t n;
+
+ *crc = *crc ^ 0xffffffff;
+
+ for (n = 0; n < len; n++)
+ *crc = crc32_table[(*crc ^ buf[n]) & 0xff] ^ (*crc >> 8);
+
+ *crc = *crc ^ 0xffffffff;
+}
diff --git a/src/ipcpd/normal/crc32.h b/src/ipcpd/normal/crc32.h
new file mode 100644
index 00000000..f22bbc19
--- /dev/null
+++ b/src/ipcpd/normal/crc32.h
@@ -0,0 +1,30 @@
+/*
+ * Ouroboros - Copyright (C) 2016
+ *
+ * 32-bit Cyclic Redundancy Check
+ *
+ * Sander Vrijders <sander.vrijders@intec.ugent.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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_IPCP_CRC32_H
+#define OUROBOROS_IPCP_CRC32_H
+
+#include <stdint.h>
+
+void crc32(uint32_t * crc, const uint8_t * buf, size_t len);
+
+#endif /* OUROBOROS_IPCP_CRC32_H */
diff --git a/src/ipcpd/normal/dt_const.h b/src/ipcpd/normal/dt_const.h
index b33f16c5..eda66838 100644
--- a/src/ipcpd/normal/dt_const.h
+++ b/src/ipcpd/normal/dt_const.h
@@ -25,14 +25,15 @@
#define IPCP_DT_CONST_H
#include <stdint.h>
+#include <stdbool.h>
struct dt_const {
- uint8_t addr_size;
- uint8_t cep_id_size;
- uint8_t pdu_length_size;
- uint8_t seqno_size;
- uint8_t ttl_size;
- uint8_t chk_size;
+ uint8_t addr_size;
+ uint8_t cep_id_size;
+ uint8_t pdu_length_size;
+ uint8_t seqno_size;
+ bool has_ttl;
+ bool has_chk;
uint32_t min_pdu_size;
uint32_t max_pdu_size;
};
diff --git a/src/ipcpd/normal/frct.c b/src/ipcpd/normal/frct.c
index 7c2eba61..417815b7 100644
--- a/src/ipcpd/normal/frct.c
+++ b/src/ipcpd/normal/frct.c
@@ -126,6 +126,14 @@ int frct_fini()
return 0;
}
+struct dt_const * frct_dt_const()
+{
+ if (frct == NULL)
+ return NULL;
+
+ return frct->dtc;
+}
+
int frct_dt_flow(int fd,
enum qos_cube qos)
{
diff --git a/src/ipcpd/normal/frct.h b/src/ipcpd/normal/frct.h
index 91b2dfc7..09873445 100644
--- a/src/ipcpd/normal/frct.h
+++ b/src/ipcpd/normal/frct.h
@@ -30,26 +30,29 @@
struct frct_i;
-int frct_init(struct dt_const * dtc,
- uint32_t address);
-int frct_fini();
+int frct_init(struct dt_const * dtc,
+ uint32_t address);
+int frct_fini();
+
+struct dt_const * frct_dt_const();
+
+int frct_dt_flow(int fd,
+ enum qos_cube qos);
-int frct_dt_flow(int fd,
- enum qos_cube qos);
/*
* FIXME: Will take the index in the DU map,
* possibly cep-ids and address
*/
-int frct_rmt_post();
+int frct_rmt_post();
-struct frct_i * frct_i_create(uint32_t address,
- buffer_t * buf,
- enum qos_cube cube);
+struct frct_i * frct_i_create(uint32_t address,
+ buffer_t * buf,
+ enum qos_cube cube);
/* FIXME: Hand QoS cube here too? We received it in the flow alloc message. */
-int frct_i_accept(struct frct_i * instance,
- buffer_t * buf);
-int frct_i_destroy(struct frct_i * instance,
- buffer_t * buf);
+int frct_i_accept(struct frct_i * instance,
+ buffer_t * buf);
+int frct_i_destroy(struct frct_i * instance,
+ buffer_t * buf);
/* FIXME: Add read/write ops for frct instances */
diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c
index 007361fd..9733abc9 100644
--- a/src/ipcpd/normal/ribmgr.c
+++ b/src/ipcpd/normal/ribmgr.c
@@ -241,8 +241,8 @@ int ribmgr_cdap_write(struct cdap * instance,
rib->dtc.cep_id_size = msg->cep_id_size;
rib->dtc.pdu_length_size = msg->pdu_length_size;
rib->dtc.seqno_size = msg->seqno_size;
- rib->dtc.ttl_size = msg->ttl_size;
- rib->dtc.chk_size = msg->chk_size;
+ rib->dtc.has_ttl = msg->has_ttl;
+ rib->dtc.has_chk = msg->has_chk;
rib->dtc.min_pdu_size = msg->min_pdu_size;
rib->dtc.max_pdu_size = msg->max_pdu_size;
@@ -318,8 +318,8 @@ int ribmgr_cdap_start(struct cdap * instance,
stat_info.cep_id_size = rib->dtc.cep_id_size;
stat_info.pdu_length_size = rib->dtc.pdu_length_size;
stat_info.seqno_size = rib->dtc.seqno_size;
- stat_info.ttl_size = rib->dtc.ttl_size;
- stat_info.chk_size = rib->dtc.chk_size;
+ stat_info.has_ttl = rib->dtc.has_ttl;
+ stat_info.has_chk = rib->dtc.has_chk;
stat_info.min_pdu_size = rib->dtc.min_pdu_size;
stat_info.max_pdu_size = rib->dtc.max_pdu_size;
@@ -529,8 +529,8 @@ int ribmgr_bootstrap(struct dif_config * conf)
rib->dtc.cep_id_size = conf->cep_id_size;
rib->dtc.pdu_length_size = conf->pdu_length_size;
rib->dtc.seqno_size = conf->seqno_size;
- rib->dtc.ttl_size = conf->ttl_size;
- rib->dtc.chk_size = conf->chk_size;
+ rib->dtc.has_ttl = conf->has_ttl;
+ rib->dtc.has_chk = conf->has_chk;
rib->dtc.min_pdu_size = conf->min_pdu_size;
rib->dtc.max_pdu_size = conf->max_pdu_size;
diff --git a/src/ipcpd/normal/shm_pci.c b/src/ipcpd/normal/shm_pci.c
index 144bd15e..94629790 100644
--- a/src/ipcpd/normal/shm_pci.c
+++ b/src/ipcpd/normal/shm_pci.c
@@ -21,127 +21,183 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include <ourboros/errno.h>
-
-#include "shm_pci.h"
-#include <stdlib.h>
-
-#define SHM_PCI_HEAD_SIZE(a, b) a.addr_size * 2 + \
- a.cep_id_size * 2 + \
- a.pdu_length_size + \
- b.ttl_size + \
- a.seqno_size + \
- a.qos_id_size
-#define SHM_PCI_TAIL_SIZE(b) b.chk_size
-
#define OUROBOROS_PREFIX "ipcpd/shm_pci"
#include <ouroboros/logs.h>
+#include <ouroboros/errno.h>
-struct shm_pci {
- /* head */
- uint8_t * dst_addr;
- uint8_t * src_addr;
- uint8_t * dst_cep_id;
- uint8_t * src_cep_id;
- uint8_t * pdu_length;
- uint8_t * ttl;
- uint8_t * seqno;
- uint8_t * qos_id;
+#include <stdlib.h>
+#include <string.h>
- uint8_t * chk;
+#include "shm_pci.h"
+#include "frct.h"
+#include "crc32.h"
- struct shm_du_buff * dub;
+#define QOS_ID_SIZE 1
+#define DEFAULT_TTL 60
+#define TTL_SIZE 1
+#define CHK_SIZE 4
- struct ipcp_dtp_const dtpc;
- struct ipcp_dup_const dupc;
+static int shm_pci_head_size(struct dt_const * dtc)
+{
+ int len = 0;
-};
+ len = dtc->addr_size * 2 + dtc->cep_id_size * 2
+ + dtc->pdu_length_size + dtc->seqno_size
+ + QOS_ID_SIZE;
-shm_pci_t * shm_pci_create(struct shm_du_buff * dub,
- const struct ipcp_dtp_const * dtpc,
- const struct ipcp_dup_const * dupc)
+ if (dtc->has_ttl)
+ len += TTL_SIZE;
+
+ return len;
+}
+
+static int shm_pci_tail_size(struct dt_const * dtc)
{
- struct shm_pci * p;
+ return dtc->has_chk ? CHK_SIZE : 0;
+}
- if (dub == NULL) {
- LOG_DBGF("Bogus input. Bugging out.");
- return NULL;
+int shm_pci_ser(struct shm_du_buff * sdb,
+ struct pci * pci)
+{
+ uint8_t * head;
+ uint8_t * tail;
+ int offset = 0;
+ struct dt_const * dtc;
+ uint8_t ttl = DEFAULT_TTL;
+
+ dtc = frct_dt_const();
+ if (dtc == NULL)
+ return -1;
+
+ head = shm_du_buff_head_alloc(sdb, shm_pci_head_size(dtc));
+ if (head == NULL)
+ return -1;
+
+ memcpy(head, &pci->dst_addr, dtc->addr_size);
+ offset += dtc->addr_size;
+ memcpy(head + offset, &pci->src_addr, dtc->addr_size);
+ offset += dtc->addr_size;
+ memcpy(head + offset, &pci->dst_cep_id, dtc->cep_id_size);
+ offset += dtc->cep_id_size;
+ memcpy(head + offset, &pci->src_cep_id, dtc->cep_id_size);
+ offset += dtc->cep_id_size;
+ memcpy(head + offset, &pci->pdu_length, dtc->pdu_length_size);
+ offset += dtc->pdu_length_size;
+ memcpy(head + offset, &pci->seqno, dtc->seqno_size);
+ offset += dtc->seqno_size;
+ memcpy(head + offset, &pci->qos_id, QOS_ID_SIZE);
+ offset += QOS_ID_SIZE;
+ if (dtc->has_ttl)
+ memcpy(head + offset, &ttl, TTL_SIZE);
+
+ if (dtc->has_chk) {
+ tail = shm_du_buff_tail_alloc(sdb, shm_pci_tail_size(dtc));
+ if (tail == NULL) {
+ shm_du_buff_head_release(sdb, shm_pci_tail_size(dtc));
+ return -1;
+ }
+
+ crc32((uint32_t *) tail, head, tail - head);
}
- p = malloc(sizeof *p);
+ return 0;
+}
- if (p == NULL)
- return NULL;
+struct pci * shm_pci_des(struct shm_du_buff * sdb)
+{
+ uint8_t * head;
+ struct pci * pci;
+ int offset = 0;
+ struct dt_const * dtc;
- p->dub = dub;
+ head = shm_du_buff_head(sdb);
+ if (head == NULL)
+ return NULL;
- p->dtpc = *dtpc;
- p->dupc = *dupc;
+ dtc = frct_dt_const();
+ if (dtc == NULL)
+ return NULL;
- p->dst_addr = NULL;
- p->src_addr = NULL;
- p->dst_cep_id = NULL;
- p->src_cep_id = NULL;
- p->pdu_length = NULL;
- p->ttl = NULL;
- p->seqno = NULL;
- p->qos_id = NULL;
- p->chk = NULL;
+ pci = malloc(sizeof(*pci));
+ if (pci == NULL)
+ return NULL;
- return p;
+ memcpy(&pci->dst_addr, head, dtc->addr_size);
+ offset += dtc->addr_size;
+ memcpy(&pci->src_addr, head + offset, dtc->addr_size);
+ offset += dtc->addr_size;
+ memcpy(&pci->dst_cep_id, head + offset, dtc->cep_id_size);
+ offset += dtc->cep_id_size;
+ memcpy(&pci->src_cep_id, head + offset, dtc->cep_id_size);
+ offset += dtc->cep_id_size;
+ memcpy(&pci->pdu_length, head + offset, dtc->pdu_length_size);
+ offset += dtc->pdu_length_size;
+ memcpy(&pci->seqno, head + offset, dtc->seqno_size);
+ offset += dtc->seqno_size;
+ memcpy(&pci->qos_id, head + offset, QOS_ID_SIZE);
+ offset += QOS_ID_SIZE;
+ if (dtc->has_ttl)
+ memcpy(&pci->ttl, head + offset, TTL_SIZE);
+
+ return pci;
}
-void shm_pci_destroy(shm_pci_t * pci)
+int shm_pci_shrink(struct shm_du_buff * sdb)
{
- free(pci);
-}
+ struct dt_const * dtc;
-int shm_pci_init(shm_pci_t * pci)
-{
- if (pci == NULL) {
- LOG_DBGF("Bogus input. Bugging out.");
- return -EINVAL;
- }
+ if (sdb == NULL)
+ return -1;
- uint8_t * pci_head = shm_du_buff_head_alloc(
- pci->dub, SHM_PCI_HEAD_SIZE(pci->dtpc, pci->dupc));
- uint8_t * pci_tail = shm_du_buff_tail_alloc(
- pci->dub, SHM_PCI_TAIL_SIZE(pci->dupc));
+ dtc = frct_dt_const();
+ if (dtc == NULL)
+ return -1;
- if (pci_head == NULL) {
- LOG_DBG("Failed to allocate space for PCI at head.");
- return -ENOBUFS;
+ if (shm_du_buff_head_release(sdb, shm_pci_head_size(dtc))) {
+ LOG_ERR("Failed to shrink head.");
+ return -1;
}
- if (pci_tail == NULL) {
- LOG_DBG("Failed to allocate space for PCI at tail.");
- return -ENOBUFS;
+ if (shm_du_buff_tail_release(sdb, shm_pci_tail_size(dtc))) {
+ LOG_ERR("Failed to shrink tail.");
+ return -1;
}
- pci->dst_addr = pci_head;
- pci->src_addr = (pci_head += pci->dtpc.addr_size);
- pci->dst_cep_id = (pci_head += pci->dtpc.addr_size);
- pci->src_cep_id = (pci_head += pci->dtpc.cep_id_size);
- pci->pdu_length = (pci_head += pci->dtpc.cep_id_size);
- pci->ttl = (pci_head += pci->dtpc.pdu_length_size);
- pci->seqno = (pci_head += pci->dupc.ttl_size);
- pci->qos_id = (pci_head += pci->dtpc.seqno_size);
-
- pci->chk = (pci_tail);
-
return 0;
}
-void shm_pci_release(shm_pci_t * pci)
+int shm_pci_dec_ttl(struct shm_du_buff * sdb)
{
- if (pci == NULL)
- return;
+ struct dt_const * dtc;
+ int offset = 0;
+ uint8_t * head;
+ uint8_t * tail;
- if (pci->dub == NULL)
- return;
+ dtc = frct_dt_const();
+ if (dtc == NULL)
+ return -1;
- shm_du_buff_head_release(pci->dub, SHM_PCI_HEAD_SIZE(pci->dtpc,
- pci->dupc));
- shm_du_buff_tail_release(pci->dub, SHM_PCI_TAIL_SIZE(pci->dupc));
+ if (dtc->has_ttl == false)
+ return 0;
+
+ offset = shm_pci_head_size(dtc) - 1;
+
+ head = shm_du_buff_head(sdb);
+ if (head == NULL)
+ return -1;
+
+ head[offset]--;
+
+ if (dtc->has_chk) {
+ tail = shm_du_buff_tail(sdb);
+ if (tail == NULL)
+ return -1;
+
+ tail -= CHK_SIZE;
+
+ crc32((uint32_t *) tail, head, tail - head);
+ }
+
+ return 0;
}
diff --git a/src/ipcpd/normal/shm_pci.h b/src/ipcpd/normal/shm_pci.h
index cb8dd5dd..aa9770b4 100644
--- a/src/ipcpd/normal/shm_pci.h
+++ b/src/ipcpd/normal/shm_pci.h
@@ -24,20 +24,28 @@
#ifndef OUROBOROS_IPCP_SHM_PCI_H
#define OUROBOROS_IPCP_SHM_PCI_H
-#include <ouroboros/shm_du_map.h>
+#include <ouroboros/shm_rdrbuff.h>
#include <dt_const.h>
-struct shm_pci;
+struct pci {
+ uint64_t dst_addr;
+ uint64_t src_addr;
+ uint32_t dst_cep_id;
+ uint32_t src_cep_id;
+ uint32_t pdu_length;
+ uint64_t seqno;
+ uint8_t qos_id;
+ uint8_t ttl;
+};
-typedef struct shm_pci shm_pci_t;
+int shm_pci_ser(struct shm_du_buff * sdb,
+ struct pci * pci);
-shm_pci_t * shm_pci_create(struct shm_du_buff * dub,
- const struct ipcp_dtp_const * dtpc,
- const struct ipcp_dup_const * dupc);
-void shm_pci_destroy(shm_pci_t * pci);
+struct pci * shm_pci_des(struct shm_du_buff * sdb);
-int shm_pci_init(shm_pci_t * pci);
-void shm_pci_release(shm_pci_t * pci);
+int shm_pci_shrink(struct shm_du_buff * sdb);
+
+int shm_pci_dec_ttl(struct shm_du_buff * sdb);
#endif /* OUROBOROS_IPCP_SHM_PCI_H */
diff --git a/src/ipcpd/normal/static_info.proto b/src/ipcpd/normal/static_info.proto
index 24b7994a..04824a38 100644
--- a/src/ipcpd/normal/static_info.proto
+++ b/src/ipcpd/normal/static_info.proto
@@ -3,8 +3,8 @@ message static_info_msg {
required uint32 cep_id_size = 2;
required uint32 pdu_length_size = 3;
required uint32 seqno_size = 4;
- required uint32 ttl_size = 5;
- required uint32 chk_size = 6;
+ required bool has_ttl = 5;
+ required bool has_chk = 6;
required uint32 min_pdu_size = 7;
required uint32 max_pdu_size = 8;
required uint32 address = 9;