1995-01-31 06:29:58 +00:00
|
|
|
/*
|
|
|
|
* PPP Line Quality Monitoring (LQM) Module
|
|
|
|
*
|
|
|
|
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms are permitted
|
|
|
|
* provided that the above copyright notice and this paragraph are
|
|
|
|
* duplicated in all such forms and that any documentation,
|
|
|
|
* advertising materials, and other materials related to such
|
|
|
|
* distribution and use acknowledge that the software was developed
|
|
|
|
* by the Internet Initiative Japan, Inc. The name of the
|
|
|
|
* IIJ may not be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
1999-05-08 11:07:56 +00:00
|
|
|
* $Id: lqr.c,v 1.32 1999/03/29 08:21:28 brian Exp $
|
1995-05-30 03:57:47 +00:00
|
|
|
*
|
1995-02-26 12:18:08 +00:00
|
|
|
* o LQR based on RFC1333
|
1995-01-31 06:29:58 +00:00
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* o LQM policy
|
|
|
|
* o Allow user to configure LQM method and interval.
|
|
|
|
*/
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1999-01-28 01:56:34 +00:00
|
|
|
#include <sys/param.h>
|
1998-04-28 01:25:46 +00:00
|
|
|
#include <sys/un.h>
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-03-12 02:23:42 +00:00
|
|
|
#include <string.h>
|
1998-02-02 19:33:40 +00:00
|
|
|
#include <termios.h>
|
1997-10-26 01:04:02 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "layer.h"
|
1997-10-26 01:04:02 +00:00
|
|
|
#include "mbuf.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "defs.h"
|
|
|
|
#include "timer.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "fsm.h"
|
1999-05-08 11:07:56 +00:00
|
|
|
#include "acf.h"
|
|
|
|
#include "proto.h"
|
1998-02-02 19:33:40 +00:00
|
|
|
#include "lcp.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
#include "lqr.h"
|
|
|
|
#include "hdlc.h"
|
1998-02-02 19:33:40 +00:00
|
|
|
#include "async.h"
|
|
|
|
#include "throughput.h"
|
1998-04-03 19:21:56 +00:00
|
|
|
#include "ccp.h"
|
1998-02-02 19:33:40 +00:00
|
|
|
#include "link.h"
|
1998-02-09 19:21:11 +00:00
|
|
|
#include "descriptor.h"
|
1998-01-30 19:46:07 +00:00
|
|
|
#include "physical.h"
|
1998-04-03 19:21:56 +00:00
|
|
|
#include "mp.h"
|
1998-04-14 07:25:37 +00:00
|
|
|
#include "chat.h"
|
|
|
|
#include "auth.h"
|
|
|
|
#include "chap.h"
|
1998-04-16 00:26:21 +00:00
|
|
|
#include "command.h"
|
1998-08-07 18:42:51 +00:00
|
|
|
#include "cbcp.h"
|
1998-04-14 07:25:37 +00:00
|
|
|
#include "datalink.h"
|
1995-01-31 06:29:58 +00:00
|
|
|
|
|
|
|
struct echolqr {
|
1998-01-11 17:50:49 +00:00
|
|
|
u_int32_t magic;
|
|
|
|
u_int32_t signature;
|
|
|
|
u_int32_t sequence;
|
1995-01-31 06:29:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define SIGNATURE 0x594e4f54
|
|
|
|
|
|
|
|
static void
|
1998-03-13 00:44:26 +00:00
|
|
|
SendEchoReq(struct lcp *lcp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-13 00:44:26 +00:00
|
|
|
struct hdlc *hdlc = &link2physical(lcp->fsm.link)->hdlc;
|
|
|
|
struct echolqr echo;
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-03-13 00:44:26 +00:00
|
|
|
echo.magic = htonl(lcp->want_magic);
|
|
|
|
echo.signature = htonl(SIGNATURE);
|
1998-03-20 19:47:10 +00:00
|
|
|
echo.sequence = htonl(hdlc->lqm.echo.seq_sent);
|
1998-05-01 19:26:12 +00:00
|
|
|
fsm_Output(&lcp->fsm, CODE_ECHOREQ, hdlc->lqm.echo.seq_sent++,
|
1998-03-13 00:44:26 +00:00
|
|
|
(u_char *)&echo, sizeof echo);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
lqr_RecvEcho(struct fsm *fp, struct mbuf * bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-13 00:44:26 +00:00
|
|
|
struct hdlc *hdlc = &link2physical(fp->link)->hdlc;
|
1995-01-31 06:29:58 +00:00
|
|
|
struct echolqr *lqr;
|
1998-01-11 17:50:49 +00:00
|
|
|
u_int32_t seq;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
if (mbuf_Length(bp) == sizeof(struct echolqr)) {
|
1997-08-25 00:29:32 +00:00
|
|
|
lqr = (struct echolqr *) MBUF_CTOP(bp);
|
1998-03-13 00:44:26 +00:00
|
|
|
if (ntohl(lqr->signature) == SIGNATURE) {
|
1995-01-31 06:29:58 +00:00
|
|
|
seq = ntohl(lqr->sequence);
|
1998-03-13 00:44:26 +00:00
|
|
|
/* careful not to update lqm.echo.seq_recv with older values */
|
|
|
|
if ((hdlc->lqm.echo.seq_recv > (u_int32_t)0 - 5 && seq < 5) ||
|
|
|
|
(hdlc->lqm.echo.seq_recv <= (u_int32_t)0 - 5 &&
|
|
|
|
seq > hdlc->lqm.echo.seq_recv))
|
|
|
|
hdlc->lqm.echo.seq_recv = seq;
|
|
|
|
} else
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogWARN, "lqr_RecvEcho: Got sig 0x%08lx, not 0x%08lx !\n",
|
|
|
|
(u_long)ntohl(lqr->signature), (u_long)SIGNATURE);
|
1998-03-13 00:44:26 +00:00
|
|
|
} else
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogWARN, "lqr_RecvEcho: Got packet size %d, expecting %ld !\n",
|
|
|
|
mbuf_Length(bp), (long)sizeof(struct echolqr));
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
lqr_ChangeOrder(struct lqrdata * src, struct lqrdata * dst)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-06-26 19:02:40 +00:00
|
|
|
u_int32_t *sp, *dp;
|
1995-01-31 06:29:58 +00:00
|
|
|
int n;
|
|
|
|
|
1998-06-26 19:02:40 +00:00
|
|
|
sp = (u_int32_t *) src;
|
|
|
|
dp = (u_int32_t *) dst;
|
1999-05-08 11:07:56 +00:00
|
|
|
for (n = 0; n < sizeof(struct lqrdata) / sizeof(u_int32_t); n++, sp++, dp++)
|
|
|
|
*dp = ntohl(*sp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-04-03 19:26:35 +00:00
|
|
|
SendLqrData(struct lcp *lcp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
|
|
|
struct mbuf *bp;
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
bp = mbuf_Alloc(sizeof(struct lqrdata), MB_LQR);
|
1999-05-08 11:07:56 +00:00
|
|
|
link_PushPacket(lcp->fsm.link, bp, lcp->fsm.bundle, PRI_LINK, PROTO_LQR);
|
1998-04-03 19:26:35 +00:00
|
|
|
}
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-01-29 00:44:16 +00:00
|
|
|
static void
|
|
|
|
SendLqrReport(void *v)
|
|
|
|
{
|
1998-03-13 00:44:26 +00:00
|
|
|
struct lcp *lcp = (struct lcp *)v;
|
1998-04-14 07:25:37 +00:00
|
|
|
struct physical *p = link2physical(lcp->fsm.link);
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&p->hdlc.lqm.timer);
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-04-14 07:25:37 +00:00
|
|
|
if (p->hdlc.lqm.method & LQM_LQR) {
|
|
|
|
if (p->hdlc.lqm.lqr.resent > 5) {
|
1998-03-13 00:44:26 +00:00
|
|
|
/* XXX: Should implement LQM strategy */
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogPHASE, "%s: ** Too many LQR packets lost **\n",
|
1998-04-24 19:16:15 +00:00
|
|
|
lcp->fsm.link->name);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogLQM, "%s: Too many LQR packets lost\n",
|
1998-04-24 19:16:15 +00:00
|
|
|
lcp->fsm.link->name);
|
1998-04-14 07:25:37 +00:00
|
|
|
p->hdlc.lqm.method = 0;
|
1998-06-15 19:05:27 +00:00
|
|
|
datalink_Down(p->dl, CLOSE_NORMAL);
|
1995-01-31 06:29:58 +00:00
|
|
|
} else {
|
1998-04-03 19:26:35 +00:00
|
|
|
SendLqrData(lcp);
|
1998-04-14 07:25:37 +00:00
|
|
|
p->hdlc.lqm.lqr.resent++;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-04-14 07:25:37 +00:00
|
|
|
} else if (p->hdlc.lqm.method & LQM_ECHO) {
|
|
|
|
if ((p->hdlc.lqm.echo.seq_sent > 5 &&
|
|
|
|
p->hdlc.lqm.echo.seq_sent - 5 > p->hdlc.lqm.echo.seq_recv) ||
|
|
|
|
(p->hdlc.lqm.echo.seq_sent <= 5 &&
|
|
|
|
p->hdlc.lqm.echo.seq_sent > p->hdlc.lqm.echo.seq_recv + 5)) {
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogPHASE, "%s: ** Too many ECHO LQR packets lost **\n",
|
1998-04-24 19:16:15 +00:00
|
|
|
lcp->fsm.link->name);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogLQM, "%s: Too many ECHO LQR packets lost\n",
|
1998-04-24 19:16:15 +00:00
|
|
|
lcp->fsm.link->name);
|
1998-04-14 07:25:37 +00:00
|
|
|
p->hdlc.lqm.method = 0;
|
1998-06-15 19:05:27 +00:00
|
|
|
datalink_Down(p->dl, CLOSE_NORMAL);
|
1995-01-31 06:29:58 +00:00
|
|
|
} else
|
1998-03-13 00:44:26 +00:00
|
|
|
SendEchoReq(lcp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
1998-04-14 07:25:37 +00:00
|
|
|
if (p->hdlc.lqm.method && p->hdlc.lqm.timer.load)
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Start(&p->hdlc.lqm.timer);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
struct mbuf *
|
|
|
|
lqr_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1999-05-08 11:07:56 +00:00
|
|
|
struct physical *p = link2physical(l);
|
|
|
|
struct lcp *lcp = p->hdlc.lqm.owner;
|
1995-01-31 06:29:58 +00:00
|
|
|
int len;
|
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
log_Printf(LogERROR, "lqr_Input: Not a physical link - dropped\n");
|
|
|
|
mbuf_Free(bp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
p->hdlc.lqm.lqr.SaveInLQRs++;
|
|
|
|
|
1998-05-01 19:26:12 +00:00
|
|
|
len = mbuf_Length(bp);
|
1998-03-13 00:44:26 +00:00
|
|
|
if (len != sizeof(struct lqrdata))
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogWARN, "lqr_Input: Got packet size %d, expecting %ld !\n",
|
|
|
|
len, (long)sizeof(struct lqrdata));
|
1999-05-08 11:07:56 +00:00
|
|
|
else if (!IsAccepted(l->lcp.cfg.lqr) && !(p->hdlc.lqm.method & LQM_LQR)) {
|
|
|
|
bp = mbuf_Contiguous(proto_Prepend(bp, PROTO_LQR, 0, 0));
|
|
|
|
lcp_SendProtoRej(lcp, MBUF_CTOP(bp), bp->cnt);
|
1995-01-31 06:29:58 +00:00
|
|
|
} else {
|
1998-03-13 00:44:26 +00:00
|
|
|
struct lqrdata *lqr;
|
|
|
|
u_int32_t lastLQR;
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1999-03-29 08:21:28 +00:00
|
|
|
bp = mbuf_Contiguous(bp);
|
1998-03-13 00:44:26 +00:00
|
|
|
lqr = (struct lqrdata *)MBUF_CTOP(bp);
|
1999-05-08 11:07:56 +00:00
|
|
|
if (ntohl(lqr->MagicNumber) != lcp->his_magic)
|
1998-06-27 23:48:54 +00:00
|
|
|
log_Printf(LogWARN, "lqr_Input: magic 0x%08lx is wrong,"
|
|
|
|
" expecting 0x%08lx\n",
|
1999-05-08 11:07:56 +00:00
|
|
|
(u_long)ntohl(lqr->MagicNumber), (u_long)lcp->his_magic);
|
1998-03-13 00:44:26 +00:00
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Remember our PeerInLQRs, then convert byte order and save
|
|
|
|
*/
|
1999-05-08 11:07:56 +00:00
|
|
|
lastLQR = p->hdlc.lqm.lqr.peer.PeerInLQRs;
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1999-05-08 11:07:56 +00:00
|
|
|
lqr_ChangeOrder(lqr, &p->hdlc.lqm.lqr.peer);
|
|
|
|
lqr_Dump(l->name, "Input", &p->hdlc.lqm.lqr.peer);
|
1998-03-13 00:44:26 +00:00
|
|
|
/* we have received an LQR from peer */
|
1999-05-08 11:07:56 +00:00
|
|
|
p->hdlc.lqm.lqr.resent = 0;
|
1998-01-29 00:44:16 +00:00
|
|
|
|
1998-03-13 00:44:26 +00:00
|
|
|
/*
|
|
|
|
* Generate an LQR response if we're not running an LQR timer OR
|
|
|
|
* two successive LQR's PeerInLQRs are the same OR we're not going to
|
|
|
|
* send our next one before the peers max timeout.
|
|
|
|
*/
|
1999-05-08 11:07:56 +00:00
|
|
|
if (p->hdlc.lqm.timer.load == 0 ||
|
|
|
|
!(p->hdlc.lqm.method & LQM_LQR) ||
|
|
|
|
(lastLQR && lastLQR == p->hdlc.lqm.lqr.peer.PeerInLQRs) ||
|
|
|
|
(p->hdlc.lqm.lqr.peer_timeout &&
|
|
|
|
p->hdlc.lqm.timer.rest * 100 / SECTICKS >
|
|
|
|
p->hdlc.lqm.lqr.peer_timeout))
|
|
|
|
SendLqrData(lcp);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
1998-05-01 19:26:12 +00:00
|
|
|
mbuf_Free(bp);
|
1999-05-08 11:07:56 +00:00
|
|
|
return NULL;
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When LCP is reached to opened state, We'll start LQM activity.
|
|
|
|
*/
|
1998-05-08 01:15:19 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
lqr_Setup(struct lcp *lcp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-03-13 00:44:26 +00:00
|
|
|
struct physical *physical = link2physical(lcp->fsm.link);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.lqr.resent = 0;
|
|
|
|
physical->hdlc.lqm.echo.seq_sent = 0;
|
|
|
|
physical->hdlc.lqm.echo.seq_recv = 0;
|
|
|
|
memset(&physical->hdlc.lqm.lqr.peer, '\0',
|
|
|
|
sizeof physical->hdlc.lqm.lqr.peer);
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.method = LQM_ECHO;
|
1998-05-08 01:15:19 +00:00
|
|
|
if (IsEnabled(lcp->cfg.lqr) && !REJECTED(lcp, TY_QUALPROTO))
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.method |= LQM_LQR;
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&physical->hdlc.lqm.timer);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.lqr.peer_timeout = lcp->his_lqrperiod;
|
1998-03-12 02:23:42 +00:00
|
|
|
if (lcp->his_lqrperiod)
|
1998-05-08 01:15:19 +00:00
|
|
|
log_Printf(LogLQM, "%s: Expecting LQR every %d.%02d secs\n",
|
|
|
|
physical->link.name, lcp->his_lqrperiod / 100,
|
|
|
|
lcp->his_lqrperiod % 100);
|
1997-08-25 00:29:32 +00:00
|
|
|
|
1998-03-12 02:23:42 +00:00
|
|
|
if (lcp->want_lqrperiod) {
|
1998-05-08 01:15:19 +00:00
|
|
|
log_Printf(LogLQM, "%s: Will send %s every %d.%02d secs\n",
|
|
|
|
physical->link.name,
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.method & LQM_LQR ? "LQR" : "ECHO LQR",
|
|
|
|
lcp->want_lqrperiod / 100, lcp->want_lqrperiod % 100);
|
|
|
|
physical->hdlc.lqm.timer.load = lcp->want_lqrperiod * SECTICKS / 100;
|
|
|
|
physical->hdlc.lqm.timer.func = SendLqrReport;
|
1998-04-03 19:21:56 +00:00
|
|
|
physical->hdlc.lqm.timer.name = "lqm";
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.timer.arg = lcp;
|
1995-01-31 06:29:58 +00:00
|
|
|
} else {
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.timer.load = 0;
|
1998-03-12 02:23:42 +00:00
|
|
|
if (!lcp->his_lqrperiod)
|
1998-05-08 01:15:19 +00:00
|
|
|
log_Printf(LogLQM, "%s: LQR/ECHO LQR not negotiated\n",
|
|
|
|
physical->link.name);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-01-30 11:08:50 +00:00
|
|
|
void
|
1998-05-08 01:15:19 +00:00
|
|
|
lqr_Start(struct lcp *lcp)
|
1996-01-30 11:08:50 +00:00
|
|
|
{
|
1998-05-08 01:15:19 +00:00
|
|
|
struct physical *p = link2physical(lcp->fsm.link);
|
|
|
|
|
|
|
|
lqr_Setup(lcp);
|
|
|
|
if (p->hdlc.lqm.timer.load)
|
|
|
|
SendLqrReport(lcp);
|
1996-01-30 11:08:50 +00:00
|
|
|
}
|
|
|
|
|
1995-01-31 06:29:58 +00:00
|
|
|
void
|
1998-05-08 01:15:19 +00:00
|
|
|
lqr_reStart(struct lcp *lcp)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-08 01:15:19 +00:00
|
|
|
struct physical *p = link2physical(lcp->fsm.link);
|
1995-01-31 06:29:58 +00:00
|
|
|
|
1998-05-08 01:15:19 +00:00
|
|
|
lqr_Setup(lcp);
|
|
|
|
if (p->hdlc.lqm.timer.load)
|
|
|
|
timer_Start(&p->hdlc.lqm.timer);
|
|
|
|
}
|
|
|
|
|
1998-01-29 00:44:16 +00:00
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
lqr_StopTimer(struct physical *physical)
|
1998-01-29 00:44:16 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&physical->hdlc.lqm.timer);
|
1998-01-29 00:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-01 19:26:12 +00:00
|
|
|
lqr_Stop(struct physical *physical, int method)
|
1998-01-29 00:44:16 +00:00
|
|
|
{
|
1995-01-31 06:29:58 +00:00
|
|
|
if (method == LQM_LQR)
|
1998-05-08 01:15:19 +00:00
|
|
|
log_Printf(LogLQM, "%s: Stop sending LQR, Use LCP ECHO instead.\n",
|
|
|
|
physical->link.name);
|
1995-01-31 06:29:58 +00:00
|
|
|
if (method == LQM_ECHO)
|
1998-05-08 01:15:19 +00:00
|
|
|
log_Printf(LogLQM, "%s: Stop sending LCP ECHO.\n",
|
|
|
|
physical->link.name);
|
1998-03-13 00:44:26 +00:00
|
|
|
physical->hdlc.lqm.method &= ~method;
|
|
|
|
if (physical->hdlc.lqm.method)
|
|
|
|
SendLqrReport(physical->hdlc.lqm.owner);
|
1995-01-31 06:29:58 +00:00
|
|
|
else
|
1998-05-01 19:26:12 +00:00
|
|
|
timer_Stop(&physical->hdlc.lqm.timer);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-05-08 01:15:19 +00:00
|
|
|
lqr_Dump(const char *link, const char *message, const struct lqrdata *lqr)
|
1995-01-31 06:29:58 +00:00
|
|
|
{
|
1998-05-01 19:26:12 +00:00
|
|
|
if (log_IsKept(LogLQM)) {
|
|
|
|
log_Printf(LogLQM, "%s: %s:\n", link, message);
|
|
|
|
log_Printf(LogLQM, " Magic: %08x LastOutLQRs: %08x\n",
|
1997-06-09 03:27:43 +00:00
|
|
|
lqr->MagicNumber, lqr->LastOutLQRs);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogLQM, " LastOutPackets: %08x LastOutOctets: %08x\n",
|
1997-06-09 03:27:43 +00:00
|
|
|
lqr->LastOutPackets, lqr->LastOutOctets);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogLQM, " PeerInLQRs: %08x PeerInPackets: %08x\n",
|
1997-06-09 03:27:43 +00:00
|
|
|
lqr->PeerInLQRs, lqr->PeerInPackets);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogLQM, " PeerInDiscards: %08x PeerInErrors: %08x\n",
|
1997-06-09 03:27:43 +00:00
|
|
|
lqr->PeerInDiscards, lqr->PeerInErrors);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogLQM, " PeerInOctets: %08x PeerOutLQRs: %08x\n",
|
1997-06-09 03:27:43 +00:00
|
|
|
lqr->PeerInOctets, lqr->PeerOutLQRs);
|
1998-05-01 19:26:12 +00:00
|
|
|
log_Printf(LogLQM, " PeerOutPackets: %08x PeerOutOctets: %08x\n",
|
1997-06-09 03:27:43 +00:00
|
|
|
lqr->PeerOutPackets, lqr->PeerOutOctets);
|
1995-01-31 06:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
1999-05-08 11:07:56 +00:00
|
|
|
|
|
|
|
static struct mbuf *
|
|
|
|
lqr_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp,
|
|
|
|
int pri, u_short *proto)
|
|
|
|
{
|
|
|
|
struct physical *p = link2physical(l);
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if (!p) {
|
|
|
|
/* Oops - can't happen :-] */
|
|
|
|
mbuf_Free(bp);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* From rfc1989:
|
|
|
|
*
|
|
|
|
* All octets which are included in the FCS calculation MUST be counted,
|
|
|
|
* including the packet header, the information field, and any padding.
|
|
|
|
* The FCS octets MUST also be counted, and one flag octet per frame
|
|
|
|
* MUST be counted. All other octets (such as additional flag
|
|
|
|
* sequences, and escape bits or octets) MUST NOT be counted.
|
|
|
|
*
|
|
|
|
* As we're stacked before the HDLC layer (otherwise HDLC wouldn't be
|
|
|
|
* able to calculate the FCS), we must not forget about these additional
|
|
|
|
* bytes when we're asynchronous.
|
|
|
|
*
|
|
|
|
* We're also expecting to be stacked *before* the proto and acf layers.
|
|
|
|
* If we were after these, it makes alignment more of a pain, and we
|
|
|
|
* don't do LQR without these layers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bp = mbuf_Contiguous(bp);
|
|
|
|
len = mbuf_Length(bp);
|
|
|
|
|
|
|
|
if (!physical_IsSync(p))
|
|
|
|
p->hdlc.lqm.OutOctets += hdlc_WrapperOctets(&l->lcp, *proto);
|
|
|
|
p->hdlc.lqm.OutOctets += acf_WrapperOctets(&l->lcp, *proto) +
|
|
|
|
proto_WrapperOctets(&l->lcp, *proto) + len + 1;
|
|
|
|
p->hdlc.lqm.OutPackets++;
|
|
|
|
|
|
|
|
if (*proto == PROTO_LQR) {
|
|
|
|
/* Overwrite the entire packet */
|
|
|
|
struct lqrdata lqr;
|
|
|
|
|
|
|
|
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;
|
|
|
|
lqr.PeerInLQRs = p->hdlc.lqm.lqr.SaveInLQRs;
|
|
|
|
lqr.PeerInPackets = p->hdlc.lqm.SaveInPackets;
|
|
|
|
lqr.PeerInDiscards = p->hdlc.lqm.SaveInDiscards;
|
|
|
|
lqr.PeerInErrors = p->hdlc.lqm.SaveInErrors;
|
|
|
|
lqr.PeerInOctets = p->hdlc.lqm.SaveInOctets;
|
|
|
|
lqr.PeerOutPackets = p->hdlc.lqm.OutPackets;
|
|
|
|
lqr.PeerOutOctets = p->hdlc.lqm.OutOctets;
|
|
|
|
if (p->hdlc.lqm.lqr.peer.LastOutLQRs == p->hdlc.lqm.lqr.OutLQRs) {
|
|
|
|
/*
|
|
|
|
* only increment if it's the first time or we've got a reply
|
|
|
|
* from the last one
|
|
|
|
*/
|
|
|
|
lqr.PeerOutLQRs = ++p->hdlc.lqm.lqr.OutLQRs;
|
|
|
|
lqr_Dump(l->name, "Output", &lqr);
|
|
|
|
} else {
|
|
|
|
lqr.PeerOutLQRs = p->hdlc.lqm.lqr.OutLQRs;
|
|
|
|
lqr_Dump(l->name, "Output (again)", &lqr);
|
|
|
|
}
|
|
|
|
lqr_ChangeOrder(&lqr, (struct lqrdata *)MBUF_CTOP(bp));
|
|
|
|
}
|
|
|
|
|
|
|
|
return bp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Statistics for pulled packets are recorded either in hdlc_PullPacket()
|
|
|
|
* or sync_PullPacket()
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct layer lqrlayer = { LAYER_LQR, "lqr", lqr_LayerPush, NULL };
|