|
|
|
@ -133,9 +133,8 @@ static void etcp_link_send_init(struct ETCP_LINK* link, uint8_t reset) { |
|
|
|
|
|
|
|
|
|
|
|
// padding
|
|
|
|
// padding
|
|
|
|
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize; |
|
|
|
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize; |
|
|
|
int s_max = (int)(link->mtu) - 3 - (int)SC_TAG_SIZE + (int)UDP_SC_HDR_SIZE - (int)SC_PUBKEY_ENC_SIZE; |
|
|
|
int s_max = (int)(link->mtu) - (int)SC_NONCE_SIZE - 3 - (int)SC_CRC32_SIZE - (int)SC_TAG_SIZE - (int)SC_PUBKEY_ENC_SIZE + (int)UDP_SC_HDR_SIZE; |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_REQ: mtu=%d s=%d s_max=%d offset=%zu", (int)link->mtu, s, s_max, offset); |
|
|
|
if (s > s_max) s = s_max; |
|
|
|
if (s > s_max) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_REQ capped s=%d -> %d", s, s_max); s = s_max; } |
|
|
|
|
|
|
|
if (s < 0) s = 0; |
|
|
|
if (s < 0) s = 0; |
|
|
|
|
|
|
|
|
|
|
|
int to_add=s-offset-UDP_HDR_SIZE - UDP_SC_HDR_SIZE; |
|
|
|
int to_add=s-offset-UDP_HDR_SIZE - UDP_SC_HDR_SIZE; |
|
|
|
@ -162,8 +161,6 @@ static void etcp_link_send_init(struct ETCP_LINK* link, uint8_t reset) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dgram->data_len = offset; |
|
|
|
dgram->data_len = offset; |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_REQ final: offset=%zu s=%d to_add=%d data_len=%d noenc=%d", |
|
|
|
|
|
|
|
offset, s, to_add, (int)dgram->data_len, (int)dgram->noencrypt_len); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "Sending INIT request to link, node_id=%016llx, retry=%d", (unsigned long long)node_id, link->init_retry_count); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "Sending INIT request to link, node_id=%016llx, retry=%d", (unsigned long long)node_id, link->init_retry_count); |
|
|
|
|
|
|
|
|
|
|
|
@ -1534,12 +1531,8 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { |
|
|
|
int xoffset=sizeof(*ack_repl_hdr); |
|
|
|
int xoffset=sizeof(*ack_repl_hdr); |
|
|
|
// padding
|
|
|
|
// padding
|
|
|
|
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize; |
|
|
|
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize; |
|
|
|
int s_max = (int)(link->mtu) - 3 - (int)SC_TAG_SIZE + (int)UDP_SC_HDR_SIZE; |
|
|
|
if (s > (int)(link->mtu)) s = (int)(link->mtu); |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_RESP: mtu=%d s=%d s_max=%d xoffset=%d", (int)link->mtu, s, s_max, xoffset); |
|
|
|
|
|
|
|
if (s > s_max) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_RESP capped s=%d -> %d", s, s_max); s = s_max; } |
|
|
|
|
|
|
|
if (s < 0) s = 0; |
|
|
|
if (s < 0) s = 0; |
|
|
|
// Remove old hardcoded caps
|
|
|
|
|
|
|
|
// if (s > 1472 + 26) s = 1472 + 26;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int to_add=s - xoffset - UDP_HDR_SIZE - UDP_SC_HDR_SIZE; |
|
|
|
int to_add=s - xoffset - UDP_HDR_SIZE - UDP_SC_HDR_SIZE; |
|
|
|
if (to_add<0) to_add=0; |
|
|
|
if (to_add<0) to_add=0; |
|
|
|
@ -1548,9 +1541,6 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { |
|
|
|
for (int i=0; i<to_add; i++) pkt->data[xoffset++]=rand();// fill pad
|
|
|
|
for (int i=0; i<to_add; i++) pkt->data[xoffset++]=rand();// fill pad
|
|
|
|
// padding end
|
|
|
|
// padding end
|
|
|
|
pkt->data_len=xoffset; |
|
|
|
pkt->data_len=xoffset; |
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "INIT_RESP final: xoffset=%d s=%d to_add=%d data_len=%d noenc=%d", |
|
|
|
|
|
|
|
xoffset, s, to_add, (int)pkt->data_len, (int)pkt->noencrypt_len); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "Sending INIT RESPONSE, link=%p, local_link_id=%d, remote_link_id=%d", link, link->local_link_id, link->remote_link_id); |
|
|
|
DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "Sending INIT RESPONSE, link=%p, local_link_id=%d, remote_link_id=%d", link, link->local_link_id, link->remote_link_id); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[ETCP DEBUG] Send INIT RESPONSE"); |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[ETCP DEBUG] Send INIT RESPONSE"); |
|
|
|
etcp_encrypt_send(pkt); |
|
|
|
etcp_encrypt_send(pkt); |
|
|
|
|