diff options
author | Uros Majstorovic <majstor@majstor.org> | 2017-08-26 21:59:08 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2017-08-26 21:59:08 +0200 |
commit | b83e58e21ea7dda57ddfda47bd1539d15abe687f (patch) | |
tree | 801339717059b1be494e872d90836b4e4564d462 /code/vconn | |
parent | e800e8df9fbe633d09a534ae07eb361833572f1a (diff) |
fragments and packet timestamp implemented
Diffstat (limited to 'code/vconn')
-rw-r--r-- | code/vconn/vconn.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/code/vconn/vconn.c b/code/vconn/vconn.c index c59aefb..4eebb62 100644 --- a/code/vconn/vconn.c +++ b/code/vconn/vconn.c @@ -70,7 +70,7 @@ static void vconn_destroy(ECPConnection *conn) { } static ssize_t _vconn_send_open(ECPConnection *conn, ECPTimerItem *ti) { - unsigned char payload[ECP_SIZE_PLD(0)]; + unsigned char payload[ECP_SIZE_PLD(0, 0)]; ecp_pld_set_type(payload, ECP_MTYPE_KGET_REQ); return ecp_pld_send_ll(conn, ti, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, payload, sizeof(payload)); @@ -185,9 +185,9 @@ static ssize_t vconn_handle_relay(ECPConnection *conn, ecp_seq_t seq, unsigned c if (conn_out == NULL) return ECP_ERR; - payload = msg - ECP_SIZE_MSG_HDR; + payload = msg - ECP_SIZE_PLD_HDR - 1; ecp_pld_set_type(payload, ECP_MTYPE_EXEC); - rv = ecp_pld_send(conn_out, payload, ECP_SIZE_MSG_HDR+size); + rv = ecp_pld_send(conn_out, payload, size + msg - payload); #ifdef ECP_WITH_PTHREAD pthread_mutex_lock(&conn_out->mutex); @@ -257,8 +257,8 @@ static void vlink_destroy(ECPConnection *conn) { static ssize_t _vlink_send_open(ECPConnection *conn, ECPTimerItem *ti) { ECPSocket *sock = conn->sock; ECPContext *ctx = sock->ctx; - unsigned char payload[ECP_SIZE_PLD(ECP_ECDH_SIZE_KEY+1)]; - unsigned char *buf = ecp_pld_get_buf(payload); + unsigned char payload[ECP_SIZE_PLD(ECP_ECDH_SIZE_KEY+1, 0)]; + unsigned char *buf = ecp_pld_get_buf(payload, 0); int rv = ECP_OK; // XXX server should verify perma_key @@ -347,9 +347,9 @@ static ssize_t vlink_handle_relay(ECPConnection *conn, ecp_seq_t seq, unsigned c if (conn == NULL) return ECP_ERR; - payload = msg - ECP_SIZE_MSG_HDR; + payload = msg - ECP_SIZE_PLD_HDR - 1; ecp_pld_set_type(payload, ECP_MTYPE_EXEC); - rv = ecp_pld_send(conn, payload, ECP_SIZE_MSG_HDR+size); + rv = ecp_pld_send(conn, payload, size + msg - payload); #ifdef ECP_WITH_PTHREAD pthread_mutex_lock(&conn->mutex); @@ -373,11 +373,11 @@ static ssize_t vconn_set_msg(ECPConnection *conn, unsigned char *pld_out, size_t unsigned char *buf = NULL; int rv; - if (pld_out_size < ECP_SIZE_MSG_HDR+2+2*ECP_ECDH_SIZE_KEY) return ECP_ERR; + if (pld_out_size < ECP_SIZE_PLD_HDR + 3 + 2 * ECP_ECDH_SIZE_KEY) return ECP_ERR; if (conn_next == NULL) return ECP_ERR; ecp_pld_set_type(pld_out, ECP_MTYPE_OPEN_REQ); - buf = ecp_pld_get_buf(pld_out); + buf = ecp_pld_get_buf(pld_out, 0); buf[0] = ECP_CTYPE_VCONN; rv = ecp_conn_dhkey_get_curr(conn_next, NULL, buf+1); @@ -386,12 +386,12 @@ static ssize_t vconn_set_msg(ECPConnection *conn, unsigned char *pld_out, size_t memcpy(buf+1+ECP_ECDH_SIZE_KEY, ctx->cr.dh_pub_get_buf(&conn_next->node.public), ECP_ECDH_SIZE_KEY); buf[1+2*ECP_ECDH_SIZE_KEY] = ECP_MTYPE_RELAY; - return ECP_SIZE_MSG_HDR+2+2*ECP_ECDH_SIZE_KEY; + return ECP_SIZE_PLD_HDR + 3 + 2 * ECP_ECDH_SIZE_KEY; } } ecp_pld_set_type(pld_out, ECP_MTYPE_RELAY); - return ECP_SIZE_MSG_HDR; + return ECP_SIZE_PLD_HDR + 1; } @@ -506,7 +506,7 @@ int ecp_vconn_init(ECPConnection *conn, ECPNode *conn_node, ECPVConnection vconn } static ssize_t _vconn_send_kget(ECPConnection *conn, ECPTimerItem *ti) { - unsigned char payload[ECP_SIZE_PLD(0)]; + unsigned char payload[ECP_SIZE_PLD(0, 0)]; ecp_pld_set_type(payload, ECP_MTYPE_KGET_REQ); return ecp_pld_send_ll(conn, ti, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, payload, sizeof(payload)); |