From: Jouni Malinen Date: Fri, 30 Jan 2015 16:38:47 +0000 (+0200) Subject: dhcp_snoop: Make IPv4 addresses human readable in debug log X-Git-Tag: hostap_2_4~275 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a565e03086bf230ebb4e61592b703479445181be;p=thirdparty%2Fhostap.git dhcp_snoop: Make IPv4 addresses human readable in debug log Use standard numbers-and-dots format for IPv4 in debug logs instead of hexdump in two different byte orders. Signed-off-by: Jouni Malinen --- diff --git a/src/ap/dhcp_snoop.c b/src/ap/dhcp_snoop.c index a70602467..3a77225f3 100644 --- a/src/ap/dhcp_snoop.c +++ b/src/ap/dhcp_snoop.c @@ -42,6 +42,17 @@ struct bootp_pkt { static const u8 ic_bootp_cookie[] = { 99, 130, 83, 99 }; +static const char * ipaddr_str(u32 addr) +{ + static char buf[17]; + + os_snprintf(buf, sizeof(buf), "%u.%u.%u.%u", + (addr >> 24) & 0xff, (addr >> 16) & 0xff, + (addr >> 8) & 0xff, addr & 0xff); + return buf; +} + + static void handle_dhcp(void *ctx, const u8 *src_addr, const u8 *buf, size_t len) { @@ -109,16 +120,17 @@ static void handle_dhcp(void *ctx, const u8 *src_addr, const u8 *buf, return; wpa_printf(MSG_DEBUG, "dhcp_snoop: Found DHCPACK for " MACSTR - " @ IPv4 address %X/%d", - MAC2STR(sta->addr), ntohl(b->your_ip), prefixlen); + " @ IPv4 address %s/%d", + MAC2STR(sta->addr), ipaddr_str(ntohl(b->your_ip)), + prefixlen); if (sta->ipaddr == b->your_ip) return; if (sta->ipaddr != 0) { wpa_printf(MSG_DEBUG, - "dhcp_snoop: Removing IPv4 address %X from the ip neigh table", - sta->ipaddr); + "dhcp_snoop: Removing IPv4 address %s from the ip neigh table", + ipaddr_str(be_to_host32(sta->ipaddr))); hostapd_drv_br_delete_ip_neigh(hapd, 4, (u8 *) &sta->ipaddr); }