* OR MODIFICATIONS.
*/
-#define RCSID "$Id: sys-svr4.c,v 1.38 1999/11/13 19:19:17 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"
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.
*/
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);
}
#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");
#ifndef CRTSCTS
inittermiox = tiox;
#endif
- ioctl(fd, TIOCGWINSZ, &wsinfo);
+ if (!sync_serial)
+ ioctl(fd, TIOCGWINSZ, &wsinfo);
}
tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
* 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);
}
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;
}
/*
*/
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;
}
}
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");
}
}
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)
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");
}
}
{
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;
}