[systemd-devel] [systemd-commits] 8 commits - src/libsystemd src/network src/shared src/systemd

Lennart Poettering lennart at poettering.net
Tue Dec 2 04:18:47 PST 2014


On Tue, 02.12.14 01:50, Tom Gundersen (tomegun at kemper.freedesktop.org) wrote:

>  
> +/* IEEE Organizationally Unique Identifier vendor string */
> +static int ieee_oui(struct udev_hwdb *hwdb, struct ether_addr *mac, char **ret) {
> +        struct udev_list_entry *entry;
> +        char *description;
> +        char str[32];

Shouldnt this be "4 + 6*2 + 1"?

> +
> +        /* skip commonly misused 00:00:00 (Xerox) prefix */
> +        if (memcmp(mac, "\0\0\0", 3) == 0)
> +                return -EINVAL;
> +
> +        snprintf(str, sizeof(str), "OUI:%02X%02X%02X%02X%02X%02X", mac->ether_addr_octet[0], mac->ether_addr_octet[1], mac->ether_addr_octet[2],
> +                                                                   mac->ether_addr_octet[3], mac->ether_addr_octet[4], mac->ether_addr_octet[5]);
> +

Hmm, maybe we should have a new set of macros for this, similar to
SD_ID128_FORMAT_STR and SD_ID128_FORMAT_VAL?


> +        udev_list_entry_foreach(entry, udev_hwdb_get_properties_list_entry(hwdb, str, 0))
> +                if (strcmp(udev_list_entry_get_name(entry), "ID_OUI_FROM_DATABASE") == 0) {
> +                        description = strdup(udev_list_entry_get_value(entry));
> +                        if (!description)
> +                                return -ENOMEM;
> +
> +                        *ret = description;
> +                        return 0;
> +                }

Hmm, why not just call udev_device_get_property_value()?

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list