From 945507d5f26990782634bfd5142dbb5f8797172a Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 14 Dec 1993 05:41:11 +0000 Subject: [PATCH] added ppp_available --- pppd/sys-bsd.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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; +} -- 2.39.2