diff options
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/network-internal.c | 52 | ||||
-rw-r--r-- | src/libsystemd-network/network-internal.h | 8 |
2 files changed, 7 insertions, 53 deletions
diff --git a/src/libsystemd-network/network-internal.c b/src/libsystemd-network/network-internal.c index 7f744215cc..208c314695 100644 --- a/src/libsystemd-network/network-internal.c +++ b/src/libsystemd-network/network-internal.c @@ -27,28 +27,27 @@ #include "strv.h" #include "siphash24.h" #include "libudev-private.h" -#include "network-internal.h" #include "dhcp-lease-internal.h" #include "log.h" #include "utf8.h" #include "util.h" #include "conf-parser.h" #include "condition.h" +#include "network-internal.h" const char *net_get_name(struct udev_device *device) { - const char *name = NULL, *field = NULL; + const char *name, *field; assert(device); /* fetch some persistent data unique (on this machine) to this device */ - FOREACH_STRING(field, "ID_NET_NAME_ONBOARD", "ID_NET_NAME_SLOT", - "ID_NET_NAME_PATH", "ID_NET_NAME_MAC") { + FOREACH_STRING(field, "ID_NET_NAME_ONBOARD", "ID_NET_NAME_SLOT", "ID_NET_NAME_PATH", "ID_NET_NAME_MAC") { name = udev_device_get_property_value(device, field); if (name) - break; + return name; } - return name; + return NULL; } #define HASH_KEY SD_ID128_MAKE(d3,1e,48,fa,90,fe,4b,4c,9d,af,d5,d7,a1,b1,2e,8a) @@ -133,12 +132,6 @@ bool net_match_config(const struct ether_addr *match_mac, return 1; } -unsigned net_netmask_to_prefixlen(const struct in_addr *addr) { - assert(addr); - - return 32 - u32ctz(be32toh(addr->s_addr)); -} - int config_parse_net_condition(const char *unit, const char *filename, unsigned line, @@ -304,41 +297,6 @@ int config_parse_hwaddr(const char *unit, return 0; } -int net_parse_inaddr(const char *address, int *family, void *dst) { - int r; - - assert(address); - assert(family); - assert(dst); - - /* IPv4 */ - r = inet_pton(AF_INET, address, dst); - if (r > 0) { - /* succsefully parsed IPv4 address */ - if (*family == AF_UNSPEC) - *family = AF_INET; - else if (*family != AF_INET) - return -EINVAL; - } else if (r < 0) - return -errno; - else { - /* not an IPv4 address, so let's try IPv6 */ - r = inet_pton(AF_INET6, address, dst); - if (r > 0) { - /* successfully parsed IPv6 address */ - if (*family == AF_UNSPEC) - *family = AF_INET6; - else if (*family != AF_INET6) - return -EINVAL; - } else if (r < 0) - return -errno; - else - return -EINVAL; - } - - return 0; -} - void serialize_in_addrs(FILE *f, const struct in_addr *addresses, size_t size) { unsigned i; diff --git a/src/libsystemd-network/network-internal.h b/src/libsystemd-network/network-internal.h index 6dd518bb48..49387d03cf 100644 --- a/src/libsystemd-network/network-internal.h +++ b/src/libsystemd-network/network-internal.h @@ -1,5 +1,7 @@ /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ +#pragma once + /*** This file is part of systemd. @@ -19,8 +21,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#pragma once - #include <netinet/ether.h> #include <netinet/in.h> #include <stdbool.h> @@ -44,8 +44,6 @@ bool net_match_config(const struct ether_addr *match_mac, const char *dev_type, const char *dev_name); -unsigned net_netmask_to_prefixlen(const struct in_addr *netmask); - int config_parse_net_condition(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); @@ -62,8 +60,6 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); -int net_parse_inaddr(const char *address, int *family, void *dst); - int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]); const char *net_get_name(struct udev_device *device); |