From: Hans Dedecker Date: Sat, 26 Dec 2020 20:38:49 +0000 (+0100) Subject: dhcpv6: display status code as a string X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0475e18804dfd9f5601511b6ffc2556efa5a68a7;p=project%2Fodhcp6c.git dhcpv6: display status code as a string For better readibility display the returned status code from the DHCPv6 server as a string Signed-off-by: Hans Dedecker --- diff --git a/src/dhcpv6.c b/src/dhcpv6.c index b9eac43..60c0b24 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -162,6 +162,37 @@ static char *dhcpv6_msg_to_str(enum dhcpv6_msg msg) return "UNKNOWN"; } +static char *dhcpv6_status_code_to_str(uint16_t code) +{ + switch (code) { + case DHCPV6_Success: + return "Success"; + + case DHCPV6_UnspecFail: + return "Unspecified Failure"; + + case DHCPV6_NoAddrsAvail: + return "No Address Available"; + + case DHCPV6_NoBinding: + return "No Binding"; + + case DHCPV6_NotOnLink: + return "Not On Link"; + + case DHCPV6_UseMulticast: + return "Use Multicast"; + + case DHCPV6_NoPrefixAvail: + return "No Prefix Available"; + + default: + break; + } + + return "Unknown"; +} + int init_dhcpv6(const char *ifname, unsigned int options, int sol_timeout) { client_options = options; @@ -1487,8 +1518,8 @@ static void dhcpv6_log_status_code(const uint16_t code, const char *scope, *dst = 0; - syslog(LOG_WARNING, "Server returned %s status %i %s", - scope, code, buf); + syslog(LOG_WARNING, "Server returned %s status '%s %s'", + scope, dhcpv6_status_code_to_str(code), buf); } static void dhcpv6_handle_status_code(const enum dhcpv6_msg orig,