int s; /* can raw socket */
struct sockaddr_can addr;
struct termios topts;
- struct ifreq ifr;
int select_stdin = 0;
int running = 1;
int tstamp = 0;
}
addr.can_family = AF_CAN;
-
- strcpy(ifr.ifr_name, argv[2]);
- if (ioctl(s, SIOCGIFINDEX, &ifr) < 0) {
- perror("SIOCGIFINDEX");
- return 1;
- }
- addr.can_ifindex = ifr.ifr_ifindex;
+ addr.can_ifindex = if_nametoindex(argv[2]);
/* disable reception of CAN frames until we are opened by 'O' */
setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);