X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fsocket-util.c;h=e3e54e8e089aeeec135b65e0754b8cf2cf1dec81;hb=aa08982d62cf45b59ea6a06c915391f5db1fb86e;hp=1a04f323abeba4af6de882540aebb07b3345687e;hpb=f01e5736f1555eec9183e48448fa3454f265b73e;p=elogind.git diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 1a04f323a..e3e54e8e0 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -426,11 +426,11 @@ bool socket_ipv6_is_supported(void) { _cleanup_free_ char *l = NULL; if (access("/sys/module/ipv6", F_OK) != 0) - return 0; + return false; /* If we can't check "disable" parameter, assume enabled */ if (read_one_line_file("/sys/module/ipv6/parameters/disable", &l) < 0) - return 1; + return true; /* If module was loaded with disable=1 no IPv6 available */ return l[0] == '0'; @@ -727,3 +727,22 @@ bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b return false; } + +char* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]) { + assert(addr); + assert(buffer); + + /* Like ether_ntoa() but uses %02x instead of %x to print + * ethernet addresses, which makes them look less funny. Also, + * doesn't use a static buffer. */ + + sprintf(buffer, "%02x:%02x:%02x:%02x:%02x:%02x", + addr->ether_addr_octet[0], + addr->ether_addr_octet[1], + addr->ether_addr_octet[2], + addr->ether_addr_octet[3], + addr->ether_addr_octet[4], + addr->ether_addr_octet[5]); + + return buffer; +}