summaryrefslogtreecommitdiff
path: root/libdhcp/dhcp_common.h
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-08 08:28:16 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-12-08 08:28:16 -0700
commit96a751d8a5d20b2acea5ae8d10ac3d051466c2c3 (patch)
tree1ce291df34d78acd6f1619a779abbd4f06134e26 /libdhcp/dhcp_common.h
parentafe6542b30def82573e070371281c05dc593a739 (diff)
parentb9ebe41358244caa9334e72ca4e3c8c7a14c86e7 (diff)
Merge commit 'b9ebe41358244caa9334e72ca4e3c8c7a14c86e7'
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_ */