From 3b0f8d2ed641ceeded11c0d3f253b0cacbf00880 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Fri, 3 Apr 1998 19:21:56 +0000 Subject: o Move struct lcp and struct ccp into struct link. o Remove bundle2lcp(), bundle2ccp() and bundle2link(). They're too resource-hungry and we have `owner pointers' to do their job. o Make our FSM understand LCPs that are always ST_OPENED (with a minimum code that != 1). o Send FSM code rejects for invalid codes. o Make our bundle fsm_parent deal with multiple links. o Make timer diagnostics pretty and allow access via ~t in `term' mode (not just when logging debug) and `show timers'. Only show timers every second in debug mode, otherwise we get too many diagnostics to be useful (we probably still do). Also, don't restrict ~m in term mode to depend on debug logging. o Rationalise our bundles' phases. o Create struct mp (multilink protocol). This is both an NCP and a type of struct link. It feeds off other NCPs for output, passing fragmented packets into the queues of available datalinks. It also gets PROTO_MP input, reassembles the fragments into ppp frames, and passes them back to the HDLC layer that the fragments were passed from. ** It's not yet possible to enter multilink mode :-( ** o Add `set weight' (requires context) for deciding on a links weighting in multilink mode. Weighting is simplistic (and probably badly implemented) for now. o Remove the function pointers in struct link. They ended up only applying to physical links. o Configure our tun device with an MTU equal to the MRU from struct mp's LCP and a speed equal to the sum of our link speeds. o `show {lcp,ccp,proto}' and `set deflate' now have optional context and use ChooseLink() to decide on which `struct link' to use. This allows behaviour as before when in non-multilink mode, and allows access to the MP logical link in multilink mode. o Ignore reconnect and redial values when in -direct mode and when cleaning up. Always redial when in -ddial or -dedicated mode (unless cleaning up). o Tell our links to `staydown' when we close them due to a signal. o Remove remaining `#ifdef SIGALRM's (ppp doesn't function without alarms). o Don't bother strdup()ing our physical link name. o Various other cosmetic changes. --- usr.sbin/ppp/Makefile | 12 +- usr.sbin/ppp/arp.c | 8 +- usr.sbin/ppp/async.c | 3 +- usr.sbin/ppp/auth.c | 5 +- usr.sbin/ppp/bundle.c | 247 ++++++++++++++----------- usr.sbin/ppp/bundle.h | 8 +- usr.sbin/ppp/ccp.c | 20 +- usr.sbin/ppp/ccp.h | 4 +- usr.sbin/ppp/chap.c | 17 +- usr.sbin/ppp/chat.c | 5 +- usr.sbin/ppp/command.c | 92 +++++++--- usr.sbin/ppp/command.h | 3 +- usr.sbin/ppp/datalink.c | 111 ++++++----- usr.sbin/ppp/datalink.h | 8 +- usr.sbin/ppp/defs.h | 4 +- usr.sbin/ppp/filter.c | 7 +- usr.sbin/ppp/fsm.c | 35 +++- usr.sbin/ppp/fsm.h | 9 +- usr.sbin/ppp/hdlc.c | 53 ++++-- usr.sbin/ppp/hdlc.h | 4 +- usr.sbin/ppp/ip.c | 16 +- usr.sbin/ppp/ip.h | 4 +- usr.sbin/ppp/ipcp.c | 14 +- usr.sbin/ppp/lcp.c | 49 +++-- usr.sbin/ppp/lcp.h | 6 +- usr.sbin/ppp/lcpproto.h | 3 +- usr.sbin/ppp/link.c | 55 +++--- usr.sbin/ppp/link.h | 16 +- usr.sbin/ppp/lqr.c | 5 +- usr.sbin/ppp/main.c | 24 +-- usr.sbin/ppp/mbuf.c | 3 +- usr.sbin/ppp/mbuf.h | 5 +- usr.sbin/ppp/modem.c | 107 +++++------ usr.sbin/ppp/modem.h | 5 +- usr.sbin/ppp/mp.c | 457 ++++++++++++++++++++++++++++++++++++++++++++++ usr.sbin/ppp/mp.h | 62 +++++++ usr.sbin/ppp/pap.c | 15 +- usr.sbin/ppp/physical.c | 30 +-- usr.sbin/ppp/physical.h | 3 +- usr.sbin/ppp/prompt.c | 31 ++-- usr.sbin/ppp/route.c | 8 +- usr.sbin/ppp/server.c | 7 +- usr.sbin/ppp/slcompress.c | 8 +- usr.sbin/ppp/throughput.c | 6 +- usr.sbin/ppp/throughput.h | 4 +- usr.sbin/ppp/timer.c | 89 +++++---- usr.sbin/ppp/timer.h | 9 +- usr.sbin/ppp/tun.c | 6 +- usr.sbin/ppp/vars.c | 5 +- usr.sbin/ppp/vjcomp.c | 6 +- 50 files changed, 1193 insertions(+), 520 deletions(-) create mode 100644 usr.sbin/ppp/mp.c create mode 100644 usr.sbin/ppp/mp.h (limited to 'usr.sbin/ppp') diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile index 6e939d86ae05..32d649cea2b0 100644 --- a/usr.sbin/ppp/Makefile +++ b/usr.sbin/ppp/Makefile @@ -1,11 +1,11 @@ -# $Id: Makefile,v 1.36.2.6 1998/02/10 03:23:04 brian Exp $ +# $Id: Makefile,v 1.36.2.7 1998/02/15 23:59:34 brian Exp $ PROG= ppp -SRCS= arp.c async.c auth.c bundle.c ccp.c chap.c chat.c command.c deflate.c \ - datalink.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 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 +SRCS= arp.c async.c auth.c bundle.c ccp.c chap.c chat.c command.c \ + deflate.c datalink.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 CFLAGS+=-Wall -Wpointer-arith LDADD+= -lmd -lcrypt -lutil -lz DPADD+= ${LIBMD} ${LIBCRYPT} ${LIBUTIL} ${LIBZ} diff --git a/usr.sbin/ppp/arp.c b/usr.sbin/ppp/arp.c index 9a6d4a6093fa..a112730706e6 100644 --- a/usr.sbin/ppp/arp.c +++ b/usr.sbin/ppp/arp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: arp.c,v 1.27.2.8 1998/03/16 22:53:25 brian Exp $ + * $Id: arp.c,v 1.27.2.9 1998/03/20 19:47:38 brian Exp $ * */ @@ -62,6 +62,12 @@ #include "ipcp.h" #include "filter.h" #include "descriptor.h" +#include "lqr.h" +#include "hdlc.h" +#include "lcp.h" +#include "ccp.h" +#include "link.h" +#include "mp.h" #include "bundle.h" #include "arp.h" diff --git a/usr.sbin/ppp/async.c b/usr.sbin/ppp/async.c index 6b4a9d20f911..d835bdf02b3a 100644 --- a/usr.sbin/ppp/async.c +++ b/usr.sbin/ppp/async.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: async.c,v 1.15.2.7 1998/02/18 19:35:07 brian Exp $ + * $Id: async.c,v 1.15.2.8 1998/03/13 00:43:50 brian Exp $ * */ #include @@ -42,6 +42,7 @@ #include "vars.h" #include "async.h" #include "throughput.h" +#include "ccp.h" #include "link.h" #include "descriptor.h" #include "physical.h" diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index dd7d520d9e05..f68c88acd186 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.14 1998/03/16 22:51:43 brian Exp $ + * $Id: auth.c,v 1.27.2.15 1998/03/16 22:53:28 brian Exp $ * * TODO: * o Implement check against with registered IP addresses. @@ -51,12 +51,14 @@ #include "lqr.h" #include "hdlc.h" #include "async.h" +#include "ccp.h" #include "link.h" #include "descriptor.h" #include "physical.h" #include "chat.h" #include "lcpproto.h" #include "filter.h" +#include "mp.h" #include "bundle.h" const char * @@ -262,6 +264,7 @@ StartAuthChallenge(struct authinfo *authp, struct physical *physical, authp->physical = physical; StopTimer(&authp->authtimer); authp->authtimer.func = AuthTimeout; + authp->authtimer.name = "auth"; authp->authtimer.load = VarRetryTimeout * SECTICKS; authp->authtimer.state = TIMER_STOPPED; authp->authtimer.arg = (void *) authp; diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index 491ae10116c4..0fc733b780cc 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.32 1998/03/25 00:59:28 brian Exp $ + * $Id: bundle.c,v 1.1.2.33 1998/03/25 18:38:38 brian Exp $ */ #include @@ -58,10 +58,8 @@ #include "throughput.h" #include "slcompress.h" #include "ipcp.h" -#include "link.h" #include "filter.h" #include "descriptor.h" -#include "bundle.h" #include "loadalias.h" #include "vars.h" #include "arp.h" @@ -69,6 +67,9 @@ #include "route.h" #include "lcp.h" #include "ccp.h" +#include "link.h" +#include "mp.h" +#include "bundle.h" #include "async.h" #include "physical.h" #include "modem.h" @@ -176,10 +177,6 @@ static void bundle_LayerStart(void *v, struct fsm *fp) { /* The given FSM is about to start up ! */ - struct bundle *bundle = (struct bundle *)v; - - if (fp->proto == PROTO_LCP && bundle_Phase(bundle) == PHASE_DEAD) - bundle_NewPhase(bundle, PHASE_ESTABLISH); } @@ -195,27 +192,37 @@ bundle_Notify(struct bundle *bundle, char c) bundle->notify.fd = -1; } } + static void -bundle_LayerUp(void *v, struct fsm *fp) +bundle_vLayerUp(void *v, struct fsm *fp) +{ + bundle_LayerUp((struct bundle *)v, fp); +} + +void +bundle_LayerUp(struct bundle *bundle, struct fsm *fp) { /* * The given fsm is now up - * If it's a datalink, adjust our mtu enter network phase - * If it's the first NCP, start the idle timer. + * If it's an LCP (including MP initialisation), set our mtu + * (This routine is also called from mp_Init() with it's LCP) * If it's an NCP, tell our background mode parent to go away. + * If it's the first NCP, start the idle timer. */ - struct bundle *bundle = (struct bundle *)v; - if (fp->proto == PROTO_LCP) { - struct lcp *lcp = fsm2lcp(fp); - - /* XXX Should figure out what the optimum mru and speed are */ - tun_configure(bundle, lcp->his_mru, modem_Speed(link2physical(fp->link))); - bundle_NewPhase(bundle, PHASE_NETWORK); - } - - if (fp->proto == PROTO_IPCP) { + if (bundle->ncp.mp.active) { + int speed; + struct datalink *dl; + + for (dl = bundle->links, speed = 0; dl; dl = dl->next) + speed += modem_Speed(dl->physical); + if (speed) + tun_configure(bundle, bundle->ncp.mp.link.lcp.his_mru, speed); + } else + tun_configure(bundle, fsm2lcp(fp)->his_mru, + modem_Speed(link2physical(fp->link))); + } else if (fp->proto == PROTO_IPCP) { bundle_StartIdleTimer(bundle); bundle_Notify(bundle, EX_NORMAL); } @@ -227,12 +234,32 @@ bundle_LayerDown(void *v, struct fsm *fp) /* * The given FSM has been told to come down. * If it's our last NCP, stop the idle timer. + * If it's our last NCP *OR* LCP, enter TERMINATE phase. + * If it's an LCP and we're in multilink mode, adjust our tun speed. */ struct bundle *bundle = (struct bundle *)v; - if (fp->proto == PROTO_IPCP) + if (fp->proto == PROTO_IPCP) { bundle_StopIdleTimer(bundle); + bundle_NewPhase(bundle, PHASE_TERMINATE); + } else if (fp->proto == PROTO_LCP) { + int speed, others_active; + struct datalink *dl; + + others_active = 0; + for (dl = bundle->links, speed = 0; dl; dl = dl->next) + if (fp != &dl->physical->link.lcp.fsm && + dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) { + speed += modem_Speed(dl->physical); + others_active++; + } + if (bundle->ncp.mp.active && speed) + tun_configure(bundle, bundle->ncp.mp.link.lcp.his_mru, speed); + + if (!others_active) + bundle_NewPhase(bundle, PHASE_TERMINATE); + } } static void @@ -241,23 +268,31 @@ bundle_LayerFinish(void *v, struct fsm *fp) /* The given fsm is now down (fp cannot be NULL) * * If it's the last LCP, FsmDown all NCPs - * If it's the last NCP, FsmClose all LCPs and enter TERMINATE phase. + * If it's the last NCP, FsmClose all LCPs */ struct bundle *bundle = (struct bundle *)v; + struct datalink *dl; if (fp->proto == PROTO_IPCP) { - struct datalink *dl; - - bundle_NewPhase(bundle, PHASE_TERMINATE); + for (dl = bundle->links; dl; dl = dl->next) + datalink_Close(dl, 0); + FsmDown(fp); + FsmClose(fp); + } else if (fp->proto == PROTO_LCP) { + int others_active; + others_active = 0; for (dl = bundle->links; dl; dl = dl->next) - datalink_Close(dl, 1); - } + if (fp != &dl->physical->link.lcp.fsm && + dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) + others_active++; - /* when either the LCP or IPCP is down, drop IPCP */ - FsmDown(&bundle->ncp.ipcp.fsm); - FsmClose(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */ + if (!others_active) { + FsmDown(&bundle->ncp.ipcp.fsm); + FsmClose(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */ + } + } } int @@ -271,33 +306,52 @@ bundle_Close(struct bundle *bundle, const char *name, int staydown) { /* * Please close the given datalink. - * - * If name == NULL or name is the last datalink, enter TERMINATE phase. - * - * If name == NULL, FsmClose all NCPs. - * - * If name is the last datalink, FsmClose all NCPs. - * - * If isn't the last datalink, just Close that datalink. + * If name == NULL or name is the last datalink, enter TERMINATE phase + * and FsmClose all NCPs (except our MP) + * If it isn't the last datalink, just Close that datalink. */ - struct datalink *dl; + struct datalink *dl, *this_dl; + int others_active; - if (bundle->ncp.ipcp.fsm.state > ST_CLOSED || - bundle->ncp.ipcp.fsm.state == ST_STARTING) { - bundle_NewPhase(bundle, PHASE_TERMINATE); - FsmClose(&bundle->ncp.ipcp.fsm); - if (staydown) - for (dl = bundle->links; dl; dl = dl->next) + if (bundle->phase == PHASE_TERMINATE || bundle->phase == PHASE_DEAD) + return; + + others_active = 0; + this_dl = NULL; + + for (dl = bundle->links; dl; dl = dl->next) { + if (name && !strcasecmp(name, dl->name)) + this_dl = dl; + if (name == NULL || this_dl == dl) { + if (staydown) datalink_StayDown(dl); - } else { - if (bundle->ncp.ipcp.fsm.state > ST_INITIAL) { + } else if (dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) + others_active++; + } + + if (name && this_dl == NULL) { + LogPrintf(LogWARN, "%s: Invalid datalink name\n", name); + return; + } + + if (!others_active) { + if (bundle->ncp.ipcp.fsm.state > ST_CLOSED || + bundle->ncp.ipcp.fsm.state == ST_STARTING) FsmClose(&bundle->ncp.ipcp.fsm); - FsmDown(&bundle->ncp.ipcp.fsm); + else { + /* This shouldn't happen ! */ + LogPrintf(LogWARN, "Tidying up hung FSMs\n"); + if (bundle->ncp.ipcp.fsm.state > ST_INITIAL) { + FsmClose(&bundle->ncp.ipcp.fsm); + FsmDown(&bundle->ncp.ipcp.fsm); + } + for (dl = bundle->links; dl; dl = dl->next) + datalink_Close(dl, staydown); } - for (dl = bundle->links; dl; dl = dl->next) - datalink_Close(dl, staydown); - } + } else if (this_dl && this_dl->state != DATALINK_CLOSED && + this_dl->state != DATALINK_HANGUP) + datalink_Close(this_dl, staydown); } static int @@ -353,7 +407,7 @@ bundle_DescriptorWrite(struct descriptor *d, struct bundle *bundle, #define MAX_TUN 256 /* * MAX_TUN is set at 256 because that is the largest minor number - * we can use (certainly with mknod(1) anyway. The search for a + * we can use (certainly with mknod(1) anyway). The search for a * device aborts when it reaches the first `Device not configured' * (ENXIO) or the third `No such file or directory' (ENOENT) error. */ @@ -448,7 +502,7 @@ bundle_Create(const char *prefix) bundle.CleaningUp = 0; bundle.fsm.LayerStart = bundle_LayerStart; - bundle.fsm.LayerUp = bundle_LayerUp; + bundle.fsm.LayerUp = bundle_vLayerUp; bundle.fsm.LayerDown = bundle_LayerDown; bundle.fsm.LayerFinish = bundle_LayerFinish; bundle.fsm.object = &bundle; @@ -539,7 +593,6 @@ bundle_Destroy(struct bundle *bundle) dl = datalink_Destroy(dl); bundle_Notify(bundle, EX_ERRDEAD); - bundle->ifname = NULL; } @@ -684,23 +737,30 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl) /* * Our datalink has closed. * If it's DIRECT or BACKGROUND, delete it. - * If it's the last data link, + * If it's the last data link, enter phase DEAD. */ - if (mode & (MODE_BACKGROUND|MODE_DIRECT)) - bundle->CleaningUp = 1; + struct datalink *odl; + int other_links; - if (!(mode & MODE_AUTO)) - bundle_DownInterface(bundle); + if (mode & (MODE_DIRECT|MODE_BACKGROUND)) { + struct datalink **dlp; + for (dlp = &bundle->links; *dlp; dlp = &(*dlp)->next) + if (*dlp == dl) + *dlp = datalink_Destroy(*dlp); + } - if (mode & MODE_DDIAL) - datalink_Up(dl, 1, 1); - else - bundle_NewPhase(bundle, PHASE_DEAD); + other_links = 0; + for (odl = bundle->links; odl; odl = odl->next) + if (odl != dl && odl->state != DATALINK_CLOSED) + other_links++; - if (mode & MODE_INTER) + if (!other_links) { + if (!(mode & MODE_AUTO)) + bundle_DownInterface(bundle); + bundle_NewPhase(bundle, PHASE_DEAD); prompt_Display(&prompt, bundle); - + } } void @@ -719,8 +779,6 @@ bundle_Open(struct bundle *bundle, const char *name) if (name != NULL) break; } - if (bundle_Phase(bundle) == PHASE_DEAD) - bundle_NewPhase(bundle, PHASE_ESTABLISH); } struct datalink * @@ -745,24 +803,6 @@ bundle2physical(struct bundle *bundle, const char *name) return dl ? dl->physical : NULL; } -struct ccp * -bundle2ccp(struct bundle *bundle, const char *name) -{ - struct datalink *dl = bundle2datalink(bundle, name); - if (dl) - return &dl->ccp; - return NULL; -} - -struct lcp * -bundle2lcp(struct bundle *bundle, const char *name) -{ - struct datalink *dl = bundle2datalink(bundle, name); - if (dl) - return &dl->lcp; - return NULL; -} - struct authinfo * bundle2pap(struct bundle *bundle, const char *name) { @@ -781,31 +821,23 @@ bundle2chap(struct bundle *bundle, const char *name) return NULL; } -struct link * -bundle2link(struct bundle *bundle, const char *name) -{ - struct physical *physical = bundle2physical(bundle, name); - return physical ? &physical->link : NULL; -} - int bundle_FillQueues(struct bundle *bundle) { - struct datalink *dl; - int packets, total; + int total; - total = 0; - for (dl = bundle->links; dl; dl = dl->next) { - packets = link_QueueLen(&dl->physical->link); - if (packets == 0) { - IpStartOutput(&dl->physical->link, bundle); - packets = link_QueueLen(&dl->physical->link); - } - total += packets; + if (bundle->ncp.mp.active) { + total = mp_FillQueues(bundle); + } else { + struct datalink *dl; + + dl = bundle2datalink(bundle, NULL); + total = link_QueueLen(&dl->physical->link); + if (total == 0 && dl->physical->out == NULL) + total = IpFlushPacket(&dl->physical->link, bundle); } - total += ip_QueueLen(); - return total; + return total + ip_QueueLen(); } int @@ -843,6 +875,7 @@ bundle_StartIdleTimer(struct bundle *bundle) if (!(mode & (MODE_DEDICATED | MODE_DDIAL)) && bundle->cfg.idle_timeout) { StopTimer(&bundle->idle.timer); bundle->idle.timer.func = bundle_IdleTimeout; + bundle->idle.timer.name = "idle"; bundle->idle.timer.load = bundle->cfg.idle_timeout * SECTICKS; bundle->idle.timer.state = TIMER_STOPPED; bundle->idle.timer.arg = bundle; @@ -872,3 +905,9 @@ bundle_RemainingIdleTime(struct bundle *bundle) return bundle->idle.done - time(NULL); return -1; } + +int +bundle_IsDead(struct bundle *bundle) +{ + return !bundle->links || (bundle->phase == PHASE_DEAD && bundle->CleaningUp); +} diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h index 2dc3df0bc609..c63d528640a6 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.20 1998/03/20 19:47:42 brian Exp $ + * $Id: bundle.h,v 1.1.2.21 1998/03/25 18:38:40 brian Exp $ */ #define PHASE_DEAD 0 /* Link is dead */ @@ -58,6 +58,7 @@ struct bundle { struct { struct ipcp ipcp; /* Our IPCP FSM */ + struct mp mp; /* Our MP */ } ncp; struct { @@ -99,11 +100,10 @@ extern void bundle_StartIdleTimer(struct bundle *); extern void bundle_SetIdleTimer(struct bundle *, int); extern void bundle_StopIdleTimer(struct bundle *); extern int bundle_RemainingIdleTime(struct bundle *); +extern void bundle_LayerUp(struct bundle *, struct fsm *); +extern int bundle_IsDead(struct bundle *); -extern struct link *bundle2link(struct bundle *, const char *); extern struct physical *bundle2physical(struct bundle *, const char *); extern struct datalink *bundle2datalink(struct bundle *, const char *); extern struct authinfo *bundle2pap(struct bundle *, const char *); extern struct chap *bundle2chap(struct bundle *, const char *); -extern struct ccp *bundle2ccp(struct bundle *, const char *); -extern struct lcp *bundle2lcp(struct bundle *, const char *); diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index 00821d45c7a3..059071f4f5e5 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.27 1998/03/20 19:47:44 brian Exp $ + * $Id: ccp.c,v 1.30.2.28 1998/03/24 18:46:37 brian Exp $ * * TODO: * o Support other compression protocols @@ -51,14 +51,17 @@ #include "ipcp.h" #include "filter.h" #include "descriptor.h" -#include "bundle.h" #include "prompt.h" #include "lqr.h" #include "hdlc.h" #include "link.h" +#include "mp.h" +#include "bundle.h" #include "chat.h" #include "auth.h" #include "chap.h" +#include "async.h" +#include "physical.h" #include "datalink.h" static void CcpSendConfigReq(struct fsm *); @@ -132,7 +135,7 @@ static const struct ccp_algorithm *algorithm[] = { int ccp_ReportStatus(struct cmdargs const *arg) { - struct ccp *ccp = arg->cx ? &arg->cx->ccp : bundle2ccp(arg->bundle, NULL); + struct ccp *ccp = &ChooseLink(arg)->ccp; prompt_Printf(&prompt, "%s [%s]\n", ccp->fsm.name, State2Nam(ccp->fsm.state)); @@ -149,8 +152,11 @@ ccp_Init(struct ccp *ccp, struct bundle *bundle, struct link *l, const struct fsm_parent *parent) { /* Initialise ourselves */ - fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, CCP_MAXCODE, 10, LogCCP, - bundle, l, parent, &ccp_Callbacks); + static const char *timer_names[] = + {"CCP restart", "CCP openmode", "CCP stopped"}; + + fsm_Init(&ccp->fsm, "CCP", PROTO_CCP, 1, CCP_MAXCODE, 10, LogCCP, + bundle, l, parent, &ccp_Callbacks, timer_names); ccp->cfg.deflate.in.winsize = 0; ccp->cfg.deflate.out.winsize = 15; ccp_Setup(ccp); @@ -483,8 +489,8 @@ CcpRecvResetAck(struct fsm *fp, u_char id) } int -ccp_Output(struct ccp *ccp, struct link *l, int pri, u_short proto, - struct mbuf *m) +ccp_Compress(struct ccp *ccp, struct link *l, int pri, u_short proto, + struct mbuf *m) { /* Compress outgoing Network Layer data */ if ((proto & 0xfff1) == 0x21 && ccp->fsm.state == ST_OPENED && diff --git a/usr.sbin/ppp/ccp.h b/usr.sbin/ppp/ccp.h index 959a49594fd4..d0c534d74574 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.12 1998/02/27 01:22:19 brian Exp $ + * $Id: ccp.h,v 1.14.2.13 1998/03/17 22:29:03 brian Exp $ * * TODO: */ @@ -111,5 +111,5 @@ extern void ccp_Setup(struct ccp *); extern void CcpSendResetReq(struct fsm *); extern void CcpInput(struct ccp *, struct bundle *, struct mbuf *); extern int ccp_ReportStatus(struct cmdargs const *); -extern int ccp_Output(struct ccp *, struct link *, int, u_short, struct mbuf *); +extern int ccp_Compress(struct ccp *, struct link *, int, u_short, struct mbuf *); extern struct mbuf *ccp_Decompress(struct ccp *, u_short *, struct mbuf *); diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index 5ad3b8cc20a7..0b2b82517ab3 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.17 1998/03/16 22:51:52 brian Exp $ + * $Id: chap.c,v 1.28.2.18 1998/03/16 22:53:34 brian Exp $ * * TODO: */ @@ -60,15 +60,16 @@ #include "chap.h" #include "async.h" #include "throughput.h" -#include "link.h" #include "descriptor.h" -#include "physical.h" #include "iplist.h" #include "slcompress.h" #include "ipcp.h" #include "filter.h" -#include "bundle.h" #include "ccp.h" +#include "link.h" +#include "physical.h" +#include "mp.h" +#include "bundle.h" #include "chat.h" #include "datalink.h" @@ -242,7 +243,7 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp, ChapOutput(physical, CHAP_SUCCESS, chp->id, "Welcome!!", 10); Physical_Login(physical, name); - if (dl->lcp.auth_iwait == 0) + if (dl->physical->link.lcp.auth_iwait == 0) /* * Either I didn't need to authenticate, or I've already been * told that I got the answer right. @@ -272,9 +273,9 @@ RecvChapResult(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp, len = ntohs(chp->length); LogPrintf(LogDEBUG, "RecvChapResult: length: %d\n", len); if (chp->code == CHAP_SUCCESS) { - if (dl->lcp.auth_iwait == PROTO_CHAP) { - dl->lcp.auth_iwait = 0; - if (dl->lcp.auth_ineed == 0) + if (dl->physical->link.lcp.auth_iwait == PROTO_CHAP) { + dl->physical->link.lcp.auth_iwait = 0; + if (dl->physical->link.lcp.auth_ineed == 0) /* * We've succeeded in our ``login'' * If we're not expecting the peer to authenticate (or he already diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index de84a18e73c7..1bac06691329 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chat.c,v 1.44.2.16 1998/03/13 21:07:59 brian Exp $ + * $Id: chat.c,v 1.44.2.17 1998/03/20 19:47:47 brian Exp $ */ #include @@ -55,6 +55,7 @@ #include "throughput.h" #include "fsm.h" #include "lcp.h" +#include "ccp.h" #include "link.h" #include "async.h" #include "descriptor.h" @@ -84,6 +85,7 @@ chat_Pause(struct chat *c, u_long load) c->pause.state = TIMER_STOPPED; c->pause.load += load; c->pause.func = chat_PauseTimer; + c->pause.name = "chat pause"; c->pause.arg = c; StartTimer(&c->pause); } @@ -104,6 +106,7 @@ chat_SetTimeout(struct chat *c) if (c->TimeoutSec > 0) { c->timeout.load = SECTICKS * c->TimeoutSec; c->timeout.func = chat_TimeoutTimer; + c->timeout.name = "chat timeout"; c->timeout.arg = c; StartTimer(&c->timeout); } diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index c8606bfee7cb..a25e383b78cc 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.42 1998/03/20 19:47:51 brian Exp $ + * $Id: command.c,v 1.131.2.43 1998/03/24 18:46:43 brian Exp $ * */ #include @@ -67,7 +67,6 @@ #include "systems.h" #include "filter.h" #include "descriptor.h" -#include "bundle.h" #include "main.h" #include "route.h" #include "ccp.h" @@ -76,6 +75,8 @@ #include "async.h" #include "link.h" #include "physical.h" +#include "mp.h" +#include "bundle.h" #include "server.h" #include "prompt.h" #include "chat.h" @@ -88,7 +89,6 @@ static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); static int QuitCommand(struct cmdargs const *); static int CloseCommand(struct cmdargs const *); -static int DialCommand(struct cmdargs const *); static int DownCommand(struct cmdargs const *); static int AllowCommand(struct cmdargs const *); static int SetCommand(struct cmdargs const *); @@ -447,22 +447,29 @@ ShowTimeout(struct cmdargs const *arg) return 0; } +static int +ShowTimerList(struct cmdargs const *arg) +{ + ShowTimers(0); + return 0; +} + static int ShowStopped(struct cmdargs const *arg) { prompt_Printf(&prompt, " Stopped Timer: LCP: "); - if (!arg->cx->lcp.fsm.StoppedTimer.load) + if (!arg->cx->physical->link.lcp.fsm.StoppedTimer.load) prompt_Printf(&prompt, "Disabled"); else prompt_Printf(&prompt, "%ld secs", - arg->cx->lcp.fsm.StoppedTimer.load / SECTICKS); + arg->cx->physical->link.lcp.fsm.StoppedTimer.load / SECTICKS); prompt_Printf(&prompt, ", CCP: "); - if (!arg->cx->ccp.fsm.StoppedTimer.load) + if (!arg->cx->physical->link.ccp.fsm.StoppedTimer.load) prompt_Printf(&prompt, "Disabled"); else prompt_Printf(&prompt, "%ld secs", - arg->cx->ccp.fsm.StoppedTimer.load / SECTICKS); + arg->cx->physical->link.ccp.fsm.StoppedTimer.load / SECTICKS); prompt_Printf(&prompt, "\n"); @@ -504,6 +511,14 @@ ShowPreferredMTU(struct cmdargs const *arg) return 0; } +int +ShowProtocolStats(struct cmdargs const *arg) +{ + link_ReportProtocolStatus(ChooseLink(arg)); + return 0; +} + + static int ShowReconnect(struct cmdargs const *arg) { @@ -572,7 +587,7 @@ static struct cmdtab const ShowCommands[] = { "Show packet filters", "show filter [in|out|dial|alive]"}, {"ipcp", NULL, ReportIpcpStatus, LOCAL_AUTH, "Show IPCP status", "show ipcp"}, - {"lcp", NULL, lcp_ReportStatus, LOCAL_AUTH | LOCAL_CX, + {"lcp", NULL, lcp_ReportStatus, LOCAL_AUTH | LOCAL_CX_OPT, "Show LCP status", "show lcp"}, {"links", "link", bundle_ShowLinks, LOCAL_AUTH, "Show available link names", "show links"}, @@ -592,7 +607,7 @@ static struct cmdtab const ShowCommands[] = { #endif {"mtu", NULL, ShowPreferredMTU, LOCAL_AUTH, "Show Preferred MTU", "show mtu"}, - {"proto", NULL, Physical_ReportProtocolStatus, LOCAL_AUTH, + {"proto", NULL, ShowProtocolStats, LOCAL_AUTH | LOCAL_CX_OPT, "Show protocol summary", "show proto"}, {"reconnect", NULL, ShowReconnect, LOCAL_AUTH | LOCAL_CX, "Show reconnect timer", "show reconnect"}, @@ -602,6 +617,8 @@ static struct cmdtab const ShowCommands[] = { "Show routing table", "show route"}, {"timeout", NULL, ShowTimeout, LOCAL_AUTH, "Show Idle timeout", "show timeout"}, + {"timers", NULL, ShowTimerList, LOCAL_AUTH, + "Show alarm timers", "show timers"}, {"stopped", NULL, ShowStopped, LOCAL_AUTH | LOCAL_CX, "Show STOPPED timeout", "show stopped"}, {"version", NULL, ShowVersion, LOCAL_NO_AUTH | LOCAL_AUTH, @@ -781,9 +798,9 @@ ShowCommand(struct cmdargs const *arg) static int TerminalCommand(struct cmdargs const *arg) { - if (arg->cx->lcp.fsm.state > ST_CLOSED) { + if (arg->cx->physical->link.lcp.fsm.state > ST_CLOSED) { prompt_Printf(&prompt, "LCP state is [%s]\n", - State2Nam(arg->cx->lcp.fsm.state)); + State2Nam(arg->cx->physical->link.lcp.fsm.state)); return 1; } @@ -821,7 +838,7 @@ CloseCommand(struct cmdargs const *arg) static int DownCommand(struct cmdargs const *arg) { - link_Close(&arg->cx->physical->link, arg->bundle, 0, 1); + datalink_Down(arg->cx, 1); return 0; } @@ -925,13 +942,15 @@ SetRedialTimeout(struct cmdargs const *arg) static int SetStoppedTimeout(struct cmdargs const *arg) { - arg->cx->lcp.fsm.StoppedTimer.load = 0; - arg->cx->ccp.fsm.StoppedTimer.load = 0; + struct link *l = &arg->cx->physical->link; + + l->lcp.fsm.StoppedTimer.load = 0; + l->ccp.fsm.StoppedTimer.load = 0; if (arg->argc <= 2) { if (arg->argc > 0) { - arg->cx->lcp.fsm.StoppedTimer.load = atoi(arg->argv[0]) * SECTICKS; + l->lcp.fsm.StoppedTimer.load = atoi(arg->argv[0]) * SECTICKS; if (arg->argc > 1) - arg->cx->ccp.fsm.StoppedTimer.load = atoi(arg->argv[1]) * SECTICKS; + l->ccp.fsm.StoppedTimer.load = atoi(arg->argv[1]) * SECTICKS; } return 0; } @@ -1316,23 +1335,25 @@ SetVariable(struct cmdargs const *arg) break; case VAR_WINSIZE: if (arg->argc > 0) { - cx->ccp.cfg.deflate.out.winsize = atoi(arg->argv[0]); - if (cx->ccp.cfg.deflate.out.winsize < 8 || - cx->ccp.cfg.deflate.out.winsize > 15) { + struct link *l = ChooseLink(arg); + + l->ccp.cfg.deflate.out.winsize = atoi(arg->argv[0]); + if (l->ccp.cfg.deflate.out.winsize < 8 || + l->ccp.cfg.deflate.out.winsize > 15) { LogPrintf(LogWARN, "%d: Invalid outgoing window size\n", - cx->ccp.cfg.deflate.out.winsize); - cx->ccp.cfg.deflate.out.winsize = 15; + l->ccp.cfg.deflate.out.winsize); + l->ccp.cfg.deflate.out.winsize = 15; } if (arg->argc > 1) { - cx->ccp.cfg.deflate.in.winsize = atoi(arg->argv[1]); - if (cx->ccp.cfg.deflate.in.winsize < 8 || - cx->ccp.cfg.deflate.in.winsize > 15) { + l->ccp.cfg.deflate.in.winsize = atoi(arg->argv[1]); + if (l->ccp.cfg.deflate.in.winsize < 8 || + l->ccp.cfg.deflate.in.winsize > 15) { LogPrintf(LogWARN, "%d: Invalid incoming window size\n", - cx->ccp.cfg.deflate.in.winsize); - cx->ccp.cfg.deflate.in.winsize = 15; + l->ccp.cfg.deflate.in.winsize); + l->ccp.cfg.deflate.in.winsize = 15; } } else - cx->ccp.cfg.deflate.in.winsize = 0; + l->ccp.cfg.deflate.in.winsize = 0; } break; case VAR_DEVICE: @@ -1406,7 +1427,7 @@ static struct cmdtab const SetCommands[] = { "Set authentication name", "set authname name", (const void *) VAR_AUTHNAME}, {"ctsrts", NULL, SetCtsRts, LOCAL_AUTH | LOCAL_CX, "Use CTS/RTS modem signalling", "set ctsrts [on|off]"}, - {"deflate", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, + {"deflate", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, "Set deflate window sizes", "set deflate out-winsize in-winsize", (const void *) VAR_WINSIZE}, {"device", "line", SetVariable, LOCAL_AUTH | LOCAL_CX, @@ -1462,6 +1483,8 @@ static struct cmdtab const SetCommands[] = { "Set Idle timeout", "set timeout idle LQR FSM-resend"}, {"vj", NULL, SetInitVJ, LOCAL_AUTH, "Set vj values", "set vj slots|slotcomp"}, + {"weight", NULL, mp_SetDatalinkWeight, LOCAL_AUTH | LOCAL_CX, + "Set datalink weighting", "set weight n"}, {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, "Display this message", "set help|? [command]", SetCommands}, {NULL, NULL, NULL}, @@ -1679,3 +1702,16 @@ LinkCommand(struct cmdargs const *arg) return 0; } + +struct link * +ChooseLink(struct cmdargs const *arg) +{ + if (arg->cx) + return &arg->cx->physical->link; + else if (arg->bundle->ncp.mp.active) + return &arg->bundle->ncp.mp.link; + else { + struct physical *p = bundle2physical(arg->bundle, NULL); + return p ? &p->link : NULL; + } +} diff --git a/usr.sbin/ppp/command.h b/usr.sbin/ppp/command.h index 10626c5b41cb..ea6acb30f60e 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.4 1998/02/17 19:27:54 brian Exp $ + * $Id: command.h,v 1.12.2.5 1998/03/17 22:29:07 brian Exp $ * * TODO: */ @@ -61,3 +61,4 @@ extern int IsInteractive(int); extern void InterpretCommand(char *, int, int *, char ***); extern void RunCommand(struct bundle *, int, char const *const *, const char *); extern void DecodeCommand(struct bundle *, char *, int, const char *); +extern struct link *ChooseLink(struct cmdargs const *); diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index 120fe169b6a7..89c9a7386254 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.27 1998/03/20 19:47:54 brian Exp $ + * $Id: datalink.c,v 1.1.2.28 1998/03/25 00:59:33 brian Exp $ */ #include @@ -51,15 +51,16 @@ #include "hdlc.h" #include "async.h" #include "throughput.h" +#include "ccp.h" #include "link.h" #include "physical.h" #include "iplist.h" #include "slcompress.h" #include "ipcp.h" #include "filter.h" +#include "mp.h" #include "bundle.h" #include "chat.h" -#include "ccp.h" #include "auth.h" #include "main.h" #include "modem.h" @@ -93,6 +94,7 @@ datalink_StartDialTimer(struct datalink *dl, int Timeout) else dl->dial_timer.load = (random() % DIAL_TIMEOUT) * SECTICKS; dl->dial_timer.func = datalink_OpenTimeout; + dl->dial_timer.name = "dial"; dl->dial_timer.arg = dl; StartTimer(&dl->dial_timer); if (dl->state == DATALINK_OPENING) @@ -107,13 +109,17 @@ datalink_HangupDone(struct datalink *dl) modem_Close(dl->physical); dl->phone.chosen = "[N/A]"; - if (!dl->dial_tries || (dl->dial_tries < 0 && !dl->reconnect_tries)) { + if (dl->bundle->CleaningUp || + (mode & MODE_DIRECT) || + ((!dl->dial_tries || (dl->dial_tries < 0 && !dl->reconnect_tries)) && + !(mode & (MODE_DDIAL|MODE_DEDICATED)))) { LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name); dl->state = DATALINK_CLOSED; dl->dial_tries = -1; dl->reconnect_tries = 0; bundle_LinkClosed(dl->bundle, dl); - datalink_StartDialTimer(dl, dl->cfg.dial_timeout); + if (!dl->bundle->CleaningUp) + datalink_StartDialTimer(dl, dl->cfg.dial_timeout); } else { LogPrintf(LogPHASE, "%s: Re-entering OPENING state\n", dl->name); dl->state = DATALINK_OPENING; @@ -170,13 +176,17 @@ datalink_LoginDone(struct datalink *dl) } else { dl->dial_tries = -1; - lcp_Setup(&dl->lcp, dl->state == DATALINK_READY ? 0 : VarOpenMode); - ccp_Setup(&dl->ccp); + hdlc_Init(&dl->physical->hdlc); + async_Init(&dl->physical->async); + + lcp_Setup(&dl->physical->link.lcp, + dl->state == DATALINK_READY ? 0 : VarOpenMode); + ccp_Setup(&dl->physical->link.ccp); LogPrintf(LogPHASE, "%s: Entering LCP state\n", dl->name); dl->state = DATALINK_LCP; - FsmUp(&dl->lcp.fsm); - FsmOpen(&dl->lcp.fsm); + FsmUp(&dl->physical->link.lcp.fsm); + FsmOpen(&dl->physical->link.lcp.fsm); } } @@ -215,14 +225,17 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, else LogPrintf(LogCHAT, "Failed to open modem\n"); - if (!(mode & MODE_DDIAL) && dl->cfg.max_dial && dl->dial_tries == 0) { + if (dl->bundle->CleaningUp || + (!(mode & (MODE_DDIAL|MODE_DEDICATED)) && + dl->cfg.max_dial && dl->dial_tries == 0)) { LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name); dl->state = DATALINK_CLOSED; dl->reconnect_tries = 0; dl->dial_tries = -1; bundle_LinkClosed(dl->bundle, dl); } - datalink_StartDialTimer(dl, dl->cfg.dial_timeout); + if (!dl->bundle->CleaningUp) + datalink_StartDialTimer(dl, dl->cfg.dial_timeout); } } break; @@ -387,17 +400,17 @@ datalink_LayerUp(void *v, struct fsm *fp) struct datalink *dl = (struct datalink *)v; if (fp->proto == PROTO_LCP) { - dl->lcp.auth_ineed = dl->lcp.want_auth; - dl->lcp.auth_iwait = dl->lcp.his_auth; - if (dl->lcp.his_auth || dl->lcp.want_auth) { - if (bundle_Phase(dl->bundle) == PHASE_DEAD || - bundle_Phase(dl->bundle) == PHASE_ESTABLISH) + dl->physical->link.lcp.auth_ineed = dl->physical->link.lcp.want_auth; + dl->physical->link.lcp.auth_iwait = dl->physical->link.lcp.his_auth; + if (dl->physical->link.lcp.his_auth || dl->physical->link.lcp.want_auth) { + if (bundle_Phase(dl->bundle) == PHASE_ESTABLISH) bundle_NewPhase(dl->bundle, PHASE_AUTHENTICATE); LogPrintf(LogPHASE, "%s: his = %s, mine = %s\n", dl->name, - Auth2Nam(dl->lcp.his_auth), Auth2Nam(dl->lcp.want_auth)); - if (dl->lcp.his_auth == PROTO_PAP) + Auth2Nam(dl->physical->link.lcp.his_auth), + Auth2Nam(dl->physical->link.lcp.want_auth)); + if (dl->physical->link.lcp.his_auth == PROTO_PAP) StartAuthChallenge(&dl->pap, dl->physical, SendPapChallenge); - if (dl->lcp.want_auth == PROTO_CHAP) + if (dl->physical->link.lcp.want_auth == PROTO_CHAP) StartAuthChallenge(&dl->chap.auth, dl->physical, SendChapChallenge); } else datalink_AuthOk(dl); @@ -407,17 +420,20 @@ datalink_LayerUp(void *v, struct fsm *fp) void datalink_AuthOk(struct datalink *dl) { - FsmUp(&dl->ccp.fsm); - FsmOpen(&dl->ccp.fsm); + /* XXX: Connect to another ppp instance HERE */ + + FsmUp(&dl->physical->link.ccp.fsm); + FsmOpen(&dl->physical->link.ccp.fsm); dl->state = DATALINK_OPEN; - (*dl->parent->LayerUp)(dl->parent->object, &dl->lcp.fsm); + bundle_NewPhase(dl->bundle, PHASE_NETWORK); + (*dl->parent->LayerUp)(dl->parent->object, &dl->physical->link.lcp.fsm); } void datalink_AuthNotOk(struct datalink *dl) { dl->state = DATALINK_LCP; - FsmClose(&dl->lcp.fsm); + FsmClose(&dl->physical->link.lcp.fsm); } static void @@ -429,8 +445,8 @@ datalink_LayerDown(void *v, struct fsm *fp) if (fp->proto == PROTO_LCP) { switch (dl->state) { case DATALINK_OPEN: - FsmDown(&dl->ccp.fsm); - FsmClose(&dl->ccp.fsm); + FsmDown(&dl->physical->link.ccp.fsm); + FsmClose(&dl->physical->link.ccp.fsm); (*dl->parent->LayerDown)(dl->parent->object, fp); /* fall through */ @@ -484,6 +500,7 @@ datalink_Create(const char *name, struct bundle *bundle, dl->phone.chosen = "N/A"; dl->script.run = 1; dl->script.packetmode = 1; + mp_linkInit(&dl->mp); dl->bundle = bundle; dl->next = NULL; @@ -500,26 +517,23 @@ datalink_Create(const char *name, struct bundle *bundle, dl->cfg.reconnect_timeout = RECONNECT_TIMEOUT; dl->name = strdup(name); - if ((dl->physical = modem_Create(dl->name, dl)) == NULL) { + dl->parent = parent; + dl->fsmp.LayerStart = datalink_LayerStart; + dl->fsmp.LayerUp = datalink_LayerUp; + dl->fsmp.LayerDown = datalink_LayerDown; + dl->fsmp.LayerFinish = datalink_LayerFinish; + dl->fsmp.object = dl; + + authinfo_Init(&dl->pap); + authinfo_Init(&dl->chap.auth); + + if ((dl->physical = modem_Create(dl)) == NULL) { free(dl->name); free(dl); return NULL; } chat_Init(&dl->chat, dl->physical, NULL, 1, NULL); - dl->parent = parent; - dl->fsm.LayerStart = datalink_LayerStart; - dl->fsm.LayerUp = datalink_LayerUp; - dl->fsm.LayerDown = datalink_LayerDown; - dl->fsm.LayerFinish = datalink_LayerFinish; - dl->fsm.object = dl; - - lcp_Init(&dl->lcp, dl->bundle, dl->physical, &dl->fsm); - ccp_Init(&dl->ccp, dl->bundle, &dl->physical->link, &dl->fsm); - - authinfo_Init(&dl->pap); - authinfo_Init(&dl->chap.auth); - LogPrintf(LogPHASE, "%s: Created in CLOSED state\n", dl->name); return dl; @@ -536,7 +550,7 @@ datalink_Destroy(struct datalink *dl) result = dl->next; chat_Destroy(&dl->chat); - link_Destroy(&dl->physical->link); + modem_Destroy(dl->physical); free(dl->name); free(dl); @@ -549,6 +563,9 @@ datalink_Up(struct datalink *dl, int runscripts, int packetmode) switch (dl->state) { case DATALINK_CLOSED: LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name); + if (bundle_Phase(dl->bundle) == PHASE_DEAD || + bundle_Phase(dl->bundle) == PHASE_TERMINATE) + bundle_NewPhase(dl->bundle, PHASE_ESTABLISH); dl->state = DATALINK_OPENING; dl->reconnect_tries = dl->cfg.max_reconnect; dl->dial_tries = dl->cfg.max_dial; @@ -579,13 +596,13 @@ datalink_Close(struct datalink *dl, int stay) /* Please close */ switch (dl->state) { case DATALINK_OPEN: - FsmDown(&dl->ccp.fsm); - FsmClose(&dl->ccp.fsm); + FsmDown(&dl->physical->link.ccp.fsm); + FsmClose(&dl->physical->link.ccp.fsm); /* fall through */ case DATALINK_AUTH: case DATALINK_LCP: - FsmClose(&dl->lcp.fsm); + FsmClose(&dl->physical->link.lcp.fsm); if (stay) { dl->dial_tries = -1; dl->reconnect_tries = 0; @@ -603,17 +620,17 @@ datalink_Down(struct datalink *dl, int stay) /* Carrier is lost */ switch (dl->state) { case DATALINK_OPEN: - FsmDown(&dl->ccp.fsm); - FsmClose(&dl->ccp.fsm); + FsmDown(&dl->physical->link.ccp.fsm); + FsmClose(&dl->physical->link.ccp.fsm); /* fall through */ case DATALINK_AUTH: case DATALINK_LCP: - FsmDown(&dl->lcp.fsm); + FsmDown(&dl->physical->link.lcp.fsm); if (stay) - FsmClose(&dl->lcp.fsm); + FsmClose(&dl->physical->link.lcp.fsm); else - FsmOpen(&dl->ccp.fsm); + FsmOpen(&dl->physical->link.ccp.fsm); /* fall through */ default: diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h index 2c3dee395e60..a677a7c975d9 100644 --- a/usr.sbin/ppp/datalink.h +++ b/usr.sbin/ppp/datalink.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.h,v 1.1.2.11 1998/03/09 19:24:56 brian Exp $ + * $Id: datalink.h,v 1.1.2.12 1998/03/13 21:07:03 brian Exp $ */ #define DATALINK_CLOSED (0) @@ -78,14 +78,14 @@ struct datalink { char *name; /* Our name */ - struct fsm_parent fsm; /* Our callback functions */ + struct fsm_parent fsmp; /* Our callback functions */ const struct fsm_parent *parent; /* Our parent */ - struct lcp lcp; /* Our line control FSM */ - struct ccp ccp; /* Our compression FSM */ struct authinfo pap; /* Authentication using pap */ struct chap chap; /* Authentication using chap */ + struct mp_link mp; /* multilink data */ + struct bundle *bundle; /* for the moment */ struct datalink *next; /* Next in the list */ }; diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h index ffa9a84148a1..5f2161d21251 100644 --- a/usr.sbin/ppp/defs.h +++ b/usr.sbin/ppp/defs.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: defs.h,v 1.29.2.6 1998/03/09 19:26:37 brian Exp $ + * $Id: defs.h,v 1.29.2.7 1998/03/25 18:38:49 brian Exp $ * * TODO: */ @@ -42,6 +42,8 @@ #define MAXARGS 40 /* How many args per config line */ #define NCP_IDLE_TIMEOUT 180 /* Drop all links */ +#define LINK_MINWEIGHT 20 + #define CONFFILE "ppp.conf" #define LINKUPFILE "ppp.linkup" #define LINKDOWNFILE "ppp.linkdown" diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c index ae2021372c86..e90d136b2706 100644 --- a/usr.sbin/ppp/filter.c +++ b/usr.sbin/ppp/filter.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: filter.c,v 1.22.2.8 1998/03/16 22:52:04 brian Exp $ + * $Id: filter.c,v 1.22.2.9 1998/03/16 22:53:42 brian Exp $ * * TODO: Shoud send ICMP error message when we discard packets. */ @@ -45,13 +45,16 @@ #include "throughput.h" #include "lqr.h" #include "hdlc.h" -#include "link.h" #include "fsm.h" +#include "lcp.h" +#include "ccp.h" +#include "link.h" #include "slcompress.h" #include "ipcp.h" #include "filter.h" #include "descriptor.h" #include "prompt.h" +#include "mp.h" #include "bundle.h" static const u_long netmasks[33] = { diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 38c1e8a77368..4963a27cb3f3 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.c,v 1.27.2.23 1998/03/20 19:46:43 brian Exp $ + * $Id: fsm.c,v 1.27.2.24 1998/03/24 18:46:55 brian Exp $ * * TODO: * o Refer loglevel for log output @@ -55,6 +55,7 @@ #include "slcompress.h" #include "ipcp.h" #include "filter.h" +#include "mp.h" #include "bundle.h" #include "auth.h" #include "chat.h" @@ -128,19 +129,24 @@ StoppedTimeout(void *v) fp->name); StopTimer(&fp->OpenTimer); } - if (link_IsActive(fp->link)) - link_Close(fp->link, fp->bundle, 0, 1); + if (fp->state == ST_STOPPED) { + /* Force ourselves back to initial */ + FsmDown(fp); + FsmClose(fp); + } } void -fsm_Init(struct fsm *fp, const char *name, u_short proto, int maxcode, - int maxcfg, int LogLevel, struct bundle *bundle, struct link *l, - const struct fsm_parent *parent, struct fsm_callbacks *fn) +fsm_Init(struct fsm *fp, const char *name, u_short proto, int mincode, + int maxcode, int maxcfg, int LogLevel, struct bundle *bundle, + struct link *l, const struct fsm_parent *parent, + struct fsm_callbacks *fn, const char *timer_names[3]) { fp->name = name; fp->proto = proto; + fp->min_code = mincode; fp->max_code = maxcode; - fp->state = ST_INITIAL; + fp->state = fp->min_code > CODE_TERMACK ? ST_OPENED : ST_INITIAL; fp->reqid = 1; fp->restart = 1; fp->maxconfig = maxcfg; @@ -152,6 +158,9 @@ fsm_Init(struct fsm *fp, const char *name, u_short proto, int maxcode, fp->bundle = bundle; fp->parent = parent; fp->fn = fn; + fp->FsmTimer.name = timer_names[0]; + fp->OpenTimer.name = timer_names[1]; + fp->StoppedTimer.name = timer_names[2]; } static void @@ -763,7 +772,7 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) break; case PROTO_CCP: if (fp->proto == PROTO_LCP) { - fp = &lcp2ccp(fsm2lcp(fp))->fsm; + fp = &fp->link->ccp.fsm; (*fp->fn->LayerFinish)(fp); switch (fp->state) { case ST_CLOSED: @@ -879,9 +888,15 @@ FsmInput(struct fsm *fp, struct mbuf *bp) return; } lhp = (struct fsmheader *) MBUF_CTOP(bp); - if (lhp->code == 0 || lhp->code > fp->max_code || + if (lhp->code < fp->min_code || lhp->code > fp->max_code || lhp->code > sizeof FsmCodes / sizeof *FsmCodes) { - pfree(bp); /* XXX: Should send code reject */ + /* + * Use a private id. This is really a response-type packet, but we + * MUST send a unique id for each REQ.... + */ + static u_char id; + FsmOutput(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt); + pfree(bp); return; } bp->offset += sizeof(struct fsmheader); diff --git a/usr.sbin/ppp/fsm.h b/usr.sbin/ppp/fsm.h index 1c4b27254068..00d5c17bb39f 100644 --- a/usr.sbin/ppp/fsm.h +++ b/usr.sbin/ppp/fsm.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: fsm.h,v 1.16.2.11 1998/03/20 19:46:46 brian Exp $ + * $Id: fsm.h,v 1.16.2.12 1998/03/24 18:46:59 brian Exp $ * * TODO: */ @@ -79,12 +79,13 @@ struct fsm_parent { struct fsm { const char *name; /* Name of protocol */ u_short proto; /* Protocol number */ + u_short min_code; u_short max_code; int open_mode; /* Delay before config REQ (-1 forever) */ int state; /* State of the machine */ u_char reqid; /* Next request id */ int restart; /* Restart counter value */ - int maxconfig; /* Max config REQ (overridden in Init funcs) */ + int maxconfig; /* Max config REQ before a close() */ struct pppTimer FsmTimer; /* Restart Timer */ struct pppTimer OpenTimer; /* Delay before opening */ @@ -139,9 +140,9 @@ struct fsmconfig { u_char length; }; -extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int, +extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int, int, struct bundle *, struct link *, const struct fsm_parent *, - struct fsm_callbacks *); + struct fsm_callbacks *, const char *[3]); extern void FsmOutput(struct fsm *, u_int, u_int, u_char *, int); extern void FsmOpen(struct fsm *); extern void FsmUp(struct fsm *); diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c index 283e3906e8f2..22cf99f6a814 100644 --- a/usr.sbin/ppp/hdlc.c +++ b/usr.sbin/ppp/hdlc.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.c,v 1.28.2.20 1998/03/16 22:52:15 brian Exp $ + * $Id: hdlc.c,v 1.28.2.21 1998/03/16 22:53:50 brian Exp $ * * TODO: */ @@ -59,6 +59,7 @@ #include "physical.h" #include "prompt.h" #include "chat.h" +#include "mp.h" #include "datalink.h" #include "filter.h" #include "bundle.h" @@ -164,7 +165,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp) mhp = mballoc(4, MB_HDLCOUT); mhp->cnt = 0; cp = MBUF_CTOP(mhp); - if (proto == PROTO_LCP || p->dl->lcp.his_acfcomp == 0) { + if (proto == PROTO_LCP || p->link.lcp.his_acfcomp == 0) { *cp++ = HDLC_ADDR; *cp++ = HDLC_UI; mhp->cnt += 2; @@ -173,7 +174,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp) /* * If possible, compress protocol field. */ - if (p->dl->lcp.his_protocomp && (proto & 0xff00) == 0) { + if (p->link.lcp.his_protocomp && (proto & 0xff00) == 0) { *cp++ = proto; mhp->cnt++; } else { @@ -196,7 +197,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp) /* Overwrite the entire packet */ struct lqrdata lqr; - lqr.MagicNumber = p->dl->lcp.want_magic; + lqr.MagicNumber = p->link.lcp.want_magic; lqr.LastOutLQRs = p->hdlc.lqm.lqr.peer.PeerOutLQRs; lqr.LastOutPackets = p->hdlc.lqm.lqr.peer.PeerOutPackets; lqr.LastOutOctets = p->hdlc.lqm.lqr.peer.PeerOutOctets; @@ -368,23 +369,22 @@ hdlc_Protocol2Nam(u_short proto) return "unrecognised protocol"; } -static void -DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp, - struct link *l) +void +hdlc_DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp, + struct link *l) { struct physical *p = link2physical(l); - struct datalink *dl = bundle2datalink(bundle, l->name); u_char *cp; LogPrintf(LogDEBUG, "DecodePacket: proto = 0x%04x\n", proto); /* decompress everything. CCP needs uncompressed data too */ - if ((bp = ccp_Decompress(&dl->ccp, &proto, bp)) == NULL) + if ((bp = ccp_Decompress(&l->ccp, &proto, bp)) == NULL) return; switch (proto) { case PROTO_LCP: - LcpInput(&dl->lcp, bp); + LcpInput(&l->lcp, bp); break; case PROTO_PAP: if (p) @@ -424,19 +424,31 @@ DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp, IpcpInput(&bundle->ncp.ipcp, bp); break; case PROTO_CCP: - CcpInput(&dl->ccp, bundle, bp); + CcpInput(&l->ccp, bundle, bp); break; + case PROTO_MP: + if (bundle->ncp.mp.active) { + if (p) + mp_Input(&bundle->ncp.mp, bp, p); + else { + LogPrintf(LogERROR, "DecodePacket: MP inside MP ?!\n"); + pfree(bp); + } + break; + } + /* Fall through */ default: - LogPrintf(LogPHASE, "Unknown protocol 0x%04x (%s)\n", + LogPrintf(LogPHASE, "%s protocol 0x%04x (%s)\n", + proto == PROTO_MP ? "Unexpected" : "Unknown", proto, hdlc_Protocol2Nam(proto)); bp->offset -= 2; bp->cnt += 2; cp = MBUF_CTOP(bp); - if (p) - lcp_SendProtoRej(&dl->lcp, cp, bp->cnt); - /* XXX: Eeek - how to we proto-reject something at the bundle level ? */ - p->hdlc.lqm.SaveInDiscards++; - p->hdlc.stats.unknownproto++; + lcp_SendProtoRej(&l->lcp, cp, bp->cnt); + if (p) { + p->hdlc.lqm.SaveInDiscards++; + p->hdlc.stats.unknownproto++; + } pfree(bp); break; } @@ -473,7 +485,7 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical) } cp = MBUF_CTOP(bp); - if (!physical->dl->lcp.want_acfcomp) { + if (!physical->link.lcp.want_acfcomp) { /* * We expect that packet is not compressed. */ @@ -505,7 +517,7 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical) bp->offset += 2; bp->cnt -= 2; } - if (physical->dl->lcp.want_protocomp) { + if (physical->link.lcp.want_protocomp) { proto = 0; cp--; do { @@ -525,7 +537,7 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical) link_ProtocolRecord(physical2link(physical), proto, PROTO_IN); physical->hdlc.lqm.SaveInPackets++; - DecodePacket(bundle, proto, bp, physical2link(physical)); + hdlc_DecodePacket(bundle, proto, bp, physical2link(physical)); } /* @@ -604,6 +616,7 @@ hdlc_StartTimer(struct hdlc *hdlc) hdlc->ReportTimer.load = 60 * SECTICKS; hdlc->ReportTimer.arg = hdlc; hdlc->ReportTimer.func = hdlc_ReportTime; + hdlc->ReportTimer.name = "hdlc"; StartTimer(&hdlc->ReportTimer); } diff --git a/usr.sbin/ppp/hdlc.h b/usr.sbin/ppp/hdlc.h index 11b5ef2156fd..82e23514aa82 100644 --- a/usr.sbin/ppp/hdlc.h +++ b/usr.sbin/ppp/hdlc.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.h,v 1.14.2.6 1998/02/18 19:35:45 brian Exp $ + * $Id: hdlc.h,v 1.14.2.7 1998/03/13 00:44:04 brian Exp $ * * TODO: */ @@ -109,3 +109,5 @@ extern void HdlcOutput(struct link *, int, u_short, struct mbuf *bp); extern u_short HdlcFcs(u_short, u_char *, int); extern int ReportProtStatus(struct cmdargs const *); extern u_char *HdlcDetect(struct physical *, u_char *, int); +extern void hdlc_DecodePacket(struct bundle *, u_short, struct mbuf *, + struct link *); diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index 61d7142a2432..a5e889c497f5 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.38.2.15 1998/03/20 19:48:02 brian Exp $ + * $Id: ip.c,v 1.38.2.16 1998/03/24 18:47:04 brian Exp $ * * TODO: * o Return ICMP message for filterd packet @@ -63,9 +63,12 @@ #include "ipcp.h" #include "filter.h" #include "descriptor.h" +#include "lcp.h" +#include "ccp.h" +#include "link.h" +#include "mp.h" #include "bundle.h" #include "vjcomp.h" -#include "lcp.h" #include "modem.h" #include "tun.h" #include "ip.h" @@ -451,15 +454,15 @@ ip_QueueLen() return result; } -void -IpStartOutput(struct link *l, struct bundle *bundle) +int +IpFlushPacket(struct link *l, struct bundle *bundle) { struct mqueue *queue; struct mbuf *bp; int cnt; if (bundle->ncp.ipcp.fsm.state != ST_OPENED) - return; + return 0; for (queue = &IpOutputQueues[PRI_FAST]; queue >= IpOutputQueues; queue--) if (queue->top) { @@ -472,8 +475,9 @@ IpStartOutput(struct link *l, struct bundle *bundle) if (!(FilterCheck(pip, &bundle->filter.alive) & A_DENY)) bundle_StartIdleTimer(bundle); ipcp_AddOutOctets(&bundle->ncp.ipcp, cnt); - break; + return 1; } } + return 0; } diff --git a/usr.sbin/ppp/ip.h b/usr.sbin/ppp/ip.h index 706d52505fde..353aa533357e 100644 --- a/usr.sbin/ppp/ip.h +++ b/usr.sbin/ppp/ip.h @@ -17,13 +17,13 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.h,v 1.8.2.5 1998/03/09 19:26:38 brian Exp $ + * $Id: ip.h,v 1.8.2.6 1998/03/16 22:52:18 brian Exp $ * */ struct filter; -extern void IpStartOutput(struct link *, struct bundle *); +extern int IpFlushPacket(struct link *, struct bundle *); extern int PacketCheck(struct bundle *, char *, int, struct filter *); extern void IpEnqueue(int, char *, int); extern void IpInput(struct bundle *, struct mbuf *); diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index 59237b0de504..8213e407aa9b 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.26 1998/03/20 19:48:04 brian Exp $ + * $Id: ipcp.c,v 1.50.2.27 1998/03/24 18:47:10 brian Exp $ * * TODO: * o More RFC1772 backwoard compatibility @@ -54,7 +54,6 @@ #include "ipcp.h" #include "filter.h" #include "descriptor.h" -#include "bundle.h" #include "loadalias.h" #include "vars.h" #include "vjcomp.h" @@ -63,8 +62,11 @@ #include "lqr.h" #include "hdlc.h" #include "async.h" +#include "ccp.h" #include "link.h" #include "physical.h" +#include "mp.h" +#include "bundle.h" #include "id.h" #include "arp.h" #include "systems.h" @@ -209,9 +211,11 @@ ipcp_Init(struct ipcp *ipcp, struct bundle *bundle, struct link *l, { struct hostent *hp; char name[MAXHOSTNAMELEN]; + static const char *timer_names[] = + {"IPCP restart", "IPCP openmode", "IPCP stopped"}; - fsm_Init(&ipcp->fsm, "IPCP", PROTO_IPCP, IPCP_MAXCODE, 10, LogIPCP, - bundle, l, parent, &ipcp_Callbacks); + 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; @@ -561,7 +565,7 @@ IpcpLayerUp(struct fsm *fp) } else SelectSystem(fp->bundle, "MYADDR", LINKUPFILE); - throughput_start(&ipcp->throughput); + throughput_start(&ipcp->throughput, "IPCP throughput"); prompt_Display(&prompt, fp->bundle); } diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 5bd36ba0f2e4..b421f037d6c9 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.32 1998/03/20 19:48:06 brian Exp $ + * $Id: lcp.c,v 1.55.2.33 1998/03/24 18:47:17 brian Exp $ * * TODO: * o Limit data field length by MRU @@ -56,7 +56,6 @@ #include "lcpproto.h" #include "filter.h" #include "descriptor.h" -#include "bundle.h" #include "lqr.h" #include "hdlc.h" #include "ccp.h" @@ -72,6 +71,8 @@ #include "tun.h" #include "link.h" #include "physical.h" +#include "mp.h" +#include "bundle.h" #include "prompt.h" #include "chat.h" #include "datalink.h" @@ -142,20 +143,22 @@ static const char *cftypes[] = { int lcp_ReportStatus(struct cmdargs const *arg) { - prompt_Printf(&prompt, "%s [%s]\n", arg->cx->lcp.fsm.name, - State2Nam(arg->cx->lcp.fsm.state)); + struct lcp *lcp = &ChooseLink(arg)->lcp; + + prompt_Printf(&prompt, "%s [%s]\n", lcp->fsm.name, + State2Nam(lcp->fsm.state)); prompt_Printf(&prompt, " his side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n" " MAGIC %08lx, REJECT %04x\n", - arg->cx->lcp.his_mru, (u_long)arg->cx->lcp.his_accmap, - arg->cx->lcp.his_protocomp, arg->cx->lcp.his_acfcomp, - (u_long)arg->cx->lcp.his_magic, arg->cx->lcp.his_reject); + lcp->his_mru, (u_long)lcp->his_accmap, + lcp->his_protocomp, lcp->his_acfcomp, + (u_long)lcp->his_magic, lcp->his_reject); prompt_Printf(&prompt, " my side: MRU %d, ACCMAP %08lx, PROTOCOMP %d, ACFCOMP %d,\n" " MAGIC %08lx, REJECT %04x\n", - arg->cx->lcp.want_mru, (u_long)arg->cx->lcp.want_accmap, - arg->cx->lcp.want_protocomp, arg->cx->lcp.want_acfcomp, - (u_long)arg->cx->lcp.want_magic, arg->cx->lcp.my_reject); + lcp->want_mru, (u_long)lcp->want_accmap, + lcp->want_protocomp, lcp->want_acfcomp, + (u_long)lcp->want_magic, lcp->my_reject); prompt_Printf(&prompt, "\nDefaults: MRU = %d, ACCMAP = %08lx\t", VarMRU, (u_long)VarAccmap); prompt_Printf(&prompt, "Open Mode: %s", @@ -175,26 +178,25 @@ GenerateMagic(void) } void -lcp_Init(struct lcp *lcp, struct bundle *bundle, struct physical *physical, +lcp_Init(struct lcp *lcp, struct bundle *bundle, struct link *l, const struct fsm_parent *parent) { /* Initialise ourselves */ - fsm_Init(&lcp->fsm, "LCP", PROTO_LCP, LCP_MAXCODE, 10, LogLCP, bundle, - &physical->link, parent, &lcp_Callbacks); + int mincode = parent ? 1 : LCP_MINMPCODE; + static const char *timer_names[] = + {"LCP restart", "LCP openmode", "LCP stopped"}; + + fsm_Init(&lcp->fsm, "LCP", PROTO_LCP, mincode, LCP_MAXCODE, 10, LogLCP, + bundle, l, parent, &lcp_Callbacks, timer_names); lcp_Setup(lcp, 1); } void lcp_Setup(struct lcp *lcp, int openmode) { - struct physical *p = link2physical(lcp->fsm.link); - lcp->fsm.open_mode = openmode; lcp->fsm.maxconfig = 10; - hdlc_Init(&p->hdlc); - async_Init(&p->async); - lcp->his_mru = DEF_MRU; lcp->his_accmap = 0xffffffff; lcp->his_magic = 0; @@ -214,6 +216,7 @@ lcp_Setup(struct lcp *lcp, int openmode) lcp->his_reject = lcp->my_reject = 0; lcp->auth_iwait = lcp->auth_ineed = 0; + lcp->LcpFailedMagic = 0; } static void @@ -333,13 +336,9 @@ LcpLayerUp(struct fsm *fp) struct lcp *lcp = fsm2lcp(fp); LogPrintf(LogLCP, "LcpLayerUp\n"); - - if (p) { - async_SetLinkParams(&p->async, lcp); - StartLqm(lcp); - hdlc_StartTimer(&p->hdlc); - } else - LogPrintf(LogERROR, "LcpLayerUp: Not a physical link !\n"); + async_SetLinkParams(&p->async, lcp); + StartLqm(lcp); + hdlc_StartTimer(&p->hdlc); } static void diff --git a/usr.sbin/ppp/lcp.h b/usr.sbin/ppp/lcp.h index c7e5a38e7844..81206e54fce4 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.14 1998/03/13 21:07:07 brian Exp $ + * $Id: lcp.h,v 1.16.2.15 1998/03/20 19:46:58 brian Exp $ * * TODO: */ @@ -50,6 +50,7 @@ struct lcp { }; #define LCP_MAXCODE CODE_DISCREQ +#define LCP_MINMPCODE CODE_CODEREJ #define TY_MRU 1 /* Maximum-Receive-Unit */ #define TY_ACCMAP 2 /* Async-Control-Character-Map */ @@ -79,9 +80,8 @@ struct lcp_opt { struct physical; #define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL) -#define lcp2ccp(lcp) (&link2physical((lcp)->fsm.link)->dl->ccp) -extern void lcp_Init(struct lcp *, struct bundle *, struct physical *, +extern void lcp_Init(struct lcp *, struct bundle *, struct link *, const struct fsm_parent *); extern void lcp_Setup(struct lcp *, int); diff --git a/usr.sbin/ppp/lcpproto.h b/usr.sbin/ppp/lcpproto.h index 74c5d4d51577..276d8a126826 100644 --- a/usr.sbin/ppp/lcpproto.h +++ b/usr.sbin/ppp/lcpproto.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcpproto.h,v 1.9 1997/10/26 01:02:59 brian Exp $ + * $Id: lcpproto.h,v 1.10 1997/10/26 12:42:12 brian Exp $ * * TODO: */ @@ -26,6 +26,7 @@ #define PROTO_IP 0x0021 /* IP */ #define PROTO_VJUNCOMP 0x002f /* VJ Uncompressed */ #define PROTO_VJCOMP 0x002d /* VJ Compressed */ +#define PROTO_MP 0x003d /* Multilink fragment */ #define PROTO_ICOMPD 0x00fb /* Individual link compressed */ #define PROTO_COMPD 0x00fd /* Compressed datagram */ diff --git a/usr.sbin/ppp/link.c b/usr.sbin/ppp/link.c index c2511f565487..14b61812ad8c 100644 --- a/usr.sbin/ppp/link.c +++ b/usr.sbin/ppp/link.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: link.c,v 1.1.2.13 1998/03/16 22:54:05 brian Exp $ + * $Id: link.c,v 1.1.2.14 1998/03/20 19:48:08 brian Exp $ * */ @@ -46,13 +46,17 @@ #include "lcpproto.h" #include "loadalias.h" #include "vars.h" -#include "link.h" #include "fsm.h" #include "iplist.h" #include "slcompress.h" #include "ipcp.h" #include "filter.h" #include "descriptor.h" +#include "async.h" +#include "lcp.h" +#include "ccp.h" +#include "link.h" +#include "mp.h" #include "bundle.h" #include "prompt.h" @@ -87,6 +91,25 @@ link_QueueLen(struct link *l) return len; } +int +link_QueueBytes(struct link *l) +{ + int i, len, bytes; + struct mbuf *m; + + bytes = 0; + for (i = 0, len = 0; i < LINK_QUEUES; i++) { + len = l->Queue[i].qlen; + m = l->Queue[i].top; + while (len--) { + bytes += plength(m); + m = m->pnext; + } + } + + return bytes; +} + struct mbuf * link_Dequeue(struct link *l) { @@ -122,12 +145,6 @@ link_Write(struct link *l, int pri, const char *ptr, int count) Enqueue(l->Queue + pri, bp); } -void -link_StartOutput(struct link *l, struct bundle *bundle) -{ - (*l->StartOutput)(l, bundle); -} - void link_Output(struct link *l, int pri, struct mbuf *bp) { @@ -143,25 +160,6 @@ link_Output(struct link *l, int pri, struct mbuf *bp) Enqueue(l->Queue + pri, wp); } -int -link_IsActive(struct link *l) -{ - return (*l->IsActive)(l); -} - -void -link_Close(struct link *l, struct bundle *bundle, int dedicated_force, int stay) -{ - (*l->Close)(l, dedicated_force); - bundle_LinkLost(bundle, l, stay); -} - -void -link_Destroy(struct link *l) -{ - (*l->Destroy)(l); -} - static struct protostatheader { u_short number; const char *name; @@ -176,6 +174,7 @@ static struct protostatheader { { PROTO_PAP, "PAP" }, { PROTO_LQR, "LQR" }, { PROTO_CHAP, "CHAP" }, + { PROTO_MP, "MULTILINK" }, { 0, "Others" } }; @@ -207,6 +206,6 @@ link_ReportProtocolStatus(struct link *l) if ((i % 2) == 0) prompt_Printf(&prompt, "\n"); } - if (i % 2) + if (!(i % 2)) prompt_Printf(&prompt, "\n"); } diff --git a/usr.sbin/ppp/link.h b/usr.sbin/ppp/link.h index d6962969f40f..b5328b70fd79 100644 --- a/usr.sbin/ppp/link.h +++ b/usr.sbin/ppp/link.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: link.h,v 1.1.2.5 1998/02/21 01:45:18 brian Exp $ + * $Id: link.h,v 1.1.2.6 1998/02/23 00:38:34 brian Exp $ * */ @@ -32,7 +32,7 @@ #define MP_LINK 2 #define LINK_QUEUES (PRI_MAX + 1) -#define NPROTOSTAT 11 +#define NPROTOSTAT 12 struct bundle; @@ -47,11 +47,8 @@ struct link { u_long proto_in[NPROTOSTAT]; /* outgoing protocol stats */ u_long proto_out[NPROTOSTAT]; /* incoming protocol stats */ - /* Implementation routines for use by link_ routines */ - void (*StartOutput)(struct link *, struct bundle *); /* send queued data */ - int (*IsActive)(struct link *); /* Are we active ? */ - void (*Close)(struct link *, int); /* Close the link */ - void (*Destroy)(struct link *); /* Destructor */ + struct lcp lcp; /* Our line control FSM */ + struct ccp ccp; /* Our compression FSM */ }; extern void link_AddInOctets(struct link *, int); @@ -59,6 +56,7 @@ extern void link_AddOutOctets(struct link *, int); extern void link_SequenceQueue(struct link *); extern int link_QueueLen(struct link *); +extern int link_QueueBytes(struct link *); extern struct mbuf *link_Dequeue(struct link *); extern void link_Write(struct link *, int, const char *, int); extern void link_StartOutput(struct link *, struct bundle *); @@ -68,7 +66,3 @@ extern void link_Output(struct link *, int, struct mbuf *); #define PROTO_OUT 2 extern void link_ProtocolRecord(struct link *, u_short, int); extern void link_ReportProtocolStatus(struct link *); - -extern int link_IsActive(struct link *); -extern void link_Close(struct link *, struct bundle *, int, int); -extern void link_Destroy(struct link *); diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index 6a628f3a87d1..a6b1e2bfaf6c 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.16 1998/03/20 19:47:30 brian Exp $ + * $Id: lqr.c,v 1.22.2.17 1998/03/25 18:37:51 brian Exp $ * * o LQR based on RFC1333 * @@ -47,6 +47,7 @@ #include "hdlc.h" #include "async.h" #include "throughput.h" +#include "ccp.h" #include "link.h" #include "descriptor.h" #include "physical.h" @@ -54,6 +55,7 @@ #include "slcompress.h" #include "ipcp.h" #include "filter.h" +#include "mp.h" #include "bundle.h" #include "loadalias.h" #include "vars.h" @@ -235,6 +237,7 @@ StartLqm(struct lcp *lcp) physical->hdlc.lqm.timer.state = TIMER_STOPPED; physical->hdlc.lqm.timer.load = lcp->want_lqrperiod * SECTICKS / 100; physical->hdlc.lqm.timer.func = SendLqrReport; + physical->hdlc.lqm.timer.name = "lqm"; physical->hdlc.lqm.timer.arg = lcp; SendLqrReport(lcp); } else { diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 241d3351065b..43da9ffe8067 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.38 1998/03/25 18:38:24 brian Exp $ + * $Id: main.c,v 1.121.2.39 1998/03/25 18:38:59 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -64,6 +64,8 @@ #include "ipcp.h" #include "filter.h" #include "descriptor.h" +#include "link.h" +#include "mp.h" #include "bundle.h" #include "loadalias.h" #include "vars.h" @@ -77,7 +79,6 @@ #include "pathnames.h" #include "tun.h" #include "route.h" -#include "link.h" #include "physical.h" #include "server.h" #include "prompt.h" @@ -104,7 +105,7 @@ Cleanup(int excode) { SignalBundle->CleaningUp = 1; if (bundle_Phase(SignalBundle) != PHASE_DEAD) - bundle_Close(SignalBundle, NULL, 0); + bundle_Close(SignalBundle, NULL, 1); } void @@ -125,10 +126,12 @@ static void CloseConnection(int signo) { /* NOTE, these are manual, we've done a setsid() */ + struct datalink *dl; + pending_signal(SIGINT, SIG_IGN); - LogPrintf(LogPHASE, "Caught signal %d, abort connection\n", signo); - /* XXX close 'em all ! */ - link_Close(bundle2link(SignalBundle, NULL), SignalBundle, 0, 1); + LogPrintf(LogPHASE, "Caught signal %d, abort connection(s)\n", signo); + for (dl = SignalBundle->links; dl; dl = dl->next) + datalink_Down(dl, 1); pending_signal(SIGINT, CloseConnection); } @@ -366,11 +369,9 @@ main(int argc, char **argv) pending_signal(SIGTERM, CloseSession); pending_signal(SIGINT, CloseConnection); pending_signal(SIGQUIT, CloseSession); + pending_signal(SIGALRM, SIG_IGN); #ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); -#endif -#ifdef SIGALRM - pending_signal(SIGALRM, SIG_IGN); #endif if (mode & MODE_INTER) { #ifdef SIGTSTP @@ -514,7 +515,7 @@ DoLoop(struct bundle *bundle) if (mode & (MODE_DIRECT|MODE_DEDICATED|MODE_BACKGROUND)) bundle_Open(bundle, NULL); - while (!bundle->CleaningUp || bundle_Phase(SignalBundle) != PHASE_DEAD) { + while (!bundle_IsDead(bundle)) { nfds = 0; FD_ZERO(&rfds); FD_ZERO(&wfds); @@ -536,7 +537,7 @@ DoLoop(struct bundle *bundle) descriptor_UpdateSet(&prompt.desc, &rfds, &wfds, &efds, &nfds); - if (bundle->CleaningUp && bundle_Phase(bundle) == PHASE_DEAD) + if (bundle_IsDead(bundle)) /* Don't select - we'll be here forever */ break; @@ -630,5 +631,6 @@ DoLoop(struct bundle *bundle) } } } + prompt_Printf(&prompt, "\n"); LogPrintf(LogDEBUG, "Job (DoLoop) done.\n"); } diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c index b16c14082761..28c111046fb7 100644 --- a/usr.sbin/ppp/mbuf.c +++ b/usr.sbin/ppp/mbuf.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.c,v 1.13.2.4 1998/02/10 03:23:33 brian Exp $ + * $Id: mbuf.c,v 1.13.2.5 1998/02/16 00:00:42 brian Exp $ * */ #include @@ -154,6 +154,7 @@ mbwrite(struct mbuf * bp, u_char * ptr, int cnt) int ShowMemMap(struct cmdargs const *arg) { + /* Watch it - ~m calls us with arg == NULL */ int i; for (i = 0; i <= MB_MAX; i += 2) diff --git a/usr.sbin/ppp/mbuf.h b/usr.sbin/ppp/mbuf.h index 121190f44656..3c99454c1686 100644 --- a/usr.sbin/ppp/mbuf.h +++ b/usr.sbin/ppp/mbuf.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.h,v 1.11 1998/01/21 02:15:21 brian Exp $ + * $Id: mbuf.h,v 1.11.2.1 1998/01/30 19:45:55 brian Exp $ * * TODO: */ @@ -48,7 +48,8 @@ struct mqueue { #define MB_VJCOMP 8 #define MB_LOG 9 #define MB_IPQ 10 -#define MB_MAX MB_IPQ +#define MB_MP 11 +#define MB_MAX MB_MP extern int plength(struct mbuf *); extern struct mbuf *mballoc(int, int); diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 0bce7b833110..cbdadca0b081 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.40 1998/03/20 19:48:14 brian Exp $ + * $Id: modem.c,v 1.77.2.41 1998/03/21 22:58:43 brian Exp $ * * TODO: */ @@ -66,12 +66,13 @@ #include "ipcp.h" #include "filter.h" #include "descriptor.h" -#include "bundle.h" +#include "ccp.h" #include "link.h" #include "physical.h" +#include "mp.h" +#include "bundle.h" #include "prompt.h" #include "chat.h" -#include "ccp.h" #include "auth.h" #include "chap.h" #include "datalink.h" @@ -83,17 +84,16 @@ #endif #endif -static void modem_StartOutput(struct link *, struct bundle *); -static int modem_IsActive(struct link *); -static void modem_Hangup(struct link *, int); -static void modem_Destroy(struct link *); +static void modem_Hangup(struct physical *, int); +static void modem_DescriptorWrite(struct descriptor *, struct bundle *, + const fd_set *); static void modem_DescriptorRead(struct descriptor *, struct bundle *, const fd_set *); static int modem_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *, int *); struct physical * -modem_Create(const char *name, struct datalink *dl) +modem_Create(struct datalink *dl) { struct physical *p; @@ -102,23 +102,19 @@ modem_Create(const char *name, struct datalink *dl) return NULL; p->link.type = PHYSICAL_LINK; - p->link.name = strdup(name); + p->link.name = dl->name; p->link.len = sizeof *p; - memset(&p->link.throughput, '\0', sizeof p->link.throughput); + throughput_init(&p->link.throughput); memset(&p->link.Timer, '\0', sizeof p->link.Timer); memset(p->link.Queue, '\0', sizeof p->link.Queue); memset(p->link.proto_in, '\0', sizeof p->link.proto_in); memset(p->link.proto_out, '\0', sizeof p->link.proto_out); - p->link.StartOutput = modem_StartOutput; - p->link.IsActive = modem_IsActive; - p->link.Close = modem_Hangup; - p->link.Destroy = modem_Destroy; p->desc.type = PHYSICAL_DESCRIPTOR; p->desc.UpdateSet = modem_UpdateSet; p->desc.IsSet = Physical_IsSet; p->desc.Read = modem_DescriptorRead; - p->desc.Write = Physical_DescriptorWrite; + p->desc.Write = modem_DescriptorWrite; hdlc_Init(&p->hdlc); async_Init(&p->async); @@ -143,6 +139,12 @@ modem_Create(const char *name, struct datalink *dl) strncpy(p->cfg.devlist, MODEM_LIST, sizeof p->cfg.devlist - 1); p->cfg.devlist[sizeof p->cfg.devlist - 1] = '\0'; + hdlc_Init(&p->hdlc); + async_Init(&p->async); + + lcp_Init(&p->link.lcp, dl->bundle, &p->link, &dl->fsmp); + ccp_Init(&p->link.ccp, dl->bundle, &p->link, &dl->fsmp); + return p; } @@ -291,7 +293,8 @@ modem_Timeout(void *data) if (to->modem->fd >= 0) { if (ioctl(to->modem->fd, TIOCMGET, &to->modem->mbits) < 0) { LogPrintf(LogPHASE, "ioctl error (%s)!\n", strerror(errno)); - link_Close(&to->modem->link, to->bundle, 0, 0); + modem_Hangup(to->modem, 0); + bundle_LinkLost(to->bundle, &to->modem->link, 0); return; } } else @@ -306,7 +309,8 @@ modem_Timeout(void *data) */ } else { LogPrintf(LogDEBUG, "modem_Timeout: online -> offline\n"); - link_Close(&to->modem->link, to->bundle, 0, 0); + modem_Hangup(to->modem, 0); + bundle_LinkLost(to->bundle, &to->modem->link, 0); } } else @@ -332,6 +336,7 @@ modem_StartTimer(struct bundle *bundle, struct physical *modem) ModemTimer->state = TIMER_STOPPED; ModemTimer->load = SECTICKS; ModemTimer->func = modem_Timeout; + ModemTimer->name = "modem CD"; ModemTimer->arg = &to; LogPrintf(LogDEBUG, "ModemTimer using modem_Timeout() - %p\n", modem_Timeout); StartTimer(ModemTimer); @@ -492,7 +497,7 @@ modem_Unlock(struct physical *modem) static void modem_Found(struct physical *modem) { - throughput_start(&modem->link.throughput); + throughput_start(&modem->link.throughput, "modem throughput"); modem->connect_count++; LogPrintf(LogPHASE, "Connected!\n"); } @@ -764,10 +769,9 @@ modem_PhysicalClose(struct physical *modem) static int force_hack; static void -modem_Hangup(struct link *l, int dedicated_force) +modem_Hangup(struct physical *modem, int dedicated_force) { /* We're about to close (pre hangup script) */ - struct physical *modem = (struct physical *)l; force_hack = dedicated_force; if (modem->fd >= 0) { @@ -801,14 +805,13 @@ modem_Offline(struct physical *modem) void modem_Close(struct physical *modem) { - LogPrintf(LogDEBUG, "Close modem (%s)\n", - modem->fd >= 0 ? "open" : "closed"); - if (modem->fd < 0) return; + LogPrintf(LogDEBUG, "Close modem\n"); + if (modem->link.Timer.load) - modem_Hangup(&modem->link, force_hack); + modem_Hangup(modem, force_hack); if (!isatty(modem->fd)) { modem_PhysicalClose(modem); @@ -837,16 +840,11 @@ modem_Close(struct physical *modem) } } -static void -modem_Destroy(struct link *l) +void +modem_Destroy(struct physical *modem) { - struct physical *p; - - p = link2physical(l); - if (p->fd != -1) - modem_Close(p); - free(l->name); - free(p); + modem_Close(modem); + free(modem); } static void @@ -861,48 +859,36 @@ modem_LogicalClose(struct physical *modem) } static void -modem_StartOutput(struct link *l, struct bundle *bundle) +modem_DescriptorWrite(struct descriptor *d, struct bundle *bundle, + const fd_set *fdset) { - struct physical *modem = (struct physical *)l; + struct physical *modem = descriptor2physical(d); int nb, nw; - if (modem->out == NULL) { - if (link_QueueLen(l) == 0) - IpStartOutput(l, bundle); - - modem->out = link_Dequeue(l); - } + if (modem->out == NULL) + modem->out = link_Dequeue(&modem->link); if (modem->out) { nb = modem->out->cnt; nw = write(modem->fd, MBUF_CTOP(modem->out), nb); - LogPrintf(LogDEBUG, "modem_StartOutput: wrote: %d(%d) to %d\n", + LogPrintf(LogDEBUG, "modem_DescriptorWrite: wrote: %d(%d) to %d\n", nw, nb, modem->fd); if (nw > 0) { - LogDumpBuff(LogDEBUG, "modem_StartOutput: modem write", - MBUF_CTOP(modem->out), nw); modem->out->cnt -= nw; modem->out->offset += nw; - if (modem->out->cnt == 0) { + if (modem->out->cnt == 0) modem->out = mbfree(modem->out); - LogPrintf(LogDEBUG, "modem_StartOutput: mbfree\n"); - } } else if (nw < 0) { if (errno != EAGAIN) { LogPrintf(LogERROR, "modem write (%d): %s\n", modem->fd, strerror(errno)); - link_Close(&modem->link, bundle, 0, 0); + modem_Hangup(modem, 0); + bundle_LinkLost(bundle, &modem->link, 0); } } } } -static int -modem_IsActive(struct link *l) -{ - return ((struct physical *)l)->fd >= 0; -} - int modem_ShowStatus(struct cmdargs const *arg) { @@ -990,19 +976,18 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle, u_char rbuff[MAX_MRU], *cp; int n; - LogPrintf(LogDEBUG, "descriptor2physical; %p -> %p\n", d, p); - /* something to read from modem */ - if (p->dl->lcp.fsm.state <= ST_CLOSED) + if (p->link.lcp.fsm.state <= ST_CLOSED) nointr_usleep(10000); n = Physical_Read(p, rbuff, sizeof rbuff); - if ((mode & MODE_DIRECT) && n <= 0) - link_Close(&p->link, bundle, 0, 1); - else + if ((mode & MODE_DIRECT) && n <= 0) { + modem_Hangup(p, 0); + bundle_LinkLost(bundle, &p->link, 1); + } else LogDumpBuff(LogASYNC, "ReadFromModem", rbuff, n); - if (p->dl->lcp.fsm.state <= ST_CLOSED) { + if (p->link.lcp.fsm.state <= ST_CLOSED) { /* In dedicated mode, we just discard input until LCP is started */ if (!(mode & MODE_DEDICATED)) { cp = HdlcDetect(p, rbuff, n); diff --git a/usr.sbin/ppp/modem.h b/usr.sbin/ppp/modem.h index effda204f48f..b4334356c160 100644 --- a/usr.sbin/ppp/modem.h +++ b/usr.sbin/ppp/modem.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.h,v 1.16.2.11 1998/03/06 00:34:44 brian Exp $ + * $Id: modem.h,v 1.16.2.12 1998/03/13 00:44:49 brian Exp $ * * TODO: */ @@ -25,7 +25,7 @@ struct physical; struct ccp; extern int modem_Raw(struct physical *, struct bundle *); -extern struct physical *modem_Create(const char *, struct datalink *); +extern struct physical *modem_Create(struct datalink *); extern int modem_Open(struct physical *, struct bundle *); extern int modem_Speed(struct physical *); extern speed_t IntToSpeed(int); @@ -33,3 +33,4 @@ extern int modem_SetParity(struct physical *, const char *); extern int modem_ShowStatus(struct cmdargs const *); extern void modem_Close(struct physical *); extern void modem_Offline(struct physical *); +extern void modem_Destroy(struct physical *); diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c new file mode 100644 index 000000000000..29f494f9c219 --- /dev/null +++ b/usr.sbin/ppp/mp.c @@ -0,0 +1,457 @@ +/*- + * Copyright (c) 1998 Brian Somers + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "command.h" +#include "mbuf.h" +#include "log.h" +#include "defs.h" +#include "timer.h" +#include "fsm.h" +#include "iplist.h" +#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" +#include "async.h" +#include "ccp.h" +#include "link.h" +#include "descriptor.h" +#include "physical.h" +#include "chat.h" +#include "lcpproto.h" +#include "filter.h" +#include "mp.h" +#include "pap.h" +#include "chap.h" +#include "datalink.h" +#include "bundle.h" +#include "ip.h" + +static u_int32_t +inc_seq(struct mp *mp, u_int32_t seq) +{ + seq++; + if (mp->is12bit) { + if (seq & 0xfffff000) + seq = 0; + } else if (seq & 0xff000000) + seq = 0; + return seq; +} + +static int +mp_ReadHeader(struct mp *mp, struct mbuf *m, struct mp_header *header) +{ + if (mp->is12bit) { + header->seq = *(u_int16_t *)MBUF_CTOP(m); + if (header->seq & 0x3000) { + LogPrintf(LogWARN, "Oops - MP header without required zero bits\n"); + return 0; + } + header->begin = header->seq & 0x8000; + header->end = header->seq & 0x4000; + header->seq &= 0x0fff; + return 2; + } else { + header->seq = *(u_int32_t *)MBUF_CTOP(m); + if (header->seq & 0x3f000000) { + LogPrintf(LogWARN, "Oops - MP header without required zero bits\n"); + return 0; + } + header->begin = header->seq & 0x80000000; + header->end = header->seq & 0x40000000; + header->seq &= 0x00ffffff; + return 4; + } +} + +static void +mp_LayerStart(void *v, struct fsm *fp) +{ + /* The given FSM is about to start up ! */ +} + +static void +mp_LayerUp(void *v, struct fsm *fp) +{ + /* The given fsm is now up */ +} + +static void +mp_LayerDown(void *v, struct fsm *fp) +{ + /* The given FSM has been told to come down */ +} + +static void +mp_LayerFinish(void *v, struct fsm *fp) +{ + /* The given fsm is now down */ +} + +void +mp_Init(struct mp *mp, struct bundle *bundle) +{ + mp->is12bit = 0; + mp->seq.out = 0; + mp->seq.min_in = 0; + mp->seq.next_in = 0; + mp->inbufs = NULL; + mp->bundle = bundle; + + mp->link.type = MP_LINK; + mp->link.name = "mp"; + mp->link.len = sizeof *mp; + throughput_init(&mp->link.throughput); + memset(&mp->link.Timer, '\0', sizeof mp->link.Timer); + memset(mp->link.Queue, '\0', sizeof mp->link.Queue); + memset(mp->link.proto_in, '\0', sizeof mp->link.proto_in); + memset(mp->link.proto_out, '\0', sizeof mp->link.proto_out); + + mp->fsmp.LayerStart = mp_LayerStart; + mp->fsmp.LayerUp = mp_LayerUp; + mp->fsmp.LayerDown = mp_LayerDown; + mp->fsmp.LayerFinish = mp_LayerFinish; + mp->fsmp.object = mp; + + lcp_Init(&mp->link.lcp, mp->bundle, &mp->link, NULL); + ccp_Init(&mp->link.ccp, mp->bundle, &mp->link, &mp->fsmp); + + /* Our lcp's already up 'cos of the NULL parent */ + FsmUp(&mp->link.ccp.fsm); + FsmOpen(&mp->link.ccp.fsm); + + mp->active = 1; + + bundle_LayerUp(mp->bundle, &mp->link.lcp.fsm); +} + +void +mp_linkInit(struct mp_link *mplink) +{ + mplink->seq = 0; + mplink->weight = 1500; +} + +void +mp_Input(struct mp *mp, struct mbuf *m, struct physical *p) +{ + struct mp_header mh, h; + struct mbuf *q, *last; + int32_t seq; + int len; + + if ((len = mp_ReadHeader(mp, m, &mh)) == 0) { + pfree(m); + return; + } + + seq = p->dl->mp.seq; + p->dl->mp.seq = mh.seq; + if (mp->seq.min_in == seq) { + /* + * We've received new data on the link that has our min (oldest) seq. + * Figure out which link now has the smallest (oldest) seq. + */ + struct datalink *dl; + + mp->seq.min_in = p->dl->mp.seq; + for (dl = mp->bundle->links; dl; dl = dl->next) + if (mp->seq.min_in > dl->mp.seq) + mp->seq.min_in = dl->mp.seq; + } + + /* + * Now process as many of our fragments as we can, adding our new + * fragment in as we go, and ordering with the oldest at the top of + * the queue. + */ + + if (!mp->inbufs) { + mp->inbufs = m; + m = NULL; + } + + last = NULL; + seq = mp->seq.next_in; + q = mp->inbufs; + while (q) { + mp_ReadHeader(mp, q, &h); + if (m && h.seq > mh.seq) { + /* Our received fragment fits in before this one, so link it in */ + if (last) + last->pnext = m; + else + mp->inbufs = m; + m->pnext = q; + q = m; + h = mh; + m = NULL; + } + + if (h.seq != seq) { + /* we're missing something :-( */ + if (mp->seq.min_in > seq) { + /* we're never gonna get it */ + struct mbuf *next; + + /* Zap all older fragments */ + while (mp->inbufs != q) { + next = mp->inbufs->pnext; + pfree(mp->inbufs); + mp->inbufs = next; + } + + /* + * Zap everything until the next `end' fragment OR just before + * the next `begin' fragment OR 'till seq.min_in - whichever + * comes first. + */ + do { + mp_ReadHeader(mp, mp->inbufs, &h); + if (h.begin) { + h.seq--; /* We're gonna look for fragment with h.seq+1 */ + break; + } + next = mp->inbufs->pnext; + pfree(mp->inbufs); + mp->inbufs = next; + } while (h.seq >= mp->seq.min_in || h.end); + + /* + * Continue processing things from here. + * This deals with the possibility that we received a fragment + * on the slowest link that invalidates some of our data (because + * of the hole at `q'), but where there are subsequent `whole' + * packets that have already been received. + */ + + mp->seq.next_in = seq = h.seq + 1; + last = NULL; + q = mp->inbufs; + } else + /* we may still receive the missing fragment */ + break; + } else if (h.end) { + /* We've got something, reassemble */ + struct mbuf **frag = &q; + int len; + u_short proto = 0; + u_char ch; + + do { + *frag = mp->inbufs; + mp->inbufs = mp->inbufs->pnext; + len = mp_ReadHeader(mp, *frag, &h); + (*frag)->offset += len; + (*frag)->cnt -= len; + (*frag)->pnext = NULL; + if (frag == &q && !h.begin) { + LogPrintf(LogWARN, "Oops - MP frag %lu should have a begin flag\n", + (u_long)h.seq); + pfree(q); + q = NULL; + } else if (frag != &q && h.begin) { + LogPrintf(LogWARN, "Oops - MP frag %lu should have an end flag\n", + (u_long)h.seq - 1); + /* + * Stuff our fragment back at the front of the queue and zap + * our half-assembed packet. + */ + (*frag)->pnext = mp->inbufs; + mp->inbufs = *frag; + *frag = NULL; + pfree(q); + q = NULL; + frag = &q; + h.end = 0; /* just in case it's a whole packet */ + } else + do + frag = &(*frag)->next; + while ((*frag)->next != NULL); + } while (!h.end); + + if (q) { + do { + q = mbread(q, &ch, 1); + proto = proto << 8; + proto += ch; + } while (!(proto & 1)); + hdlc_DecodePacket(mp->bundle, proto, q, &mp->link); + } + + mp->seq.next_in = seq = h.seq + 1; + last = NULL; + q = mp->inbufs; + } else { + /* Look for the next fragment */ + seq++; + last = q; + q = q->pnext; + } + } + + if (m) { + /* We still have to find a home for our new fragment */ + last = NULL; + for (q = mp->inbufs; q; last = q, q = q->pnext) { + mp_ReadHeader(mp, q, &h); + if (h.seq > mh.seq) { + /* Our received fragment fits in before this one, so link it in */ + if (last) + last->pnext = m; + else + mp->inbufs = m; + m->pnext = q; + break; + } + } + } +} + +static void +mp_Output(struct mp *mp, struct link *l, struct mbuf *m, int begin, int end) +{ + struct mbuf *mo; + u_char *cp; + u_int32_t *seq32; + u_int16_t *seq16; + + mo = mballoc(4, MB_MP); + mo->next = m; + cp = MBUF_CTOP(mo); + seq32 = (u_int32_t *)cp; + seq16 = (u_int16_t *)cp; + *seq32 = 0; + *cp = (begin << 7) | (end << 6); + if (mp->is12bit) { + *seq16 |= (u_int16_t)mp->seq.out; + mo->cnt = 2; + } else { + *seq32 |= (u_int32_t)mp->seq.out; + mo->cnt = 4; + } + mp->seq.out = inc_seq(mp, mp->seq.out); + + HdlcOutput(l, PRI_NORMAL, PROTO_MP, mo); +} + +int +mp_FillQueues(struct bundle *bundle) +{ + struct mp *mp = &bundle->ncp.mp; + struct datalink *dl; + int total, add, len, begin, end, looped; + struct mbuf *m, *mo; + + /* + * XXX: This routine is fairly simplistic. It should re-order the + * links based on the amount of data less than the links weight + * that was queued. That way we'd ``prefer'' the least used + * links the next time 'round. + */ + + total = 0; + for (dl = bundle->links; dl; dl = dl->next) { + if (dl->physical->out) + /* this link has suffered a short write. Let it continue */ + continue; + add = link_QueueLen(&dl->physical->link); + total += add; + if (add) + /* this link has got stuff already queued. Let it continue */ + continue; + if (!link_QueueLen(&mp->link) && !IpFlushPacket(&mp->link, bundle)) + /* Nothing else to send */ + break; + + m = link_Dequeue(&mp->link); + len = plength(m); + add += len; + begin = 1; + end = 0; + looped = 0; + + for (; !end; dl = dl->next) { + if (dl == NULL) { + /* Keep going 'till we get rid of the whole of `m' */ + looped = 1; + dl = bundle->links; + } + if (len <= dl->mp.weight + LINK_MINWEIGHT) { + mo = m; + end = 1; + } else { + mo = mballoc(dl->mp.weight, MB_MP); + mo->cnt = dl->mp.weight; + len -= mo->cnt; + m = mbread(m, MBUF_CTOP(mo), mo->cnt); + } + mp_Output(mp, &dl->physical->link, mo, begin, end); + begin = 0; + } + if (looped) + break; + } + + return total; +} + +int +mp_SetDatalinkWeight(struct cmdargs const *arg) +{ + int val; + + if (arg->argc != 1) + return -1; + + val = atoi(arg->argv[0]); + if (val < LINK_MINWEIGHT) { + LogPrintf(LogWARN, "Link weights must not be less than %d\n", + LINK_MINWEIGHT); + return 1; + } + arg->cx->mp.weight = val; + return 0; +} diff --git a/usr.sbin/ppp/mp.h b/usr.sbin/ppp/mp.h new file mode 100644 index 000000000000..c69fb9fee131 --- /dev/null +++ b/usr.sbin/ppp/mp.h @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 1998 Brian Somers + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +struct mp { + struct link link; + + unsigned active : 1; + unsigned is12bit : 1; /* 12 / 24bit seq nos */ + + struct { + u_int32_t out; /* next outgoing seq */ + u_int32_t min_in; /* minimum received incoming seq */ + u_int32_t next_in; /* next incoming seq to process */ + } seq; + struct mbuf *inbufs; /* Received fragments */ + + struct fsm_parent fsmp; /* Our callback functions */ + + struct bundle *bundle; +}; + +struct mp_link { + u_int32_t seq; /* 12 or 24 bit incoming seq */ + int weight; /* bytes to send with each write */ +}; + +struct mp_header { + unsigned begin : 1; + unsigned end : 1; + u_int32_t seq; +}; + +extern void mp_Init(struct mp *, struct bundle *); +extern void mp_linkInit(struct mp_link *); +extern void mp_Input(struct mp *, struct mbuf *, struct physical *); +extern int mp_FillQueues(struct bundle *); +extern int mp_SetDatalinkWeight(struct cmdargs const *); diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index 8eebd192900f..b678177ec33c 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.18 1998/03/16 22:52:35 brian Exp $ + * $Id: pap.c,v 1.20.2.19 1998/03/16 22:54:16 brian Exp $ * * TODO: */ @@ -55,6 +55,7 @@ #include "lcpproto.h" #include "async.h" #include "throughput.h" +#include "ccp.h" #include "link.h" #include "descriptor.h" #include "physical.h" @@ -62,9 +63,9 @@ #include "slcompress.h" #include "ipcp.h" #include "filter.h" +#include "mp.h" #include "bundle.h" #include "chat.h" -#include "ccp.h" #include "chap.h" #include "datalink.h" @@ -163,10 +164,10 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical) cp = (u_char *) (php + 1); if (PapValidate(bundle, cp, cp + *cp + 1, physical)) { SendPapCode(php->id, PAP_ACK, "Greetings!!", physical); - dl->lcp.auth_ineed = 0; + dl->physical->link.lcp.auth_ineed = 0; Physical_Login(physical, cp + 1); - if (dl->lcp.auth_iwait == 0) + if (dl->physical->link.lcp.auth_iwait == 0) /* * Either I didn't need to authenticate, or I've already been * told that I got the answer right. @@ -184,9 +185,9 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical) len = *cp++; cp[len] = 0; LogPrintf(LogPHASE, "Received PAP_ACK (%s)\n", cp); - if (dl->lcp.auth_iwait == PROTO_PAP) { - dl->lcp.auth_iwait = 0; - if (dl->lcp.auth_ineed == 0) + if (dl->physical->link.lcp.auth_iwait == PROTO_PAP) { + dl->physical->link.lcp.auth_iwait = 0; + if (dl->physical->link.lcp.auth_ineed == 0) /* * We've succeeded in our ``login'' * If we're not expecting the peer to authenticate (or he already diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index 9899847989b2..5eed49cf2c0c 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.18 1998/03/16 22:54:18 brian Exp $ + * $Id: physical.c,v 1.1.2.19 1998/03/20 19:48:16 brian Exp $ * */ @@ -55,6 +55,7 @@ #include "fsm.h" #include "lcp.h" #include "async.h" +#include "ccp.h" #include "link.h" #include "descriptor.h" @@ -65,6 +66,12 @@ #include "slcompress.h" #include "ipcp.h" #include "filter.h" +#include "mp.h" +#include "auth.h" +#include "chap.h" +#include "pap.h" +#include "chat.h" +#include "datalink.h" #include "bundle.h" #include "log.h" #include "id.h" @@ -183,13 +190,6 @@ Physical_Write(struct physical *phys, const void *buf, size_t nbytes) { return write(phys->fd, buf, nbytes); } -int -Physical_ReportProtocolStatus(struct cmdargs const *arg) -{ - link_ReportProtocolStatus(bundle2link(arg->bundle, NULL)); - return 0; -} - int Physical_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n, int force) @@ -197,8 +197,6 @@ Physical_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, struct physical *p = descriptor2physical(d); int sets; - LogPrintf(LogDEBUG, "descriptor2physical; %p -> %p\n", d, p); - sets = 0; if (p->fd >= 0) { if (r) { @@ -224,21 +222,9 @@ int Physical_IsSet(struct descriptor *d, const fd_set *fdset) { struct physical *p = descriptor2physical(d); - - LogPrintf(LogDEBUG, "descriptor2physical; %p -> %p\n", d, p); return p->fd >= 0 && FD_ISSET(p->fd, fdset); } -void -Physical_DescriptorWrite(struct descriptor *d, struct bundle *bundle, - const fd_set *fdset) -{ - struct physical *p = descriptor2physical(d); - - LogPrintf(LogDEBUG, "descriptor2physical; %p -> %p\n", d, p); - link_StartOutput(&p->link, bundle); -} - void Physical_Login(struct physical *phys, const char *name) { diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h index f967537e9902..5a2fd0c7adc6 100644 --- a/usr.sbin/ppp/physical.h +++ b/usr.sbin/ppp/physical.h @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.h,v 1.1.2.16 1998/03/20 19:47:22 brian Exp $ + * $Id: physical.h,v 1.1.2.17 1998/03/20 19:48:18 brian Exp $ * */ @@ -98,7 +98,6 @@ int Physical_FD_ISSET(struct physical *, fd_set *); void Physical_DupAndClose(struct physical *); ssize_t Physical_Read(struct physical *phys, void *buf, size_t nbytes); ssize_t Physical_Write(struct physical *phys, const void *buf, size_t nbytes); -int Physical_ReportProtocolStatus(struct cmdargs const *); int Physical_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *, int *, int); int Physical_IsSet(struct descriptor *, const fd_set *); diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c index 4b41b3ca4f8b..4867323cb625 100644 --- a/usr.sbin/ppp/prompt.c +++ b/usr.sbin/ppp/prompt.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: prompt.c,v 1.1.2.15 1998/03/16 22:54:22 brian Exp $ + * $Id: prompt.c,v 1.1.2.16 1998/03/20 19:48:19 brian Exp $ */ #include @@ -55,15 +55,16 @@ #include "slcompress.h" #include "ipcp.h" #include "filter.h" -#include "bundle.h" #include "lqr.h" #include "hdlc.h" #include "async.h" #include "mbuf.h" +#include "ccp.h" #include "link.h" #include "physical.h" +#include "mp.h" +#include "bundle.h" #include "chat.h" -#include "ccp.h" #include "chap.h" #include "datalink.h" @@ -75,8 +76,6 @@ prompt_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n) struct prompt *p = descriptor2prompt(d); int sets; - LogPrintf(LogDEBUG, "descriptor2prompt; %p -> %p\n", d, p); - sets = 0; if (p->fd_in >= 0) { if (r) { @@ -98,7 +97,6 @@ static int prompt_IsSet(struct descriptor *d, const fd_set *fdset) { struct prompt *p = descriptor2prompt(d); - LogPrintf(LogDEBUG, "descriptor2prompt; %p -> %p\n", d, p); return p->fd_in >= 0 && FD_ISSET(p->fd_in, fdset); } @@ -110,8 +108,8 @@ prompt_ShowHelp(struct prompt *p) prompt_Printf(p, " ~p\tEnter Packet mode\r\n"); prompt_Printf(p, " ~-\tDecrease log level\r\n"); prompt_Printf(p, " ~+\tIncrease log level\r\n"); - prompt_Printf(p, " ~t\tShow timers (only in \"log debug\" mode)\r\n"); - prompt_Printf(p, " ~m\tShow memory map (only in \"log debug\" mode)\r\n"); + prompt_Printf(p, " ~t\tShow timers\r\n"); + prompt_Printf(p, " ~m\tShow memory map\r\n"); prompt_Printf(p, " ~.\tTerminate program\r\n"); prompt_Printf(p, " ~?\tThis help\r\n"); } @@ -125,7 +123,6 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) static int ttystate; char linebuff[LINE_LEN]; - LogPrintf(LogDEBUG, "descriptor2prompt; %p -> %p\n", d, p); LogPrintf(LogDEBUG, "termode = %p, p->fd_in = %d, mode = %d\n", p->TermMode, p->fd_in, mode); @@ -136,9 +133,9 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) linebuff[--n] = '\0'; else linebuff[n] = '\0'; + prompt_nonewline = 1; /* In case DecodeCommand does a prompt */ if (n) DecodeCommand(bundle, linebuff, n, IsInteractive(0) ? NULL : "Client"); - prompt_nonewline = 1; prompt_Display(&prompt, bundle); } else if (n <= 0) { LogPrintf(LogPHASE, "Client connection closed.\n"); @@ -201,15 +198,11 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) prompt_Display(&prompt, bundle); break; case 't': - if (LogIsKept(LogDEBUG)) { - ShowTimers(); - break; - } + ShowTimers(0); + break; case 'm': - if (LogIsKept(LogDEBUG)) { - ShowMemMap(NULL); - break; - } + ShowMemMap(NULL); + break; default: if (Physical_Write(bundle2physical(bundle, NULL), &ch, n) < 0) LogPrintf(LogERROR, "error writing to modem.\n"); @@ -270,7 +263,7 @@ prompt_Display(struct prompt *p, struct bundle *bundle) { const char *pconnect, *pauth; - if (!p->Term || p->TermMode != NULL || bundle->CleaningUp) + if (!p->Term || p->TermMode != NULL) return; if (prompt_nonewline) diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index 23268322e500..7c41141d16eb 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.42.2.12 1998/03/16 22:54:23 brian Exp $ + * $Id: route.c,v 1.42.2.13 1998/03/20 19:48:21 brian Exp $ * */ @@ -55,12 +55,16 @@ #include "throughput.h" #include "lqr.h" #include "hdlc.h" -#include "link.h" +#include "async.h" #include "fsm.h" +#include "lcp.h" +#include "ccp.h" +#include "link.h" #include "slcompress.h" #include "ipcp.h" #include "filter.h" #include "descriptor.h" +#include "mp.h" #include "bundle.h" #include "route.h" #include "prompt.h" diff --git a/usr.sbin/ppp/server.c b/usr.sbin/ppp/server.c index e6197c2cec5b..ce43b5f9ed56 100644 --- a/usr.sbin/ppp/server.c +++ b/usr.sbin/ppp/server.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: server.c,v 1.16.2.8 1998/02/23 00:38:42 brian Exp $ + * $Id: server.c,v 1.16.2.9 1998/03/20 19:48:23 brian Exp $ */ #include @@ -58,7 +58,6 @@ server_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n) { struct server *s = descriptor2server(d); - LogPrintf(LogDEBUG, "descriptor2server; %p -> %p\n", d, s); if (r && s->fd >= 0) { if (*n < s->fd + 1) *n = s->fd + 1; @@ -72,8 +71,6 @@ static int server_IsSet(struct descriptor *d, const fd_set *fdset) { struct server *s = descriptor2server(d); - - LogPrintf(LogDEBUG, "descriptor2server; %p -> %p\n", d, s); return s->fd >= 0 && FD_ISSET(s->fd, fdset); } @@ -90,8 +87,6 @@ server_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) struct sockaddr_in *sin = (struct sockaddr_in *)hisaddr; int ssize = ADDRSZ, wfd; - LogPrintf(LogDEBUG, "descriptor2server; %p -> %p\n", d, s); - wfd = accept(s->fd, sa, &ssize); if (wfd < 0) { LogPrintf(LogERROR, "server_Read: accept(): %s\n", strerror(errno)); diff --git a/usr.sbin/ppp/slcompress.c b/usr.sbin/ppp/slcompress.c index 7b0f92f031b3..c0311ac16bb8 100644 --- a/usr.sbin/ppp/slcompress.c +++ b/usr.sbin/ppp/slcompress.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: slcompress.c,v 1.15.2.2 1998/02/10 03:23:42 brian Exp $ + * $Id: slcompress.c,v 1.15.2.3 1998/03/16 22:54:25 brian Exp $ * * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: * - Initial distribution. @@ -48,6 +48,12 @@ #include "iplist.h" #include "ipcp.h" #include "filter.h" +#include "lqr.h" +#include "hdlc.h" +#include "lcp.h" +#include "ccp.h" +#include "link.h" +#include "mp.h" #include "bundle.h" void diff --git a/usr.sbin/ppp/throughput.c b/usr.sbin/ppp/throughput.c index 79a33fb4e81f..e2b2cb9c9d31 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 1997/12/21 12:11:09 brian Exp $ + * $Id: throughput.c,v 1.4.4.1 1998/02/10 03:23:43 brian Exp $ */ #include @@ -53,6 +53,7 @@ throughput_init(struct pppThroughput *t) for (f = 0; f < SAMPLE_PERIOD; f++) t->SampleOctets[f] = 0; t->OctetsPerSecond = t->BestOctetsPerSecond = t->nSample = 0; + t->Timer.name = "throughput"; throughput_stop(t); } @@ -124,7 +125,7 @@ throughput_sampler(void *v) } void -throughput_start(struct pppThroughput *t) +throughput_start(struct pppThroughput *t, const char *name) { throughput_init(t); time(&t->uptime); @@ -132,6 +133,7 @@ throughput_start(struct pppThroughput *t) t->Timer.state = TIMER_STOPPED; t->Timer.load = SECTICKS; t->Timer.func = throughput_sampler; + t->Timer.name = name; t->Timer.arg = t; StartTimer(&t->Timer); } diff --git a/usr.sbin/ppp/throughput.h b/usr.sbin/ppp/throughput.h index 4a26611c88b0..44f2f88689c0 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 1997/12/21 12:11:09 brian Exp $ + * $Id: throughput.h,v 1.2.4.1 1998/02/10 03:23:48 brian Exp $ */ #define SAMPLE_PERIOD 5 @@ -42,7 +42,7 @@ struct pppThroughput { extern void throughput_init(struct pppThroughput *); extern void throughput_disp(struct pppThroughput *); extern void throughput_log(struct pppThroughput *, int, const char *); -extern void throughput_start(struct pppThroughput *); +extern void throughput_start(struct pppThroughput *, const char *); 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/timer.c b/usr.sbin/ppp/timer.c index fa53b3949f79..3a732b2d191c 100644 --- a/usr.sbin/ppp/timer.c +++ b/usr.sbin/ppp/timer.c @@ -17,16 +17,16 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: timer.c,v 1.26 1997/12/29 22:23:52 brian Exp $ + * $Id: timer.c,v 1.27 1998/01/21 02:15:29 brian Exp $ * * TODO: */ -#include -#ifdef SIGALRM #include -#endif +#include +#include #include +#include #include #include "command.h" @@ -34,24 +34,32 @@ #include "log.h" #include "sig.h" #include "timer.h" +#include "descriptor.h" +#include "prompt.h" static struct pppTimer *TimerList = NULL; static void StopTimerNoBlock(struct pppTimer *); static void InitTimerService(void); +static const char * +tState2Nam(u_int state) +{ + static const char *StateNames[] = { "stopped", "running", "expired" }; + + if (state >= sizeof StateNames / sizeof StateNames[0]) + return "unknown"; + return StateNames[state]; +} + void StopTimer(struct pppTimer * tp) { -#ifdef SIGALRM int omask; omask = sigblock(sigmask(SIGALRM)); -#endif StopTimerNoBlock(tp); -#ifdef SIGALRM sigsetmask(omask); -#endif } void @@ -59,25 +67,20 @@ StartTimer(struct pppTimer * tp) { struct pppTimer *t, *pt; u_long ticks = 0; - -#ifdef SIGALRM int omask; omask = sigblock(sigmask(SIGALRM)); -#endif if (tp->state != TIMER_STOPPED) { StopTimerNoBlock(tp); } if (tp->load == 0) { - LogPrintf(LogDEBUG, "timer %x has 0 load!\n", tp); + LogPrintf(LogDEBUG, "%s timer[%p] has 0 load!\n", tp->name, tp); sigsetmask(omask); return; } pt = NULL; for (t = TimerList; t; t = t->next) { - LogPrintf(LogDEBUG, "StartTimer: %x(%d): ticks: %d, rest: %d\n", - t, t->state, ticks, t->rest); if (ticks + t->rest >= tp->load) break; ticks += t->rest; @@ -86,8 +89,13 @@ StartTimer(struct pppTimer * tp) tp->state = TIMER_RUNNING; tp->rest = tp->load - ticks; - LogPrintf(LogDEBUG, "StartTimer: Inserting %x before %x, rest = %d\n", - tp, t, tp->rest); + + if (t) + LogPrintf(LogDEBUG, "StartTimer: Inserting %s timer[%p] before %s " + "timer[%p], delta = %d\n", tp->name, tp, t->name, t, tp->rest); + else + LogPrintf(LogDEBUG, "StartTimer: Inserting %s timer[%p]\n", tp->name, tp); + /* Insert given *tp just before *t */ tp->next = t; if (pt) { @@ -99,9 +107,7 @@ StartTimer(struct pppTimer * tp) if (t) t->rest -= tp->rest; -#ifdef SIGALRM sigsetmask(omask); -#endif } static void @@ -114,8 +120,6 @@ StopTimerNoBlock(struct pppTimer * tp) * already removing TimerList. So just marked as TIMER_STOPPED. Do not * change tp->enext!! (Might be Called by expired proc) */ - LogPrintf(LogDEBUG, "StopTimer: %x, next = %x state=%x\n", - tp, tp->next, tp->state); if (tp->state != TIMER_RUNNING) { tp->next = NULL; tp->state = TIMER_STOPPED; @@ -146,8 +150,14 @@ TimerService() { struct pppTimer *tp, *exp, *wt; - if (LogIsKept(LogDEBUG)) - ShowTimers(); + if (LogIsKept(LogDEBUG)) { + static time_t t; + time_t n = time(NULL); /* Only show timers every second */ + + if (n > t) + ShowTimers(LogDEBUG); + t = n; + } tp = TimerList; if (tp) { tp->rest--; @@ -162,15 +172,12 @@ TimerService() wt = tp->next; tp->enext = exp; exp = tp; - LogPrintf(LogDEBUG, "TimerService: Add %x to exp\n", tp); tp = wt; } while (tp && (tp->rest == 0)); TimerList = tp; if (TimerList == NULL) /* No timers ? */ TermTimerService(); /* Terminate Timer Service */ - LogPrintf(LogDEBUG, "TimerService: next is %x(%d)\n", - TimerList, TimerList ? TimerList->rest : 0); /* * Process all expired timers. @@ -193,19 +200,33 @@ TimerService() } void -ShowTimers() +ShowTimers(int LogLevel) { struct pppTimer *pt; + int rest = 0; + +#define SECS(val) ((val) / SECTICKS) +#define HSECS(val) (((val) % SECTICKS) * 100 / SECTICKS) +#define DISP \ + "%s timer[%p]: freq = %d.%02ds, next = %d.%02ds, state = %s\n", \ + pt->name, pt, SECS(pt->load), HSECS(pt->load), SECS(rest), \ + HSECS(rest), tState2Nam(pt->state) + + if (LogIsKept(LogLevel)) + LogPrintf(LogLevel, "---- Begin of Timer Service List---\n"); + + for (pt = TimerList; pt; pt = pt->next) { + rest += pt->rest; + if (LogIsKept(LogLevel)) + LogPrintf(LogLevel, DISP); + else if (LogLevel < LogMIN) + prompt_Printf(&prompt, DISP); + } - LogPrintf(LogDEBUG, "---- Begin of Timer Service List---\n"); - for (pt = TimerList; pt; pt = pt->next) - LogPrintf(LogDEBUG, "%x: load = %d, rest = %d, state =%x\n", - pt, pt->load, pt->rest, pt->state); - LogPrintf(LogDEBUG, "---- End of Timer Service List ---\n"); + if (LogIsKept(LogLevel)) + LogPrintf(LogLevel, "---- End of Timer Service List ---\n"); } -#ifdef SIGALRM - static void nointr_dosleep(u_int sec, u_int usec) { @@ -285,5 +306,3 @@ TermTimerService(void) LogPrintf(LogERROR, "Unable to set itimer.\n"); pending_signal(SIGALRM, SIG_IGN); } - -#endif diff --git a/usr.sbin/ppp/timer.h b/usr.sbin/ppp/timer.h index e8df9b9387c7..d664f3c5b29a 100644 --- a/usr.sbin/ppp/timer.h +++ b/usr.sbin/ppp/timer.h @@ -15,16 +15,17 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: timer.h,v 1.4 1997/12/28 21:55:05 brian Exp $ + * $Id: timer.h,v 1.5 1998/01/21 02:15:30 brian Exp $ * * TODO: */ -#define TICKUNIT 100000 /* Unit in usec */ -#define SECTICKS (1000000/TICKUNIT) +#define TICKUNIT 100000 /* usec's per Unit */ +#define SECTICKS (1000000/TICKUNIT) /* Units per second */ struct pppTimer { int state; + const char *name; u_long rest; /* Ticks to expire */ u_long load; /* Initial load value */ void (*func)(void *); /* Function called when timer is expired */ @@ -40,7 +41,7 @@ struct pppTimer { extern void StartTimer(struct pppTimer *); extern void StopTimer(struct pppTimer *); extern void TermTimerService(void); -extern void ShowTimers(void); +extern void ShowTimers(int LogLevel); #ifdef SIGALRM extern void nointr_sleep(u_int); diff --git a/usr.sbin/ppp/tun.c b/usr.sbin/ppp/tun.c index 500bcef9c31b..51aa67cacb7a 100644 --- a/usr.sbin/ppp/tun.c +++ b/usr.sbin/ppp/tun.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: tun.c,v 1.6.4.8 1998/03/16 22:54:28 brian Exp $ + * $Id: tun.c,v 1.6.4.9 1998/03/20 19:48:25 brian Exp $ */ #include @@ -57,6 +57,10 @@ #include "ipcp.h" #include "filter.h" #include "descriptor.h" +#include "lcp.h" +#include "ccp.h" +#include "link.h" +#include "mp.h" #include "bundle.h" #include "tun.h" diff --git a/usr.sbin/ppp/vars.c b/usr.sbin/ppp/vars.c index e3156f22562f..3cd972ff8ef1 100644 --- a/usr.sbin/ppp/vars.c +++ b/usr.sbin/ppp/vars.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vars.c,v 1.45.2.16 1998/03/20 19:47:07 brian Exp $ + * $Id: vars.c,v 1.45.2.17 1998/03/24 18:47:27 brian Exp $ * */ #include @@ -41,13 +41,14 @@ #include "lcp.h" #include "async.h" #include "throughput.h" +#include "ccp.h" #include "link.h" #include "descriptor.h" #include "physical.h" #include "prompt.h" char VarVersion[] = "PPP Version 2.0-beta"; -char VarLocalVersion[] = "$Date: 1998/03/20 19:47:07 $"; +char VarLocalVersion[] = "$Date: 1998/03/24 18:47:27 $"; /* * Order of conf option is important. See vars.h. diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c index 8c688e82c29d..66fab1ad64f6 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.9 1998/03/16 22:54:32 brian Exp $ + * $Id: vjcomp.c,v 1.16.2.10 1998/03/20 19:48:28 brian Exp $ * * TODO: */ @@ -47,6 +47,7 @@ #include "link.h" #include "filter.h" #include "descriptor.h" +#include "mp.h" #include "bundle.h" #include "vjcomp.h" @@ -58,7 +59,6 @@ SendPppFrame(struct link *l, struct mbuf * bp, struct bundle *bundle) int type; u_short proto; u_short cproto = bundle->ncp.ipcp.peer_compproto >> 16; - struct ccp *ccp = bundle2ccp(bundle, l->name); LogPrintf(LogDEBUG, "SendPppFrame: proto = %x\n", bundle->ncp.ipcp.peer_compproto); @@ -87,7 +87,7 @@ SendPppFrame(struct link *l, struct mbuf * bp, struct bundle *bundle) } else proto = PROTO_IP; - if (!ccp_Output(ccp, l, PRI_NORMAL, proto, bp)) + if (!ccp_Compress(&l->ccp, l, PRI_NORMAL, proto, bp)) HdlcOutput(l, PRI_NORMAL, proto, bp); } -- cgit v1.2.3