summaryrefslogtreecommitdiff
path: root/libdhcp/dhcp_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'libdhcp/dhcp_common.h')
-rw-r--r--libdhcp/dhcp_common.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/libdhcp/dhcp_common.h b/libdhcp/dhcp_common.h
index b265df3..5b51ce2 100644
--- a/libdhcp/dhcp_common.h
+++ b/libdhcp/dhcp_common.h
@@ -68,6 +68,7 @@
#define _LIBDHCP_DHCP_COMMON_H_
#include <libmisc/endian.h>
+#include <libmisc/log.h> /* for const_byte_str() */
/* Config *********************************************************************/
@@ -302,4 +303,18 @@ static inline bool dhcp_opt_length_is_valid(uint8_t opt, uint16_t len) {
#define DHCP_MSGTYP_RELEASE ((uint8_t) 7) /* RFC2132, client->server */
#define DHCP_MSGTYP_INFORM ((uint8_t) 8) /* RFC2132, client->server */
+static const char *dhcp_msgtyp_str(uint8_t typ) {
+ switch (typ) {
+ case DHCP_MSGTYP_DISCOVER: return "DHCP_MSGTYP_DISCOVER";
+ case DHCP_MSGTYP_OFFER: return "DHCP_MSGTYP_OFFER";
+ case DHCP_MSGTYP_REQUEST: return "DHCP_MSGTYP_REQUEST";
+ case DHCP_MSGTYP_DECLINE: return "DHCP_MSGTYP_DECLINE";
+ case DHCP_MSGTYP_ACK: return "DHCP_MSGTYP_ACK";
+ case DHCP_MSGTYP_NAK: return "DHCP_MSGTYP_NAK";
+ case DHCP_MSGTYP_RELEASE: return "DHCP_MSGTYP_RELEASE";
+ case DHCP_MSGTYP_INFORM: return "DHCP_MSGTYP_INFORM";
+ default: return const_byte_str(typ);
+ }
+}
+
#endif /* _LIBDHCP_DHCP_COMMON_H_ */