]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-svr4.c
clock32_t is clock_t (long)
[ppp.git] / pppd / sys-svr4.c
index 50c32033995cc7b9311e386d6598deb276ef06b5..0743da189060271b1194ff54726f242d9dc3e1b9 100644 (file)
@@ -25,7 +25,7 @@
  * OR MODIFICATIONS.
  */
 
-#define RCSID  "$Id: sys-svr4.c,v 1.36 1999/10/08 01:09:03 masputra Exp $"
+#define RCSID  "$Id: sys-svr4.c,v 1.41 2000/02/11 03:09:19 masputra Exp $"
 
 #include <limits.h>
 #include <stdio.h>
 #endif
 
 #include "pppd.h"
+#include "fsm.h"
+#include "lcp.h"
+#include "ipcp.h"
+#include "ccp.h"
 
 #if !defined(PPP_DEV_NAME)
 #define PPP_DEV_NAME   "/dev/ppp"
 
 static const char rcsid[] = RCSID;
 
-static         char *mux_dev_name;
+#if defined(SOL2)
+/*
+ * "/dev/udp" is used as a multiplexor to PLINK the interface stream
+ * under. It is used in place of "/dev/ip" since STREAMS will not let
+ * a driver be PLINK'ed under itself, and "/dev/ip" is typically the
+ * driver at the bottom of the tunneling interfaces stream.
+ */
+static char *mux_dev_name = UDP_DEV_NAME;
+#else
+static char *mux_dev_name = IP_DEV_NAME;
+#endif
 static int     pppfd;
 static int     fdmuxid = -1;
 static int     ipfd;
@@ -364,18 +378,6 @@ sys_init()
     } reply;
 #endif /* !defined(SOL2) */
 
-#if defined(SOL2)
-    /*
-     * "/dev/udp" is used as a multiplexor to PLINK the interface stream
-     * under. It is used in place of "/dev/ip" since STREAMS will not let
-     * a driver be PLINK'ed under itself, and "/dev/ip" is typically the
-     * driver at the bottom of the tunneling interfaces stream.
-     */
-    mux_dev_name = UDP_DEV_NAME;
-#else
-    mux_dev_name = IP_DEV_NAME;
-#endif
-
     ipfd = open(mux_dev_name, O_RDWR, 0);
     if (ipfd < 0)
        fatal("Couldn't open IP device: %m");
@@ -494,7 +496,7 @@ sys_init()
     ifr.ifr_ip_muxid = ipmuxid;
 
     /*
-     * In Sol 8 and later, STREAMS dynamic module plumbing feature exits.
+     * In Sol 8 and later, STREAMS dynamic module plumbing feature exists.
      * This is so that an arbitrary module can be inserted, or deleted, 
      * between ip module and the device driver without tearing down the 
      * existing stream. Such feature requires the mux ids, which is set 
@@ -689,6 +691,27 @@ ppp_available()
     return stat(PPP_DEV_NAME, &buf) >= 0;
 }
 
+/*
+ * any_compressions - see if compression is enabled or not
+ *
+ * In the STREAMS implementation of kernel-portion pppd,
+ * the comp STREAMS module performs the ACFC, PFC, as well
+ * CCP and VJ compressions. However, if the user has explicitly
+ * declare to not enable them from the command line, there is
+ * no point of having the comp module be pushed on the stream.
+ */
+static int
+any_compressions()
+{
+    if ((!lcp_wantoptions[0].neg_accompression) &&
+       (!lcp_wantoptions[0].neg_pcompression) &&
+       (!ccp_protent.enabled_flag) &&
+       (!ipcp_wantoptions[0].neg_vj)) {
+           return 0;
+    }
+    return 1;
+}
+
 /*
  * establish_ppp - Turn the serial port into a ppp interface.
  */
@@ -720,12 +743,21 @@ establish_ppp(fd)
        i = PPPDBG_LOG + PPPDBG_AHDLC;
        strioctl(pppfd, PPPIO_DEBUG, &i, sizeof(int), 0);
     }
-    if (ioctl(fd, I_PUSH, COMP_MOD_NAME) < 0)
-       error("Couldn't push PPP compression module: %m");
-    else
-       ++tty_npushed;
+    /*
+     * There's no need to push comp module if we don't intend
+     * to compress anything
+     */
+    if (any_compressions()) { 
+        if (ioctl(fd, I_PUSH, COMP_MOD_NAME) < 0)
+           error("Couldn't push PPP compression module: %m");
+       else
+           ++tty_npushed;
+    }
+
     if (kdebugflag & 2) {
-       i = PPPDBG_LOG + PPPDBG_COMP;
+       i = PPPDBG_LOG; 
+       if (any_compressions())
+           i += PPPDBG_COMP;
        strioctl(pppfd, PPPIO_DEBUG, &i, sizeof(int), 0);
     }
 
@@ -892,6 +924,18 @@ struct speed {
 #endif
 #ifdef B115200
     { 115200, B115200 },
+#endif
+#ifdef B153600
+    { 153600, B153600 },
+#endif
+#ifdef B230400
+    { 230400, B230400 },
+#endif
+#ifdef B307200
+    { 307200, B307200 },
+#endif
+#ifdef B460800
+    { 460800, B460800 },
 #endif
     { 0, 0 }
 };
