From 91389ac2c28ae10f2b7f766e4dfe7a7fd96dc5e0 Mon Sep 17 00:00:00 2001 From: Marco Varlese Date: Wed, 31 Jan 2018 11:00:01 +0100 Subject: Out-of-order data chunks handling and more This patch addresses the need to handle out-of-order data chunks received by a peer. To do that effectively, we had to add the handling of data chunks flags (E/B/U bit) to understand whether the stream is fragmenting user-message data and in that case if a fragment is the FIRST/MIDDLE/LAST one of a transmission. The same patch also addresses the security requirement to have a HMAC calculated and incorporated in the INIT_ACK and COOKIE_ECHO chunks. The algorithm used is the HMAC-SHA1. Change-Id: Ib6a9a80492e2aafe5c8480d6e02da895efe9f90b Signed-off-by: Marco Varlese --- src/vnet/sctp/sctp.h | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/vnet/sctp/sctp.h') diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h index 3e3750ea92a..8f80d840c33 100644 --- a/src/vnet/sctp/sctp.h +++ b/src/vnet/sctp/sctp.h @@ -110,9 +110,25 @@ typedef struct } sctp_options_t; -#define SetBit(A,k) ( A[(k/32)] |= (1 << (k%32)) ) -#define ClearBit(A,k) ( A[(k/32)] &= ~(1 << (k%32)) ) -#define TestBit(A,k) ( A[(k/32)] & (1 << (k%32)) ) +/* Useful macros to deal with the out_of_order_map (array of bit) */ +#define SET_BIT(A,k) ( A[(k/32)] |= (1 << (k%32)) ) +#define CLEAR_BIT(A,k) ( A[(k/32)] &= ~(1 << (k%32)) ) +#define TEST_BIT(A,k) ( A[(k/32)] & (1 << (k%32)) ) + +always_inline void +_bytes_swap (void *pv, size_t n) +{ + char *p = pv; + size_t lo, hi; + for (lo = 0, hi = n - 1; hi > lo; lo++, hi--) + { + char tmp = p[lo]; + p[lo] = p[hi]; + p[hi] = tmp; + } +} + +#define ENDIANESS_SWAP(x) _bytes_swap(&x, sizeof(x)); #define MAX_INFLIGHT_PACKETS 128 #define MAX_ENQUEABLE_SACKS 2 @@ -182,6 +198,10 @@ typedef struct _sctp_connection u32 rtt_ts; u32 rtt_seq; + u8 overall_sending_status; /**< 0 indicates first fragment of a user message + 1 indicates normal stream + 2 indicates last fragment of a user message */ + sctp_options_t rcv_opts; sctp_options_t snd_opts; -- cgit 1.2.3-korg