From c2da98a69fbafc85ebff9625db0845806b40c8cc Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 13 Dec 2021 11:03:23 +0000 Subject: [PATCH] Treat xid as a uint32_t in network byte order on the wire. Internally this doesn't matter since we only care about equality. This makes logging output comparable to tcpdump(8). Pointed out by joel@ OK claudio --- sbin/dhcpleased/engine.c | 6 +++--- sbin/dhcpleased/frontend.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/dhcpleased/engine.c b/sbin/dhcpleased/engine.c index 5b7ac0c5c4e..7c7cb458c4f 100644 --- a/sbin/dhcpleased/engine.c +++ b/sbin/dhcpleased/engine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: engine.c,v 1.31 2021/12/13 11:02:26 florian Exp $ */ +/* $OpenBSD: engine.c,v 1.32 2021/12/13 11:03:23 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -848,7 +848,7 @@ parse_dhcp(struct dhcpleased_iface *iface, struct imsg_dhcp *dhcp) return; } - if (dhcp_hdr->xid != iface->xid) + if (ntohl(dhcp_hdr->xid) != iface->xid) return; /* silently ignore wrong xid */ if (rem < sizeof(cookie)) @@ -1770,7 +1770,7 @@ log_dhcp_hdr(struct dhcp_hdr *dhcp_hdr) "Unknown", dhcp_hdr->htype); log_debug("dhcp_hdr hlen: %d", dhcp_hdr->hlen); log_debug("dhcp_hdr hops: %d", dhcp_hdr->hops); - log_debug("dhcp_hdr xid: 0x%x", dhcp_hdr->xid); + log_debug("dhcp_hdr xid: 0x%x", ntohl(dhcp_hdr->xid)); log_debug("dhcp_hdr secs: %u", dhcp_hdr->secs); log_debug("dhcp_hdr flags: 0x%x", dhcp_hdr->flags); log_debug("dhcp_hdr ciaddr: %s", inet_ntop(AF_INET, &dhcp_hdr->ciaddr, diff --git a/sbin/dhcpleased/frontend.c b/sbin/dhcpleased/frontend.c index 903d38083ac..90b6c20d7bd 100644 --- a/sbin/dhcpleased/frontend.c +++ b/sbin/dhcpleased/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.26 2021/12/13 11:02:26 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.27 2021/12/13 11:03:23 florian Exp $ */ /* * Copyright (c) 2017, 2021 Florian Obser @@ -935,7 +935,7 @@ build_packet(uint8_t message_type, char *if_name, uint32_t xid, hdr->htype = HTYPE_ETHER; hdr->hlen = 6; hdr->hops = 0; - hdr->xid = xid; + hdr->xid = htonl(xid); hdr->secs = 0; hdr->ciaddr = *ciaddr; memcpy(hdr->chaddr, hw_address, sizeof(*hw_address)); -- 2.20.1