]> git.ozlabs.org Git - ppp.git/commitdiff
added ppp_available
authorPaul Mackerras <paulus@samba.org>
Tue, 14 Dec 1993 05:41:11 +0000 (05:41 +0000)
committerPaul Mackerras <paulus@samba.org>
Tue, 14 Dec 1993 05:41:11 +0000 (05:41 +0000)
pppd/sys-bsd.c

index 350e0a0d860f359a873f2d90bf1a96b880a1cf40..cb105f5ac0b3e873c17e65304a659a29da0e3fd8 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: sys-bsd.c,v 1.1 1993/11/11 03:54:25 paulus Exp $";
+static char rcsid[] = "$Id: sys-bsd.c,v 1.2 1993/12/14 05:41:11 paulus Exp $";
 #endif
 
 /*
@@ -480,3 +480,24 @@ get_ether_addr(ipaddr, hwaddr)
 
     return 0;
 }
+
+/*
+ * ppp_available - check whether the system has any ppp interfaces
+ * (in fact we check whether we can do an ioctl on ppp0).
+ */
+
+int
+ppp_available()
+{
+    int s, ok;
+    struct ifreq ifr;
+
+    if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+       return 1;               /* can't tell - maybe we're not root */
+
+    strncpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name));
+    ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
+    close(s);
+
+    return ok;
+}