X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsys-bsd.c;h=cb105f5ac0b3e873c17e65304a659a29da0e3fd8;hp=350e0a0d860f359a873f2d90bf1a96b880a1cf40;hb=945507d5f26990782634bfd5142dbb5f8797172a;hpb=545b1502b4f32570e64eb75d74cf9521035115e8 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; +}