projects
/
project
/
netifd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
8a671b5
)
utils.c: add helper function to format mac addresses as strings
author
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 28 Sep 2012 15:40:38 +0000
(17:40 +0200)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 28 Sep 2012 20:16:06 +0000
(23:16 +0300)
utils.c
patch
|
blob
|
history
utils.h
patch
|
blob
|
history
diff --git
a/utils.c
b/utils.c
index 986cee96e147f062f24bb03a527716d71b57d8c3..14e966a49f8052dbe6a2727987aa54ff238fe80b 100644
(file)
--- a/
utils.c
+++ b/
utils.c
@@
-129,3
+129,14
@@
parse_ip_and_netmask(int af, const char *str, void *addr, unsigned int *netmask)
return inet_pton(af, astr, addr);
}
+
+char *
+format_macaddr(uint8_t *mac)
+{
+ static char str[sizeof("ff:ff:ff:ff:ff:ff ")];
+
+ snprintf(str, sizeof(str), "%02x:%02x:%02x:%02x:%02x:%02x",
+ mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+ return str;
+}
diff --git
a/utils.h
b/utils.h
index ec2231331c9d1cdbe4828b95f238e1268ffb7ca4..048ad8f6deb72e802f59f23b70683c66fe79e737 100644
(file)
--- a/
utils.h
+++ b/
utils.h
@@
-114,4
+114,6
@@
unsigned int parse_netmask_string(const char *str, bool v6);
bool split_netmask(char *str, unsigned int *netmask, bool v6);
int parse_ip_and_netmask(int af, const char *str, void *addr, unsigned int *netmask);
+char * format_macaddr(uint8_t *mac);
+
#endif