diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-08-16 21:21:33 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-08-16 21:21:33 +0200 |
commit | 8f44e2151cb3f91b220c4a3393a06068d0ee7302 (patch) | |
tree | 8320c304887ac9b0d922bc27b51330c084f34ee0 /code/core/rbuf.h | |
parent | 38e2385f5846860916f8880d818b3b024b8c7dd9 (diff) |
fixed rbuf; fixed error code for pthread_mitex_init
Diffstat (limited to 'code/core/rbuf.h')
-rw-r--r-- | code/core/rbuf.h | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/code/core/rbuf.h b/code/core/rbuf.h index 67ac8c9..b09b19c 100644 --- a/code/core/rbuf.h +++ b/code/core/rbuf.h @@ -1,26 +1,16 @@ -#define ECP_RBUF_FLAG_RECEIVED 0x01 -#define ECP_RBUF_FLAG_DELIVERED 0x02 -#define ECP_RBUF_FLAG_CCWAIT 0x04 +#define ECP_RBUF_FLAG_IN_RBUF 0x01 +#define ECP_RBUF_FLAG_IN_MSGQ 0x02 +#define ECP_RBUF_FLAG_DELIVERED 0x04 +#define ECP_RBUF_FLAG_CCWAIT 0x08 #define ECP_RBUF_FLAG_RELIABLE 0x01 #define ECP_RBUF_FLAG_MSGQ 0x02 -#define ECP_MTYPE_RBOPEN 0x04 -#define ECP_MTYPE_RBCLOSE 0x05 -#define ECP_MTYPE_RBFLUSH 0x06 -#define ECP_MTYPE_RBACK 0x07 +#define ECP_MTYPE_RBACK 0x04 +#define ECP_MTYPE_RBFLUSH 0x05 -#define ECP_MTYPE_RBOPEN_REQ (ECP_MTYPE_RBOPEN) -#define ECP_MTYPE_RBOPEN_REP (ECP_MTYPE_RBOPEN | ECP_MTYPE_FLAG_REP) -#define ECP_MTYPE_RBCLOSE_REQ (ECP_MTYPE_RBCLOSE) -#define ECP_MTYPE_RBCLOSE_REP (ECP_MTYPE_RBCLOSE | ECP_MTYPE_FLAG_REP) -#define ECP_MTYPE_RBFLUSH_REQ (ECP_MTYPE_RBFLUSH) -#define ECP_MTYPE_RBFLUSH_REP (ECP_MTYPE_RBFLUSH | ECP_MTYPE_FLAG_REP) - -#define ECP_ERR_RBUF_FLAG -100 -#define ECP_ERR_RBUF_IDX -101 -#define ECP_ERR_RBUF_DUP -102 -#define ECP_ERR_RBUF_FULL -103 +#define ECP_ERR_RBUF_DUP -100 +#define ECP_ERR_RBUF_FULL -101 typedef uint32_t ecp_ack_t; typedef uint32_t ecp_win_t; @@ -33,10 +23,12 @@ typedef uint32_t ecp_win_t; #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) +/* size must be power of 2 */ #define ECP_RBUF_IDX_MASK(idx, size) ((idx) & ((size) - 1)) -/* If size not 2^x: -#define ECP_RBUF_IDX_MASK(idx, size) ((idx) % (size)) -*/ + +#ifdef ECP_WITH_MSGQ +#include "msgq.h" +#endif typedef struct ECPRBMessage { unsigned char msg[ECP_MAX_PKT]; @@ -112,3 +104,5 @@ void ecp_conn_rbuf_send_destroy(struct ECPConnection *conn); int ecp_conn_rbuf_send_start(struct ECPConnection *conn); ssize_t ecp_conn_rbuf_send_store(struct ECPConnection *conn, ecp_seq_t seq, int idx, unsigned char *msg, size_t msg_size); +ssize_t ecp_rbuf_handle_ack(struct ECPConnection *conn, ecp_seq_t seq, unsigned char mtype, unsigned char *msg, ssize_t size); +ssize_t ecp_rbuf_handle_flush(struct ECPConnection *conn, ecp_seq_t seq, unsigned char mtype, unsigned char *msg, ssize_t size); |