]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-bsd.c
add support for CCP, use select/poll instead of signals.
[ppp.git] / pppd / sys-bsd.c
index 65c0b7716faf423c0a6d5cc542575f35a9b753b5..d0cd22829accd7743cdf4d3e4cd31293eae083b2 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: sys-bsd.c,v 1.7 1994/05/30 06:10:07 paulus Exp $";
+static char rcsid[] = "$Id: sys-bsd.c,v 1.8 1994/08/09 06:30:38 paulus Exp $";
 #endif
 
 /*
@@ -153,6 +153,27 @@ output(unit, p, len)
 }
 
 
+/*
+ * wait_input - wait until there is data available on fd,
+ * for the length of time specified by *timo (indefinite
+ * if timo is NULL).
+ */
+wait_input(timo)
+    struct timeval *timo;
+{
+    fd_set ready;
+    int n;
+
+    FD_ZERO(&ready);
+    FD_SET(fd, &ready);
+    n = select(fd+1, &ready, NULL, &ready, timo);
+    if (n < 0 && errno != EINTR) {
+       syslog(LOG_ERR, "select: %m");
+       die(1);
+    }
+}
+
+
 /*
  * read_packet - get a PPP packet from the serial device.
  */
@@ -256,6 +277,25 @@ ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
     }
 }
 
+/*
+ * ccp_flags_set - inform kernel about the current state of CCP.
+ */
+void
+ccp_flags_set(unit, isopen, isup)
+    int unit, isopen, isup;
+{
+    int x;
+
+    if (ioctl(fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) {
+       syslog(LOG_ERR, "ioctl (PPPIOCGFLAGS): %m");
+       return;
+    }
+    x = isopen? x | SC_CCP_OPEN: x &~ SC_CCP_OPEN;
+    x = isup? x | SC_CCP_UP: x &~ SC_CCP_UP;
+    if (ioctl(fd, PPPIOCSFLAGS, (caddr_t) &x) < 0)
+       syslog(LOG_ERR, "ioctl(PPPIOCSFLAGS): %m");
+}
+
 /*
  * sifvjcomp - config tcp header compression
  */
@@ -413,7 +453,6 @@ cifaddr(u, o, h)
     return 1;
 }
 
-
 /*
  * sifdefaultroute - assign a default route through the address given.
  */