fix: INIT padding cap computed from actual link MTU, not hardcoded 1472
Hardcoded 1472-46 cap exceeded link MTU=1460, causing 'packet too long' error on INIT handshake. Use link->mtu - UDP_HDR_SIZE - offset - 19 instead of fixed 1472.
This commit is contained in:
1 parent
aefa49bc1c
commit
85076df223
1 file changed
+3
-3
@@ -133,9 +133,9 @@ static void etcp_link_send_init(struct ETCP_LINK* link, uint8_t reset) {
|
||||
|
||||
// padding
|
||||
int s = rand() % (link->handshake_maxsize - link->handshake_minsize) + link->handshake_minsize;
|
||||
if (s > link->mtu - dgram->noencrypt_len) s = link->mtu - dgram->noencrypt_len;
|
||||
// Cap s: final encrypted = s + 46 for REQUEST (noencrypt=72)
|
||||
if (s > 1472 - 46) s = 1472 - 46; // s ≤ 1426
|
||||
int s_max = (int)(link->mtu - UDP_HDR_SIZE) - (int)offset - 19; // 19=3hdr+16tag-72unenc
|
||||
if (s > s_max) s = s_max;
|
||||
if (s < 0) s = 0;
|
||||
|
||||
int to_add=s-offset-UDP_HDR_SIZE - UDP_SC_HDR_SIZE;
|
||||
if (to_add<0) to_add=0;
|
||||
|
||||
Reference in new issue
Block a user