From 1342caed9c9c94c4524363408e77113333963bd5 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Thu, 16 Apr 1998 00:26:21 +0000 Subject: [PATCH] o Move the accept/deny/disable/enable globals either to the bundle (non-negotiated vars) or to their respective IPCP, LCP or CCP. o Enable rolling throughput statistics by default. o Remove the `display' command. These values now appear in `show bundle', `show ipcp', `show ccp' and `show lcp'. o Initialise auth name & key at bundle create time (oops). o Rename pppd-deflate (the id-24 hack) to deflate24. o Don't send both a REJ and a NAK to an IPCP or LCP REQ. Favour the REJ (already done at the CCP level). o Recurse in datalink_UpdateSet() when we change state, otherwise we end up setting no descriptors and getting jammed in the imminent select() instead of doing the dial/login/hangup. o Display our CHAP encryption method despite being built with DES. o Display VJ as not negotiated in ``show ipcp'' when necessary. --- usr.sbin/ppp/Makefile | 4 +- usr.sbin/ppp/auth.c | 5 +- usr.sbin/ppp/bundle.c | 27 +++- usr.sbin/ppp/bundle.h | 13 +- usr.sbin/ppp/ccp.c | 55 ++++---- usr.sbin/ppp/ccp.h | 10 +- usr.sbin/ppp/chap.c | 5 +- usr.sbin/ppp/command.c | 269 ++++++++++++++++++++++++++++++++++++-- usr.sbin/ppp/command.h | 27 +--- usr.sbin/ppp/datalink.c | 27 ++-- usr.sbin/ppp/deflate.c | 7 +- usr.sbin/ppp/fsm.c | 30 +++-- usr.sbin/ppp/ipcp.c | 70 ++++++---- usr.sbin/ppp/ipcp.h | 9 +- usr.sbin/ppp/lcp.c | 61 ++++++--- usr.sbin/ppp/lcp.h | 8 +- usr.sbin/ppp/lqr.c | 18 +-- usr.sbin/ppp/main.c | 5 +- usr.sbin/ppp/modem.c | 15 ++- usr.sbin/ppp/mp.c | 5 +- usr.sbin/ppp/pap.c | 5 +- usr.sbin/ppp/physical.c | 7 +- usr.sbin/ppp/ppp.8 | 37 +++--- usr.sbin/ppp/pred.c | 5 +- usr.sbin/ppp/throughput.c | 15 ++- usr.sbin/ppp/throughput.h | 5 +- usr.sbin/ppp/vars.c | 138 ------------------- usr.sbin/ppp/vars.h | 65 --------- usr.sbin/ppp/vjcomp.c | 9 +- 29 files changed, 543 insertions(+), 413 deletions(-) delete mode 100644 usr.sbin/ppp/vars.c delete mode 100644 usr.sbin/ppp/vars.h diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile index a499ccf96565..f427da1cb8ce 100644 --- a/usr.sbin/ppp/Makefile +++ b/usr.sbin/ppp/Makefile @@ -1,11 +1,11 @@ -# $Id: Makefile,v 1.36.2.8 1998/04/03 19:21:03 brian Exp $ +# $Id: Makefile,v 1.36.2.9 1998/04/03 19:25:19 brian Exp $ PROG= ppp SRCS= arp.c async.c auth.c bundle.c ccp.c chap.c chat.c command.c \ datalink.c deflate.c defs.c filter.c fsm.c hdlc.c id.c ip.c \ ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c mbuf.c modem.c \ mp.c pap.c physical.c pred.c prompt.c route.c server.c sig.c \ - slcompress.c systems.c throughput.c timer.c tun.c vars.c vjcomp.c + slcompress.c systems.c throughput.c timer.c tun.c vjcomp.c CFLAGS+=-Wall -Wpointer-arith LDADD+= -lmd -lcrypt -lutil -lz DPADD+= ${LIBMD} ${LIBCRYPT} ${LIBUTIL} ${LIBZ} diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index 88bf255b1ac2..a1954a1b35ef 100644 --- a/usr.sbin/ppp/auth.c +++ b/usr.sbin/ppp/auth.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.c,v 1.27.2.19 1998/04/06 09:12:22 brian Exp $ + * $Id: auth.c,v 1.27.2.20 1998/04/07 00:53:18 brian Exp $ * * TODO: * o Implement check against with registered IP addresses. @@ -40,7 +40,6 @@ #include "throughput.h" #include "slcompress.h" #include "ipcp.h" -#include "vars.h" #include "auth.h" #include "systems.h" #include "lcp.h" @@ -126,7 +125,7 @@ AuthValidate(struct bundle *bundle, const char *fname, const char *system, } #ifndef NOPASSWDAUTH - if (Enabled(ConfPasswdAuth)) + if (Enabled(bundle, OPT_PASSWDAUTH)) return auth_CheckPasswd(system, "*", key); #endif diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index b4b726a7ad45..14c6aff00e2b 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.1.2.45 1998/04/11 21:50:37 brian Exp $ + * $Id: bundle.c,v 1.1.2.46 1998/04/14 23:17:24 brian Exp $ */ #include @@ -518,6 +518,9 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type) bundle.fsm.object = &bundle; bundle.cfg.idle_timeout = NCP_IDLE_TIMEOUT; + *bundle.cfg.auth.name = '\0'; + *bundle.cfg.auth.key = '\0'; + bundle.cfg.opt = OPT_IDCHECK | OPT_LOOPBACK | OPT_THROUGHPUT | OPT_UTMP; bundle.phys_type = type; bundle.links = datalink_Create("default", &bundle, &bundle.fsm, type); @@ -535,6 +538,7 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type) bundle.desc.Read = bundle_DescriptorRead; bundle.desc.Write = bundle_DescriptorWrite; + /* XXX: what's an IPCP link anyway :-( */ ipcp_Init(&bundle.ncp.ipcp, &bundle, &bundle.links->physical->link, &bundle.fsm); @@ -850,6 +854,12 @@ bundle_ShowLinks(struct cmdargs const *arg) return 0; } +static const char * +optval(struct bundle *bundle, int bit) +{ + return (bundle->cfg.opt & bit) ? "enabled" : "disabled"; +} + int bundle_ShowStatus(struct cmdargs const *arg) { @@ -870,6 +880,21 @@ bundle_ShowStatus(struct cmdargs const *arg) } else prompt_Printf(arg->prompt, "disabled\n"); + prompt_Printf(arg->prompt, " ID check: %s\n", + optval(arg->bundle, OPT_IDCHECK)); + prompt_Printf(arg->prompt, " Loopback: %s\n", + optval(arg->bundle, OPT_LOOPBACK)); + prompt_Printf(arg->prompt, " MS Ext: %s\n", + optval(arg->bundle, OPT_MSEXT)); + prompt_Printf(arg->prompt, " PasswdAuth: %s\n", + optval(arg->bundle, OPT_PASSWDAUTH)); + prompt_Printf(arg->prompt, " Proxy: %s\n", + optval(arg->bundle, OPT_PROXY)); + prompt_Printf(arg->prompt, " Throughput: %s\n", + optval(arg->bundle, OPT_THROUGHPUT)); + prompt_Printf(arg->prompt, " Utmp: %s\n", + optval(arg->bundle, OPT_UTMP)); + return 0; } diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h index 4a806c462d69..c184af3d03aa 100644 --- a/usr.sbin/ppp/bundle.h +++ b/usr.sbin/ppp/bundle.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.h,v 1.1.2.27 1998/04/10 13:19:01 brian Exp $ + * $Id: bundle.h,v 1.1.2.28 1998/04/11 21:50:39 brian Exp $ */ #define PHASE_DEAD 0 /* Link is dead */ @@ -32,6 +32,16 @@ #define PHASE_NETWORK 3 /* We're alive ! */ #define PHASE_TERMINATE 4 /* Terminating link */ +/* cfg.opt bit settings */ +#define OPT_IDCHECK 0x01 +#define OPT_LOOPBACK 0x02 +#define OPT_MSEXT 0x04 +#define OPT_PASSWDAUTH 0x08 +#define OPT_PROXY 0x10 +#define OPT_THROUGHPUT 0x20 +#define OPT_UTMP 0x40 + +#define Enabled(b, o) ((b)->cfg.opt & (o)) struct datalink; struct physical; @@ -61,6 +71,7 @@ struct bundle { char name[50]; /* PAP/CHAP system name */ char key[50]; /* PAP/CHAP key */ } auth; + unsigned opt; /* Uses OPT_ bits from above */ } cfg; struct { diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index 3c11973503fd..bf4d0736f66d 100644 --- a/usr.sbin/ppp/ccp.c +++ b/usr.sbin/ppp/ccp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.c,v 1.30.2.32 1998/04/06 09:12:23 brian Exp $ + * $Id: ccp.c,v 1.30.2.33 1998/04/07 00:53:22 brian Exp $ * * TODO: * o Support other compression protocols @@ -40,7 +40,6 @@ #include "lcpproto.h" #include "lcp.h" #include "ccp.h" -#include "vars.h" #include "pred.h" #include "deflate.h" #include "throughput.h" @@ -100,7 +99,7 @@ static char const *cftypes[] = { "???", "LZS-DCP", /* 23: LZS-DCP Compression Protocol (rfc1967) */ "MAGNALINK/DEFLATE", /* 24: Magnalink Variable Resource (rfc1975) */ - /* 24: Deflate (according to pppd-2.3.1) */ + /* 24: Deflate (according to pppd-2.3.*) */ "DCE", /* 25: Data Circuit-Terminating Equip (rfc1976) */ "DEFLATE", /* 26: Deflate (rfc1979) */ }; @@ -139,10 +138,16 @@ ccp_ReportStatus(struct cmdargs const *arg) ccp->compin, ccp->uncompin); prompt_Printf(arg->prompt, "\n Defaults: "); - prompt_Printf(arg->prompt, "deflate windows: "); + prompt_Printf(arg->prompt, "FSM retry = %us\n", ccp->cfg.fsmretry); + prompt_Printf(arg->prompt, " deflate windows: "); prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize); prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize); - prompt_Printf(arg->prompt, " FSM retry = %us\n", ccp->cfg.fsmretry); + prompt_Printf(arg->prompt, " DEFLATE: %s\n", + command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE])); + prompt_Printf(arg->prompt, " PREDICTOR1: %s\n", + command_ShowNegval(ccp->cfg.neg[CCP_NEG_PRED1])); + prompt_Printf(arg->prompt, " DEFLATE24: %s\n", + command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE24])); return 0; } @@ -160,6 +165,9 @@ ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l, ccp->cfg.deflate.in.winsize = 0; ccp->cfg.deflate.out.winsize = 15; ccp->cfg.fsmretry = DEF_FSMRETRY; + ccp->cfg.neg[CCP_NEG_DEFLATE] = NEG_ENABLED|NEG_ACCEPTED; + ccp->cfg.neg[CCP_NEG_PRED1] = NEG_ENABLED|NEG_ACCEPTED; + ccp->cfg.neg[CCP_NEG_DEFLATE24] = 0; ccp_Setup(ccp); } @@ -206,7 +214,8 @@ CcpSendConfigReq(struct fsm *fp) ccp->my_proto = -1; ccp->out.algorithm = -1; for (f = 0; f < NALGORITHMS; f++) - if (Enabled(algorithm[f]->Conf) && !REJECTED(ccp, algorithm[f]->id)) { + if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) && + !REJECTED(ccp, algorithm[f]->id)) { if (alloc) { *o = (struct ccp_opt *)malloc(sizeof(struct ccp_opt)); (*o)->val.id = algorithm[f]->id; @@ -385,7 +394,8 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, switch (mode_type) { case MODE_REQ: - if (Acceptable(algorithm[f]->Conf) && ccp->in.algorithm == -1) { + if (IsAccepted(ccp->cfg.neg[algorithm[f]->Neg]) && + ccp->in.algorithm == -1) { memcpy(&ccp->in.opt, cp, length); switch ((*algorithm[f]->i.Set)(&ccp->in.opt, &ccp->cfg)) { case MODE_REJ: @@ -435,22 +445,23 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, cp += cp[1]; } - if (mode_type != MODE_NOP && dec->rejend != dec->rej) { - /* rejects are preferred */ - dec->ackend = dec->ack; - dec->nakend = dec->nak; - if (ccp->in.state == NULL) { - ccp->his_proto = -1; - ccp->in.algorithm = -1; + if (mode_type != MODE_NOP) + if (dec->rejend != dec->rej) { + /* rejects are preferred */ + dec->ackend = dec->ack; + dec->nakend = dec->nak; + if (ccp->in.state == NULL) { + ccp->his_proto = -1; + ccp->in.algorithm = -1; + } + } else if (dec->nakend != dec->nak) { + /* then NAKs */ + dec->ackend = dec->ack; + if (ccp->in.state == NULL) { + ccp->his_proto = -1; + ccp->in.algorithm = -1; + } } - } else if (mode_type != MODE_NOP && dec->nakend != dec->nak) { - /* then NAKs */ - dec->ackend = dec->ack; - if (ccp->in.state == NULL) { - ccp->his_proto = -1; - ccp->in.algorithm = -1; - } - } } void diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h index 2e05ec7e05b6..b9840638fada 100644 --- a/usr.sbin/ppp/ccp.h +++ b/usr.sbin/ppp/ccp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.h,v 1.14.2.15 1998/04/03 19:23:54 brian Exp $ + * $Id: ccp.h,v 1.14.2.16 1998/04/07 00:53:24 brian Exp $ * * TODO: */ @@ -35,6 +35,11 @@ #define TY_PPPD_DEFLATE 24 /* Deflate (gzip) - (mis) numbered by pppd */ #define TY_DEFLATE 26 /* Deflate (gzip) - rfc 1979 */ +#define CCP_NEG_DEFLATE 0 +#define CCP_NEG_PRED1 1 +#define CCP_NEG_DEFLATE24 2 +#define CCP_NEG_TOTAL 3 + struct mbuf; struct ccp_config { @@ -44,6 +49,7 @@ struct ccp_config { } in, out; } deflate; u_int fsmretry; /* FSM retry frequency */ + unsigned neg[CCP_NEG_TOTAL]; }; struct ccp_opt { @@ -86,7 +92,7 @@ struct ccp { struct ccp_algorithm { int id; - int Conf; /* A Conf value from vars.h */ + int Neg; /* ccp_config neg array item */ const char *(*Disp)(struct lcp_opt *); struct { int (*Set)(struct lcp_opt *, const struct ccp_config *); diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index 7a917a09ced7..957065a5d78c 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.28.2.22 1998/04/06 09:12:24 brian Exp $ + * $Id: chap.c,v 1.28.2.23 1998/04/07 00:53:25 brian Exp $ * * TODO: */ @@ -228,7 +228,8 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp, */ if (memcmp(cp, cdigest, 16) == 0) { ChapOutput(physical, CHAP_SUCCESS, chp->id, "Welcome!!", 10); - Physical_Login(physical, name); + if (Enabled(bundle, OPT_UTMP)) + Physical_Login(physical, name); if (physical->link.lcp.auth_iwait == 0) /* diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 3ec9c379c3c6..680747b8b697 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.131.2.59 1998/04/11 21:50:44 brian Exp $ + * $Id: command.c,v 1.131.2.60 1998/04/14 23:17:01 brian Exp $ * */ #include @@ -62,7 +62,6 @@ #include "lqr.h" #include "hdlc.h" #include "loadalias.h" -#include "vars.h" #include "systems.h" #include "filter.h" #include "descriptor.h" @@ -81,6 +80,43 @@ #include "chap.h" #include "datalink.h" +/* ``set'' values */ +#define VAR_AUTHKEY 0 +#define VAR_DIAL 1 +#define VAR_LOGIN 2 +#define VAR_AUTHNAME 3 +#define VAR_WINSIZE 4 +#define VAR_DEVICE 5 +#define VAR_ACCMAP 6 +#define VAR_MRU 7 +#define VAR_MTU 8 +#define VAR_OPENMODE 9 +#define VAR_PHONE 10 +#define VAR_HANGUP 11 +#define VAR_ENC 12 +#define VAR_IDLETIMEOUT 13 +#define VAR_LQRPERIOD 14 +#define VAR_LCPRETRY 15 +#define VAR_CHAPRETRY 16 +#define VAR_PAPRETRY 17 +#define VAR_CCPRETRY 18 +#define VAR_IPCPRETRY 19 + +/* ``accept|deny|disable|enable'' masks */ +#define NEG_HISMASK (1) +#define NEG_MYMASK (2) + +/* ``accept|deny|disable|enable'' values */ +#define NEG_ACFCOMP 40 +#define NEG_CHAP 41 +#define NEG_DEFLATE 42 +#define NEG_LQR 43 +#define NEG_PAP 44 +#define NEG_PPPDDEFLATE 45 +#define NEG_PRED1 46 +#define NEG_PROTOCOMP 47 +#define NEG_VJCOMP 48 + static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); static int QuitCommand(struct cmdargs const *); @@ -91,6 +127,7 @@ static int SetCommand(struct cmdargs const *); static int LinkCommand(struct cmdargs const *); static int AddCommand(struct cmdargs const *); static int DeleteCommand(struct cmdargs const *); +static int NegotiateCommand(struct cmdargs const *); #ifndef NOALIAS static int AliasCommand(struct cmdargs const *); static int AliasEnable(struct cmdargs const *); @@ -351,7 +388,7 @@ FgShellCommand(struct cmdargs const *arg) } static struct cmdtab const Commands[] = { - {"accept", NULL, AcceptCommand, LOCAL_AUTH, + {"accept", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, "accept option request", "accept option .."}, {"add", NULL, AddCommand, LOCAL_AUTH, "add route", "add dest mask gateway", NULL}, @@ -373,17 +410,15 @@ static struct cmdtab const Commands[] = { "delete route", "delete dest", NULL}, {NULL, "delete!", DeleteCommand, LOCAL_AUTH, "delete a route if it exists", "delete! dest", (void *)1}, - {"deny", NULL, DenyCommand, LOCAL_AUTH, + {"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, "Deny option request", "deny option .."}, {"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT, "Dial and login", "dial|call [remote]"}, - {"disable", NULL, DisableCommand, LOCAL_AUTH, + {"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, "Disable option", "disable option .."}, - {"display", NULL, DisplayCommand, LOCAL_AUTH, - "Display option configs", "display"}, {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX, "Generate a down event", "down"}, - {"enable", NULL, EnableCommand, LOCAL_AUTH, + {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, "Enable option", "enable option .."}, {"link", "datalink", LinkCommand, LOCAL_AUTH, "Link specific commands", "link name command ..."}, @@ -462,7 +497,7 @@ static int ShowVersion(struct cmdargs const *arg) { static char VarVersion[] = "PPP Version 2.0-beta"; - static char VarLocalVersion[] = "$Date: 1998/04/11 21:50:44 $"; + static char VarLocalVersion[] = "$Date: 1998/04/14 23:17:01 $"; prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion); return 0; @@ -1555,3 +1590,219 @@ ChooseLink(struct cmdargs const *arg) return dl ? &dl->physical->link : NULL; } } + +static const char * +ident_cmd(const char *cmd, unsigned *keep, unsigned *add) +{ + const char *result; + + switch (*cmd) { + case 'A': + case 'a': + result = "accept"; + *keep = NEG_MYMASK; + *add = NEG_ACCEPTED; + break; + case 'D': + case 'd': + switch (cmd[1]) { + case 'E': + case 'e': + result = "deny"; + *keep = NEG_MYMASK; + *add = 0; + break; + case 'I': + case 'i': + result = "disable"; + *keep = NEG_HISMASK; + *add = 0; + break; + default: + return NULL; + } + break; + case 'E': + case 'e': + result = "enable"; + *keep = NEG_HISMASK; + *add = NEG_ENABLED; + break; + default: + return NULL; + } + + return result; +} + +static int +OptSet(struct cmdargs const *arg) +{ + int bit = (int)arg->cmd->args; + const char *cmd; + unsigned keep; /* Keep these bits */ + unsigned add; /* Add these bits */ + + if ((cmd = ident_cmd(arg->argv[arg->argn-2], &keep, &add)) == NULL) + return 1; + + if (add) + arg->bundle->cfg.opt |= bit; + else + arg->bundle->cfg.opt &= ~bit; + return 0; +} + +static int +NegotiateSet(struct cmdargs const *arg) +{ + int param = (int)arg->cmd->args; + struct link *l = ChooseLink(arg); /* AUTH_CX_OPT uses this */ + struct datalink *cx = arg->cx; /* AUTH_CX uses this */ + const char *cmd; + unsigned keep; /* Keep these bits */ + unsigned add; /* Add these bits */ + + if ((cmd = ident_cmd(arg->argv[arg->argn-2], &keep, &add)) == NULL) + return 1; + + if ((arg->cmd->lauth & LOCAL_CX) && !cx) { + LogPrintf(LogWARN, "%s %s: No context (use the `link' command)\n", + cmd, arg->cmd->name); + return 2; + } else if (cx && !(arg->cmd->lauth & (LOCAL_CX|LOCAL_CX_OPT))) { + LogPrintf(LogWARN, "%s %s: Redundant context (%s) ignored\n", + cmd, arg->cmd->name, cx->name); + cx = NULL; + } + + switch (param) { + case NEG_ACFCOMP: + cx->physical->link.lcp.cfg.acfcomp &= keep; + cx->physical->link.lcp.cfg.acfcomp |= add; + break; + case NEG_CHAP: + cx->physical->link.lcp.cfg.chap &= keep; + cx->physical->link.lcp.cfg.chap |= add; + break; + case NEG_DEFLATE: + l->ccp.cfg.neg[CCP_NEG_DEFLATE] &= keep; + l->ccp.cfg.neg[CCP_NEG_DEFLATE] |= add; + break; + case NEG_LQR: + cx->physical->link.lcp.cfg.lqr &= keep; + cx->physical->link.lcp.cfg.lqr |= add; + break; + case NEG_PAP: + cx->physical->link.lcp.cfg.pap &= keep; + cx->physical->link.lcp.cfg.pap |= add; + break; + case NEG_PPPDDEFLATE: + l->ccp.cfg.neg[CCP_NEG_DEFLATE24] &= keep; + l->ccp.cfg.neg[CCP_NEG_DEFLATE24] |= add; + break; + case NEG_PRED1: + l->ccp.cfg.neg[CCP_NEG_PRED1] &= keep; + l->ccp.cfg.neg[CCP_NEG_PRED1] |= add; + break; + case NEG_PROTOCOMP: + cx->physical->link.lcp.cfg.protocomp &= keep; + cx->physical->link.lcp.cfg.protocomp |= add; + break; + case NEG_VJCOMP: + arg->bundle->ncp.ipcp.cfg.vj.neg &= keep; + arg->bundle->ncp.ipcp.cfg.vj.neg |= add; + break; + } + + return 0; +} + +static struct cmdtab const NegotiateCommands[] = { + {"idcheck", NULL, OptSet, LOCAL_AUTH, "Check reply FSM ids", + "disable|enable", (const void *)OPT_IDCHECK}, + {"loopback", NULL, OptSet, LOCAL_AUTH, "Loop packets for local iface", + "disable|enable", (const void *)OPT_LOOPBACK}, + {"msext", NULL, OptSet, LOCAL_AUTH, "Send NS & NBNS values", + "disable|enable", (const void *)OPT_MSEXT}, + {"passwdauth", NULL, OptSet, LOCAL_AUTH, "Use passwd file", + "disable|enable", (const void *)OPT_PASSWDAUTH}, + {"proxy", NULL, OptSet, LOCAL_AUTH, "Create proxy ARP entry", + "disable|enable", (const void *)OPT_PROXY}, + {"throughput", NULL, OptSet, LOCAL_AUTH, "Rolling throughput", + "disable|enable", (const void *)OPT_THROUGHPUT}, + {"utmp", NULL, OptSet, LOCAL_AUTH, "Log connections in utmp", + "disable|enable", (const void *)OPT_UTMP}, + +#define OPT_MAX 7 /* accept/deny allowed below and not above */ + + {"acfcomp", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX, + "Address & Control field compression", "accept|deny|disable|enable", + (const void *)NEG_ACFCOMP}, + {"chap", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX, + "Challenge Handshake Authentication Protocol", "accept|deny|disable|enable", + (const void *)NEG_CHAP}, + {"deflate", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT, + "Deflate compression", "accept|deny|disable|enable", + (const void *)NEG_DEFLATE}, + {"lqr", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX, + "Link Quality Reports", "accept|deny|disable|enable", + (const void *)NEG_LQR}, + {"pap", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX, + "Password Authentication protocol", "accept|deny|disable|enable", + (const void *)NEG_PAP}, + {"deflate24", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT, + "Deflate (type 24) compression", "accept|deny|disable|enable", + (const void *)NEG_PPPDDEFLATE}, + {"pred1", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX_OPT, + "Predictor 1 compression", "accept|deny|disable|enable", + (const void *)NEG_PRED1}, + {"protocomp", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX, + "Protocol field compression", "accept|deny|disable|enable", + (const void *)NEG_PROTOCOMP}, + {"vjcomp", NULL, NegotiateSet, LOCAL_AUTH, + "Van Jacobson header compression", "accept|deny|disable|enable", + (const void *)NEG_VJCOMP}, + {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, + "Display this message", "accept|deny|disable|enable help|? [value]", + NegotiateCommands}, + {NULL, NULL, NULL}, +}; + +static int +NegotiateCommand(struct cmdargs const *arg) +{ + if (arg->argc > arg->argn) { + char const *argv[3]; + unsigned keep, add; + int n; + + if ((argv[0] = ident_cmd(arg->argv[arg->argn-1], &keep, &add)) == NULL) + return -1; + argv[2] = NULL; + + for (n = arg->argn; n < arg->argc; n++) { + argv[1] = arg->argv[n]; + FindExec(arg->bundle, NegotiateCommands + (keep == NEG_HISMASK ? + 0 : OPT_MAX), 2, 1, argv, arg->prompt, arg->cx); + } + } else if (arg->prompt) + prompt_Printf(arg->prompt, "Use `%s ?' to get a list or `%s ? ' for" + " syntax help.\n", arg->argv[arg->argn], arg->argv[arg->argn] ); + else + LogPrintf(LogWARN, "%s command must have arguments\n", + arg->argv[arg->argn] ); + + return 0; +} + +const char * +command_ShowNegval(unsigned val) +{ + switch (val&3) { + case 1: return "disabled & accepted"; + case 2: return "enabled & denied"; + case 3: return "enabled & accepted"; + } + return "disabled & denied"; +} diff --git a/usr.sbin/ppp/command.h b/usr.sbin/ppp/command.h index 91cb9643f9e1..1bd0b37ebfb3 100644 --- a/usr.sbin/ppp/command.h +++ b/usr.sbin/ppp/command.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.h,v 1.12.2.9 1998/04/07 00:53:34 brian Exp $ + * $Id: command.h,v 1.12.2.10 1998/04/14 23:17:03 brian Exp $ * * TODO: */ @@ -46,26 +46,10 @@ struct cmdtab { const void *args; }; -#define VAR_AUTHKEY 0 -#define VAR_DIAL 1 -#define VAR_LOGIN 2 -#define VAR_AUTHNAME 3 -#define VAR_WINSIZE 4 -#define VAR_DEVICE 5 -#define VAR_ACCMAP 6 -#define VAR_MRU 7 -#define VAR_MTU 8 -#define VAR_OPENMODE 9 -#define VAR_PHONE 10 -#define VAR_HANGUP 11 -#define VAR_ENC 12 -#define VAR_IDLETIMEOUT 13 -#define VAR_LQRPERIOD 14 -#define VAR_LCPRETRY 15 -#define VAR_CHAPRETRY 16 -#define VAR_PAPRETRY 17 -#define VAR_CCPRETRY 18 -#define VAR_IPCPRETRY 19 +#define NEG_ACCEPTED (1) +#define NEG_ENABLED (2) +#define IsAccepted(x) ((x) & NEG_ACCEPTED) +#define IsEnabled(x) ((x) & NEG_ENABLED) extern int IsInteractive(struct prompt *); extern void InterpretCommand(char *, int, int *, char ***); @@ -74,3 +58,4 @@ extern void RunCommand(struct bundle *, int, char const *const *, extern void DecodeCommand(struct bundle *, char *, int, struct prompt *, const char *); extern struct link *ChooseLink(struct cmdargs const *); +const char *command_ShowNegval(unsigned); diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index a2c622e77c84..482568563251 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.c,v 1.1.2.36 1998/04/10 13:19:05 brian Exp $ + * $Id: datalink.c,v 1.1.2.37 1998/04/14 23:17:04 brian Exp $ */ #include @@ -223,6 +223,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, LogPrintf(LogCHAT, "%s: Dial attempt %u of %d\n", dl->name, dl->cfg.dial.max - dl->dial_tries, dl->cfg.dial.max); + return datalink_UpdateSet(d, r, w, e, n); } else datalink_LoginDone(dl); } else { @@ -263,7 +264,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, LogPrintf(LogPHASE, "%s: Entering LOGIN state\n", dl->name); dl->state = DATALINK_LOGIN; chat_Init(&dl->chat, dl->physical, dl->cfg.script.login, 0, NULL); - break; + return datalink_UpdateSet(d, r, w, e, n); case DATALINK_LOGIN: datalink_LoginDone(dl); break; @@ -282,7 +283,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, dl->state = DATALINK_HANGUP; modem_Offline(dl->physical); chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1, NULL); - break; + return datalink_UpdateSet(d, r, w, e, n); } break; } @@ -716,17 +717,15 @@ void datalink_Show(struct datalink *dl, struct prompt *prompt) { prompt_Printf(prompt, "Name: %s\n", dl->name); - prompt_Printf(prompt, " State: %s\n", datalink_State(dl)); -#ifdef HAVE_DES - prompt_Printf(arg->prompt, " Encryption = %s\n", + prompt_Printf(prompt, " State: %s\n", datalink_State(dl)); + prompt_Printf(prompt, " CHAP Encryption: %s\n", dl->chap.using_MSChap ? "MSChap" : "MD5" ); -#endif prompt_Printf(prompt, "\nDefaults:\n"); - prompt_Printf(prompt, " Phone List: %s\n", dl->cfg.phone.list); + prompt_Printf(prompt, " Phone List: %s\n", dl->cfg.phone.list); if (dl->cfg.dial.max) - prompt_Printf(prompt, " Dial tries: %d, delay ", dl->cfg.dial.max); + prompt_Printf(prompt, " Dial tries: %d, delay ", dl->cfg.dial.max); else - prompt_Printf(prompt, " Dial tries: infinite, delay "); + prompt_Printf(prompt, " Dial tries: infinite, delay "); if (dl->cfg.dial.next_timeout > 0) prompt_Printf(prompt, "%ds/", dl->cfg.dial.next_timeout); else @@ -735,14 +734,14 @@ datalink_Show(struct datalink *dl, struct prompt *prompt) prompt_Printf(prompt, "%ds\n", dl->cfg.dial.timeout); else prompt_Printf(prompt, "random\n"); - prompt_Printf(prompt, " Reconnect tries: %d, delay ", dl->cfg.reconnect.max); + prompt_Printf(prompt, " Reconnect tries: %d, delay ", dl->cfg.reconnect.max); if (dl->cfg.reconnect.timeout > 0) prompt_Printf(prompt, "%ds\n", dl->cfg.reconnect.timeout); else prompt_Printf(prompt, "random\n"); - prompt_Printf(prompt, " Dial Script: %s\n", dl->cfg.script.dial); - prompt_Printf(prompt, " Login Script: %s\n", dl->cfg.script.login); - prompt_Printf(prompt, " Hangup Script: %s\n", dl->cfg.script.hangup); + prompt_Printf(prompt, " Dial Script: %s\n", dl->cfg.script.dial); + prompt_Printf(prompt, " Login Script: %s\n", dl->cfg.script.login); + prompt_Printf(prompt, " Hangup Script: %s\n", dl->cfg.script.hangup); } int diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c index f3e1921ff361..dd5ce7fcd896 100644 --- a/usr.sbin/ppp/deflate.c +++ b/usr.sbin/ppp/deflate.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: deflate.c,v 1.6.4.9 1998/04/06 09:12:26 brian Exp $ + * $Id: deflate.c,v 1.6.4.10 1998/04/07 00:53:37 brian Exp $ */ #include @@ -34,7 +34,6 @@ #include "mbuf.h" #include "log.h" -#include "vars.h" #include "timer.h" #include "lqr.h" #include "hdlc.h" @@ -551,7 +550,7 @@ DeflateTermOutput(void *v) const struct ccp_algorithm PppdDeflateAlgorithm = { TY_PPPD_DEFLATE, /* pppd (wrongly) expects this ``type'' field */ - ConfPppdDeflate, + CCP_NEG_DEFLATE24, DeflateDispOpts, { DeflateSetOptsInput, @@ -573,7 +572,7 @@ const struct ccp_algorithm PppdDeflateAlgorithm = { const struct ccp_algorithm DeflateAlgorithm = { TY_DEFLATE, /* rfc 1979 */ - ConfDeflate, + CCP_NEG_DEFLATE, DeflateDispOpts, { DeflateSetOptsInput, diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index ff1da1140a2a..316ec9fc7ec9 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,13 +17,15 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.27.2.26 1998/04/06 09:12:27 brian Exp $ + * $Id: fsm.c,v 1.27.2.27 1998/04/07 00:53:41 brian Exp $ * * TODO: - * o Refer loglevel for log output - * o Better option log display */ + #include +#include +#include +#include #include #include @@ -33,17 +35,22 @@ #include "defs.h" #include "timer.h" #include "fsm.h" +#include "iplist.h" #include "lqr.h" #include "hdlc.h" -#include "lcpproto.h" +#include "throughput.h" +#include "slcompress.h" +#include "ipcp.h" +#include "filter.h" +#include "descriptor.h" #include "lcp.h" #include "ccp.h" -#include "vars.h" -#include "throughput.h" -#include "async.h" #include "link.h" -#include "descriptor.h" +#include "mp.h" +#include "bundle.h" +#include "async.h" #include "physical.h" +#include "lcpproto.h" static void FsmSendConfigReq(struct fsm *); static void FsmSendTerminateReq(struct fsm *); @@ -885,7 +892,8 @@ FsmInput(struct fsm *fp, struct mbuf *bp) bp->cnt -= sizeof(struct fsmheader); codep = FsmCodes + lhp->code - 1; - if (lhp->id != fp->reqid && codep->check_reqid && Enabled(ConfIdCheck)) { + if (lhp->id != fp->reqid && codep->check_reqid && + Enabled(fp->bundle, OPT_IDCHECK)) { LogPrintf(fp->LogLevel, "Recv%s(%d), dropped (expected %d)\n", codep->name, lhp->id, fp->reqid); return; @@ -898,10 +906,10 @@ FsmInput(struct fsm *fp, struct mbuf *bp) LogMemory(); if (codep->inc_reqid && (lhp->id == fp->reqid || - (!Enabled(ConfIdCheck) && codep->check_reqid))) + (!Enabled(fp->bundle, OPT_IDCHECK) && codep->check_reqid))) fp->reqid++; /* That's the end of that ``exchange''.... */ - (codep->recv)(fp, lhp, bp); + (*codep->recv)(fp, lhp, bp); if (LogIsKept(LogDEBUG)) LogMemory(); diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index b7397082ea55..18a29a9656b1 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.50.2.35 1998/04/10 13:19:08 brian Exp $ + * $Id: ipcp.c,v 1.50.2.36 1998/04/14 23:17:07 brian Exp $ * * TODO: * o More RFC1772 backwoard compatibility @@ -54,7 +54,6 @@ #include "filter.h" #include "descriptor.h" #include "loadalias.h" -#include "vars.h" #include "vjcomp.h" #include "lqr.h" #include "hdlc.h" @@ -142,34 +141,38 @@ ReportIpcpStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, "%s [%s]\n", arg->bundle->ncp.ipcp.fsm.name, State2Nam(arg->bundle->ncp.ipcp.fsm.state)); if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED) { - prompt_Printf(arg->prompt, " His side: %s, %s\n", + prompt_Printf(arg->prompt, " His side: %s, %s\n", inet_ntoa(arg->bundle->ncp.ipcp.peer_ip), vj2asc(arg->bundle->ncp.ipcp.peer_compproto)); - prompt_Printf(arg->prompt, " My side: %s, %s\n", + prompt_Printf(arg->prompt, " My side: %s, %s\n", inet_ntoa(arg->bundle->ncp.ipcp.my_ip), vj2asc(arg->bundle->ncp.ipcp.my_compproto)); } prompt_Printf(arg->prompt, "\nDefaults:\n"); - prompt_Printf(arg->prompt, " My Address: %s/%d\n", + prompt_Printf(arg->prompt, " My Address: %s/%d\n", inet_ntoa(arg->bundle->ncp.ipcp.cfg.my_range.ipaddr), arg->bundle->ncp.ipcp.cfg.my_range.width); if (iplist_isvalid(&arg->bundle->ncp.ipcp.cfg.peer_list)) - prompt_Printf(arg->prompt, " His Address: %s\n", + prompt_Printf(arg->prompt, " His Address: %s\n", arg->bundle->ncp.ipcp.cfg.peer_list.src); else - prompt_Printf(arg->prompt, " His Address: %s/%d\n", + prompt_Printf(arg->prompt, " His Address: %s/%d\n", inet_ntoa(arg->bundle->ncp.ipcp.cfg.peer_range.ipaddr), arg->bundle->ncp.ipcp.cfg.peer_range.width); + + prompt_Printf(arg->prompt, "\nNegotiation:\n"); if (arg->bundle->ncp.ipcp.cfg.HaveTriggerAddress) - prompt_Printf(arg->prompt, " Negotiation(trigger): %s\n", + prompt_Printf(arg->prompt, " Trigger Address: %s\n", inet_ntoa(arg->bundle->ncp.ipcp.cfg.TriggerAddress)); else - prompt_Printf(arg->prompt, " Negotiation(trigger): MYADDR\n"); - prompt_Printf(arg->prompt, " Initial VJ slots: %d\n", - arg->bundle->ncp.ipcp.cfg.VJInitSlots); - prompt_Printf(arg->prompt, " Initial VJ compression: %s\n", - arg->bundle->ncp.ipcp.cfg.VJInitComp ? "on" : "off"); + prompt_Printf(arg->prompt, " Trigger Address: MYADDR\n"); + + prompt_Printf(arg->prompt, " VJ compression: %s (%d slots %s slot compression)\n", + command_ShowNegval(arg->bundle->ncp.ipcp.cfg.vj.neg), + arg->bundle->ncp.ipcp.cfg.vj.slots, + arg->bundle->ncp.ipcp.cfg.vj.slotcomp ? "with" : "without" +); prompt_Printf(arg->prompt, "\n"); throughput_disp(&arg->bundle->ncp.ipcp.throughput, arg->prompt); @@ -188,13 +191,13 @@ SetInitVJ(struct cmdargs const *arg) slots = atoi(arg->argv[arg->argn+1]); if (slots < 4 || slots > 16) return 1; - arg->bundle->ncp.ipcp.cfg.VJInitSlots = slots; + arg->bundle->ncp.ipcp.cfg.vj.slots = slots; return 0; } else if (!strcasecmp(arg->argv[arg->argn], "slotcomp")) { if (!strcasecmp(arg->argv[arg->argn+1], "on")) - arg->bundle->ncp.ipcp.cfg.VJInitComp = 1; + arg->bundle->ncp.ipcp.cfg.vj.slotcomp = 1; else if (!strcasecmp(arg->argv[arg->argn+1], "off")) - arg->bundle->ncp.ipcp.cfg.VJInitComp = 0; + arg->bundle->ncp.ipcp.cfg.vj.slotcomp = 0; else return 2; return 0; @@ -214,8 +217,8 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l, fsm_Init(&ipcp->fsm, "IPCP", PROTO_IPCP, 1, IPCP_MAXCODE, 10, LogIPCP, bundle, l, parent, &ipcp_Callbacks, timer_names); - ipcp->cfg.VJInitSlots = DEF_VJ_STATES; - ipcp->cfg.VJInitComp = 1; + ipcp->cfg.vj.slots = DEF_VJ_STATES; + ipcp->cfg.vj.slotcomp = 1; memset(&ipcp->cfg.my_range, '\0', sizeof ipcp->cfg.my_range); if (gethostname(name, sizeof name) == 0) { hp = gethostbyname(name); @@ -238,6 +241,7 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l, #endif ipcp->cfg.fsmretry = DEF_FSMRETRY; + ipcp->cfg.vj.neg = NEG_ENABLED|NEG_ACCEPTED; memset(&ipcp->vj, '\0', sizeof ipcp->vj); @@ -291,13 +295,13 @@ ipcp_Setup(struct ipcp *ipcp) else ipcp->my_ip = ipcp->cfg.my_range.ipaddr; - if (Enabled(ConfVjcomp)) + if (IsEnabled(ipcp->cfg.vj.neg)) ipcp->my_compproto = (PROTO_VJCOMP << 16) + - ((ipcp->cfg.VJInitSlots - 1) << 8) + - ipcp->cfg.VJInitComp; + ((ipcp->cfg.vj.slots - 1) << 8) + + ipcp->cfg.vj.slotcomp; else ipcp->my_compproto = 0; - sl_compress_init(&ipcp->vj.cslc, ipcp->cfg.VJInitSlots - 1); + sl_compress_init(&ipcp->vj.cslc, ipcp->cfg.vj.slots - 1); ipcp->peer_reject = 0; ipcp->my_reject = 0; @@ -372,7 +376,7 @@ ipcp_SetIPaddress(struct bundle *bundle, struct in_addr myaddr, bundle->ncp.ipcp.peer_ifip.s_addr = hisaddr.s_addr; bundle->ncp.ipcp.my_ifip.s_addr = myaddr.s_addr; - if (Enabled(ConfProxy)) + if (Enabled(bundle, OPT_PROXY)) sifproxyarp(bundle, bundle->ncp.ipcp.peer_ifip, s); close(s); @@ -484,7 +488,7 @@ IpcpCleanInterface(struct ipcp *ipcp) return; } - if (Enabled(ConfProxy)) + if (Enabled(ipcp->fsm.bundle, OPT_PROXY)) cifproxyarp(ipcp->fsm.bundle, ipcp->peer_ifip, s); if (ipcp->my_ifip.s_addr != INADDR_ANY || @@ -577,7 +581,8 @@ IpcpLayerUp(struct fsm *fp) } else SelectSystem(fp->bundle, "MYADDR", LINKUPFILE, NULL); - throughput_start(&ipcp->throughput, "IPCP throughput"); + throughput_start(&ipcp->throughput, "IPCP throughput", + Enabled(fp->bundle, OPT_THROUGHPUT)); bundle_DisplayPrompt(fp->bundle); } @@ -698,7 +703,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, switch (mode_type) { case MODE_REQ: - if (!Acceptable(ConfVjcomp)) { + if (!IsAccepted(ipcp->cfg.vj.neg)) { memcpy(dec->rejend, cp, length); dec->rejend += length; } else { @@ -789,7 +794,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, case TY_SECONDARY_DNS: switch (mode_type) { case MODE_REQ: - if (!Enabled(ConfMSExt)) { + if (Enabled(ipcp->fsm.bundle, OPT_MSEXT)) { LogPrintf(LogIPCP, "MS NS req - rejected - msext disabled\n"); ipcp->my_reject |= (1 << type); memcpy(dec->rejend, cp, length); @@ -836,7 +841,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, case TY_SECONDARY_NBNS: switch (mode_type) { case MODE_REQ: - if (!Enabled(ConfMSExt)) { + if (!Enabled(ipcp->fsm.bundle, OPT_MSEXT)) { LogPrintf(LogIPCP, "MS NBNS req - rejected - msext disabled\n"); ipcp->my_reject |= (1 << type); memcpy(dec->rejend, cp, length); @@ -882,6 +887,15 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type, plen -= length; cp += length; } + + if (mode_type != MODE_NOP) + if (dec->rejend != dec->rej) { + /* rejects are preferred */ + dec->ackend = dec->ack; + dec->nakend = dec->nak; + } else if (dec->nakend != dec->nak) + /* then NAKs */ + dec->ackend = dec->ack; } void diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h index 5ec8768b5eb4..7e392ce32a55 100644 --- a/usr.sbin/ppp/ipcp.h +++ b/usr.sbin/ppp/ipcp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.h,v 1.18.2.20 1998/04/07 00:53:52 brian Exp $ + * $Id: ipcp.h,v 1.18.2.21 1998/04/10 13:19:09 brian Exp $ * * TODO: */ @@ -43,8 +43,11 @@ struct ipcp { struct fsm fsm; /* The finite state machine */ struct { - int VJInitSlots; /* Maximum VJ slots */ - unsigned VJInitComp : 1; /* Slot compression */ + struct { + int slots; /* Maximum VJ slots */ + unsigned slotcomp : 1; /* Slot compression */ + unsigned neg : 2; /* VJ negotiation */ + } vj; struct in_range my_range; /* MYADDR spec */ struct in_addr netmask; /* netmask (unused by most OSs) */ diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 3001335e8251..d2809d6f00b5 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.55.2.40 1998/04/06 09:12:30 brian Exp $ + * $Id: lcp.c,v 1.55.2.41 1998/04/07 00:53:55 brian Exp $ * * TODO: * o Limit data field length by MRU @@ -42,7 +42,6 @@ #include "lqr.h" #include "hdlc.h" #include "ccp.h" -#include "vars.h" #include "async.h" #include "link.h" #include "physical.h" @@ -146,6 +145,18 @@ lcp_ReportStatus(struct cmdargs const *arg) prompt_Printf(arg->prompt, " (delay %ds)", lcp->cfg.openmode); prompt_Printf(arg->prompt, "\n FSM retry = %us\n", lcp->cfg.fsmretry); + prompt_Printf(arg->prompt, "\n Negotiation:\n"); + prompt_Printf(arg->prompt, " ACFCOMP = %s\n", + command_ShowNegval(lcp->cfg.acfcomp)); + prompt_Printf(arg->prompt, " CHAP = %s\n", + command_ShowNegval(lcp->cfg.chap)); + prompt_Printf(arg->prompt, " LQR = %s\n", + command_ShowNegval(lcp->cfg.lqr)); + prompt_Printf(arg->prompt, " PAP = %s\n", + command_ShowNegval(lcp->cfg.pap)); + prompt_Printf(arg->prompt, " PROTOCOMP = %s\n", + command_ShowNegval(lcp->cfg.protocomp)); + return 0; } @@ -176,6 +187,12 @@ lcp_Init(struct lcp *lcp, struct bundle *bundle, struct link *l, lcp->cfg.lqrperiod = DEF_LQRPERIOD; lcp->cfg.fsmretry = DEF_FSMRETRY; + lcp->cfg.acfcomp = NEG_ENABLED|NEG_ACCEPTED; + lcp->cfg.chap = NEG_ACCEPTED; + lcp->cfg.lqr = NEG_ACCEPTED; + lcp->cfg.pap = NEG_ACCEPTED; + lcp->cfg.protocomp = NEG_ENABLED|NEG_ACCEPTED; + lcp_Setup(lcp, lcp->cfg.openmode); } @@ -192,17 +209,18 @@ lcp_Setup(struct lcp *lcp, int openmode) lcp->his_auth = 0; lcp->want_mru = lcp->cfg.mru; - lcp->want_acfcomp = Enabled(ConfAcfcomp) ? 1 : 0; + lcp->want_acfcomp = IsEnabled(lcp->cfg.acfcomp) ? 1 : 0; if (lcp->fsm.parent) { lcp->his_accmap = 0xffffffff; lcp->want_accmap = lcp->cfg.accmap; lcp->his_protocomp = 0; - lcp->want_protocomp = Enabled(ConfProtocomp) ? 1 : 0; + lcp->want_protocomp = IsEnabled(lcp->cfg.protocomp) ? 1 : 0; lcp->want_magic = GenerateMagic(); - lcp->want_auth = Enabled(ConfChap) ? PROTO_CHAP : - Enabled(ConfPap) ? PROTO_PAP : 0; - lcp->want_lqrperiod = Enabled(ConfLqr) ? lcp->cfg.lqrperiod * 100 : 0; + lcp->want_auth = IsEnabled(lcp->cfg.chap) ? PROTO_CHAP : + IsEnabled(lcp->cfg.pap) ? PROTO_PAP : 0; + lcp->want_lqrperiod = IsEnabled(lcp->cfg.lqr) ? + lcp->cfg.lqrperiod * 100 : 0; } else { lcp->his_accmap = lcp->want_accmap = 0; lcp->his_protocomp = lcp->want_protocomp = 1; @@ -445,11 +463,11 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, LogPrintf(LogLCP, " Bad length!\n"); goto reqreject; } - if (Acceptable(ConfPap)) { + if (IsAccepted(lcp->cfg.pap)) { lcp->his_auth = proto; memcpy(dec->ackend, cp, length); dec->ackend += length; - } else if (Acceptable(ConfChap)) { + } else if (IsAccepted(lcp->cfg.chap)) { *dec->nakend++ = *cp; *dec->nakend++ = 5; *dec->nakend++ = (unsigned char) (PROTO_CHAP >> 8); @@ -465,9 +483,9 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, goto reqreject; } #ifdef HAVE_DES - if (Acceptable(ConfChap) && (cp[4] == 5 || cp[4] == 0x80)) + if (IsAccepted(lcp->cfg.chap) && (cp[4] == 0x05 || cp[4] == 0x80)) #else - if (Acceptable(ConfChap) && cp[4] == 5) + if (IsAccepted(lcp->cfg.chap) && cp[4] == 0x05) #endif { lcp->his_auth = proto; @@ -476,7 +494,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, #ifdef HAVE_DES link2physical(fp->link)->dl->chap.using_MSChap = cp[4] == 0x80; #endif - } else if (Acceptable(ConfPap)) { + } else if (IsAccepted(lcp->cfg.pap)) { *dec->nakend++ = *cp; *dec->nakend++ = 4; *dec->nakend++ = (unsigned char) (PROTO_PAP >> 8); @@ -496,7 +514,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, case MODE_NAK: switch (proto) { case PROTO_PAP: - if (Enabled(ConfPap)) + if (IsEnabled(lcp->cfg.pap)) lcp->want_auth = PROTO_PAP; else { LogPrintf(LogLCP, "Peer will only send PAP (not enabled)\n"); @@ -504,7 +522,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, } break; case PROTO_CHAP: - if (Enabled(ConfChap)) + if (IsEnabled(lcp->cfg.chap)) lcp->want_auth = PROTO_CHAP; else { LogPrintf(LogLCP, "Peer will only send CHAP (not enabled)\n"); @@ -529,7 +547,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, request, ntohs(req->proto), ntohl(req->period) * 10); switch (mode_type) { case MODE_REQ: - if (ntohs(req->proto) != PROTO_LQR || !Acceptable(ConfLqr)) + if (ntohs(req->proto) != PROTO_LQR || !IsAccepted(lcp->cfg.lqr)) goto reqreject; else { lcp->his_lqrperiod = ntohl(req->period); @@ -593,7 +611,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, switch (mode_type) { case MODE_REQ: - if (Acceptable(ConfProtocomp)) { + if (IsAccepted(lcp->cfg.protocomp)) { lcp->his_protocomp = 1; memcpy(dec->ackend, cp, 2); dec->ackend += 2; @@ -623,7 +641,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, LogPrintf(LogLCP, "%s\n", request); switch (mode_type) { case MODE_REQ: - if (Acceptable(ConfAcfcomp)) { + if (IsAccepted(lcp->cfg.acfcomp)) { lcp->his_acfcomp = 1; memcpy(dec->ackend, cp, 2); dec->ackend += 2; @@ -693,6 +711,15 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, plen -= length; cp += length; } + + if (mode_type != MODE_NOP) + if (dec->rejend != dec->rej) { + /* rejects are preferred */ + dec->ackend = dec->ack; + dec->nakend = dec->nak; + } else if (dec->nakend != dec->nak) + /* then NAKs */ + dec->ackend = dec->ack; } void diff --git a/usr.sbin/ppp/lcp.h b/usr.sbin/ppp/lcp.h index 85b8f74e3707..201505ef2b05 100644 --- a/usr.sbin/ppp/lcp.h +++ b/usr.sbin/ppp/lcp.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.h,v 1.16.2.18 1998/04/05 19:02:49 brian Exp $ + * $Id: lcp.h,v 1.16.2.19 1998/04/07 00:53:56 brian Exp $ * * TODO: */ @@ -55,6 +55,12 @@ struct lcp { int openmode; /* when to start CFG REQs */ u_int lqrperiod; /* LQR frequency */ u_int fsmretry; /* FSM retry frequency */ + + unsigned acfcomp : 2; /* Address & Control Field Compression neg */ + unsigned chap : 2; /* Challenge Handshake Authentication proto */ + unsigned lqr : 2; /* Link Quality Report */ + unsigned pap : 2; /* Password Authentication protocol */ + unsigned protocomp : 2; /* Protocol field compression */ } cfg; }; diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index f377e0eda8a0..bc171d69e6bc 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.22.2.21 1998/04/07 00:54:01 brian Exp $ + * $Id: lqr.c,v 1.22.2.22 1998/04/14 07:25:37 brian Exp $ * * o LQR based on RFC1333 * @@ -27,9 +27,6 @@ */ #include -#include -#include -#include #include #include @@ -49,17 +46,11 @@ #include "link.h" #include "descriptor.h" #include "physical.h" -#include "iplist.h" -#include "slcompress.h" -#include "ipcp.h" -#include "filter.h" #include "mp.h" -#include "bundle.h" -#include "vars.h" #include "chat.h" #include "auth.h" #include "chap.h" -#include "pap.h" +#include "command.h" #include "datalink.h" struct echolqr { @@ -172,7 +163,8 @@ LqrInput(struct physical *physical, struct mbuf *bp) if (len != sizeof(struct lqrdata)) LogPrintf(LogERROR, "LqrInput: Got packet size %d, expecting %d !\n", len, sizeof(struct lqrdata)); - else if (!Acceptable(ConfLqr) && !(physical->hdlc.lqm.method & LQM_LQR)) { + else if (!IsAccepted(physical->link.lcp.cfg.lqr) && + !(physical->hdlc.lqm.method & LQM_LQR)) { bp->offset -= 2; bp->cnt += 2; lcp_SendProtoRej(physical->hdlc.lqm.owner, MBUF_CTOP(bp), bp->cnt); @@ -229,7 +221,7 @@ StartLqm(struct lcp *lcp) sizeof physical->hdlc.lqm.lqr.peer); physical->hdlc.lqm.method = LQM_ECHO; - if (Enabled(ConfLqr) && !REJECTED(lcp, TY_QUALPROTO)) + if (IsEnabled(physical->link.lcp.cfg.lqr) && !REJECTED(lcp, TY_QUALPROTO)) physical->hdlc.lqm.method |= LQM_LQR; StopTimer(&physical->hdlc.lqm.timer); diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 91deb69b55a1..d27dfee4e1f0 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.121.2.47 1998/04/07 23:46:02 brian Exp $ + * $Id: main.c,v 1.121.2.48 1998/04/10 13:19:11 brian Exp $ * * TODO: */ @@ -57,7 +57,6 @@ #include "mp.h" #include "bundle.h" #include "loadalias.h" -#include "vars.h" #include "auth.h" #include "systems.h" #include "ip.h" @@ -554,7 +553,7 @@ DoLoop(struct bundle *bundle, struct prompt *prompt) if (((struct ip *)tun.data)->ip_dst.s_addr == bundle->ncp.ipcp.my_ip.s_addr) { /* we've been asked to send something addressed *to* us :( */ - if (Enabled(ConfLoopback)) { + if (Enabled(bundle, OPT_LOOPBACK)) { pri = PacketCheck(bundle, tun.data, n, &bundle->filter.in); if (pri >= 0) { struct mbuf *bp; diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index a447ab973172..b31c061672ca 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.77.2.48 1998/04/10 14:55:11 brian Exp $ + * $Id: modem.c,v 1.77.2.49 1998/04/10 23:51:30 brian Exp $ * * TODO: */ @@ -478,9 +478,10 @@ modem_Unlock(struct physical *modem) } static void -modem_Found(struct physical *modem) +modem_Found(struct physical *modem, struct bundle *bundle) { - throughput_start(&modem->link.throughput, "modem throughput"); + throughput_start(&modem->link.throughput, "modem throughput", + Enabled(bundle, OPT_THROUGHPUT)); modem->connect_count++; LogPrintf(LogPHASE, "Connected!\n"); } @@ -507,12 +508,12 @@ modem_Open(struct physical *modem, struct bundle *bundle) return -1; } modem->fd = STDIN_FILENO; - modem_Found(modem); + modem_Found(modem, bundle); } else { LogPrintf(LogDEBUG, "modem_Open(direct): Modem is not a tty\n"); modem_SetDevice(modem, ""); /* We don't call modem_Timeout() with this type of connection */ - modem_Found(modem); + modem_Found(modem, bundle); return modem->fd = STDIN_FILENO; } } else { @@ -535,7 +536,7 @@ modem_Open(struct physical *modem, struct bundle *bundle) modem->fd = -1; } else { - modem_Found(modem); + modem_Found(modem, bundle); LogPrintf(LogDEBUG, "modem_Open: Modem is %s\n", modem->name.full); } } @@ -555,7 +556,7 @@ modem_Open(struct physical *modem, struct bundle *bundle) *cp = ':'; /* Don't destroy name.full */ if (modem->fd < 0) return (-1); - modem_Found(modem); + modem_Found(modem, bundle); LogPrintf(LogDEBUG, "modem_Open: Modem is socket %s\n", modem->name.full); } else { diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index 8a960b5cbe8e..501b33192c7f 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp.c,v 1.1.2.2 1998/04/06 09:12:34 brian Exp $ + * $Id: mp.c,v 1.1.2.3 1998/04/14 23:17:09 brian Exp $ */ #include @@ -45,10 +45,7 @@ #include "throughput.h" #include "slcompress.h" #include "ipcp.h" -/* #include "loadalias.h" */ -/* #include "vars.h" */ #include "auth.h" -/* #include "systems.h" */ #include "lcp.h" #include "lqr.h" #include "hdlc.h" diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index 2b39cc75a2cc..8596a20da561 100644 --- a/usr.sbin/ppp/pap.c +++ b/usr.sbin/ppp/pap.c @@ -18,7 +18,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pap.c,v 1.20.2.23 1998/04/06 09:12:34 brian Exp $ + * $Id: pap.c,v 1.20.2.24 1998/04/07 00:54:12 brian Exp $ * * TODO: */ @@ -152,7 +152,8 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical) if (PapValidate(bundle, cp, cp + *cp + 1, physical)) { SendPapCode(php->id, PAP_ACK, "Greetings!!", physical); physical->link.lcp.auth_ineed = 0; - Physical_Login(physical, cp + 1); + if (Enabled(bundle, OPT_UTMP)) + Physical_Login(physical, cp + 1); if (physical->link.lcp.auth_iwait == 0) /* diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index 1aaec89ed9fc..b662c9598ca4 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/ppp/physical.c @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.c,v 1.1.2.23 1998/04/10 13:19:15 brian Exp $ + * $Id: physical.c,v 1.1.2.24 1998/04/10 23:51:32 brian Exp $ * */ @@ -32,8 +32,6 @@ #include -/* XXX Name space pollution from vars.h */ - #include "defs.h" /* XXX Name space pollution from hdlc.h */ @@ -53,7 +51,6 @@ #include "descriptor.h" #include "physical.h" -#include "vars.h" #include "log.h" #include "id.h" @@ -179,7 +176,7 @@ Physical_IsSet(struct descriptor *d, const fd_set *fdset) void Physical_Login(struct physical *phys, const char *name) { - if (phys->type == PHYS_STDIN && Physical_IsATTY(phys) && Enabled(ConfUtmp)) + if (phys->type == PHYS_STDIN && Physical_IsATTY(phys)) if (phys->Utmp) LogPrintf(LogERROR, "Oops, already logged in on %s\n", phys->name.base); else { diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 21948f04daaa..c32cc44f0da9 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.97.2.14 1998/04/10 13:19:17 brian Exp $ +.\" $Id: ppp.8,v 1.97.2.15 1998/04/11 21:50:47 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -1572,11 +1572,20 @@ in is capable of negotiating with .Nm pppd , but only if -.Dq pppd-deflate +.Dq deflate24 is .Ar enable Ns No d and .Ar accept Ns No ed . +.It deflate24 +Default: Disabled and Denied. This is a variance of the +.Ar deflate +option, allowing negotiation with the +.Xr pppd 8 +program. Refer to the +.Ar deflate +section above for details. It is disabled by default as it violates +.Pa rfc1975 . .It lqr Default: Disabled and Accepted. This option decides if Link Quality Requests will be sent or accepted. LQR is a protocol that allows @@ -1629,15 +1638,6 @@ and in .Pa /etc/ppp/ppp.conf . PAP is accepted by default. -.It pppd-deflate -Default: Disabled and Denied. This is a variance of the -.Ar deflate -option, allowing negotiation with the -.Xr pppd 8 -program. Refer to the -.Ar deflate -section above for details. It is disabled by default as it violates -.Pa rfc1975 . .It pred1 Default: Enabled and Accepted. This option decides if Predictor 1 compression will be used by the Compression Control Protocol (CCP). @@ -1704,7 +1704,7 @@ Default: Disabled. Enabling this option will tell .Nm to proxy ARP for the peer. .It throughput -Default: Disabled. Enabling this option will tell +Default: Enabled. This option tells .Nm to gather thoroughput statistics. Input and output is sampled over a rolling 5 second window, and current, best and total figures are @@ -1712,7 +1712,7 @@ retained. This data is output when the relevent .Em PPP layer shuts down, and is also available using the .Dq show -command. Troughput statistics are available at the +command. Throughput statistics are available at the .Dq IPCP and .Dq modem @@ -1972,11 +1972,6 @@ scripts for the given .Ar label . Otherwise, the current settings are used to establish the connection. -.It display -Displays the current status of the negotiable protocol -values as specified under -.Dq accept|deny|enable|disable option.... -above. .It down Bring the link down ungracefully, as if the physical layer had become unavailable. It's not considered polite to use this command. @@ -2082,8 +2077,10 @@ and .Em 15 . If .Ar in-winsize -is specified, ppp will insist that this window size is used and will not -accept any other values from the peer. +is specified, +.Nm +will insist that this window size is used and will not accept any other +values from the peer. .It set device|line Ar value[,value...] This sets the device(s) to which .Nm diff --git a/usr.sbin/ppp/pred.c b/usr.sbin/ppp/pred.c index 493a62c9f848..2590e22798e0 100644 --- a/usr.sbin/ppp/pred.c +++ b/usr.sbin/ppp/pred.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pred.c,v 1.20.2.7 1998/04/06 09:12:35 brian Exp $ + * $Id: pred.c,v 1.20.2.8 1998/04/07 00:54:15 brian Exp $ */ #include @@ -36,7 +36,6 @@ #include "mbuf.h" #include "log.h" -#include "vars.h" #include "timer.h" #include "fsm.h" #include "lqr.h" @@ -313,7 +312,7 @@ Pred1SetOptsInput(struct lcp_opt *o, const struct ccp_config *cfg) const struct ccp_algorithm Pred1Algorithm = { TY_PRED1, - ConfPred1, + CCP_NEG_PRED1, Pred1DispOpts, { Pred1SetOptsInput, diff --git a/usr.sbin/ppp/throughput.c b/usr.sbin/ppp/throughput.c index e9dde10dcde0..4fa3c99ac6f6 100644 --- a/usr.sbin/ppp/throughput.c +++ b/usr.sbin/ppp/throughput.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: throughput.c,v 1.4.4.5 1998/04/07 00:54:21 brian Exp $ + * $Id: throughput.c,v 1.4.4.6 1998/04/10 13:19:23 brian Exp $ */ #include @@ -35,7 +35,6 @@ #include "log.h" #include "timer.h" #include "throughput.h" -#include "vars.h" #include "descriptor.h" #include "prompt.h" @@ -50,6 +49,7 @@ throughput_init(struct pppThroughput *t) t->OctetsPerSecond = t->BestOctetsPerSecond = t->nSample = 0; t->Timer.name = "throughput"; t->uptime = 0; + t->rolling = 0; throughput_stop(t); } @@ -64,7 +64,7 @@ throughput_disp(struct pppThroughput *t, struct prompt *prompt) secs_up = 1; prompt_Printf(prompt, "%ld octets in, %ld octets out\n", t->OctetsIn, t->OctetsOut); - if (Enabled(ConfThroughput)) { + if (t->rolling) { prompt_Printf(prompt, " overall %5ld bytes/sec\n", (t->OctetsIn+t->OctetsOut)/secs_up); prompt_Printf(prompt, " currently %5d bytes/sec\n", t->OctetsPerSecond); @@ -91,7 +91,7 @@ throughput_log(struct pppThroughput *t, int level, const char *title) secs_up, t->OctetsIn, t->OctetsOut); if (secs_up == 0) secs_up = 1; - if (Enabled(ConfThroughput)) + if (t->rolling) LogPrintf(level, " total %ld bytes/sec, peak %d bytes/sec\n", (t->OctetsIn+t->OctetsOut)/secs_up, t->BestOctetsPerSecond); else @@ -121,11 +121,12 @@ throughput_sampler(void *v) } void -throughput_start(struct pppThroughput *t, const char *name) +throughput_start(struct pppThroughput *t, const char *name, int rolling) { throughput_init(t); + t->rolling = rolling ? 1 : 0; time(&t->uptime); - if (Enabled(ConfThroughput)) { + if (t->rolling) { t->Timer.state = TIMER_STOPPED; t->Timer.load = SECTICKS; t->Timer.func = throughput_sampler; @@ -138,7 +139,7 @@ throughput_start(struct pppThroughput *t, const char *name) void throughput_stop(struct pppThroughput *t) { - if (Enabled(ConfThroughput)) + if (t->rolling) StopTimer(&t->Timer); } diff --git a/usr.sbin/ppp/throughput.h b/usr.sbin/ppp/throughput.h index 95d553998106..14ceec75368f 100644 --- a/usr.sbin/ppp/throughput.h +++ b/usr.sbin/ppp/throughput.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: throughput.h,v 1.2.4.2 1998/04/03 19:21:53 brian Exp $ + * $Id: throughput.h,v 1.2.4.3 1998/04/03 19:26:00 brian Exp $ */ #define SAMPLE_PERIOD 5 @@ -36,13 +36,14 @@ struct pppThroughput { int OctetsPerSecond; int BestOctetsPerSecond; int nSample; + unsigned rolling : 1; struct pppTimer Timer; }; extern void throughput_init(struct pppThroughput *); extern void throughput_disp(struct pppThroughput *, struct prompt *); extern void throughput_log(struct pppThroughput *, int, const char *); -extern void throughput_start(struct pppThroughput *, const char *); +extern void throughput_start(struct pppThroughput *, const char *, int); extern void throughput_stop(struct pppThroughput *); extern void throughput_addin(struct pppThroughput *, int); extern void throughput_addout(struct pppThroughput *, int); diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c deleted file mode 100644 index 207bc450d7ef..000000000000 --- a/usr.sbin/ppp/vars.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * PPP configuration variables - * - * Written by Toshiharu OHNO (tony-o@iij.ad.jp) - * - * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the Internet Initiative Japan, Inc. The name of the - * IIJ may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: vars.c,v 1.45.2.26 1998/04/07 00:54:24 brian Exp $ - * - */ -#include - -#include -#include - -#include "command.h" -#include "log.h" -#include "termios.h" -#include "vars.h" -#include "descriptor.h" -#include "prompt.h" - -/* - * Order of conf option is important. See vars.h. - */ -struct confdesc pppConfs[NCONFS] = { - {"acfcomp", CONF_ENABLE, CONF_ACCEPT}, - {"chap", CONF_DISABLE, CONF_ACCEPT}, - {"deflate", CONF_ENABLE, CONF_ACCEPT}, - {"lqr", CONF_DISABLE, CONF_ACCEPT}, - {"pap", CONF_DISABLE, CONF_ACCEPT}, - {"pppd-deflate", CONF_DISABLE, CONF_DENY}, - {"pred1", CONF_ENABLE, CONF_ACCEPT}, - {"protocomp", CONF_ENABLE, CONF_ACCEPT}, - {"vjcomp", CONF_ENABLE, CONF_ACCEPT}, - - {"idcheck", CONF_ENABLE, CONF_NONE}, - {"loopback", CONF_ENABLE, CONF_NONE}, - {"msext", CONF_DISABLE, CONF_NONE}, - {"passwdauth", CONF_DISABLE, CONF_NONE}, - {"proxy", CONF_DISABLE, CONF_NONE}, - {"throughput", CONF_DISABLE, CONF_NONE}, - {"utmp", CONF_ENABLE, CONF_NONE} -}; - -int -DisplayCommand(struct cmdargs const *arg) -{ - int f; - - prompt_Printf(arg->prompt, "Current configuration option settings..\n\n"); - prompt_Printf(arg->prompt, "Name\t\tMy Side\t\tHis Side\n"); - prompt_Printf(arg->prompt, "----------------------------------------\n"); - for (f = 0; f < NCONFS; f++) - prompt_Printf(arg->prompt, "%-10s\t%s\t\t%s\n", pppConfs[f].name, - (pppConfs[f].myside == CONF_ENABLE) ? "enable" : - (pppConfs[f].myside == CONF_DISABLE ? "disable" : "N/A"), - (pppConfs[f].hisside == CONF_ACCEPT) ? "accept" : - (pppConfs[f].hisside == CONF_DENY ? "deny" : "N/A")); - - return 0; -} - -static int -ConfigCommand(struct cmdargs const *arg, int mine, int val) -{ - int f; - int err; - int narg = arg->argn; - - if (arg->argc < narg+1) - return -1; - - err = 0; - do { - for (f = 0; f < NCONFS; f++) - if (strcasecmp(pppConfs[f].name, arg->argv[narg]) == 0) { - if (mine) { - if (pppConfs[f].myside == CONF_NONE) { - LogPrintf(LogWARN, "Config: %s cannot be enabled or disabled\n", - pppConfs[f].name); - err++; - } else - pppConfs[f].myside = val; - } else { - if (pppConfs[f].hisside == CONF_NONE) { - LogPrintf(LogWARN, "Config: %s cannot be accepted or denied\n", - pppConfs[f].name); - err++; - } else - pppConfs[f].hisside = val; - } - break; - } - if (f == NCONFS) { - LogPrintf(LogWARN, "Config: %s: No such key word\n", arg->argv[narg]); - err++; - } - } while (++narg < arg->argc); - - return err; -} - -int -EnableCommand(struct cmdargs const *arg) -{ - return ConfigCommand(arg, 1, CONF_ENABLE); -} - -int -DisableCommand(struct cmdargs const *arg) -{ - return ConfigCommand(arg, 1, CONF_DISABLE); -} - -int -AcceptCommand(struct cmdargs const *arg) -{ - return ConfigCommand(arg, 0, CONF_ACCEPT); -} - -int -DenyCommand(struct cmdargs const *arg) -{ - return ConfigCommand(arg, 0, CONF_DENY); -} diff --git a/usr.sbin/ppp/vars.h b/usr.sbin/ppp/vars.h deleted file mode 100644 index 843b7798a988..000000000000 --- a/usr.sbin/ppp/vars.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Written by Toshiharu OHNO (tony-o@iij.ad.jp) - * - * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. - * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the Internet Initiative Japan. The name of the - * IIJ may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * $Id: vars.h,v 1.42.2.21 1998/04/03 19:26:29 brian Exp $ - * - * TODO: - */ - -struct confdesc { - const char *name; - int myside, hisside; -}; - -#define CONF_NONE -1 -#define CONF_DISABLE 0 -#define CONF_ENABLE 1 - -#define CONF_DENY 0 -#define CONF_ACCEPT 1 - -#define ConfAcfcomp 0 -#define ConfChap 1 -#define ConfDeflate 2 -#define ConfLqr 3 -#define ConfPap 4 -#define ConfPppdDeflate 5 -#define ConfPred1 6 -#define ConfProtocomp 7 -#define ConfVjcomp 8 - -#define ConfIdCheck 9 -#define ConfLoopback 10 -#define ConfMSExt 11 -#define ConfPasswdAuth 12 -#define ConfProxy 13 -#define ConfThroughput 14 -#define ConfUtmp 15 -#define NCONFS 16 - -#define Enabled(x) (pppConfs[x].myside & CONF_ENABLE) -#define Acceptable(x) (pppConfs[x].hisside & CONF_ACCEPT) - -extern struct confdesc pppConfs[NCONFS]; - -struct cmdargs; - -extern int EnableCommand(struct cmdargs const *); -extern int DisableCommand(struct cmdargs const *); -extern int AcceptCommand(struct cmdargs const *); -extern int DenyCommand(struct cmdargs const *); -extern int DisplayCommand(struct cmdargs const *); diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c index 83d555eda910..7f92caf11218 100644 --- a/usr.sbin/ppp/vjcomp.c +++ b/usr.sbin/ppp/vjcomp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vjcomp.c,v 1.16.2.12 1998/04/06 09:12:38 brian Exp $ + * $Id: vjcomp.c,v 1.16.2.13 1998/04/07 00:54:25 brian Exp $ * * TODO: */ @@ -164,7 +164,10 @@ vj2asc(u_int32_t val) { static char asc[50]; - sprintf(asc, "%d VJ slots %s slot compression", - (int)((val>>8)&15)+1, val & 1 ? "with" : "without"); + if (val) + snprintf(asc, sizeof asc, "%d VJ slots %s slot compression", + (int)((val>>8)&15)+1, val & 1 ? "with" : "without"); + else + strcpy(asc, "VJ disabled"); return asc; }