When printing MAC addresses, always use trailing zeroes.
authorEtienne Dechamps <etienne@edechamps.fr>
Sat, 5 Jul 2014 17:52:03 +0000 (18:52 +0100)
committerEtienne Dechamps <etienne@edechamps.fr>
Sat, 5 Jul 2014 19:00:50 +0000 (20:00 +0100)
tinc currently prints MAC addresses without trailing zeroes, for example:

    1:2:3:4:5:6

This looks weird and is inconsistent with how MAC addresses are
displayed everywhere else. This commit adds trailing zeroes, so the
above address will be printed as the following:

    01:02:03:04:05:06

src/subnet_parse.c

index 35f078afb5f7e931a03ce81f0bf15a8caa81b21a..5fac415b8b83eafa71ead0a2b53eea2a7a38095e 100644 (file)
@@ -308,7 +308,7 @@ bool net2str(char *netstr, int len, const subnet_t *subnet) {
 
        switch (subnet->type) {
                case SUBNET_MAC:
-                       snprintf(netstr, len, "%hx:%hx:%hx:%hx:%hx:%hx#%d",
+                       snprintf(netstr, len, "%02hx:%02hx:%02hx:%02hx:%02hx:%02hx#%d",
                                         subnet->net.mac.address.x[0],
                                         subnet->net.mac.address.x[1],
                                         subnet->net.mac.address.x[2],