178189Sbrian/*-
278189Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
378189Sbrian *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
478189Sbrian *                           Internet Initiative Japan, Inc (IIJ)
578189Sbrian * All rights reserved.
66059Samurai *
778189Sbrian * Redistribution and use in source and binary forms, with or without
878189Sbrian * modification, are permitted provided that the following conditions
978189Sbrian * are met:
1078189Sbrian * 1. Redistributions of source code must retain the above copyright
1178189Sbrian *    notice, this list of conditions and the following disclaimer.
1278189Sbrian * 2. Redistributions in binary form must reproduce the above copyright
1378189Sbrian *    notice, this list of conditions and the following disclaimer in the
1478189Sbrian *    documentation and/or other materials provided with the distribution.
156059Samurai *
1678189Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1778189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1878189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1978189Sbrian * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2078189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2178189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2278189Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2378189Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2478189Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2578189Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2678189Sbrian * SUCH DAMAGE.
276059Samurai *
2850479Speter * $FreeBSD$
296059Samurai */
306059Samurai
316059Samurai/*
3236285Sbrian *  Structure of LQR packet defined in RFC1989
336059Samurai */
346059Samuraistruct lqrdata {
3532439Sbrian  u_int32_t MagicNumber;
3636285Sbrian  u_int32_t LastOutLQRs;	/* most recently received PeerOutLQRs */
3736285Sbrian  u_int32_t LastOutPackets;	/* most recently received PeerOutPackets */
3836285Sbrian  u_int32_t LastOutOctets;	/* most recently received PeerOutOctets */
3936285Sbrian  u_int32_t PeerInLQRs;		/* Peers SaveInLQRs */
4036285Sbrian  u_int32_t PeerInPackets;	/* Peers SaveInPackets */
4136285Sbrian  u_int32_t PeerInDiscards;	/* Peers SaveInDiscards */
4236285Sbrian  u_int32_t PeerInErrors;	/* Peers SaveInErrors */
4336285Sbrian  u_int32_t PeerInOctets;	/* Peers SaveInOctets */
4436285Sbrian  u_int32_t PeerOutLQRs;	/* Peers OutLQRs (hdlc.h) */
4536285Sbrian  u_int32_t PeerOutPackets;	/* Peers OutPackets (hdlc.h) */
4636285Sbrian  u_int32_t PeerOutOctets;	/* Peers OutOctets (hdlc.h) */
476059Samurai};
486059Samurai
49131327Sbrianstruct lqrsavedata {	/* Saved on receipt of an LQR */
50131327Sbrian  u_int32_t InLQRs;	/* From ifInLQRs */
51131327Sbrian  u_int32_t InPackets;	/* From ifInPackets */
52131327Sbrian  u_int32_t InDiscards;	/* From ifInDiscards */
53131327Sbrian  u_int32_t InErrors;	/* From ifInErrors */
54131327Sbrian  u_int32_t InOctets;	/* From InGoodOctets ! */
55131327Sbrian};
56131327Sbrian
576059Samurai/*
586059Samurai *  We support LQR and ECHO as LQM method
596059Samurai */
606059Samurai#define	LQM_LQR	  1
616059Samurai#define	LQM_ECHO  2
626059Samurai
6336285Sbrianstruct mbuf;
6436285Sbrianstruct physical;
6536285Sbrianstruct lcp;
6636285Sbrianstruct fsm;
67131327Sbrianstruct hdlc;
6846686Sbrianstruct link;
6946686Sbrianstruct bundle;
7036285Sbrian
7136285Sbrianextern void lqr_Dump(const char *, const char *, const struct lqrdata *);
72131327Sbrianextern void lqr_Analyse(const struct hdlc *, const struct lqrdata *,
73131327Sbrian                        const struct lqrdata *);
7436285Sbrianextern void lqr_ChangeOrder(struct lqrdata *, struct lqrdata *);
7536285Sbrianextern void lqr_Start(struct lcp *);
7636285Sbrianextern void lqr_reStart(struct lcp *);
7736285Sbrianextern void lqr_Stop(struct physical *, int);
7836285Sbrianextern void lqr_StopTimer(struct physical *);
7946828Sbrianextern struct mbuf *lqr_RecvEcho(struct fsm *, struct mbuf *);
8046686Sbrianextern struct mbuf *lqr_Input(struct bundle *, struct link *, struct mbuf *);
8146686Sbrian
8246686Sbrianextern struct layer lqrlayer;
83