From cbba099541d27400ad45083a4b1102b86f9e8dea Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Thu, 10 Aug 2017 21:02:16 +0200 Subject: rbuffer almost implemented --- code/proxy/proxy.c | 20 ++++++++------------ code/proxy/proxy.h | 3 ++- 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'code/proxy') diff --git a/code/proxy/proxy.c b/code/proxy/proxy.c index 67d4d01..e9cd93f 100644 --- a/code/proxy/proxy.c +++ b/code/proxy/proxy.c @@ -70,12 +70,11 @@ static ssize_t _proxyf_send_open(ECPConnection *conn) { ECPConnProxy *conn_p = (ECPConnProxy *)conn; ECPConnection *conn_next = conn_p->next; unsigned char payload[ECP_SIZE_PLD(0)]; - ecp_seq_t seq; if (conn_next == NULL) return ECP_ERR; ecp_pld_set_type(payload, ECP_MTYPE_KGET_REQ); - return ecp_pld_send_wkey(conn_next, &seq, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, payload, sizeof(payload)); + return ecp_pld_send_wkey(conn_next, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, payload, sizeof(payload)); } static ssize_t _proxyf_retry_kget(ECPConnection *conn, ECPTimerItem *ti) { @@ -363,37 +362,35 @@ static ssize_t proxy_set_msg(ECPConnection *conn, unsigned char *pld_out, size_t } -static ssize_t proxy_pack(ECPConnection *conn, ECPNetAddr *addr, ecp_seq_t *seq, unsigned char *packet, size_t pkt_size, unsigned char s_idx, unsigned char c_idx, unsigned char *payload, size_t payload_size) { +static ssize_t proxy_pack(ECPConnection *conn, unsigned char *packet, size_t pkt_size, unsigned char s_idx, unsigned char c_idx, unsigned char *payload, size_t payload_size, ECPNetAddr *addr, ecp_seq_t *seq, int *rbuf_idx) { ECPContext *ctx = conn->sock->ctx; if (conn->proxy) { unsigned char payload_[ECP_MAX_PLD]; - ecp_seq_t _seq; ssize_t rv, hdr_size = proxy_set_msg(conn->proxy, payload_, sizeof(payload_), payload, payload_size); if (hdr_size < 0) return hdr_size; - rv = ecp_conn_pack(conn, NULL, &_seq, payload_+hdr_size, ECP_MAX_PLD-hdr_size, s_idx, c_idx, payload, payload_size); + rv = ecp_conn_pack(conn, payload_+hdr_size, ECP_MAX_PLD-hdr_size, s_idx, c_idx, payload, payload_size, NULL, seq, rbuf_idx); if (rv < 0) return rv; - return proxy_pack(conn->proxy, addr, seq, packet, pkt_size, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, payload_, rv+hdr_size); + return proxy_pack(conn->proxy, packet, pkt_size, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, payload_, rv+hdr_size, addr, NULL, NULL); } else { - return ecp_conn_pack(conn, addr, seq, packet, pkt_size, s_idx, c_idx, payload, payload_size); + return ecp_conn_pack(conn, packet, pkt_size, s_idx, c_idx, payload, payload_size, addr, seq, rbuf_idx); } } -static ssize_t proxy_pack_raw(ECPSocket *sock, ECPConnection *proxy, ECPNetAddr *addr, unsigned char *packet, size_t pkt_size, unsigned char s_idx, unsigned char c_idx, ecp_dh_public_t *public, ecp_aead_key_t *shsec, unsigned char *nonce, ecp_seq_t seq, unsigned char *payload, size_t payload_size) { +static ssize_t proxy_pack_raw(ECPSocket *sock, ECPConnection *proxy, unsigned char *packet, size_t pkt_size, unsigned char s_idx, unsigned char c_idx, ecp_dh_public_t *public, ecp_aead_key_t *shsec, unsigned char *nonce, ecp_seq_t seq, unsigned char *payload, size_t payload_size, ECPNetAddr *addr) { ECPContext *ctx = sock->ctx; if (proxy) { unsigned char payload_[ECP_MAX_PLD]; - ecp_seq_t _seq; ssize_t rv, hdr_size = proxy_set_msg(proxy, payload_, sizeof(payload_), payload, payload_size); if (hdr_size < 0) return hdr_size; rv = ecp_pack(ctx, payload_+hdr_size, ECP_MAX_PLD-hdr_size, s_idx, c_idx, public, shsec, nonce, seq, payload, payload_size); if (rv < 0) return rv; - return proxy_pack(proxy, addr, &_seq, packet, pkt_size, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, payload_, rv+hdr_size); + return proxy_pack(proxy, packet, pkt_size, ECP_ECDH_IDX_INV, ECP_ECDH_IDX_INV, payload_, rv+hdr_size, addr, NULL, NULL); } else { return ecp_pack(ctx, packet, pkt_size, s_idx, c_idx, public, shsec, nonce, seq, payload, payload_size); } @@ -472,10 +469,9 @@ int ecp_conn_proxy_init(ECPConnection *conn, ECPNode *conn_node, ECPConnProxy pr static ssize_t _proxy_send_kget(ECPConnection *conn, ECPTimerItem *ti) { unsigned char payload[ECP_SIZE_PLD(0)]; - ecp_seq_t seq; ecp_pld_set_type(payload, ECP_MTYPE_KGET_REQ); - return ecp_pld_send_wkey(conn, &seq, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, payload, sizeof(payload)); + return ecp_pld_send_wkey(conn, ECP_ECDH_IDX_PERMA, ECP_ECDH_IDX_INV, payload, sizeof(payload)); } int ecp_conn_proxy_open(ECPConnection *conn, ECPNode *conn_node, ECPConnProxy proxy[], ECPNode proxy_node[], int size) { diff --git a/code/proxy/proxy.h b/code/proxy/proxy.h index 1ae2566..6f82cd2 100644 --- a/code/proxy/proxy.h +++ b/code/proxy/proxy.h @@ -1,7 +1,8 @@ #define ECP_CTYPE_PROXYF 1 #define ECP_CTYPE_PROXYB 2 -#define ECP_MTYPE_RELAY 0x04 +#define ECP_MTYPE_RELAY 0x08 +#define ECP_MTYPE_EXEC 0x09 typedef struct ECPConnProxy { ECPConnection b; -- cgit v1.2.3