diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2024-08-24 09:42:41 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2024-08-24 09:42:41 +0000 |
commit | ffaf41f3ccc59f7930b81dc9f2649da26c7e7c59 (patch) | |
tree | de709639eb103e0ecde998b1820fa200656f9be6 | |
parent | 5a69726c7ec7b48d9d70476ebe02a8560a17942f (diff) |
Helper function for logging imsg type names.
OK tb as part of a larger diff
-rw-r--r-- | sbin/slaacd/slaacd.c | 53 | ||||
-rw-r--r-- | sbin/slaacd/slaacd.h | 4 |
2 files changed, 55 insertions, 2 deletions
diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c index 05af06e68de..8d3f183d716 100644 --- a/sbin/slaacd/slaacd.c +++ b/sbin/slaacd/slaacd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.c,v 1.69 2024/04/21 17:33:05 florian Exp $ */ +/* $OpenBSD: slaacd.c,v 1.70 2024/08/24 09:42:40 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -899,3 +899,54 @@ open_icmp6sock(int rdomain) main_imsg_compose_frontend(IMSG_ICMP6SOCK, icmp6sock, &rdomain, sizeof(rdomain)); } + +#ifndef SMALL + +#define I2S(x) case x: return #x + +const char* +i2s(uint32_t type) +{ + static char unknown[sizeof("IMSG_4294967295")]; + + switch (type) { + I2S(IMSG_NONE); + I2S(IMSG_CTL_LOG_VERBOSE); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_RA); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_RA_PREFIX); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_RA_RDNS); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSALS); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_ADDR_PROPOSAL); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSALS); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSAL); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_RDNS_PROPOSALS); + I2S(IMSG_CTL_SHOW_INTERFACE_INFO_RDNS_PROPOSAL); + I2S(IMSG_CTL_END); + I2S(IMSG_PROPOSE_RDNS); + I2S(IMSG_REPROPOSE_RDNS); + I2S(IMSG_CTL_SEND_SOLICITATION); + I2S(IMSG_SOCKET_IPC); + I2S(IMSG_OPEN_ICMP6SOCK); + I2S(IMSG_ICMP6SOCK); + I2S(IMSG_ROUTESOCK); + I2S(IMSG_CONTROLFD); + I2S(IMSG_STARTUP); + I2S(IMSG_UPDATE_IF); + I2S(IMSG_REMOVE_IF); + I2S(IMSG_RA); + I2S(IMSG_CONFIGURE_ADDRESS); + I2S(IMSG_WITHDRAW_ADDRESS); + I2S(IMSG_DEL_ADDRESS); + I2S(IMSG_DEL_ROUTE); + I2S(IMSG_CONFIGURE_DFR); + I2S(IMSG_WITHDRAW_DFR); + I2S(IMSG_DUP_ADDRESS); + default: + snprintf(unknown, sizeof(unknown), "IMSG_%u", type); + return unknown; + } +} +#undef I2S + +#endif /* SMALL */ diff --git a/sbin/slaacd/slaacd.h b/sbin/slaacd/slaacd.h index 2844f4a63b7..77087c3c56a 100644 --- a/sbin/slaacd/slaacd.h +++ b/sbin/slaacd/slaacd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: slaacd.h,v 1.38 2022/07/12 16:55:00 florian Exp $ */ +/* $OpenBSD: slaacd.h,v 1.39 2024/08/24 09:42:40 florian Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -206,6 +206,8 @@ int imsg_compose_event(struct imsgev *, uint16_t, uint32_t, pid_t, int, void *, uint16_t); #ifndef SMALL const char *sin6_to_str(struct sockaddr_in6 *); +const char *i2s(uint32_t); #else #define sin6_to_str(x...) "" +#define i2s(x...) "" #endif /* SMALL */ |