udev-builtin-net_id.c revision 01d183ddae6fb3445c4519cf1d90c6575f17292e
/***
This file is part of systemd.
Copyright 2012 Kay Sievers <kay@vrfy.org>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
/*
* eno<index> -- ethernet on-board
* ID_NET_NAME_FIRMWARE=eno1
*
* ID_NET_NAME_PATH=enp19s0f0
*
* enm<MAC address> -- MAC address
* ID_NET_NAME_MAC=enxf0def180d479
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "udev.h"
struct udev_device *d;
unsigned int bus;
unsigned int slot;
unsigned int func;
const char *index;
int err;
/* skip other buses than direct PCI parents */
d = udev_device_get_parent(dev);
return -ENOENT;
/* ACPI _SUN -- slot user number */
/* SMBIOS type 41 -- Onboard Devices Extended Information */
if (!index)
if (index) {
unsigned int idx;
if (idx > 0) {
const char *label;
char s[16];
if (label)
}
}
/* compose a name based on the PCI bus location */
char str[16];
if (err < 0)
return err;
}
return 0;
}
const char *s;
unsigned int i;
char str[16];
int err;
/* check for NET_ADDR_PERM, skip random MAC addresses */
if (!s)
return EXIT_FAILURE;
if (i != 0)
return 0;
if (!s)
return -ENOENT;
return -EINVAL;
/* skip empty MAC addresses */
return -EINVAL;
/* add IEEE Organizationally Unique Identifier */
if (err < 0)
return err;
return 0;
}
const char *s;
unsigned int i;
const char *devtype;
const char *prefix = "en";
/* handle only ARPHRD_ETHER devices */
if (!s)
return EXIT_FAILURE;
if (i != 1)
return 0;
if (devtype) {
prefix = "wl";
prefix = "ww";
}
return EXIT_SUCCESS;
}
const struct udev_builtin udev_builtin_net_id = {
.name = "net_id",
.cmd = builtin_net_id,
.help = "network device properties",
};