fix(native): accept physical TCP header options
This commit is contained in:
parent
bc41cf02d9
commit
f0b069f850
4 changed files with 124 additions and 19 deletions
|
|
@ -104,7 +104,10 @@ def tcp_frame(
|
|||
sequence: int,
|
||||
acknowledgement: int,
|
||||
payload: bytes = b"",
|
||||
options: bytes = b"",
|
||||
) -> bytes:
|
||||
if len(options) % 4 or len(options) > 40:
|
||||
raise ValueError("TCP options must be 32-bit aligned and no more than 40 bytes")
|
||||
tcp = bytearray(
|
||||
struct.pack(
|
||||
"!HHIIBBHHH",
|
||||
|
|
@ -112,12 +115,13 @@ def tcp_frame(
|
|||
ANCHOR_PORT,
|
||||
sequence,
|
||||
acknowledgement,
|
||||
5 << 4,
|
||||
(5 + len(options) // 4) << 4,
|
||||
flags,
|
||||
16384,
|
||||
0,
|
||||
0,
|
||||
)
|
||||
+ options
|
||||
+ payload
|
||||
)
|
||||
pseudo = GATEWAY_IP + GUEST_IP + b"\0\x06" + struct.pack("!H", len(tcp))
|
||||
|
|
@ -228,6 +232,7 @@ def main() -> None:
|
|||
ANCHOR_CLIENT_SEQUENCE + 1,
|
||||
server_sequence + 1,
|
||||
request,
|
||||
options=b"\x01\x01\x08\x0a\xd8\x8d\xec\x56\x00\x00\x00\x01",
|
||||
),
|
||||
qemu,
|
||||
)
|
||||
|
|
@ -284,7 +289,18 @@ def main() -> None:
|
|||
and sequence == 6
|
||||
and not anchor_syn_sent
|
||||
):
|
||||
peer.sendto(tcp_frame(0x02, ANCHOR_CLIENT_SEQUENCE, 0), qemu)
|
||||
peer.sendto(
|
||||
tcp_frame(
|
||||
0x02,
|
||||
ANCHOR_CLIENT_SEQUENCE,
|
||||
0,
|
||||
options=(
|
||||
b"\x02\x04\x05\x90\x04\x02\x08\x0a"
|
||||
b"\xd8\x8d\xec\x56\x00\x00\x00\x00\x01\x03\x03\x07"
|
||||
),
|
||||
),
|
||||
qemu,
|
||||
)
|
||||
anchor_syn_sent = True
|
||||
|
||||
terminal = (
|
||||
|
|
|
|||
Loading…
Reference in a new issue