From 89805fb092fa5509c52bbbaefa2c06aa248b44d6 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 5 Feb 2024 01:24:45 +0200 Subject: [PATCH] dhcp-client: Use dprintln for debug printing --- userspace/dhcp-client/main.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/userspace/dhcp-client/main.cpp b/userspace/dhcp-client/main.cpp index cbc8ff3828..b781c3d6d4 100644 --- a/userspace/dhcp-client/main.cpp +++ b/userspace/dhcp-client/main.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -12,7 +13,7 @@ #include #include -#define DEBUG_DHCP 0 +#define DEBUG_DHCP 1 struct DHCPPacket { @@ -304,12 +305,12 @@ int main() auto mac_address = get_mac_address(socket); #if DEBUG_DHCP - BAN::Formatter::println(putchar, "MAC: {}", mac_address); + dprintln("MAC: {}", mac_address); #endif send_dhcp_discover(socket, mac_address); #if DEBUG_DHCP - printf("DHCPDISCOVER sent\n"); + dprintln("DHCPDISCOVER sent"); #endif auto dhcp_offer = read_dhcp_packet(socket); @@ -322,15 +323,15 @@ int main() } #if DEBUG_DHCP - BAN::Formatter::println(putchar, "DHCPOFFER"); - BAN::Formatter::println(putchar, " IP {}", dhcp_offer->address); - BAN::Formatter::println(putchar, " SUBNET {}", dhcp_offer->subnet); - BAN::Formatter::println(putchar, " SERVER {}", dhcp_offer->server); + dprintln("DHCPOFFER"); + dprintln(" IP {}", dhcp_offer->address); + dprintln(" SUBNET {}", dhcp_offer->subnet); + dprintln(" SERVER {}", dhcp_offer->server); #endif send_dhcp_request(socket, mac_address, dhcp_offer->address, dhcp_offer->server); #if DEBUG_DHCP - printf("DHCPREQUEST sent\n"); + dprintln("DHCPREQUEST sent"); #endif auto dhcp_ack = read_dhcp_packet(socket); @@ -343,10 +344,10 @@ int main() } #if DEBUG_DHCP - BAN::Formatter::println(putchar, "DHCPACK"); - BAN::Formatter::println(putchar, " IP {}", dhcp_ack->address); - BAN::Formatter::println(putchar, " SUBNET {}", dhcp_ack->subnet); - BAN::Formatter::println(putchar, " SERVER {}", dhcp_ack->server); + dprintln("DHCPACK"); + dprintln(" IP {}", dhcp_ack->address); + dprintln(" SUBNET {}", dhcp_ack->subnet); + dprintln(" SERVER {}", dhcp_ack->server); #endif if (dhcp_offer->address != dhcp_ack->address)