dhcp: drop the 16-bit swap on the 32-bit transaction id

The id was built and checked with HTONS(), which casts to 16 bits, so the
top half of the 32-bit transaction id was thrown away and the rest byte
swapped. The id is opaque: the client only has to receive its own value
back, so there is no byte order to honour and no reason to narrow it.

Assign and compare the field directly, so the full 32-bit id round-trips.
This commit is contained in:
d00f committed 2026-09-06 20:30:40 +02:00
1 parent dc5cbcda16
commit 97d44fbf4b
1 file changed
+2 -2
+2 -2
View File
@@ -94,7 +94,7 @@ void dhcp_prepare_request(void)
DHCP_P->hw_len = 6;
DHCP_P->hops = 0;
DHCP_P->tid = HTONS(dhcp_state.transaction_id);
DHCP_P->tid = dhcp_state.transaction_id;
DHCP_P->delay = HTONS(0);
DHCP_P->flags = 0;
// Clear fields client_ip to bootp_file
@@ -300,7 +300,7 @@ void parse_opts(void)
void parse_dhcp(void)
{
if (DHCP_P->tid != HTONS(dhcp_state.transaction_id))
if (DHCP_P->tid != dhcp_state.transaction_id)
return;
if (DHCP_P->cookie[0] != 0x63 || DHCP_P->cookie[1] != 0x82 || DHCP_P->cookie[2] != 0x53 || DHCP_P->cookie[3] != 0x63)
return;