]> rtime.felk.cvut.cz Git - can-utils.git/blobdiff - slcand.c
can-calc-bit-timing: use "struct can_bittiming_const" from uapi headers
[can-utils.git] / slcand.c
index c4c81c54bbcf2d1b7bfffd51fb6f987764404797..e8c70e0c8189bbecc65b540360e9103f11435110 100644 (file)
--- a/slcand.c
+++ b/slcand.c
@@ -37,9 +37,8 @@
 #include <sys/ioctl.h>
 #include <net/if.h>
 #include <termios.h>
-
-/* default slcan line discipline since Kernel 2.6.25 */
-#define LDISC_N_SLCAN 17
+#include <linux/tty.h>
+#include <linux/sockios.h>
 
 /* Change this to whatever your daemon is called */
 #define DAEMON_NAME "slcand"
@@ -180,7 +179,7 @@ int main(int argc, char *argv[])
        char *btr = NULL;
        int run_as_daemon = 1;
        char *pch;
-       int ldisc = LDISC_N_SLCAN;
+       int ldisc = N_SLCAN;
        int fd;
 
        ttypath[0] = '\0';
@@ -334,13 +333,13 @@ int main(int argc, char *argv[])
        /* set slcan like discipline on given tty */
        if (ioctl(fd, TIOCSETD, &ldisc) < 0) {
                perror("ioctl TIOCSETD");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
        
        /* retrieve the name of the created CAN netdevice */
        if (ioctl(fd, SIOCGIFNAME, buf) < 0) {
                perror("ioctl SIOCGIFNAME");
-               exit(1);
+               exit(EXIT_FAILURE);
        }
 
        syslog(LOG_NOTICE, "attached TTY %s to netdevice %s\n", ttypath, buf);
@@ -359,7 +358,7 @@ int main(int argc, char *argv[])
                        if (ioctl(s, SIOCSIFNAME, &ifr) < 0) {
                                syslog(LOG_NOTICE, "netdevice %s rename to %s failed\n", buf, name);
                                perror("ioctl SIOCSIFNAME rename");
-                               exit(1);
+                               exit(EXIT_FAILURE);
                        } else
                                syslog(LOG_NOTICE, "netdevice %s renamed to %s\n", buf, name);