summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/dt_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipcpd/normal/dt_pci.c')
-rw-r--r--src/ipcpd/normal/dt_pci.c59
1 files changed, 25 insertions, 34 deletions
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)