summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2022-03-06 15:15:51 +0100
committerSander Vrijders <sander@ouroboros.rocks>2022-03-08 17:40:17 +0100
commit40ca5385e97f393d0c231446f117ad43465735a7 (patch)
tree019bfcefe5899c545403648807372d7b2e97ee73 /src/lib/dev.c
parent22526848c5a7b48f8b45988bdfbc6e0ce7a9f712 (diff)
downloadouroboros-40ca5385e97f393d0c231446f117ad43465735a7.tar.gz
ouroboros-40ca5385e97f393d0c231446f117ad43465735a7.zip
ipdpd: Pass MPL to application at flow_allocation
The maximum packet lifetime (MPL) is a property of the flow that needs to be passed to the reliable transmission protocol (FRCP) for its correct operation. Previously, the value of MPL was set fixed as one of the (fixed) Delta-t parameters. This patch makes the MPL a property of the layer, and it can now be set per layer-type at build time. This is a step towards a proper MPL estimator in the flow allocator. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 2e61df52..5f6a3694 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -574,6 +574,7 @@ int flow_accept(qosspec_t * qs,
uint8_t buf[MSGBUFSZ];
int err = -EIRMD;
ssize_t key_len;
+ time_t mpl;
memset(s, 0, SYMMKEYSZ);
@@ -617,7 +618,7 @@ int flow_accept(qosspec_t * qs,
}
if (!recv_msg->has_pid || !recv_msg->has_flow_id ||
- recv_msg->qosspec == NULL)
+ !recv_msg->has_mpl || recv_msg->qosspec == NULL)
goto fail_result;
if (recv_msg->pk.len != 0 &&
@@ -632,6 +633,8 @@ int flow_accept(qosspec_t * qs,
fd = flow_init(recv_msg->flow_id, recv_msg->pid,
msg_to_spec(recv_msg->qosspec), s);
+ mpl = recv_msg->mpl;
+
irm_msg__free_unpacked(recv_msg, NULL);
if (fd < 0)
@@ -642,7 +645,7 @@ int flow_accept(qosspec_t * qs,
assert(ai.flows[fd].frcti == NULL);
if (ai.flows[fd].qs.in_order != 0) {
- ai.flows[fd].frcti = frcti_create(fd, DELT_A, DELT_R, DELT_MPL);
+ ai.flows[fd].frcti = frcti_create(fd, DELT_A, DELT_R, mpl);
if (ai.flows[fd].frcti == NULL) {
pthread_rwlock_unlock(&ai.lock);
flow_dealloc(fd);
@@ -678,6 +681,7 @@ static int __flow_alloc(const char * dst,
uint8_t s[SYMMKEYSZ]; /* secret key for flow */
uint8_t buf[MSGBUFSZ];
int err = -EIRMD;
+ time_t mpl;
memset(s, 0, SYMMKEYSZ);
@@ -726,7 +730,8 @@ static int __flow_alloc(const char * dst,
goto fail_result;
}
- if (!recv_msg->has_pid || !recv_msg->has_flow_id)
+ if (!recv_msg->has_pid || !recv_msg->has_flow_id ||
+ !recv_msg->has_mpl)
goto fail_result;
if (!join && qs != NULL && qs->cypher_s != 0) {
@@ -747,6 +752,8 @@ static int __flow_alloc(const char * dst,
fd = flow_init(recv_msg->flow_id, recv_msg->pid,
qs == NULL ? qos_raw : *qs, s);
+ mpl = recv_msg->mpl;
+
irm_msg__free_unpacked(recv_msg, NULL);
if (fd < 0)
@@ -757,7 +764,7 @@ static int __flow_alloc(const char * dst,
assert(ai.flows[fd].frcti == NULL);
if (ai.flows[fd].qs.in_order != 0) {
- ai.flows[fd].frcti = frcti_create(fd, DELT_A, DELT_R, DELT_MPL);
+ ai.flows[fd].frcti = frcti_create(fd, DELT_A, DELT_R, mpl);
if (ai.flows[fd].frcti == NULL) {
pthread_rwlock_unlock(&ai.lock);
flow_dealloc(fd);
@@ -1771,6 +1778,7 @@ int ipcp_create_r(int result)
int ipcp_flow_req_arr(const uint8_t * dst,
size_t len,
qosspec_t qs,
+ time_t mpl,
const void * data,
size_t dlen)
{
@@ -1789,6 +1797,8 @@ int ipcp_flow_req_arr(const uint8_t * dst,
msg.hash.data = (uint8_t *) dst;
qs_msg = spec_to_msg(&qs);
msg.qosspec = &qs_msg;
+ msg.has_mpl = true;
+ msg.mpl = mpl;
msg.has_pk = true;
msg.pk.data = (uint8_t *) data;
msg.pk.len = dlen;
@@ -1817,6 +1827,7 @@ int ipcp_flow_req_arr(const uint8_t * dst,
int ipcp_flow_alloc_reply(int fd,
int response,
+ time_t mpl,
const void * data,
size_t len)
{
@@ -1831,6 +1842,8 @@ int ipcp_flow_alloc_reply(int fd,
msg.has_pk = true;
msg.pk.data = (uint8_t *) data;
msg.pk.len = (uint32_t) len;
+ msg.has_mpl = true;
+ msg.mpl = mpl;
pthread_rwlock_rdlock(&ai.lock);