Lines Matching defs:names
21 * Predictable network interface device names based on:
35 * Type of names:
136 static int dev_pci_onboard(struct udev_device *dev, struct netnames *names) {
144 attr = udev_device_get_sysattr_value(names->pcidev, "acpi_index");
147 attr = udev_device_get_sysattr_value(names->pcidev, "index");
167 s = names->pci_onboard;
168 l = sizeof(names->pci_onboard);
173 names->pci_onboard[0] = '\0';
175 names->pci_onboard_label = udev_device_get_sysattr_value(names->pcidev, "label");
200 static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
201 struct udev *udev = udev_device_get_udev(names->pcidev);
212 if (sscanf(udev_device_get_sysname(names->pcidev), "%x:%x:%x.%u", &domain, &bus, &slot, &func) != 4)
221 s = names->pci_path;
222 l = sizeof(names->pci_path);
226 if (func > 0 || is_pci_multifunction(names->pcidev))
231 names->pci_path[0] = '\0';
261 if (strneq(address, udev_device_get_sysname(names->pcidev), strlen(address)))
271 s = names->pci_slot;
272 l = sizeof(names->pci_slot);
276 if (func > 0 || is_pci_multifunction(names->pcidev))
281 names->pci_slot[0] = '\0';
288 static int names_pci(struct udev_device *dev, struct netnames *names) {
292 assert(names);
307 names->type = NET_PCI;
308 names->pcidev = parent;
310 names->pcidev = udev_device_get_parent_with_subsystem_devtype(dev, "pci", NULL);
311 if (!names->pcidev)
314 dev_pci_onboard(dev, names);
315 dev_pci_slot(dev, names);
319 static int names_usb(struct udev_device *dev, struct netnames *names) {
329 assert(names);
358 s = names->usb_ports;
359 l = strpcpyl(&s, sizeof(names->usb_ports), "u", ports, NULL);
363 l = strpcpyl(&s, sizeof(names->usb_ports), "c", config, NULL);
367 l = strpcpyl(&s, sizeof(names->usb_ports), "i", interf, NULL);
371 names->type = NET_USB;
375 static int names_bcma(struct udev_device *dev, struct netnames *names) {
380 assert(names);
391 xsprintf(names->bcma_core, "b%u", core);
393 names->type = NET_BCMA;
397 static int names_ccw(struct udev_device *dev, struct netnames *names) {
404 assert(names);
432 * keeps the ccw names stable, yet much shorter in general case of
439 rc = snprintf(names->ccw_group, sizeof(names->ccw_group), "c%s", bus_id);
440 if (rc >= 0 && rc < (int)sizeof(names->ccw_group))
441 names->type = NET_CCWGROUP;
445 static int names_mac(struct udev_device *dev, struct netnames *names) {
468 names->mac[0] = a1;
469 names->mac[1] = a2;
470 names->mac[2] = a3;
471 names->mac[3] = a4;
472 names->mac[4] = a5;
473 names->mac[5] = a6;
474 names->mac_valid = true;
479 static int ieee_oui(struct udev_device *dev, struct netnames *names, bool test) {
482 if (!names->mac_valid)
485 if (memcmp(names->mac, "\0\0\0", 3) == 0)
487 xsprintf(str, "OUI:%02X%02X%02X%02X%02X%02X", names->mac[0],
488 names->mac[1], names->mac[2], names->mac[3], names->mac[4],
489 names->mac[5]);
500 struct netnames names = {};
537 err = names_mac(dev, &names);
538 if (err >= 0 && names.mac_valid) {
542 names.mac[0], names.mac[1], names.mac[2],
543 names.mac[3], names.mac[4], names.mac[5]);
546 ieee_oui(dev, &names, test);
549 /* get path names for Linux on System z network devices */
550 err = names_ccw(dev, &names);
551 if (err >= 0 && names.type == NET_CCWGROUP) {
554 if (snprintf(str, sizeof(str), "%s%s", prefix, names.ccw_group) < (int)sizeof(str))
559 /* get PCI based path names, we compose only PCI based paths */
560 err = names_pci(dev, &names);
565 if (names.type == NET_PCI) {
568 if (names.pci_onboard[0])
569 if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_onboard) < (int)sizeof(str))
572 if (names.pci_onboard_label)
573 if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_onboard_label) < (int)sizeof(str))
576 if (names.pci_path[0])
577 if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_path) < (int)sizeof(str))
580 if (names.pci_slot[0])
581 if (snprintf(str, sizeof(str), "%s%s", prefix, names.pci_slot) < (int)sizeof(str))
587 err = names_usb(dev, &names);
588 if (err >= 0 && names.type == NET_USB) {
591 if (names.pci_path[0])
592 if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.usb_ports) < (int)sizeof(str))
595 if (names.pci_slot[0])
596 if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.usb_ports) < (int)sizeof(str))
602 err = names_bcma(dev, &names);
603 if (err >= 0 && names.type == NET_BCMA) {
606 if (names.pci_path[0])
607 if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_path, names.bcma_core) < (int)sizeof(str))
610 if (names.pci_slot[0])
611 if (snprintf(str, sizeof(str), "%s%s%s", prefix, names.pci_slot, names.bcma_core) < (int)sizeof(str))