From f851084c96e0a932e51c15ad9551e2cd85362147 Mon Sep 17 00:00:00 2001 From: Stas Sergeev Date: Tue, 3 Oct 2023 13:01:22 +0500 Subject: dhcp: put option 53 at the beginning ... unless it is listed in 55. Many clients expect option 53 at the beginning. mTCP has this code: if ( resp->options[0] != 53 ) { TRACE_WARN(( "Dhcp: first option was not a Dhcp msg type\n" )); return; } wattcp32 has this: static int DHCP_is_ack (void) { const BYTE *opt = (const BYTE*) &dhcp_in.dh_opt[4]; return (opt[0] == DHCP_OPT_MSG_TYPE && opt[1] == 1 && opt[2] == DHCP_ACK); } static int DHCP_is_nack (void) { const BYTE *opt = (const BYTE*) &dhcp_in.dh_opt[4]; return (opt[0] == DHCP_OPT_MSG_TYPE && opt[1] == 1 && opt[2] == DHCP_NAK); } Link: https://bugs.passt.top/show_bug.cgi?id=77 Signed-off-by: Stas Sergeev [sbrivio: s/options 53/option 53/ and s/other/others/ in comment] Signed-off-by: Stefano Brivio --- dhcp.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'dhcp.c') diff --git a/dhcp.c b/dhcp.c index 46c258e..53b4029 100644 --- a/dhcp.c +++ b/dhcp.c @@ -149,6 +149,13 @@ static int fill(struct msg *m) for (o = 0; o < 255; o++) opts[o].sent = 0; + /* Some clients (wattcp32, mTCP, maybe some others) expect + * option 53 at the beginning of the list. + * Put it there explicitly, unless requested via option 55. + */ + if (!memchr(opts[55].c, 53, opts[55].clen)) + fill_one(m, 53, &offset); + for (i = 0; i < opts[55].clen; i++) { o = opts[55].c[i]; if (opts[o].slen) -- cgit v1.2.3