summaryrefslogtreecommitdiff
path: root/src/basic/ether-addr-util.h
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-11-11 11:55:04 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-11-11 18:29:52 +0900
commite44cd43788705ced5a851564d2d6d53a4294492b (patch)
tree96066aad61d70503f2c2a86f2d9a56d16db13786 /src/basic/ether-addr-util.h
parenta704137c20fcde3fa9077832d9ee29b89d6217e5 (diff)
downloadsystemd-e44cd43788705ced5a851564d2d6d53a4294492b.tar.gz
ether-addr-util: introduce hw_addr_to_string_full()
Diffstat (limited to 'src/basic/ether-addr-util.h')
-rw-r--r--src/basic/ether-addr-util.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/basic/ether-addr-util.h b/src/basic/ether-addr-util.h
index ae6605fb11..b362824a8f 100644
--- a/src/basic/ether-addr-util.h
+++ b/src/basic/ether-addr-util.h
@@ -31,13 +31,24 @@ static inline int parse_hw_addr(const char *s, struct hw_addr_data *ret) {
}
int parse_ether_addr(const char *s, struct ether_addr *ret);
+typedef enum HardwareAddressToStringFlags {
+ HW_ADDR_TO_STRING_NO_COLON = 1 << 0,
+} HardwareAddressToStringFlags;
+
#define HW_ADDR_TO_STRING_MAX (3*HW_ADDR_MAX_SIZE)
-char* hw_addr_to_string(const struct hw_addr_data *addr, char buffer[HW_ADDR_TO_STRING_MAX]);
+char *hw_addr_to_string_full(
+ const struct hw_addr_data *addr,
+ HardwareAddressToStringFlags flags,
+ char buffer[static HW_ADDR_TO_STRING_MAX]);
+static inline char *hw_addr_to_string(const struct hw_addr_data *addr, char buffer[static HW_ADDR_TO_STRING_MAX]) {
+ return hw_addr_to_string_full(addr, 0, buffer);
+}
/* Note: the lifetime of the compound literal is the immediately surrounding block,
* see C11 ยง6.5.2.5, and
* https://stackoverflow.com/questions/34880638/compound-literal-lifetime-and-if-blocks */
-#define HW_ADDR_TO_STR(hw_addr) hw_addr_to_string((hw_addr), (char[HW_ADDR_TO_STRING_MAX]){})
+#define HW_ADDR_TO_STR_FULL(hw_addr, flags) hw_addr_to_string_full((hw_addr), flags, (char[HW_ADDR_TO_STRING_MAX]){})
+#define HW_ADDR_TO_STR(hw_addr) HW_ADDR_TO_STR_FULL(hw_addr, 0)
#define HW_ADDR_NULL ((const struct hw_addr_data){})