hdlc.h revision 36285
16059Samurai/*
26059Samurai *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
36059Samurai *
46059Samurai *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
56059Samurai *
66059Samurai * Redistribution and use in source and binary forms are permitted
76059Samurai * provided that the above copyright notice and this paragraph are
86059Samurai * duplicated in all such forms and that any documentation,
96059Samurai * advertising materials, and other materials related to such
106059Samurai * distribution and use acknowledge that the software was developed
116059Samurai * by the Internet Initiative Japan.  The name of the
126059Samurai * IIJ may not be used to endorse or promote products derived
136059Samurai * from this software without specific prior written permission.
146059Samurai * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
156059Samurai * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
166059Samurai * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
176059Samurai *
1836285Sbrian * $Id: hdlc.h,v 1.14.2.12 1998/05/01 19:24:39 brian Exp $
196059Samurai *
206059Samurai *	TODO:
216059Samurai */
226059Samurai
236059Samurai/*
246059Samurai *  Definition for Async HDLC
256059Samurai */
2628679Sbrian#define HDLC_SYN 0x7e		/* SYNC character */
2728679Sbrian#define HDLC_ESC 0x7d		/* Escape character */
2828679Sbrian#define HDLC_XOR 0x20		/* Modifier value */
296059Samurai
306059Samurai#define	HDLC_ADDR 0xff
316059Samurai#define	HDLC_UI	  0x03
326059Samurai/*
336059Samurai *  Definition for HDLC Frame Check Sequence
346059Samurai */
3528679Sbrian#define INITFCS 0xffff		/* Initial value for FCS computation */
3628679Sbrian#define GOODFCS 0xf0b8		/* Good FCS value */
376059Samurai
386059Samurai#define	DEF_MRU		1500
3926341Sbrian#define	MAX_MRU		2048
406059Samurai#define	MIN_MRU		296
416059Samurai
4226326Sbrian#define	DEF_MTU		0	/* whatever peer says */
4326341Sbrian#define	MAX_MTU		2048
4426326Sbrian#define	MIN_MTU		296
4526326Sbrian
466059Samurai/*
476059Samurai *  Output priority
486059Samurai */
4913733Sdfr/* PRI_NORMAL and PRI_FAST have meaning only on the IP queue.
5013733Sdfr * All IP frames have the same priority once they are compressed.
5113733Sdfr * IP frames stay on the IP queue till they can be sent on the
5213733Sdfr * link. They are compressed at that time.
5313733Sdfr*/
546059Samurai#define	PRI_NORMAL	0	/* Normal priority */
5513733Sdfr#define	PRI_FAST	1	/* Fast (interractive) */
5613733Sdfr#define	PRI_LINK	1	/* Urgent (LQR packets) */
5736285Sbrian#define	PRI_MAX		1
586059Samurai
5936285Sbrianstruct physical;
6036285Sbrianstruct link;
6136285Sbrianstruct lcp;
6236285Sbrianstruct bundle;
6336285Sbrianstruct mbuf;
6436285Sbrianstruct cmdargs;
656059Samurai
6636285Sbrianstruct hdlc {
6736285Sbrian  struct pppTimer ReportTimer;
6836285Sbrian
6936285Sbrian  struct {
7036285Sbrian    int badfcs;
7136285Sbrian    int badaddr;
7236285Sbrian    int badcommand;
7336285Sbrian    int unknownproto;
7436285Sbrian  } laststats, stats;
7536285Sbrian
7636285Sbrian  struct {
7736285Sbrian    struct lcp *owner;			/* parent LCP */
7836285Sbrian    struct pppTimer timer;		/* When to send */
7936285Sbrian    int method;				/* bit-mask for LQM_* from lqr.h */
8036285Sbrian
8136285Sbrian    u_int32_t OutPackets;		/* Packets sent by me */
8236285Sbrian    u_int32_t OutOctets;		/* Octets sent by me */
8336285Sbrian    u_int32_t SaveInPackets;		/* Packets received from peer */
8436285Sbrian    u_int32_t SaveInDiscards;		/* Discards */
8536285Sbrian    u_int32_t SaveInErrors;		/* Errors */
8636285Sbrian    u_int32_t SaveInOctets;		/* Octets received from peer */
8736285Sbrian
8836285Sbrian    struct {
8936285Sbrian      u_int32_t OutLQRs;		/* LQRs sent by me */
9036285Sbrian      u_int32_t SaveInLQRs;		/* LQRs received from peer */
9136285Sbrian      struct lqrdata peer;		/* Last LQR from peer */
9236285Sbrian      int peer_timeout;			/* peers max lqr timeout */
9336285Sbrian      int resent;			/* Resent last packet `resent' times */
9436285Sbrian    } lqr;
9536285Sbrian
9636285Sbrian    struct {
9736285Sbrian      u_int32_t seq_sent;		/* last echo sent */
9836285Sbrian      u_int32_t seq_recv;		/* last echo received */
9936285Sbrian    } echo;
10036285Sbrian  } lqm;
10136285Sbrian};
10236285Sbrian
10336285Sbrian
10436285Sbrianextern void hdlc_Init(struct hdlc *, struct lcp *);
10536285Sbrianextern void hdlc_StartTimer(struct hdlc *);
10636285Sbrianextern void hdlc_StopTimer(struct hdlc *);
10736285Sbrianextern int hdlc_ReportStatus(struct cmdargs const *);
10836285Sbrianextern const char *hdlc_Protocol2Nam(u_short);
10936285Sbrianextern void hdlc_DecodePacket(struct bundle *, u_short, struct mbuf *,
11036285Sbrian                              struct link *);
11136285Sbrian
11236285Sbrianextern void hdlc_Input(struct bundle *, struct mbuf *, struct physical *);
11336285Sbrianextern void hdlc_Output(struct link *, int, u_short, struct mbuf *bp);
11436285Sbrianextern u_short hdlc_Fcs(u_short, u_char *, int);
11536285Sbrianextern u_char *hdlc_Detect(struct physical *, u_char *, int);
116