From baa394af9a7b7b3d853265893088353e848c22f5 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Tue, 15 Apr 2014 20:54:35 -0400 Subject: [PATCH] UDP listen sockets should be requested with 'U' instead of 'u'. --- src/dhcp.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/dhcp.c b/src/dhcp.c index ac8b1a2..f0044e2 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -57,12 +57,9 @@ typedef enum { static int get_udp_unicast_socket(struct client_state_t *cs) { char buf[32]; - size_t buflen = 0; buf[0] = 'u'; - buflen += 1; - memcpy(buf + buflen, &cs->clientAddr, sizeof cs->clientAddr); - buflen += sizeof cs->clientAddr; - return request_sockd_fd(buf, buflen, NULL); + memcpy(buf + 1, &cs->clientAddr, sizeof cs->clientAddr); + return request_sockd_fd(buf, 1 + sizeof cs->clientAddr, NULL); } static int get_raw_broadcast_socket(void) @@ -70,12 +67,9 @@ static int get_raw_broadcast_socket(void) return request_sockd_fd("s", 1, NULL); } -static int get_udp_listen_socket(struct client_state_t *cs) +static int get_udp_listen_socket(void) { - char buf[32]; - buf[0] = 'u'; - memcpy(buf + 1, &cs->clientAddr, sizeof cs->clientAddr); - return request_sockd_fd(buf, 1 + sizeof cs->clientAddr, NULL); + return request_sockd_fd("U", 1, NULL); } static int get_raw_listen_socket(struct client_state_t *cs) @@ -369,7 +363,7 @@ static void change_listen_mode(struct client_state_t *cs, int new_mode) switch (cs->listenMode) { default: return; case LM_RAW: cs->listenFd = get_raw_listen_socket(cs); break; - case LM_COOKED: cs->listenFd = get_udp_listen_socket(cs); break; + case LM_COOKED: cs->listenFd = get_udp_listen_socket(); break; } if (cs->listenFd < 0) suicide("%s: FATAL: Couldn't listen on socket: %s",