Lines Matching refs:device
64 struct device {
76 struct device device = {
120 "Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n"
130 " -I device : which ethernet device to use"
550 * This function checks 1) if the device (if given) is okay for ARP,
551 * or 2) find fist appropriate device on the system.
554 * >0 : Succeeded, and appropriate device not found.
555 * device.ifindex remains 0.
556 * 0 : Succeeded, and approptiate device found.
557 * device.ifindex is set.
561 * If an appropriate device found, it is recorded inside the
562 * "device" variable for later reference.
569 * means, you need to supply the device name for
578 printf("Interface \"%s\" is down\n", device.name);
586 printf("Interface \"%s\" is not ARPable\n", device.name);
612 if (device.name && ifa->ifa_name && strcmp(ifa->ifa_name, device.name))
615 if (check_ifflags(ifa->ifa_flags, device.name != NULL) < 0)
623 device.ifa = ifa;
629 if (count == 1 && device.ifa) {
630 device.ifindex = if_nametoindex(device.ifa->ifa_name);
631 if (!device.ifindex) {
636 device.name = device.ifa->ifa_name;
729 if (!device.sysfs) {
730 device.sysfs = malloc(sizeof(*device.sysfs));
731 sysfs_devattr_values_init(device.sysfs, 0);
752 if (device.name && strcmp(dev->name, device.name))
780 device.name != NULL) < 0)
786 if (device.sysfs->value[SYSFS_DEVATTR_IFINDEX].ulong) {
787 if (device.sysfs->value[SYSFS_DEVATTR_FLAGS].ulong & IFF_RUNNING)
797 sysfs_devattr_values_init(device.sysfs, 1);
798 memcpy(device.sysfs, &sysfs_devattr_values, sizeof(*device.sysfs));
810 device.ifindex = device.sysfs->value[SYSFS_DEVATTR_IFINDEX].ulong;
811 device.name = device.sysfs->ifname;
813 rc = !device.ifindex;
827 if (check_ifflags(ifr->ifr_flags, device.name != NULL) < 0)
855 if (device.name) {
856 strncpy(ifrbuf.ifr_name, device.name, sizeof(ifrbuf.ifr_name) - 1);
903 device.ifindex = ifrbuf.ifr_ifindex;
904 device.name = ifrbuf.ifr_name;
906 return !device.ifindex;
929 * This fills the device "broadcast address"
932 static int set_device_broadcast_ifaddrs_one(struct device *device, unsigned char *ba, size_t balen, int fatal)
938 if (!device)
941 ifa = device->ifa;
961 int set_device_broadcast_sysfs(struct device *device, unsigned char *ba, size_t balen)
965 if (!device)
967 v = device->sysfs;
979 static int set_device_broadcast_fallback(struct device *device, unsigned char *ba, size_t balen)
987 static void set_device_broadcast(struct device *dev, unsigned char *ba, size_t balen)
1041 device.name = optarg;
1066 if (device.name && !*device.name)
1067 device.name = NULL;
1078 if (!device.ifindex) {
1079 if (device.name) {
1080 fprintf(stderr, "arping: Device %s not available.\n", device.name);
1083 fprintf(stderr, "arping: device (option -I) is required.\n");
1130 if (device.name) {
1133 if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device.name, strlen(device.name)+1) == -1)
1169 ((struct sockaddr_ll *)&me)->sll_ifindex = device.ifindex;
1185 printf("Interface \"%s\" is not ARPable (no ll address)\n", device.name);
1191 set_device_broadcast(&device, ((struct sockaddr_ll *)&he)->sll_addr,
1196 printf("from %s %s\n", inet_ntoa(src), device.name ? : "");