]> git.ozlabs.org Git - ppp.git/commitdiff
check if we have ppp early on
authorPaul Mackerras <paulus@samba.org>
Tue, 14 Dec 1993 05:16:01 +0000 (05:16 +0000)
committerPaul Mackerras <paulus@samba.org>
Tue, 14 Dec 1993 05:16:01 +0000 (05:16 +0000)
pppd/main.c
pppd/sys-str.c

index 4e1e3de522e4ea4dda2dabd9a600e826b4cc4ffa..30596d160b47b8773700143f2c5d19670d32a20e 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: main.c,v 1.2 1993/11/23 23:40:53 paulus Exp $";
+static char rcsid[] = "$Id: main.c,v 1.3 1993/12/14 05:16:01 paulus Exp $";
 #endif
 
 #define SETSID
 #endif
 
 #define SETSID
@@ -223,6 +223,11 @@ main(argc, argv)
 
     pid = getpid();
 
 
     pid = getpid();
 
+    if (!ppp_available()) {
+       fprintf(stderr, "Sorry - PPP is not available on this system\n");
+       exit(1);
+    }
+
     /*
      * Initialize to the standard option set, then parse, in order,
      * the system options file, the user's options file, and the command
     /*
      * Initialize to the standard option set, then parse, in order,
      * the system options file, the user's options file, and the command
index ecee95b576ff8b001a92ea4a9d013aa749991631..6bd2fc91b6cb5be54d43f7ec622834763bd61ffb 100644 (file)
  * TODO:
  */
 
  * TODO:
  */
 
+#include <stdio.h>
 #include <errno.h>
 #include <syslog.h>
 #include <errno.h>
 #include <syslog.h>
+#include <fcntl.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -50,7 +52,24 @@ static struct        modlist {
 } str_modules[MAXMODULES];
 static int     str_module_count = 0;
 
 } str_modules[MAXMODULES];
 static int     str_module_count = 0;
 
-extern int hungup;
+extern int hungup;             /* has the physical layer been disconnected? */
+
+/*
+ * ppp_available - check if this kernel supports PPP.
+ */
+int
+ppp_available()
+{
+    int fd, ret;
+
+    fd = open("/dev/tty", O_RDONLY, 0);
+    if (fd < 0)
+       return 1;               /* can't find out - assume we have ppp */
+    ret = ioctl(fd, I_FIND, "pppasync") >= 0;
+    close(fd);
+    return ret;
+}
+
 
 /*
  * establish_ppp - Turn the serial port into a ppp interface.
 
 /*
  * establish_ppp - Turn the serial port into a ppp interface.