xref: /freebsd/usr.sbin/ppp/hdlc.h (revision 3b0f8d2e)
1 /*
2  *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
3  *
4  *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
5  *
6  * Redistribution and use in source and binary forms are permitted
7  * provided that the above copyright notice and this paragraph are
8  * duplicated in all such forms and that any documentation,
9  * advertising materials, and other materials related to such
10  * distribution and use acknowledge that the software was developed
11  * by the Internet Initiative Japan.  The name of the
12  * IIJ may not be used to endorse or promote products derived
13  * from this software without specific prior written permission.
14  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  * $Id: hdlc.h,v 1.14.2.7 1998/03/13 00:44:04 brian Exp $
19  *
20  *	TODO:
21  */
22 
23 /*
24  *  Definition for Async HDLC
25  */
26 #define HDLC_SYN 0x7e		/* SYNC character */
27 #define HDLC_ESC 0x7d		/* Escape character */
28 #define HDLC_XOR 0x20		/* Modifier value */
29 
30 #define	HDLC_ADDR 0xff
31 #define	HDLC_UI	  0x03
32 /*
33  *  Definition for HDLC Frame Check Sequence
34  */
35 #define INITFCS 0xffff		/* Initial value for FCS computation */
36 #define GOODFCS 0xf0b8		/* Good FCS value */
37 
38 #define	DEF_MRU		1500
39 #define	MAX_MRU		2048
40 #define	MIN_MRU		296
41 
42 #define	DEF_MTU		0	/* whatever peer says */
43 #define	MAX_MTU		2048
44 #define	MIN_MTU		296
45 
46 /*
47  *  Output priority
48  */
49 /* PRI_NORMAL and PRI_FAST have meaning only on the IP queue.
50  * All IP frames have the same priority once they are compressed.
51  * IP frames stay on the IP queue till they can be sent on the
52  * link. They are compressed at that time.
53 */
54 #define	PRI_NORMAL	0	/* Normal priority */
55 #define	PRI_FAST	1	/* Fast (interractive) */
56 #define	PRI_LINK	1	/* Urgent (LQR packets) */
57 #define	PRI_MAX		1
58 
59 struct physical;
60 struct link;
61 
62 struct hdlc {
63   struct pppTimer ReportTimer;
64 
65   struct {
66     int badfcs;
67     int badaddr;
68     int badcommand;
69     int unknownproto;
70   } laststats, stats;
71 
72   struct {
73     struct lcp *owner;			/* parent LCP */
74     struct pppTimer timer;		/* When to send */
75     int method;				/* bit-mask for LQM_* from lqr.h */
76 
77     u_int32_t OutPackets;		/* Packets sent by me */
78     u_int32_t OutOctets;		/* Octets sent by me */
79     u_int32_t SaveInPackets;		/* Packets received from peer */
80     u_int32_t SaveInDiscards;		/* Discards */
81     u_int32_t SaveInErrors;		/* Errors */
82     u_int32_t SaveInOctets;		/* Octets received from peer */
83 
84     struct {
85       u_int32_t OutLQRs;		/* LQRs sent by me */
86       u_int32_t SaveInLQRs;		/* LQRs received from peer */
87       struct lqrdata peer;		/* Last LQR from peer */
88       int peer_timeout;			/* peers max lqr timeout */
89       int resent;			/* Resent last packet `resent' times */
90     } lqr;
91 
92     struct {
93       u_int32_t seq_sent;		/* last echo sent */
94       u_int32_t seq_recv;		/* last echo received */
95     } echo;
96   } lqm;
97 
98 };
99 
100 
101 extern void hdlc_Init(struct hdlc *);
102 extern void hdlc_StartTimer(struct hdlc *);
103 extern void hdlc_StopTimer(struct hdlc *);
104 extern int hdlc_ReportStatus(struct cmdargs const *);
105 extern const char *hdlc_Protocol2Nam(u_short);
106 
107 extern void HdlcInput(struct bundle *, struct mbuf *, struct physical *);
108 extern void HdlcOutput(struct link *, int, u_short, struct mbuf *bp);
109 extern u_short HdlcFcs(u_short, u_char *, int);
110 extern int ReportProtStatus(struct cmdargs const *);
111 extern u_char *HdlcDetect(struct physical *, u_char *, int);
112 extern void hdlc_DecodePacket(struct bundle *, u_short, struct mbuf *,
113                               struct link *);
114