From b218c6525807557e67f7985e546681757b45977c Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 24 May 1994 11:27:56 +0000 Subject: [PATCH 01/16] fix some minor compilation warnings --- pppd/sys-bsd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pppd/sys-bsd.c b/pppd/sys-bsd.c index ffce36a..709fe99 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.5 1994/05/09 02:33:41 paulus Exp $"; +static char rcsid[] = "$Id: sys-bsd.c,v 1.6 1994/05/24 11:27:56 paulus Exp $"; #endif /* @@ -282,6 +282,7 @@ sifvjcomp(u, vjcomp, cidcomp, maxcid) */ int sifup(u) + int u; { struct ifreq ifr; u_int x; @@ -313,6 +314,7 @@ sifup(u) */ int sifdown(u) + int u; { struct ifreq ifr; u_int x; @@ -357,6 +359,8 @@ sifdown(u) */ int sifaddr(u, o, h, m) + int u; + u_long o, h, m; { struct ifaliasreq ifra; @@ -386,6 +390,8 @@ sifaddr(u, o, h, m) */ int cifaddr(u, o, h) + int u; + u_long o, h; { struct ifaliasreq ifra; @@ -407,6 +413,8 @@ cifaddr(u, o, h) */ int sifdefaultroute(u, g) + int u; + u_long g; { struct ortentry rt; @@ -426,6 +434,8 @@ sifdefaultroute(u, g) */ int cifdefaultroute(u, g) + int u; + u_long g; { struct ortentry rt; -- 2.39.2 From 641e6003d6cb48bf970a590914d30ded6bc0952f Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 24 May 1994 11:28:26 +0000 Subject: [PATCH 02/16] incorporate logwtmp in here --- pppd/sys-linux.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 42fadaa..cbf0558 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -799,3 +802,19 @@ int ppp_available(void) return ok; } + +int +logwtmp(line, name, host) + char *line, *name, *host; +{ + struct utmp ut; + + memset (&ut, 0, sizeof (ut)); + (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line)); + (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name)); + (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host)); + (void)time(&ut.ut_time); + + pututline (&ut); /* Write the line to the proper place */ + endutent(); /* Indicate operation is complete */ +} -- 2.39.2 From dd0be651886e784c52772f29da4955a0b0e3f61e Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 24 May 1994 11:29:16 +0000 Subject: [PATCH 03/16] Initial revision --- pppd/Makefile.linux | 64 ++++++++++++++++++++++++++++++++++++++++++++ pppd/Makefile.ultrix | 56 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 pppd/Makefile.linux create mode 100644 pppd/Makefile.ultrix diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux new file mode 100644 index 0000000..d9a1364 --- /dev/null +++ b/pppd/Makefile.linux @@ -0,0 +1,64 @@ +# +# pppd makefile for Linux +# $Id: Makefile.linux,v 1.1 1994/05/24 11:29:16 paulus Exp $ +# + +BINDIR = /usr/etc +MANDIR = /usr/man + +PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c \ + auth.c options.c lock.c sys-linux.c logwtmp.c +HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h +MANPAGES = pppd.8 + +PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o \ + auth.o options.o lock.o sys-linux.o logwtmp.o + +all: pppd + +# +# include dependancies if present and backup if as a header file +ifeq (.depend,$(wildcard .depend)) +include .depend +HEADERS := $(HEADERS) .depend +endif + +# CC = gcc +# SECURE_FLAGS = -DREQ_SYSOPTIONS=1 +DEBUG_FLAGS = -DDEBUGALL +COMPILE_FLAGS = -I.. -D_linux_=1 -DGIDSET_TYPE=gid_t +COPTS = -g # -O2 +LOCKPREFIX = \"/usr/spool/uucp/LCK..\" +VER = 0.2.8 + +CFLAGS = $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS) $(SECURE_FLAGS) +SOURCE= RELNOTES Makefile.linux $(PPPDSRCS) $(HEADERS) $(MANPAGES) + +install: + install -c -m 4555 -o root pppd $(BINDIR)/pppd + install -c -m 555 -o root pppd.8 $(MANDIR)/man8 + +pppd: $(PPPDOBJS) + $(CC) $(CFLAGS) -o pppd $(PPPDOBJS) $(LIBS) + +pppd.tar: $(SOURCE) + tar -cvf pppd.tar $(SOURCE) + +pppd.tar.gz: pppd.tar + gzip pppd.tar + +clean: + rm -f $(PPPDOBJS) pppd *~ #* core + +depend: + $(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend + +options.o: options.c + $(CC) -c -o options.o $(CFLAGS) \ + "-DIMPLEMENTATION=\" (Linux $(VER))\"" options.c + +lock.o: lock.c + $(CC) -c -o lock.o $(CFLAGS) -DPIDSTRING=1 -DLOCK_DIR=1 \ + "-DLOCK_PREFIX=$(LOCKPREFIX)" lock.c + +saber_pppd: diff --git a/pppd/Makefile.ultrix b/pppd/Makefile.ultrix new file mode 100644 index 0000000..b5d0b97 --- /dev/null +++ b/pppd/Makefile.ultrix @@ -0,0 +1,56 @@ +# +# pppd makefile for Ultrix +# $Id: Makefile.ultrix,v 1.1 1994/05/24 11:29:16 paulus Exp $ +# + +BINDIR = /usr/local/etc +MANDIR = /usr/local/man + +PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c logwtmp.c chap.c md5.c \ + auth.c options.c lock.c sys-bsd.c sys-str.c sys-ultrix.c +HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h +MANPAGES = pppd.8 + +PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o logwtmp.o chap.o md5.o \ + auth.o options.o lock.o sys-ultrix.o + +# CC = gcc +DEBUG_FLAGS = +SECURE_FLAGS = -DREQ_SYSOPTIONS=1 +COMPILE_FLAGS = -DNO_DRAND48 +COPTS = -O +LIBS = + +CFLAGS = -I.. $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS) $(SECURE_FLAGS) + +SOURCE= RELNOTES Makefile \ + $(PPPDSRCS) $(HEADERS) $(MANPAGES) + +all: pppd + +install: + install -c -m 4555 -o root -g daemon pppd $(BINDIR)/pppd + install -c -m 555 -o root pppd.8 $(MANDIR)/man8 + +pppd: $(PPPDOBJS) + $(CC) $(CFLAGS) -o pppd $(PPPDOBJS) $(LIBS) + +pppd.tar: $(SOURCE) + tar -cvf pppd.tar $(SOURCE) + +pppd.tar.Z: pppd.tar + compress pppd.tar + +clean: + rm -f $(PPPDOBJS) pppd *~ #* core + +depend: + cpp -M $(CFLAGS) $(PPPDSRCS) >.depend +# makedepend $(CFLAGS) $(PPPDSRCS) + +saber_pppd: + #setopt load_flags $(CFLAGS) + #setopt ansi + #suppress 452 md5.c + #load $(PPPDSRCS) + -- 2.39.2 From f27c83b9477c241da09be3225915153a3deeabdb Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 24 May 1994 11:31:54 +0000 Subject: [PATCH 04/16] removed logwtmp --- pppd/Makefile.linux | 6 +++--- pppd/Makefile.sun | 6 +++--- pppd/Makefile.ultrix | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux index d9a1364..a3936b8 100644 --- a/pppd/Makefile.linux +++ b/pppd/Makefile.linux @@ -1,18 +1,18 @@ # # pppd makefile for Linux -# $Id: Makefile.linux,v 1.1 1994/05/24 11:29:16 paulus Exp $ +# $Id: Makefile.linux,v 1.2 1994/05/24 11:31:54 paulus Exp $ # BINDIR = /usr/etc MANDIR = /usr/man PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c \ - auth.c options.c lock.c sys-linux.c logwtmp.c + auth.c options.c lock.c sys-linux.c HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h MANPAGES = pppd.8 PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o \ - auth.o options.o lock.o sys-linux.o logwtmp.o + auth.o options.o lock.o sys-linux.o all: pppd diff --git a/pppd/Makefile.sun b/pppd/Makefile.sun index c327f63..32ea015 100644 --- a/pppd/Makefile.sun +++ b/pppd/Makefile.sun @@ -1,17 +1,17 @@ # # pppd makefile for Suns -# $Id: Makefile.sun,v 1.4 1994/04/20 00:09:02 paulus Exp $ +# $Id: Makefile.sun,v 1.5 1994/05/24 11:30:39 paulus Exp $ # BINDIR = /usr/local/etc MANDIR = /usr/local/man -PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c logwtmp.c chap.c md5.c \ +PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c \ auth.c options.c lock.c sys-bsd.c sys-str.c sys-ultrix.c HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h MANPAGES = pppd.8 -PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o logwtmp.o chap.o md5.o \ +PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o \ auth.o options.o lock.o sys-str.o # CC = gcc diff --git a/pppd/Makefile.ultrix b/pppd/Makefile.ultrix index b5d0b97..8dc3aad 100644 --- a/pppd/Makefile.ultrix +++ b/pppd/Makefile.ultrix @@ -1,17 +1,17 @@ # # pppd makefile for Ultrix -# $Id: Makefile.ultrix,v 1.1 1994/05/24 11:29:16 paulus Exp $ +# $Id: Makefile.ultrix,v 1.2 1994/05/24 11:31:14 paulus Exp $ # BINDIR = /usr/local/etc MANDIR = /usr/local/man -PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c logwtmp.c chap.c md5.c \ +PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c \ auth.c options.c lock.c sys-bsd.c sys-str.c sys-ultrix.c HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h MANPAGES = pppd.8 -PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o logwtmp.o chap.o md5.o \ +PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o \ auth.o options.o lock.o sys-ultrix.o # CC = gcc -- 2.39.2 From a5aa46a5e2377042a0e39434fa41d4dd40e8facf Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 25 May 1994 06:25:05 +0000 Subject: [PATCH 05/16] remove commented-out code --- pppd/auth.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pppd/auth.c b/pppd/auth.c index 9a04ecf..950ef02 100644 --- a/pppd/auth.c +++ b/pppd/auth.c @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: auth.c,v 1.5 1994/05/24 11:20:26 paulus Exp $"; +static char rcsid[] = "$Id: auth.c,v 1.6 1994/05/25 06:25:05 paulus Exp $"; #endif #include @@ -59,10 +59,6 @@ static char rcsid[] = "$Id: auth.c,v 1.5 1994/05/24 11:20:26 paulus Exp $"; #ifdef sparc #include -#ifndef __GNUC__ -/* why alloca.h doesn't define what alloca() returns is a mystery */ -/* char *alloca __ARGS((int)); */ -#endif /*__GNUC__*/ #endif /*sparc*/ /* Used for storing a sequence of words. Usually malloced. */ -- 2.39.2 From ba68145197d2cf11987325628a330ee0ca651787 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 25 May 1994 06:25:48 +0000 Subject: [PATCH 06/16] formatting, fixed compiler warnings, added -vjccomp option --- pppd/options.c | 224 +++++++++++++++++++++++++++---------------------- 1 file changed, 124 insertions(+), 100 deletions(-) diff --git a/pppd/options.c b/pppd/options.c index e92fb20..a8ded25 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -18,12 +18,13 @@ */ #ifndef lint -static char rcsid[] = "$Id: options.c,v 1.8 1994/05/24 11:24:32 paulus Exp $"; +static char rcsid[] = "$Id: options.c,v 1.9 1994/05/25 06:25:48 paulus Exp $"; #endif #include #include #include +#include #include #include #include @@ -64,6 +65,8 @@ static int setpassive __ARGS((void)); static int setsilent __ARGS((void)); static int noopt __ARGS((void)); static int setnovj __ARGS((void)); +static int setnovjccomp __ARGS((void)); +static int setvjslots __ARGS((char **)); static int reqpap __ARGS((void)); static int nopap __ARGS((void)); static int setupapfile __ARGS((char **)); @@ -116,9 +119,8 @@ static int setchapchal __ARGS((char **)); static int setchapintv __ARGS((char **)); static int setipcpaccl __ARGS((void)); static int setipcpaccr __ARGS((void)); -static int setlcpechointerval __ARGS((char **)); +static int setlcpechointv __ARGS((char **)); static int setlcpechofails __ARGS((char **)); -static int setslots __ARGS((char **)); static int number_option __ARGS((char *, long *, int)); static int readable __ARGS((int fd)); @@ -146,7 +148,6 @@ extern int auth_required; extern int proxyarp; extern int persist; extern int uselogin; -extern int nslots; extern u_long lcp_echo_interval; extern u_long lcp_echo_fails; extern char our_name[]; @@ -162,71 +163,72 @@ static struct cmd { int num_args; int (*cmd_func)(); } cmds[] = { - "-all", 0, noopt, /* Don't request/allow any options */ - "-ac", 0, noaccomp, /* Disable Address/Control compress */ - "-am", 0, noasyncmap, /* Disable asyncmap negotiation */ - "-as", 1, setasyncmap, /* set the desired async map */ - "-d", 0, setdebug, /* Increase debugging level */ - "-detach", 0, setnodetach, /* don't fork */ - "-ip", 0, noipaddr, /* Disable IP address negotiation */ - "-mn", 0, nomagicnumber, /* Disable magic number negotiation */ - "-mru", 0, nomru, /* Disable mru negotiation */ - "-p", 0, setpassive, /* Set passive mode */ - "-pc", 0, nopcomp, /* Disable protocol field compress */ - "+ua", 1, setupapfile, /* Get PAP user and password from file */ - "+pap", 0, reqpap, /* Require PAP auth from peer */ - "-pap", 0, nopap, /* Don't allow UPAP authentication with peer */ - "+chap", 0, reqchap, /* Require CHAP authentication from peer */ - "-chap", 0, nochap, /* Don't allow CHAP authentication with peer */ - "-vj", 0, setnovj, /* disable VJ compression */ - "asyncmap", 1, setasyncmap, /* set the desired async map */ - "escape", 1, setescape, /* set chars to escape on transmission */ - "connect", 1, setconnector, /* A program to set up a connection */ - "disconnect", 1, setdisconnector, /* program to disconnect serial dev. */ - "crtscts", 0, setcrtscts, /* set h/w flow control */ - "xonxoff", 0, setxonxoff, /* set s/w flow control */ - "-crtscts", 0, setxonxoff, /* another name for xonxoff */ - "debug", 0, setdebug, /* Increase debugging level */ - "kdebug", 1, setkdebug, /* Enable kernel-level debugging */ - "domain", 1, setdomain, /* Add given domain name to hostname*/ - "mru", 1, setmru, /* Set MRU value for negotiation */ - "mtu", 1, setmtu, /* Set our MTU */ - "netmask", 1, setnetmask, /* set netmask */ - "passive", 0, setpassive, /* Set passive mode */ - "silent", 0, setsilent, /* Set silent mode */ - "modem", 0, setmodem, /* Use modem control lines */ - "local", 0, setlocal, /* Don't use modem control lines */ - "lock", 0, setlock, /* Lock serial device (with lock file) */ - "name", 1, setname, /* Set local name for authentication */ - "user", 1, setuser, /* Set username for PAP auth with peer */ - "usehostname", 0, setusehostname, /* Must use hostname for auth. */ - "remotename", 1, setremote, /* Set remote name for authentication */ - "auth", 0, setauth, /* Require authentication from peer */ - "file", 1, readfile, /* Take options from a file */ - "defaultroute", 0, setdefaultroute, /* Add default route */ - "proxyarp", 0, setproxyarp, /* Add proxy ARP entry */ - "persist", 0, setpersist, /* Keep on reopening connection after close */ - "login", 0, setdologin, /* Use system password database for UPAP */ - "noipdefault", 0, setnoipdflt, /* Don't use name for default IP adrs */ - "lcp-echo-failure", 1, setlcpechofails, /* consecutive echo failures */ - "lcp-echo-interval", 1, setlcpechointerval, /* time for lcp echo events */ - "lcp-restart", 1, setlcptimeout, /* Set timeout for LCP */ - "lcp-max-terminate", 1, setlcpterm, /* Set max #xmits for term-reqs */ - "lcp-max-configure", 1, setlcpconf, /* Set max #xmits for conf-reqs */ - "lcp-max-failure", 1, setlcpfails, /* Set max #conf-naks for LCP */ - "ipcp-restart", 1, setipcptimeout, /* Set timeout for IPCP */ - "ipcp-max-terminate", 1, setipcpterm, /* Set max #xmits for term-reqs */ - "ipcp-max-configure", 1, setipcpconf, /* Set max #xmits for conf-reqs */ - "ipcp-max-failure", 1, setipcpfails, /* Set max #conf-naks for IPCP */ - "ipcp-max-slots", 1, setslots, /* Set maximum vj header slots */ - "pap-restart", 1, setpaptimeout, /* Set timeout for UPAP */ - "pap-max-authreq", 1, setpapreqs, /* Set max #xmits for auth-reqs */ - "chap-restart", 1, setchaptimeout, /* Set timeout for CHAP */ - "chap-max-challenge", 1, setchapchal, /* Set max #xmits for challenge */ - "chap-interval", 1, setchapintv, /* Set interval for rechallenge */ - "ipcp-accept-local", 0, setipcpaccl, /* Accept peer's address for us */ - "ipcp-accept-remote", 0, setipcpaccr, /* Accept peer's address for it */ - NULL + {"-all", 0, noopt}, /* Don't request/allow any options */ + {"-ac", 0, noaccomp}, /* Disable Address/Control compress */ + {"-am", 0, noasyncmap}, /* Disable asyncmap negotiation */ + {"-as", 1, setasyncmap}, /* set the desired async map */ + {"-d", 0, setdebug}, /* Increase debugging level */ + {"-detach", 0, setnodetach}, /* don't fork */ + {"-ip", 0, noipaddr}, /* Disable IP address negotiation */ + {"-mn", 0, nomagicnumber}, /* Disable magic number negotiation */ + {"-mru", 0, nomru}, /* Disable mru negotiation */ + {"-p", 0, setpassive}, /* Set passive mode */ + {"-pc", 0, nopcomp}, /* Disable protocol field compress */ + {"+ua", 1, setupapfile}, /* Get PAP user and password from file */ + {"+pap", 0, reqpap}, /* Require PAP auth from peer */ + {"-pap", 0, nopap}, /* Don't allow UPAP authentication with peer */ + {"+chap", 0, reqchap}, /* Require CHAP authentication from peer */ + {"-chap", 0, nochap}, /* Don't allow CHAP authentication with peer */ + {"-vj", 0, setnovj}, /* disable VJ compression */ + {"-vjccomp", 0, setnovjccomp}, /* disable VJ connection-ID compression */ + {"vj-max-slots", 1, setvjslots}, /* Set maximum VJ header slots */ + {"asyncmap", 1, setasyncmap}, /* set the desired async map */ + {"escape", 1, setescape}, /* set chars to escape on transmission */ + {"connect", 1, setconnector}, /* A program to set up a connection */ + {"disconnect", 1, setdisconnector}, /* program to disconnect serial dev. */ + {"crtscts", 0, setcrtscts}, /* set h/w flow control */ + {"xonxoff", 0, setxonxoff}, /* set s/w flow control */ + {"-crtscts", 0, setxonxoff}, /* another name for xonxoff */ + {"debug", 0, setdebug}, /* Increase debugging level */ + {"kdebug", 1, setkdebug}, /* Enable kernel-level debugging */ + {"domain", 1, setdomain}, /* Add given domain name to hostname*/ + {"mru", 1, setmru}, /* Set MRU value for negotiation */ + {"mtu", 1, setmtu}, /* Set our MTU */ + {"netmask", 1, setnetmask}, /* set netmask */ + {"passive", 0, setpassive}, /* Set passive mode */ + {"silent", 0, setsilent}, /* Set silent mode */ + {"modem", 0, setmodem}, /* Use modem control lines */ + {"local", 0, setlocal}, /* Don't use modem control lines */ + {"lock", 0, setlock}, /* Lock serial device (with lock file) */ + {"name", 1, setname}, /* Set local name for authentication */ + {"user", 1, setuser}, /* Set username for PAP auth with peer */ + {"usehostname", 0, setusehostname}, /* Must use hostname for auth. */ + {"remotename", 1, setremote}, /* Set remote name for authentication */ + {"auth", 0, setauth}, /* Require authentication from peer */ + {"file", 1, readfile}, /* Take options from a file */ + {"defaultroute", 0, setdefaultroute}, /* Add default route */ + {"proxyarp", 0, setproxyarp}, /* Add proxy ARP entry */ + {"persist", 0, setpersist}, /* Keep on reopening connection after close */ + {"login", 0, setdologin}, /* Use system password database for UPAP */ + {"noipdefault", 0, setnoipdflt}, /* Don't use name for default IP adrs */ + {"lcp-echo-failure", 1, setlcpechofails}, /* consecutive echo failures */ + {"lcp-echo-interval", 1, setlcpechointv}, /* time for lcp echo events */ + {"lcp-restart", 1, setlcptimeout}, /* Set timeout for LCP */ + {"lcp-max-terminate", 1, setlcpterm}, /* Set max #xmits for term-reqs */ + {"lcp-max-configure", 1, setlcpconf}, /* Set max #xmits for conf-reqs */ + {"lcp-max-failure", 1, setlcpfails}, /* Set max #conf-naks for LCP */ + {"ipcp-restart", 1, setipcptimeout}, /* Set timeout for IPCP */ + {"ipcp-max-terminate", 1, setipcpterm}, /* Set max #xmits for term-reqs */ + {"ipcp-max-configure", 1, setipcpconf}, /* Set max #xmits for conf-reqs */ + {"ipcp-max-failure", 1, setipcpfails}, /* Set max #conf-naks for IPCP */ + {"pap-restart", 1, setpaptimeout}, /* Set timeout for UPAP */ + {"pap-max-authreq", 1, setpapreqs}, /* Set max #xmits for auth-reqs */ + {"chap-restart", 1, setchaptimeout}, /* Set timeout for CHAP */ + {"chap-max-challenge", 1, setchapchal}, /* Set max #xmits for challenge */ + {"chap-interval", 1, setchapintv}, /* Set interval for rechallenge */ + {"ipcp-accept-local", 0, setipcpaccl}, /* Accept peer's address for us */ + {"ipcp-accept-remote", 0, setipcpaccr}, /* Accept peer's address for it */ + {NULL, 0, NULL} }; @@ -879,7 +881,7 @@ reqchap() /* - * setnovj - diable vj compression + * setnovj - disable vj compression */ static int setnovj() @@ -889,6 +891,39 @@ setnovj() return (1); } + +/* + * setnovjccomp - disable VJ connection-ID compression + */ +static int +setnovjccomp() +{ + ipcp_wantoptions[0].cflag = 0; + ipcp_allowoptions[0].cflag = 0; +} + + +/* + * setvjslots - set maximum number of connection slots for VJ compression + */ +static int +setvjslots(argv) + char **argv; +{ + int value; + + if (!int_option(*argv, &value)) + return 0; + if (value < 2 || value > 16) { + fprintf(stderr, "pppd: vj-max-slots value must be between 2 and 16\n"); + return 0; + } + ipcp_wantoptions [0].maxslotindex = + ipcp_allowoptions[0].maxslotindex = value - 1; + return 1; +} + + /* * setconnector - Set a program to connect to a serial line */ @@ -1316,16 +1351,18 @@ setdologin() * Functions to set the echo interval for modem-less monitors */ -static int setlcpechointerval(argv) +static int +setlcpechointv(argv) char **argv; { - return int_option(*argv, &lcp_echo_interval, 0); + return int_option(*argv, &lcp_echo_interval); } -static int setlcpechofails(argv) +static int +setlcpechofails(argv) char **argv; { - return int_option(*argv, &lcp_echo_fails, 0); + return int_option(*argv, &lcp_echo_fails); } /* @@ -1335,90 +1372,77 @@ static int setlcptimeout(argv) char **argv; { - return int_option(*argv, &lcp_fsm[0].timeouttime, 0); + return int_option(*argv, &lcp_fsm[0].timeouttime); } static int setlcpterm(argv) char **argv; { - return int_option(*argv, &lcp_fsm[0].maxtermtransmits, 0); + return int_option(*argv, &lcp_fsm[0].maxtermtransmits); } static int setlcpconf(argv) char **argv; { - return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits, 0); + return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits); } static int setlcpfails(argv) char **argv; { - return int_option(*argv, &lcp_fsm[0].maxnakloops, 0); + return int_option(*argv, &lcp_fsm[0].maxnakloops); } static int setipcptimeout(argv) char **argv; { - return int_option(*argv, &ipcp_fsm[0].timeouttime, 0); + return int_option(*argv, &ipcp_fsm[0].timeouttime); } static int setipcpterm(argv) char **argv; { - return int_option(*argv, &ipcp_fsm[0].maxtermtransmits, 0); + return int_option(*argv, &ipcp_fsm[0].maxtermtransmits); } static int setipcpconf(argv) char **argv; { - return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits, 0); + return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits); } static int setipcpfails(argv) char **argv; { - return int_option(*argv, &lcp_fsm[0].maxnakloops, 0); + return int_option(*argv, &lcp_fsm[0].maxnakloops); } static int setpaptimeout(argv) char **argv; { - return int_option(*argv, &upap[0].us_timeouttime, 0); + return int_option(*argv, &upap[0].us_timeouttime); } static int setpapreqs(argv) char **argv; { - return int_option(*argv, &upap[0].us_maxtransmits, 0); + return int_option(*argv, &upap[0].us_maxtransmits); } static int setchaptimeout(argv) char **argv; { - return int_option(*argv, &chap[0].timeouttime, 0); + return int_option(*argv, &chap[0].timeouttime); } static int setchapchal(argv) char **argv; { - return int_option(*argv, &chap[0].max_transmits, 0); + return int_option(*argv, &chap[0].max_transmits); } static int setchapintv(argv) char **argv; { - return int_option(*argv, &chap[0].chal_interval, 0); -} - -static int setslots(argv) - char **argv; -{ - int value; - int answer = int_option(*argv, &value, 0); - - if (answer == 1 && value > 1 && value < 17) { - ipcp_wantoptions [0].maxslotindex = - ipcp_allowoptions[0].maxslotindex = value - 1; - } - return answer; + return int_option(*argv, &chap[0].chal_interval); } -- 2.39.2 From ad1633bf83dad763f6a048e439ba23649abf07a5 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 25 May 1994 06:26:35 +0000 Subject: [PATCH 07/16] fixed compilation errors and warnings --- pppd/sys-str.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pppd/sys-str.c b/pppd/sys-str.c index b7c2c5a..0f9a78c 100644 --- a/pppd/sys-str.c +++ b/pppd/sys-str.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -364,6 +363,7 @@ sifvjcomp(u, vjcomp, cidcomp, maxcid) */ int sifup(u) + int u; { struct ifreq ifr; @@ -385,6 +385,7 @@ sifup(u) */ int sifdown(u) + int u; { struct ifreq ifr; strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); @@ -412,6 +413,8 @@ sifdown(u) */ int sifaddr(u, o, h, m) + int u; + u_long o, h, m; { int ret; struct ifreq ifr; @@ -446,6 +449,8 @@ sifaddr(u, o, h, m) */ int cifaddr(u, o, h) + int u; + u_long o, h; { struct rtentry rt; @@ -466,6 +471,8 @@ cifaddr(u, o, h) */ int sifdefaultroute(u, g) + int u; + u_long g; { struct rtentry rt; @@ -485,6 +492,8 @@ sifdefaultroute(u, g) */ int cifdefaultroute(u, g) + int u; + u_long g; { struct rtentry rt; @@ -601,7 +610,7 @@ cifproxyarp(unit, hisaddr) static struct nlist nl[] = { #define N_IFNET 0 { "_ifnet" }, - 0 + { 0 } }; static void kread(); -- 2.39.2 From 81e6dc9bf0111a40024285a9f7e66b0cd14e2e94 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 25 May 1994 06:30:49 +0000 Subject: [PATCH 08/16] fixed compilation errors --- pppd/sys-ultrix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pppd/sys-ultrix.c b/pppd/sys-ultrix.c index d1f3cb7..ca8f2a4 100644 --- a/pppd/sys-ultrix.c +++ b/pppd/sys-ultrix.c @@ -19,7 +19,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-ultrix.c,v 1.3 1994/05/24 11:26:21 paulus Exp $"; +static char rcsid[] = "$Id: sys-ultrix.c,v 1.4 1994/05/25 06:30:49 paulus Exp $"; #endif /* @@ -27,11 +27,14 @@ static char rcsid[] = "$Id: sys-ultrix.c,v 1.3 1994/05/24 11:26:21 paulus Exp $" */ #include +#include #include +#include #include #include #include #include +#include #include -- 2.39.2 From 73bed7c25b5e8f4015c8a274fbef1f34342bca65 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 25 May 1994 06:31:10 +0000 Subject: [PATCH 09/16] *** empty log message *** --- pppd/Makefile.sun | 7 +++---- pppd/Makefile.ultrix | 7 +++---- pppd/patchlevel.h | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pppd/Makefile.sun b/pppd/Makefile.sun index 32ea015..932156e 100644 --- a/pppd/Makefile.sun +++ b/pppd/Makefile.sun @@ -1,13 +1,13 @@ # # pppd makefile for Suns -# $Id: Makefile.sun,v 1.5 1994/05/24 11:30:39 paulus Exp $ +# $Id: Makefile.sun,v 1.6 1994/05/25 06:28:42 paulus Exp $ # BINDIR = /usr/local/etc MANDIR = /usr/local/man PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c \ - auth.c options.c lock.c sys-bsd.c sys-str.c sys-ultrix.c + auth.c options.c lock.c sys-bsd.c sys-str.c sys-ultrix.c sys-linux.c HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h MANPAGES = pppd.8 @@ -16,12 +16,11 @@ PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o \ # CC = gcc DEBUG_FLAGS = -# SECURE_FLAGS = -DREQ_SYSOPTIONS=1 COMPILE_FLAGS = -DSTREAMS COPTS = -O LIBS = -lkvm -CFLAGS = -I.. $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS) $(SECURE_FLAGS) +CFLAGS = -I.. $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS) SOURCE= RELNOTES Makefile \ $(PPPDSRCS) $(HEADERS) $(MANPAGES) diff --git a/pppd/Makefile.ultrix b/pppd/Makefile.ultrix index 8dc3aad..8281767 100644 --- a/pppd/Makefile.ultrix +++ b/pppd/Makefile.ultrix @@ -1,13 +1,13 @@ # # pppd makefile for Ultrix -# $Id: Makefile.ultrix,v 1.2 1994/05/24 11:31:14 paulus Exp $ +# $Id: Makefile.ultrix,v 1.3 1994/05/25 06:31:10 paulus Exp $ # BINDIR = /usr/local/etc MANDIR = /usr/local/man PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c \ - auth.c options.c lock.c sys-bsd.c sys-str.c sys-ultrix.c + auth.c options.c lock.c sys-bsd.c sys-str.c sys-ultrix.c sys-linux.c HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h MANPAGES = pppd.8 @@ -16,12 +16,11 @@ PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o \ # CC = gcc DEBUG_FLAGS = -SECURE_FLAGS = -DREQ_SYSOPTIONS=1 COMPILE_FLAGS = -DNO_DRAND48 COPTS = -O LIBS = -CFLAGS = -I.. $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS) $(SECURE_FLAGS) +CFLAGS = -I.. $(COPTS) $(DEBUG_FLAGS) $(COMPILE_FLAGS) SOURCE= RELNOTES Makefile \ $(PPPDSRCS) $(HEADERS) $(MANPAGES) diff --git a/pppd/patchlevel.h b/pppd/patchlevel.h index 2ace50e..8ff8b23 100644 --- a/pppd/patchlevel.h +++ b/pppd/patchlevel.h @@ -1,5 +1,5 @@ -/* $Id: patchlevel.h,v 1.8 1994/05/18 06:34:56 paulus Exp $ */ +/* $Id: patchlevel.h,v 1.9 1994/05/25 06:26:15 paulus Exp $ */ #define PATCHLEVEL 1 #define VERSION "2.1" -#define DATE "18 May 94" +#define DATE "25 May 94" -- 2.39.2 From b2a66daf7f277c6f7e1b38e6889ce62fd8f661ad Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 26 May 1994 06:33:18 +0000 Subject: [PATCH 10/16] added ext_accm defn so we don't need if_ppp.h --- include/net/ppp_str.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/net/ppp_str.h b/include/net/ppp_str.h index 8339f96..e468b4b 100644 --- a/include/net/ppp_str.h +++ b/include/net/ppp_str.h @@ -9,6 +9,9 @@ #include +/* Extended asyncmap - allows any character to be escaped. */ +typedef u_long ext_accm[8]; + #ifdef __STDC__ #define SIOCSIFCOMPAC _IOW('p', 130, char) #define SIOCSIFCOMPPROT _IOW('p', 131, char) -- 2.39.2 From e507f7cddfb46ae65a2ae01c3b52de087728cdca Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 26 May 1994 06:36:22 +0000 Subject: [PATCH 11/16] don't need if_ppp.h --- pppd/main.c | 10 +++------- pppd/sys-str.c | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pppd/main.c b/pppd/main.c index 1bdca87..5fd465c 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -18,12 +18,13 @@ */ #ifndef lint -static char rcsid[] = "$Id: main.c,v 1.11 1994/05/24 11:25:33 paulus Exp $"; +static char rcsid[] = "$Id: main.c,v 1.12 1994/05/26 06:36:22 paulus Exp $"; #endif #define SETSID #include +#include #include #include #include @@ -55,14 +56,9 @@ static char rcsid[] = "$Id: main.c,v 1.11 1994/05/24 11:25:33 paulus Exp $"; #include #include #include - -#include "callout.h" - #include -#include - -#include +#include "callout.h" #include "ppp.h" #include "magic.h" #include "fsm.h" diff --git a/pppd/sys-str.c b/pppd/sys-str.c index 0f9a78c..c197d4b 100644 --- a/pppd/sys-str.c +++ b/pppd/sys-str.c @@ -43,7 +43,6 @@ #include "pppd.h" #include "ppp.h" -#include #include #ifndef ifr_mtu -- 2.39.2 From f50d423b796b25ea4a7cf6f9fd33bfdb82546512 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 26 May 1994 06:37:34 +0000 Subject: [PATCH 12/16] don't need if.h or if_ppp.h --- pppd/ipcp.c | 5 +---- pppd/lcp.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/pppd/ipcp.c b/pppd/ipcp.c index 7d71463..6c9abb1 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: ipcp.c,v 1.7 1994/05/24 11:21:52 paulus Exp $"; +static char rcsid[] = "$Id: ipcp.c,v 1.8 1994/05/26 06:37:34 paulus Exp $"; #endif /* @@ -31,9 +31,6 @@ static char rcsid[] = "$Id: ipcp.c,v 1.7 1994/05/24 11:21:52 paulus Exp $"; #include #include -#include -#include - #include "pppd.h" #include "ppp.h" #include "fsm.h" diff --git a/pppd/lcp.c b/pppd/lcp.c index cd0f6f8..6da9631 100644 --- a/pppd/lcp.c +++ b/pppd/lcp.c @@ -18,7 +18,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: lcp.c,v 1.5 1994/05/24 11:23:13 paulus Exp $"; +static char rcsid[] = "$Id: lcp.c,v 1.6 1994/05/26 06:37:19 paulus Exp $"; #endif /* @@ -32,9 +32,6 @@ static char rcsid[] = "$Id: lcp.c,v 1.5 1994/05/24 11:23:13 paulus Exp $"; #include #include #include - -#include -#include #include #include -- 2.39.2 From b8d13a030e509e50293be06c42f7b2b0f8c30dcf Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 26 May 1994 06:43:42 +0000 Subject: [PATCH 13/16] add casts to eliminate compiler warnings --- pppd/pppd.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pppd/pppd.h b/pppd/pppd.h index fcd170d..e38687d 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pppd.h,v 1.2 1994/04/18 04:08:41 paulus Exp $ + * $Id: pppd.h,v 1.3 1994/05/26 06:43:42 paulus Exp $ */ /* @@ -89,7 +89,7 @@ u_long GetMask __ARGS((u_long)); /* get netmask for address */ (c) = *(cp)++; \ } #define PUTCHAR(c, cp) { \ - *(cp)++ = (c); \ + *(cp)++ = (u_char) (c); \ } @@ -98,8 +98,8 @@ u_long GetMask __ARGS((u_long)); /* get netmask for address */ (s) |= *(cp)++; \ } #define PUTSHORT(s, cp) { \ - *(cp)++ = (s) >> 8; \ - *(cp)++ = (s); \ + *(cp)++ = (u_char) ((s) >> 8); \ + *(cp)++ = (u_char) (s); \ } #define GETLONG(l, cp) { \ @@ -109,10 +109,10 @@ u_long GetMask __ARGS((u_long)); /* get netmask for address */ (l) |= *(cp)++; \ } #define PUTLONG(l, cp) { \ - *(cp)++ = (l) >> 24; \ - *(cp)++ = (l) >> 16; \ - *(cp)++ = (l) >> 8; \ - *(cp)++ = (l); \ + *(cp)++ = (u_char) ((l) >> 24); \ + *(cp)++ = (u_char) ((l) >> 16); \ + *(cp)++ = (u_char) ((l) >> 8); \ + *(cp)++ = (u_char) (l); \ } #define INCPTR(n, cp) ((cp) += (n)) -- 2.39.2 From e7cd65cd2988e1b6b7661ffcf5cd1f037879e583 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 26 May 1994 06:45:03 +0000 Subject: [PATCH 14/16] now have man page --- chat/Makefile.bsd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chat/Makefile.bsd b/chat/Makefile.bsd index c2e10e5..c7e5081 100644 --- a/chat/Makefile.bsd +++ b/chat/Makefile.bsd @@ -1,8 +1,8 @@ -# $Id: Makefile.bsd,v 1.1 1994/05/20 05:32:16 paulus Exp $ +# $Id: Makefile.bsd,v 1.2 1994/05/26 06:45:03 paulus Exp $ PROG= chat SRCS= chat.c -NOMAN= noman +MAN8= chat.0 BINDIR= /usr/sbin .include -- 2.39.2 From fe1af7dab67e6bcbcd0c5eab58921d4732fcb0aa Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Thu, 26 May 1994 06:45:52 +0000 Subject: [PATCH 15/16] will compile under non-ANSI compiler; removed varargs/stdarg stuff --- chat/chat.c | 715 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 494 insertions(+), 221 deletions(-) diff --git a/chat/chat.c b/chat/chat.c index 4987369..4079415 100644 --- a/chat/chat.c +++ b/chat/chat.c @@ -6,6 +6,11 @@ * * Please send all bug reports, requests for information, etc. to: * + * Al Longyear (longyear@netcom.com) + * (I was the last person to change this code.) + * + * The original author is: + * * Karl Fox * Morning Star Technologies, Inc. * 1760 Zollinger Road @@ -13,19 +18,18 @@ * (614)451-1883 */ -/*static char sccs_id[] = "@(#)chat.c 1.7";*/ -static char rcsid[] = "$Id: chat.c,v 1.1 1994/05/20 05:32:16 paulus Exp $"; - #include #include #include #include +#include +#include #include #include -#include #include #ifndef TERMIO +#undef TERMIOS #define TERMIOS #endif @@ -37,10 +41,6 @@ static char rcsid[] = "$Id: chat.c,v 1.1 1994/05/20 05:32:16 paulus Exp $"; # endif #endif -#ifdef ultrix -#define SIGHAND_TYPE int (*)() -#endif - #ifdef TERMIO #include #endif @@ -54,6 +54,14 @@ static char rcsid[] = "$Id: chat.c,v 1.1 1994/05/20 05:32:16 paulus Exp $"; #define SIGTYPE void #endif +#ifdef __STDC__ +#undef __P +#define __P(x) x +#else +#define __P(x) () +#define const +#endif + /*************** Micro getopt() *********************************************/ #define OPTION(c,v) (_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \ (--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\ @@ -68,10 +76,6 @@ static int _O = 0; /* Internal state */ char *program_name; -extern char *strcpy(), *strcat(), *malloc(); -extern int strlen(); -#define copyof(s) ((s) ? strcpy(malloc(strlen(s) + 1), s) : (s)) - #ifndef LOCK_DIR # ifdef __NetBSD__ # define PIDSTRING @@ -92,6 +96,7 @@ extern int strlen(); int verbose = 0; int quiet = 0; char *lock_file = (char *)0; +char *chat_file = (char *)0; int timeout = DEFAULT_CHAT_TIMEOUT; int have_tty_parameters = 0; @@ -106,17 +111,69 @@ char *abort_string[MAX_ABORTS], *fail_reason = (char *)0, fail_buffer[50]; int n_aborts = 0, abort_next = 0, timeout_next = 0; +void *dup_mem __P((void *b, size_t c)); +void *copy_of __P((char *s)); +void usage __P((void)); +void logf __P((const char *str)); +void logflush __P((void)); +void fatal __P((const char *msg)); +void sysfatal __P((const char *msg)); +SIGTYPE sigalrm __P((int signo)); +SIGTYPE sigint __P((int signo)); +SIGTYPE sigterm __P((int signo)); +SIGTYPE sighup __P((int signo)); +void unalarm __P((void)); +void init __P((void)); +void set_tty_parameters __P((void)); +void break_sequence __P((void)); +void terminate __P((int status)); +void do_file __P((char *chat_file)); +void lock __P((void)); +void delay __P((void)); +int get_string __P((register char *string)); +int put_string __P((register char *s)); +int write_char __P((int c)); +int put_char __P((char c)); +int get_char __P((void)); +void chat_send __P((register char *s)); +char *character __P((char c)); +void chat_expect __P((register char *s)); +char *clean __P((register char *s, int sending)); +void unlock __P((void)); +void lock __P((void)); +void break_sequence __P((void)); +void terminate __P((int status)); +void die __P((void)); + +void *dup_mem(b, c) +void *b; +size_t c; + { + void *ans = malloc (c); + if (!ans) + fatal ("memory error!\n"); + memcpy (ans, b, c); + return ans; + } + +void *copy_of (s) +char *s; + { + return dup_mem (s, strlen (s) + 1); + } + /* - * chat [ -v ] [ -t timeout ] [ -l lock-file ] \ + * chat [ -v ] [ -t timeout ] [ -l lock-file ] [ -f chat-file ] \ * [...[[expect[-say[-expect...]] say expect[-say[-expect]] ...]]] * * Perform a UUCP-dialer-like chat script on stdin and stdout. */ +int main(argc, argv) int argc; char **argv; { - int option, n; + int option; char *arg; program_name = *argv; @@ -128,9 +185,17 @@ char **argv; ++verbose; break; + case 'f': + if (arg = OPTARG(argc, argv)) + chat_file = copy_of(arg); + else + usage(); + + break; + case 'l': if (arg = OPTARG(argc, argv)) - lock_file = copyof(arg); + lock_file = copy_of(arg); else usage(); @@ -154,61 +219,168 @@ char **argv; openlog("chat", LOG_PID | LOG_NDELAY, LOG_LOCAL2); if (verbose) { - setlogmask(LOG_UPTO(LOG_INFO)); + setlogmask(LOG_UPTO(LOG_INFO)); } else { - setlogmask(LOG_UPTO(LOG_WARNING)); + setlogmask(LOG_UPTO(LOG_WARNING)); } #endif - init(); - while (arg = ARG(argc, argv)) + if (chat_file != NULL) { - chat_expect(arg); + arg = ARG(argc, argv); + if (arg != NULL) + usage(); + else + do_file (chat_file); + } + else + { + while (arg = ARG(argc, argv)) + { + chat_expect(arg); - if (arg = ARG(argc, argv)) - chat_send(arg); + if (arg = ARG(argc, argv)) + chat_send(arg); + } } terminate(0); } +/* + * Process a chat script when read from a file. + */ + +void do_file (chat_file) +char *chat_file; + { + int linect, len, sendflg; + char *sp, *arg, quote; + char buf [STR_LEN]; + FILE *cfp; + + if ((cfp = fopen (chat_file, "r")) == NULL) + { + syslog (LOG_ERR, "%s -- open failed: %m", chat_file); + terminate (1); + } + + linect = 0; + sendflg = 0; + + while (fgets(buf, STR_LEN, cfp) != NULL) + { + sp = strchr (buf, '\n'); + if (sp) + *sp = '\0'; + + linect++; + sp = buf; + while (*sp != '\0') + { + if (*sp == ' ' || *sp == '\t') + { + ++sp; + continue; + } + + if (*sp == '"' || *sp == '\'') + { + quote = *sp++; + arg = sp; + while (*sp != quote) + { + if (*sp == '\0') + { + syslog (LOG_ERR, "unterminated quote (line %d)", + linect); + terminate (1); + } + + if (*sp++ == '\\') + if (*sp != '\0') + ++sp; + } + } + else + { + arg = sp; + while (*sp != '\0' && *sp != ' ' && *sp != '\t') + ++sp; + } + + if (*sp != '\0') + *sp++ = '\0'; + + if (sendflg) + { + chat_send (arg); + } + else + { + chat_expect (arg); + } + sendflg = !sendflg; + } + } + fclose (cfp); + } + /* * We got an error parsing the command line. */ -usage() +void usage() { - fprintf(stderr, - "Usage: %s [ -v ] [ -l lock-file ] [ -t timeout ] chat-script\n", + fprintf(stderr, "\ +Usage: %s [-v] [-l lock-file] [-t timeout] {-f chat-file || chat-script}\n", program_name); exit(1); } +char line[256]; +char *p; + +void logf (str) +const char *str; + { + p = line + strlen(line); + strcat (p, str); + + if (str[strlen(str)-1] == '\n') + { + syslog (LOG_INFO, "%s", line); + line[0] = 0; + } + } + +void logflush() + { + if (line[0] != 0) + { + syslog(LOG_INFO, "%s", line); + line[0] = 0; + } + } + /* - * Print a warning message. + * Unlock and terminate with an error. */ -/*VARARGS1*/ -warn(format, arg1, arg2, arg3, arg4) -char *format; -int arg1, arg2, arg3, arg4; +void die() { - logf("%s: Warning: ", program_name); - logf(format, arg1, arg2, arg3, arg4); - logf("\n"); + unlock(); + terminate(1); } /* * Print an error message and terminate. */ -/*VARARGS1*/ -fatal(format, arg1, arg2, arg3, arg4) -char *format; -int arg1, arg2, arg3, arg4; + +void fatal (msg) +const char *msg; { - logf("%s: ", program_name); - logf(format, arg1, arg2, arg3, arg4); - logf("\n"); + syslog(LOG_ERR, "%s", msg); unlock(); terminate(1); } @@ -217,30 +389,27 @@ int arg1, arg2, arg3, arg4; * Print an error message along with the system error message and * terminate. */ -/*VARARGS1*/ -sysfatal(format, arg1, arg2, arg3, arg4) -char *format; -int arg1, arg2, arg3, arg4; - { - char message[STR_LEN]; - sprintf(message, "%s: ", program_name); - sprintf(message + strlen(message), format, arg1, arg2, arg3, arg4); - perror(message); +void sysfatal (msg) +const char *msg; + { + syslog(LOG_ERR, "%s: %m", msg); unlock(); terminate(1); } int alarmed = 0; -SIGTYPE - sigalrm() -{ +SIGTYPE sigalrm(signo) +int signo; + { int flags; - alarm(1); alarmed = 1; /* Reset alarm to avoid race window */ + alarm(1); + alarmed = 1; /* Reset alarm to avoid race window */ signal(SIGALRM, sigalrm); /* that can cause hanging in read() */ + logflush(); if ((flags = fcntl(0, F_GETFL, 0)) == -1) sysfatal("Can't get file mode flags on stdin"); else @@ -249,11 +418,11 @@ SIGTYPE if (verbose) { - logf("alarm\n"); + syslog(LOG_INFO, "alarm"); } } -unalarm() +void unalarm() { int flags; @@ -264,25 +433,25 @@ unalarm() sysfatal("Can't set file mode flags on stdin"); } -SIGTYPE - sigint() -{ - fatal("SIGINT"); -} +SIGTYPE sigint(signo) +int signo; + { + fatal("SIGINT"); + } -SIGTYPE - sigterm() -{ - fatal("SIGTERM"); -} +SIGTYPE sigterm(signo) +int signo; + { + fatal("SIGTERM"); + } -SIGTYPE - sighup() -{ - fatal("SIGHUP"); -} +SIGTYPE sighup(signo) +int signo; + { + fatal("SIGHUP"); + } -init() +void init() { signal(SIGINT, sigint); signal(SIGTERM, sigterm); @@ -293,11 +462,11 @@ init() set_tty_parameters(); signal(SIGALRM, sigalrm); - alarm(0); alarmed = 0; + alarm(0); + alarmed = 0; } - -set_tty_parameters() +void set_tty_parameters() { #ifdef TERMIO struct termio t; @@ -315,9 +484,9 @@ set_tty_parameters() saved_tty_parameters = t; have_tty_parameters = 1; - t.c_iflag = IGNBRK | ISTRIP | IGNPAR; - t.c_oflag = 0; - t.c_lflag = 0; + t.c_iflag |= IGNBRK | ISTRIP | IGNPAR; + t.c_oflag = 0; + t.c_lflag = 0; t.c_cc[VERASE] = t.c_cc[VKILL] = 0; t.c_cc[VMIN] = 1; t.c_cc[VTIME] = 0; @@ -332,31 +501,40 @@ set_tty_parameters() #endif } +void break_sequence() + { +#ifdef TERMIOS + tcsendbreak (0, 0); +#endif + } -terminate(status) -{ - if (have_tty_parameters && +void terminate(status) +int status; + { + if (have_tty_parameters && #ifdef TERMIO - ioctl(0, TCSETA, &saved_tty_parameters) < 0 + ioctl(0, TCSETA, &saved_tty_parameters) < 0 #endif #ifdef TERMIOS - tcsetattr(0, TCSANOW, &saved_tty_parameters) < 0 + tcsetattr(0, TCSANOW, &saved_tty_parameters) < 0 #endif - ) { - perror("Can't restore terminal parameters"); - unlock(); - exit(1); - } - exit(status); -} + ) { + syslog(LOG_ERR, "Can't restore terminal parameters: %m"); + unlock(); + exit(1); + } + exit(status); + } /* * Create a lock file for the named lock device */ -lock() +void lock() { - char hdb_lock_buffer[12]; int fd, pid; +# ifdef PIDSTRING + char hdb_lock_buffer[12]; +# endif lock_file = strcat(strcat(strcpy(malloc(strlen(LOCK_DIR) + 1 + strlen(lock_file) + 1), @@ -365,9 +543,9 @@ lock() if ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) { char *s = lock_file; - lock_file = (char *)0; /* Don't remove someone else's lock file! */ - sysfatal("Can't get lock file '%s'", s); + syslog(LOG_ERR, "Can't get lock file '%s': %m", s); + die(); } # ifdef PIDSTRING @@ -384,7 +562,7 @@ lock() /* * Remove our lockfile */ -unlock() +void unlock() { if (lock_file) { @@ -400,59 +578,142 @@ char *clean(s, sending) register char *s; int sending; { - char temp[STR_LEN]; + char temp[STR_LEN], cur_chr; register char *s1; int add_return = sending; +#define isoctal(chr) (((chr) >= '0') && ((chr) <= '7')) - for (s1 = temp; *s; ++s) - switch (*s) - { - case '\\': - switch (*++s) - { - case '\\': - case 'd': if (sending) - *s1++ = '\\'; + s1 = temp; + while (*s) + { + cur_chr = *s++; + if (cur_chr == '^') + { + cur_chr = *s++; + if (cur_chr == '\0') + { + *s1++ = '^'; + break; + } + cur_chr &= 0x1F; + if (cur_chr != 0) + *s1++ = cur_chr; + continue; + } + + if (cur_chr != '\\') + { + *s1++ = cur_chr; + continue; + } + + cur_chr = *s++; + if (cur_chr == '\0') + { + if (sending) + { + *s1++ = '\\'; + *s1++ = '\\'; + } + break; + } - *s1++ = *s; - break; + switch (cur_chr) + { + case 'b': + *s1++ = '\b'; + break; + + case 'c': + if (sending && *s == '\0') + add_return = 0; + else + *s1++ = cur_chr; + break; - case 'q': quiet = ! quiet; break; - case 'r': *s1++ = '\r'; break; - case 'n': *s1++ = '\n'; break; - case 's': *s1++ = ' '; break; + case '\\': + case 'K': + case 'p': + case 'd': + if (sending) + *s1++ = '\\'; - case 'c': if (sending && s[1] == '\0') - add_return = 0; - else - *s1++ = *s; + *s1++ = cur_chr; + break; - break; + case 'q': + quiet = ! quiet; + break; - default: *s1++ = *s; - } + case 'r': + *s1++ = '\r'; + break; - break; + case 'n': + *s1++ = '\n'; + break; - case '^': - *s1++ = (int)(*++s) & 0x1F; - break; + case 's': + *s1++ = ' '; + break; + + case 't': + *s1++ = '\t'; + break; + + case 'N': + if (sending) + { + *s1++ = '\\'; + *s1++ = '\0'; + } + else + *s1++ = 'N'; + break; + + default: + if (isoctal (cur_chr)) + { + cur_chr &= 0x07; + if (isoctal (*s)) + { + cur_chr <<= 3; + cur_chr |= *s++ - '0'; + if (isoctal (*s)) + { + cur_chr <<= 3; + cur_chr |= *s++ - '0'; + } + } + + if (cur_chr != 0 || sending) + { + if (sending && (cur_chr == '\\' || cur_chr == 0)) + *s1++ = '\\'; + *s1++ = cur_chr; + } + break; + } + + if (sending) + *s1++ = '\\'; + *s1++ = cur_chr; + break; + } + } - default: - *s1++ = *s; - } - if (add_return) *s1++ = '\r'; - *s1 = '\0'; - return (copyof(temp)); + *s1++ = '\0'; /* guarantee closure */ + *s1++ = '\0'; /* terminate the string */ + return dup_mem (temp, (size_t) (s1 - temp)); /* may have embedded nuls */ } /* - * + * Process the expect string */ -chat_expect(s) +void chat_expect(s) register char *s; { if (strcmp(s, "ABORT") == 0) @@ -511,9 +772,9 @@ register char *s; else { if (fail_reason) - logf("Failed(%s)\n", fail_reason); + syslog(LOG_INFO, "Failed (%s)", fail_reason); else - logf("Failed\n"); + syslog(LOG_INFO, "Failed"); unlock(); terminate(1); @@ -542,9 +803,9 @@ char c; } /* - * + * process the reply string */ -chat_send(s) +void chat_send (s) register char *s; { if (abort_next) @@ -558,11 +819,11 @@ register char *s; s1 = clean(s, 0); - if (strlen(s1) > strlen(s)) - fatal("Illegal ABORT string ('%s')\n", s); - - if (strlen(s1) > sizeof fail_buffer - 1) - fatal("Too long ABORT string ('%s')\n", s); + if (strlen(s1) > strlen(s) || strlen(s1) > sizeof fail_buffer - 1) + { + syslog(LOG_WARNING, "Illegal or too-long ABORT string ('%s')", s); + die(); + } strcpy(s, s1); abort_string[n_aborts++] = s; @@ -574,7 +835,7 @@ register char *s; logf("abort on ("); for (s1 = s; *s1; ++s1) - logf("%s", character(*s1)); + logf(character(*s1)); logf(")\n"); } @@ -590,16 +851,23 @@ register char *s; if (verbose) { - logf("timeout set to %d seconds\n", timeout); + syslog(LOG_INFO, "timeout set to %d seconds", timeout); } } else + { + if (strcmp(s, "EOT") == 0) + s = "^D\\c"; + else + if (strcmp(s, "BREAK") == 0) + s = "\\K\\c"; if ( ! put_string(s)) { - logf("Failed\n"); + syslog(LOG_INFO, "Failed"); unlock(); terminate(1); } + } } int get_char() @@ -615,7 +883,8 @@ int get_char() return ((int)c & 0x7F); default: - warn("read() on stdin returned %d", status); + syslog(LOG_WARNING, "warning: read() on stdin returned %d", + status); case -1: if ((status = fcntl(0, F_GETFL, 0)) == -1) @@ -643,7 +912,8 @@ char c; return (0); default: - warn("write() on stdout returned %d", status); + syslog(LOG_WARNING, "warning: write() on stdout returned %d", + status); case -1: if ((status = fcntl(0, F_GETFL, 0)) == -1) @@ -656,7 +926,28 @@ char c; } } -int put_string(s) +int write_char (c) +int c; + { + if (alarmed || put_char(c) < 0) + { + extern int errno; + + alarm(0); alarmed = 0; + + if (verbose) + { + if (errno == EINTR || errno == EWOULDBLOCK) + syslog(LOG_INFO, " -- write timed out"); + else + syslog(LOG_INFO, " -- write failed: %m"); + } + return (0); + } + return (1); + } + +int put_string (s) register char *s; { s = clean(s, 1); @@ -672,7 +963,7 @@ register char *s; register char *s1 = s; for (s1 = s; *s1; ++s1) - logf("%s", character(*s1)); + logf(character(*s1)); } logf(")\n"); @@ -680,39 +971,41 @@ register char *s; alarm(timeout); alarmed = 0; - for ( ; *s; ++s) + while (*s) { - register char c = *s; + register char c = *s++; - if (c == '\\') - if ((c = *++s) == '\0') - break; - else - if (c == 'd') /* \d -- Delay */ - { - sleep(2); - continue; - } + if (c != '\\') + { + if (!write_char (c)) + return 0; + continue; + } - if (alarmed || put_char(*s) < 0) + c = *s++; + switch (c) { - extern int errno; + case 'd': + sleep(1); + break; - alarm(0); alarmed = 0; + case 'K': + break_sequence(); + break; - if (verbose) - { - if (errno == EINTR || errno == EWOULDBLOCK) - logf(" -- write timed out\n"); - else - syslog(LOG_INFO, " -- write failed: %m"); - } + case 'p': + usleep(10000); /* 1/100th of a second. */ + break; - return (0); + default: + if (!write_char (c)) + return 0; + break; } } - alarm(0); alarmed = 0; + alarm(0); + alarmed = 0; return (1); } @@ -738,22 +1031,22 @@ register char *string; logf("expect ("); for (s1 = string; *s1; ++s1) - logf("%s", character(*s1)); + logf(character(*s1)); logf(")\n"); } if (len > STR_LEN) { - logf("expect string is too long\n"); - return; + syslog(LOG_INFO, "expect string is too long"); + return 0; } if (len == 0) { if (verbose) { - logf("got it\n"); + syslog(LOG_INFO, "got it"); } return (1); @@ -770,7 +1063,7 @@ register char *string; if (c == '\n') logf("\n"); else - logf("%s", character(c)); + logf(character(c)); } *s++ = c; @@ -781,7 +1074,7 @@ register char *string; { if (verbose) { - logf("got it\n"); + logf(" -- got it\n"); } alarm(0); alarmed = 0; @@ -809,63 +1102,28 @@ register char *string; } if (alarmed && verbose) - warn("Alarm synchronization problem"); + syslog(LOG_WARNING, "warning: alarm synchronization problem"); } alarm(0); if (verbose && printed) { - extern int errno; - if (alarmed) logf(" -- read timed out\n"); else + { + logflush(); syslog(LOG_INFO, " -- read failed: %m"); + } } alarmed = 0; return (0); } -/* - * Delay an amount appropriate for between typed characters. - */ -delay() - { - register int i; - -# ifdef NO_USLEEP - for (i = 0; i < 30000; ++i) /* ... did we just say appropriate? */ - ; -# else /* NO_USLEEP */ - usleep(100); -# endif /* NO_USLEEP */ - } - -char line[256]; -char *p; - -logf(fmt, va_alist) -char *fmt; -va_dcl -{ - va_list pvar; - char buf[256]; - - va_start(pvar); - vsprintf(buf, fmt, pvar); - va_end(pvar); - - p = line + strlen(line); - strcat(p, buf); - - if (buf[strlen(buf)-1] == '\n') { - syslog(LOG_INFO, "%s", line); - line[0] = 0; - } -} #ifdef ultrix +#undef NO_USLEEP #include #include @@ -874,17 +1132,17 @@ va_dcl last edit: 29-Oct-1984 D A Gwyn */ -extern int select(); +extern int select(); int -usleep( usec ) /* returns 0 if ok, else -1 */ - long usec; /* delay in microseconds */ +usleep( usec ) /* returns 0 if ok, else -1 */ + long usec; /* delay in microseconds */ { - static struct /* `timeval' */ + static struct /* `timeval' */ { - long tv_sec; /* seconds */ - long tv_usec; /* microsecs */ - } delay; /* _select() timeout */ + long tv_sec; /* seconds */ + long tv_usec; /* microsecs */ + } delay; /* _select() timeout */ delay.tv_sec = usec / 1000000L; delay.tv_usec = usec % 1000000L; @@ -892,3 +1150,18 @@ usleep( usec ) /* returns 0 if ok, else -1 */ return select( 0, (long *)0, (long *)0, (long *)0, &delay ); } #endif + +/* + * Delay an amount appropriate for between typed characters. + */ +void delay() + { +# ifdef NO_USLEEP + register int i; + + for (i = 0; i < 30000; ++i) /* ... did we just say appropriate? */ + ; +# else /* NO_USLEEP */ + usleep(100); +# endif /* NO_USLEEP */ + } -- 2.39.2 From d9bd48c35d1c5d6c26dd746efd93edb4d0de7745 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 27 May 1994 00:40:53 +0000 Subject: [PATCH 16/16] added in definitions from if_ppp.h so we don't need to include if_ppp.h in sun driver code. --- include/net/ppp_str.h | 45 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/include/net/ppp_str.h b/include/net/ppp_str.h index e468b4b..c2ee6c1 100644 --- a/include/net/ppp_str.h +++ b/include/net/ppp_str.h @@ -1,14 +1,50 @@ /* ppp_str.h - streams version include file - defines ioctl calls for MRU, COMPPROT and ASYNCMAP - Copyright (C) 1990 Brad K. Clements, All Rights Reserved, See copyright statement in NOTES */ #include +#define PPP_HDRLEN 4 /* octets for standard ppp header */ +#define PPP_FCSLEN 2 /* octets for FCS */ + +#define PPP_ADDRESS(cp) ((cp)[0]) +#define PPP_CONTROL(cp) ((cp)[1]) +#define PPP_PROTOCOL(cp) (((cp)[2] << 8) + (cp)[3]) + +#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ +#define PPP_UI 0x03 /* Unnumbered Information */ +#define PPP_FLAG 0x7e /* Flag Sequence */ +#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ +#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ + +/* + * Protocol field values. + */ +#define PPP_IP 0x21 /* Internet Protocol */ +#define PPP_XNS 0x25 /* Xerox NS */ +#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ +#define PPP_COMP 0xfd /* compressed packet */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_CCP 0x80fd /* Compression Control Protocol */ + +/* + * Important FCS values. + */ +#define PPP_INITFCS 0xffff /* Initial FCS value */ +#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ +#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) + +/* + * Packet sizes + */ +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#define PPP_MRU 1500 /* Default MRU (max receive unit) */ +#define PPP_MAXMRU 65000 /* Largest MRU we allow */ + /* Extended asyncmap - allows any character to be escaped. */ typedef u_long ext_accm[8]; @@ -82,11 +118,12 @@ struct ppp_if_info { #endif }; -#ifdef STREAMS /* defines for streams modules */ #define IF_INPUT_ERROR 0xe1 #define IF_OUTPUT_ERROR 0xe2 #define ALLOCBSIZE 64 /* how big of a buffer block to allocate for each chunk of the input chain */ -#endif + +#define PPP_MTU 1500 /* Default MTU (size of Info field) */ +#define PPP_HDRLEN 4 /* sizeof(struct ppp_header) must be 4 */ -- 2.39.2