chiark / gitweb /
network-internal: split out net_get_name()
authorTom Gundersen <teg@jklm.no>
Thu, 19 Jun 2014 12:39:05 +0000 (15:39 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Thu, 19 Jun 2014 12:44:43 +0000 (15:44 +0300)
src/libsystemd-network/network-internal.c
src/libsystemd-network/network-internal.h

index 2e9667c167d00849492aeae687d3eb25d72ff210..97217c12e5b626167529bc7d7ac220255fd3e60f 100644 (file)
 #include "conf-parser.h"
 #include "condition.h"
 
-#define HASH_KEY SD_ID128_MAKE(d3,1e,48,fa,90,fe,4b,4c,9d,af,d5,d7,a1,b1,2e,8a)
-
-int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]) {
-        size_t l, sz = 0;
+const char *net_get_name(struct udev_device *device) {
         const char *name = NULL, *field = NULL;
-        int r;
-        uint8_t *v;
+
+        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;
+}
+
+#define HASH_KEY SD_ID128_MAKE(d3,1e,48,fa,90,fe,4b,4c,9d,af,d5,d7,a1,b1,2e,8a)
+
+int net_get_unique_predictable_data(struct udev_device *device, uint8_t result[8]) {
+        size_t l, sz = 0;
+        const char *name = NULL;
+        int r;
+        uint8_t *v;
+
+        assert(device);
+
+        name = net_get_name(device);
         if (!name)
                 return -ENOENT;
 
index 2aeecf0ce2237a65feadf59be71a06cfe8c869e2..db48c2c06c543dc514d55902d7876c2aa645046c 100644 (file)
@@ -65,6 +65,7 @@ int config_parse_ifalias(const char *unit, const char *filename, unsigned line,
 int net_parse_inaddr(const char *address, unsigned char *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);
 
 void serialize_in_addrs(FILE *f, const char *key, struct in_addr *addresses, size_t size);
 int deserialize_in_addrs(struct in_addr **addresses, size_t *size, const char *string);