summaryrefslogtreecommitdiff
path: root/ecp/src
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/src')
-rw-r--r--ecp/src/ecp/core.c26
-rw-r--r--ecp/src/ecp/core.h28
-rw-r--r--ecp/src/ecp/dir/dir.c4
-rw-r--r--ecp/src/ecp/ext/frag.c4
-rw-r--r--ecp/src/ecp/ext/rbuf_recv.c4
-rw-r--r--ecp/src/ecp/ext/rbuf_send.c8
-rw-r--r--ecp/src/ecp/vconn/vconn.c4
7 files changed, 39 insertions, 39 deletions
diff --git a/ecp/src/ecp/core.c b/ecp/src/ecp/core.c
index 33debdb..64f6730 100644
--- a/ecp/src/ecp/core.c
+++ b/ecp/src/ecp/core.c
@@ -1709,8 +1709,8 @@ void ecp_err_handle(ECPConnection *conn, unsigned char mtype, int err) {
static ssize_t _send_ireq(ECPConnection *conn, ECPTimerItem *ti) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF_IREQ(ECP_SIZE_ZPAD_PLD, ECP_MTYPE_INIT_REQ, conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF_IREQ(ECP_SIZE_ZPAD_PLD, ECP_MTYPE_INIT_REQ, conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF_IREQ(ECP_SIZE_PLD(ECP_SIZE_ZPAD_PLD, ECP_MTYPE_INIT_REQ), conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF_IREQ(ECP_SIZE_PLD(ECP_SIZE_ZPAD_PLD, ECP_MTYPE_INIT_REQ), conn)];
unsigned char *msg;
ssize_t rv;
@@ -1814,8 +1814,8 @@ ssize_t ecp_send_init_rep(ECPSocket *sock, ECPConnection *parent, ecp_tr_addr_t
ECPBuffer packet;
ECPBuffer payload;
ECPPktMeta pkt_meta;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF_IREP(1+ECP_SIZE_ECDH_PUB+ECP_SIZE_ATAG, ECP_MTYPE_INIT_REP, parent)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF_IREP(1+ECP_SIZE_ECDH_PUB+ECP_SIZE_ATAG, ECP_MTYPE_INIT_REP, parent)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF_IREP(ECP_SIZE_PLD(1+ECP_SIZE_ECDH_PUB+ECP_SIZE_ATAG, ECP_MTYPE_INIT_REP), parent)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF_IREP(ECP_SIZE_PLD(1+ECP_SIZE_ECDH_PUB+ECP_SIZE_ATAG, ECP_MTYPE_INIT_REP), parent)];
unsigned char atag[ECP_SIZE_ATAG];
unsigned char *msg;
ecp_nonce_t nonce;
@@ -1931,8 +1931,8 @@ ssize_t ecp_write_open_req(ECPConnection *conn, ECPBuffer *payload) {
ssize_t ecp_send_open_req(ECPConnection *conn, unsigned char *cookie) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF_OREQ(ECP_SIZE_PLD(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ), conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF_OREQ(ECP_SIZE_PLD(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ), conn)];
ssize_t rv;
packet.buffer = pkt_buf;
@@ -2022,8 +2022,8 @@ ssize_t ecp_handle_open_req(ECPSocket *sock, ECPConnection *parent, unsigned cha
ssize_t ecp_send_open_rep(ECPConnection *conn) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(0, ECP_MTYPE_OPEN_REP, conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(0, ECP_MTYPE_OPEN_REP, conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(0, ECP_MTYPE_OPEN_REP), conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF(ECP_SIZE_PLD(0, ECP_MTYPE_OPEN_REP), conn)];
ssize_t rv;
packet.buffer = pkt_buf;
@@ -2135,8 +2135,8 @@ handle_open_fin:
static ssize_t _send_kxreq(ECPConnection *conn, ECPTimerItem *ti) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REQ, conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REQ, conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REQ), conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF(ECP_SIZE_PLD(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REQ), conn)];
unsigned char *msg;
ssize_t rv;
int _rv;
@@ -2171,8 +2171,8 @@ ssize_t ecp_send_keyx_req(ECPConnection *conn, int retry) {
ssize_t ecp_send_keyx_rep(ECPConnection *conn) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REP, conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REP, conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REP), conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF(ECP_SIZE_PLD(1+ECP_SIZE_ECDH_PUB, ECP_MTYPE_KEYX_REP), conn)];
unsigned char *msg;
ssize_t rv;
int _rv;
@@ -3026,7 +3026,7 @@ ssize_t ecp_msg_send(ECPConnection *conn, unsigned char mtype, unsigned char *ms
rv = ecp_ext_msg_send(conn, mtype, msg, msg_size, &packet, &payload);
if (rv) return rv;
- if (ECP_SIZE_PKT_BUF(msg_size, mtype, conn) <= ECP_MAX_PKT) {
+ if (ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(msg_size, mtype), conn) <= ECP_MAX_PKT) {
ecp_pld_set_type(pld_buf, ECP_MAX_PLD, mtype);
msg_buf = ecp_pld_get_msg(pld_buf, ECP_MAX_PLD);
diff --git a/ecp/src/ecp/core.h b/ecp/src/ecp/core.h
index 9e6a775..f0d6534 100644
--- a/ecp/src/ecp/core.h
+++ b/ecp/src/ecp/core.h
@@ -87,33 +87,33 @@
#define ECP_CONN_PCOUNT(C) ECP_MAX_PARENT
#ifdef ECP_WITH_VCONN
-#define ECP_SIZE_PLD_BUF(X,T,C) (ECP_SIZE_PLD(X,T)+ECP_CONN_PCOUNT(C)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG))
+#define ECP_SIZE_PLD_BUF(X,C) ((X)+ECP_CONN_PCOUNT(C)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG))
#else
-#define ECP_SIZE_PLD_BUF(X,T,C) (ECP_SIZE_PLD(X,T))
+#define ECP_SIZE_PLD_BUF(X,C) (X)
#endif
-#define ECP_SIZE_PKT_BUF(X,T,C) (ECP_SIZE_PKT_HDR+ECP_SIZE_PLD_BUF(X,T,C)+ECP_SIZE_AEAD_TAG)
+#define ECP_SIZE_PKT_BUF(X,C) (ECP_SIZE_PKT_HDR+ECP_SIZE_PLD_BUF(X,C)+ECP_SIZE_AEAD_TAG)
#ifdef ECP_WITH_VCONN
-#define ECP_SIZE_PLD_BUF_IREP(X,T,P) (ECP_SIZE_PLD(X,T)+((P) ? (ECP_CONN_PCOUNT(P)+1)*(ECP_SIZE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ECP_CONN_PCOUNT(C)*(ECP_SIZE_PKT_HDR+ECP_SIZE_MTYPE+ECP_SIZE_AEAD_TAG))
#else
-#define ECP_SIZE_PLD_BUF_OREQ(X,T,C) (ECP_SIZE_PLD(X,T))
-#define ECP_SIZE_PKT_BUF_OREQ(X,T,C) (ECP_SIZE_PKT_HDR_OREQ+ECP_SIZE_PLD(X,T)+ECP_SIZE_AEAD_TAG)
+#define ECP_SIZE_PLD_BUF_OREQ(X,C) (X)
+#define ECP_SIZE_PKT_BUF_OREQ(X,C) (ECP_SIZE_PKT_HDR_OREQ+(X)+ECP_SIZE_AEAD_TAG)
#endif
#ifdef ECP_WITH_VCONN
diff --git a/ecp/src/ecp/dir/dir.c b/ecp/src/ecp/dir/dir.c
index 47a43f2..e329054 100644
--- a/ecp/src/ecp/dir/dir.c
+++ b/ecp/src/ecp/dir/dir.c
@@ -91,8 +91,8 @@ int ecp_dir_handle_open(ECPConnection *conn, ECP2Buffer *b) {
static ssize_t _dir_send_req(ECPConnection *conn, ECPTimerItem *ti) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(0, ECP_MTYPE_DIR_REQ, conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(0, ECP_MTYPE_DIR_REQ, conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(0, ECP_MTYPE_DIR_REQ), conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF(ECP_SIZE_PLD(0, ECP_MTYPE_DIR_REQ), conn)];
packet.buffer = pkt_buf;
packet.size = sizeof(pkt_buf);
diff --git a/ecp/src/ecp/ext/frag.c b/ecp/src/ecp/ext/frag.c
index 8795470..f348da6 100644
--- a/ecp/src/ecp/ext/frag.c
+++ b/ecp/src/ecp/ext/frag.c
@@ -81,7 +81,7 @@ ssize_t ecp_msg_send_wfrag(ECPConnection *conn, unsigned char mtype, unsigned ch
int i;
mtype |= ECP_MTYPE_FLAG_FRAG;
- frag_size = ECP_MAX_PKT - ECP_SIZE_PKT_BUF(0, mtype, conn);
+ frag_size = ECP_MAX_PKT - ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(0, mtype), conn);
pkt_cnt = msg_size / frag_size;
frag_size_final = msg_size - frag_size * pkt_cnt;
if (frag_size_final) pkt_cnt++;
@@ -135,7 +135,7 @@ ssize_t ecp_ext_pld_handle_one(ECPConnection *conn, ecp_seq_t seq, unsigned char
}
ssize_t ecp_ext_msg_send(ECPConnection *conn, unsigned char mtype, unsigned char *msg, size_t msg_size, ECPBuffer *packet, ECPBuffer *payload) {
- if (ECP_SIZE_PKT_BUF(msg_size, mtype, conn) > ECP_MAX_PKT) {
+ if (ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(msg_size, mtype), conn) > ECP_MAX_PKT) {
return ecp_msg_send_wfrag(conn, mtype, msg, msg_size, packet, payload);
} else {
return 0;
diff --git a/ecp/src/ecp/ext/rbuf_recv.c b/ecp/src/ecp/ext/rbuf_recv.c
index b981e3f..1282a78 100644
--- a/ecp/src/ecp/ext/rbuf_recv.c
+++ b/ecp/src/ecp/ext/rbuf_recv.c
@@ -182,8 +182,8 @@ static int ack_send(ECPRBConn *conn, ecp_seq_t seq_ack, ecp_seq_t ack_map) {
ECPRBRecv *buf = conn->recv;
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBACK, _conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBACK, _conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBACK), _conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF(ECP_SIZE_PLD(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBACK), _conn)];
unsigned char *_buf;
ssize_t rv;
diff --git a/ecp/src/ecp/ext/rbuf_send.c b/ecp/src/ecp/ext/rbuf_send.c
index 40d526c..5716f92 100644
--- a/ecp/src/ecp/ext/rbuf_send.c
+++ b/ecp/src/ecp/ext/rbuf_send.c
@@ -57,8 +57,8 @@ static void cc_flush(ECPRBConn *conn, unsigned char flags) {
static ssize_t _rbuf_send_flush(ECPConnection *_conn, ECPTimerItem *ti) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(0, ECP_MTYPE_RBFLUSH, _conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(0, ECP_MTYPE_RBFLUSH, _conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(0, ECP_MTYPE_RBFLUSH), _conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF(ECP_SIZE_PLD(0, ECP_MTYPE_RBFLUSH), _conn)];
packet.buffer = pkt_buf;
packet.size = sizeof(pkt_buf);
@@ -170,8 +170,8 @@ ssize_t ecp_rbuf_handle_ack(ECPRBConn *conn, unsigned char *msg, size_t msg_size
if ((buf->flags & ECP_RBUF_FLAG_RELIABLE) && ack_map_nop) {
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBNOP, _conn)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBNOP, _conn)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF(ECP_SIZE_PLD(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBNOP), _conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF(ECP_SIZE_PLD(sizeof(ecp_seq_t) + sizeof(ecp_ack_t), ECP_MTYPE_RBNOP), _conn)];
unsigned char *_buf;
packet.buffer = pkt_buf;
diff --git a/ecp/src/ecp/vconn/vconn.c b/ecp/src/ecp/vconn/vconn.c
index 337c693..b1be561 100644
--- a/ecp/src/ecp/vconn/vconn.c
+++ b/ecp/src/ecp/vconn/vconn.c
@@ -343,8 +343,8 @@ ssize_t ecp_vconn_send_open_req(ECPConnection *conn, unsigned char *cookie) {
ECPDHPub key_next;
ECPBuffer packet;
ECPBuffer payload;
- unsigned char pkt_buf[ECP_SIZE_PKT_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT)];
- unsigned char pld_buf[ECP_SIZE_PLD_BUF_OREQ(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ, conn)+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT)];
+ unsigned char pkt_buf[ECP_SIZE_PKT_BUF_OREQ(ECP_SIZE_PLD(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ)+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT), conn)];
+ unsigned char pld_buf[ECP_SIZE_PLD_BUF_OREQ(ECP_SIZE_PLD(2+ECP_SIZE_VBOX, ECP_MTYPE_OPEN_REQ)+ECP_SIZE_PLD(ECP_SIZE_ECDH_PUB, ECP_MTYPE_NEXT), conn)];
unsigned char *msg;
unsigned char *_pld_buf;
size_t _pld_size;