summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Dedecker2020-12-26 20:38:49 +0000
committerHans Dedecker2020-12-26 20:40:18 +0000
commit0475e18804dfd9f5601511b6ffc2556efa5a68a7 (patch)
tree44aba9551f03ca1cf6dbd4102fabf1834a62df8c
parent0ffa3a31f7146d320214f431291c1196070a010f (diff)
downloadodhcp6c-0475e18804dfd9f5601511b6ffc2556efa5a68a7.tar.gz
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 <dedeckeh@gmail.com>
-rw-r--r--src/dhcpv6.c35
1 files changed, 33 insertions, 2 deletions
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,