X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsys-bsd.c;h=cb105f5ac0b3e873c17e65304a659a29da0e3fd8;hp=350e0a0d860f359a873f2d90bf1a96b880a1cf40;hb=f1085e1db51d5fc24764f1e1a9f0101e86bf7ca0;hpb=0b63a24d54ba4708c88e31bdd74b0145956c1478;ds=sidebyside diff --git a/pppd/sys-bsd.c b/pppd/sys-bsd.c index 350e0a0..cb105f5 100644 --- a/pppd/sys-bsd.c +++ b/pppd/sys-bsd.c @@ -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; +}