@@ -951,7 +995,7 @@ set_up_tty(fd, local)
 
 #ifndef CRTSCTS
     termiox_ok = 1;
-    if (ioctl (fd, TCGETX, &tiox) < 0) {
+    if (!sync_serial && ioctl (fd, TCGETX, &tiox) < 0) {
        termiox_ok = 0;
        if (errno != ENOTTY)
            error("TCGETX: %m");
@@ -963,7 +1007,8 @@ set_up_tty(fd, local)
 #ifndef CRTSCTS
        inittermiox = tiox;
 #endif
-       ioctl(fd, TIOCGWINSZ, &wsinfo);
+       if (!sync_serial)
+           ioctl(fd, TIOCGWINSZ, &wsinfo);
     }
 
     tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
@@ -1007,7 +1052,7 @@ set_up_tty(fd, local)
         * We can't proceed if the serial port speed is 0,
         * since that implies that the serial port is disabled.
         */
-       if (speed == B0)
+       if ((speed == B0) && !sync_serial)
            fatal("Baud rate for %s is 0; need explicit baud rate", devnam);
     }
 
@@ -1015,13 +1060,14 @@ set_up_tty(fd, local)
        fatal("tcsetattr: %m");
 
 #ifndef CRTSCTS
-    if (termiox_ok && ioctl (fd, TCSETXF, &tiox) < 0){
+    if (!sync_serial && termiox_ok && ioctl (fd, TCSETXF, &tiox) < 0){
        error("TCSETXF: %m");
     }
 #endif
 
     baud_rate = inspeed = baud_rate_of(speed);
-    restore_term = 1;
+    if (!sync_serial)
+       restore_term = 1;
 }
 
 /*
@@ -1041,16 +1087,17 @@ restore_tty(fd)
             */
            inittermios.c_lflag &= ~(ECHO | ECHONL);
        }
-       if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
+       if (!sync_serial && tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
            if (!hungup && errno != ENXIO)
                warn("tcsetattr: %m");
 #ifndef CRTSCTS
-       if (ioctl (fd, TCSETXF, &inittermiox) < 0){
+       if (!sync_serial && ioctl (fd, TCSETXF, &inittermiox) < 0){
            if (!hungup && errno != ENXIO)
                error("TCSETXF: %m");
        }
 #endif
-       ioctl(fd, TIOCSWINSZ, &wsinfo);
+       if (!sync_serial)
+           ioctl(fd, TIOCSWINSZ, &wsinfo);
        restore_term = 0;
     }
 }
@@ -1274,13 +1321,15 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
        error("Couldn't set MTU: %m");
     }
     if (fdmuxid >= 0) {
-       /* can't set these if we don't have a stream attached below /dev/ppp */
-       if (strioctl(pppfd, PPPIO_XACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
-           error("Couldn't set transmit ACCM: %m");
+       if (!sync_serial) {
+           if (strioctl(pppfd, PPPIO_XACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
+               error("Couldn't set transmit ACCM: %m");
+           }
        }
        cf[0] = (pcomp? COMP_PROT: 0) + (accomp? COMP_AC: 0);
        cf[1] = COMP_PROT | COMP_AC;
-       if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
+       if (any_compressions() &&
+           strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
            error("Couldn't set prot/AC compression: %m");
        }
     }
@@ -1317,6 +1366,9 @@ ppp_set_xaccm(unit, accm)
     int unit;
     ext_accm accm;
 {
+    if (sync_serial)
+       return;
+
     if (fdmuxid >= 0
        && strioctl(pppfd, PPPIO_XACCM, accm, sizeof(ext_accm), 0) < 0) {
        if (!hungup || errno != ENXIO)
@@ -1343,13 +1395,15 @@ ppp_recv_config(unit, mru, asyncmap, pcomp, accomp)
        error("Couldn't set MRU: %m");
     }
     if (fdmuxid >= 0) {
-       /* can't set these if we don't have a stream attached below /dev/ppp */
-       if (strioctl(pppfd, PPPIO_RACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
-           error("Couldn't set receive ACCM: %m");
+       if (!sync_serial) {
+           if (strioctl(pppfd, PPPIO_RACCM, &asyncmap, sizeof(asyncmap), 0) < 0) {
+               error("Couldn't set receive ACCM: %m");
+           }
        }
        cf[0] = (pcomp? DECOMP_PROT: 0) + (accomp? DECOMP_AC: 0);
        cf[1] = DECOMP_PROT | DECOMP_AC;
-       if (strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
+       if (any_compressions() &&
+           strioctl(pppfd, PPPIO_CFLAGS, cf, sizeof(cf), sizeof(int)) < 0) {
            error("Couldn't set prot/AC decompression: %m");
        }
     }
@@ -1408,7 +1462,8 @@ get_ppp_stats(u, stats)
 {
     struct ppp_stats s;
 
-    if (strioctl(pppfd, PPPIO_GETSTAT, &s, 0, sizeof(s)) < 0) {
+    if (!sync_serial && 
+       strioctl(pppfd, PPPIO_GETSTAT, &s, 0, sizeof(s)) < 0) {
        error("Couldn't get link statistics: %m");
        return 0;
     }