diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-07-21 00:33:35 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-07-21 00:33:35 +0200 |
commit | d580fc0e00bf4b7acd3f9ee3345fad32223b40db (patch) | |
tree | f1b128e938ea37a437d1ec05686e5abc2b724238 /code/core/rbuf.h | |
parent | 50a392349a2e06ea5ff08e35cfb2558a1c97b993 (diff) |
send ring buffer implementation; not done
Diffstat (limited to 'code/core/rbuf.h')
-rw-r--r-- | code/core/rbuf.h | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/code/core/rbuf.h b/code/core/rbuf.h index 172f043..3577211 100644 --- a/code/core/rbuf.h +++ b/code/core/rbuf.h @@ -1,20 +1,27 @@ #define ECP_RBUF_FLAG_PRESENT 1 -#define ECP_RBUF_SEQ_LT(a,b) ((ecp_seq_t)((ecp_seq_t)(a) - (ecp_seq_t)(b)) > SEQ_HALF) -#define ECP_RBUF_SEQ_LTE(a,b) ((ecp_seq_t)((ecp_seq_t)(b) - (ecp_seq_t)(a)) < SEQ_HALF) - -#define ECP_RBUF_IDX_MASK(idx, size) ((idx) & ((size) - 1)) -/* If size not 2^x: -#define ECP_RBUF_IDX_MASK(idx, size) ((idx) % (size)) -*/ #define ECP_ERR_RBUF_FLAG -100 #define ECP_ERR_RBUF_IDX -101 #define ECP_ERR_RBUF_DUP -102 typedef uint32_t ecp_ack_t; +typedef uint32_t ecp_win_t; + +#define ECP_RBUF_SEQ_HALF ((ecp_seq_t)1 << (sizeof(ecp_seq_t)*8-1)) + +#define ECP_RBUF_ACK_FULL (~(ecp_ack_t)0) +#define ECP_RBUF_ACK_SIZE (sizeof(ecp_ack_t)*8) + +#define ECP_RBUF_SEQ_LT(a,b) ((ecp_seq_t)((ecp_seq_t)(a) - (ecp_seq_t)(b)) > ECP_RBUF_SEQ_HALF) +#define ECP_RBUF_SEQ_LTE(a,b) ((ecp_seq_t)((ecp_seq_t)(b) - (ecp_seq_t)(a)) < ECP_RBUF_SEQ_HALF) + +#define ECP_RBUF_IDX_MASK(idx, size) ((idx) & ((size) - 1)) +/* If size not 2^x: +#define ECP_RBUF_IDX_MASK(idx, size) ((idx) % (size)) +*/ typedef struct ECPRBMessage { - unsigned char msg[ECP_MAX_MSG]; + unsigned char msg[ECP_MAX_PKT]; ssize_t size; unsigned char flags; } ECPRBMessage; @@ -42,6 +49,9 @@ typedef struct ECPRBRecv { typedef struct ECPRBSend { unsigned char reliable; + ecp_win_t win_size; + ecp_win_t in_transit; + unsigned int nack_rate; ECPRBuffer rbuf; } ECPRBSend; |