From 066e69986b96bf83dfa2ec09f6b03b6a7ad6bbd6 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 21 Aug 2024 14:19:58 +1000 Subject: util: Helper for formatting MAC addresses There are a couple of places where we somewhat messily open code formatting an Ethernet like MAC address for display. Add an eth_ntop() helper for this. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- util.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'util.h') diff --git a/util.h b/util.h index cb4d181..a716849 100644 --- a/util.h +++ b/util.h @@ -215,9 +215,12 @@ static inline const char *af_name(sa_family_t af) #define SOCKADDR_STRLEN MAX(SOCKADDR_INET_STRLEN, SOCKADDR_INET6_STRLEN) +#define ETH_ADDRSTRLEN (sizeof("00:11:22:33:44:55")) + struct sock_extended_err; const char *sockaddr_ntop(const void *sa, char *dst, socklen_t size); +const char *eth_ntop(const unsigned char *mac, char *dst, size_t size); const char *str_ee_origin(const struct sock_extended_err *ee); /** -- cgit v1.2.3