xref: /freebsd/usr.sbin/ppp/hdlc.c (revision 147613eadf80e250bb3a6837dde6b077d09a3e6d)
11ae349f5Scvs2svn /*
21ae349f5Scvs2svn  *	     PPP High Level Link Control (HDLC) Module
31ae349f5Scvs2svn  *
41ae349f5Scvs2svn  *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
51ae349f5Scvs2svn  *
61ae349f5Scvs2svn  *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
71ae349f5Scvs2svn  *
81ae349f5Scvs2svn  * Redistribution and use in source and binary forms are permitted
91ae349f5Scvs2svn  * provided that the above copyright notice and this paragraph are
101ae349f5Scvs2svn  * duplicated in all such forms and that any documentation,
111ae349f5Scvs2svn  * advertising materials, and other materials related to such
121ae349f5Scvs2svn  * distribution and use acknowledge that the software was developed
131ae349f5Scvs2svn  * by the Internet Initiative Japan, Inc.  The name of the
141ae349f5Scvs2svn  * IIJ may not be used to endorse or promote products derived
151ae349f5Scvs2svn  * from this software without specific prior written permission.
161ae349f5Scvs2svn  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
171ae349f5Scvs2svn  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
181ae349f5Scvs2svn  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
191ae349f5Scvs2svn  *
20147613eaSBrian Somers  * $Id: hdlc.c,v 1.28.2.32 1998/05/03 11:24:13 brian Exp $
211ae349f5Scvs2svn  *
221ae349f5Scvs2svn  *	TODO:
231ae349f5Scvs2svn  */
242764b86aSBrian Somers #include <sys/types.h>
251ae349f5Scvs2svn #include <netinet/in.h>
26eaa4df37SBrian Somers #include <netinet/in_systm.h>
27eaa4df37SBrian Somers #include <netinet/ip.h>
281fa665f5SBrian Somers #include <sys/un.h>
291ae349f5Scvs2svn 
301ae349f5Scvs2svn #include <stdio.h>
311ae349f5Scvs2svn #include <string.h>
321ae349f5Scvs2svn #include <termios.h>
331ae349f5Scvs2svn 
341ae349f5Scvs2svn #include "command.h"
351ae349f5Scvs2svn #include "mbuf.h"
361ae349f5Scvs2svn #include "log.h"
371ae349f5Scvs2svn #include "defs.h"
381ae349f5Scvs2svn #include "timer.h"
391ae349f5Scvs2svn #include "fsm.h"
40879ed6faSBrian Somers #include "lqr.h"
411ae349f5Scvs2svn #include "hdlc.h"
421ae349f5Scvs2svn #include "lcpproto.h"
4329e275ceSBrian Somers #include "iplist.h"
4429e275ceSBrian Somers #include "throughput.h"
45eaa4df37SBrian Somers #include "slcompress.h"
461ae349f5Scvs2svn #include "ipcp.h"
471ae349f5Scvs2svn #include "ip.h"
481ae349f5Scvs2svn #include "vjcomp.h"
49e2ebb036SBrian Somers #include "auth.h"
501ae349f5Scvs2svn #include "pap.h"
511ae349f5Scvs2svn #include "chap.h"
521ae349f5Scvs2svn #include "lcp.h"
531ae349f5Scvs2svn #include "async.h"
541ae349f5Scvs2svn #include "ccp.h"
558c07a7b2SBrian Somers #include "link.h"
5642d4d396SBrian Somers #include "descriptor.h"
5763b73463SBrian Somers #include "physical.h"
5885b542cfSBrian Somers #include "prompt.h"
5963258dccSBrian Somers #include "chat.h"
603b0f8d2eSBrian Somers #include "mp.h"
6163258dccSBrian Somers #include "datalink.h"
625ca5389aSBrian Somers #include "filter.h"
63503a7782SBrian Somers #include "bundle.h"
641ae349f5Scvs2svn 
651ae349f5Scvs2svn static u_short const fcstab[256] = {
661ae349f5Scvs2svn    /* 00 */ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
671ae349f5Scvs2svn    /* 08 */ 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
681ae349f5Scvs2svn    /* 10 */ 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
691ae349f5Scvs2svn    /* 18 */ 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
701ae349f5Scvs2svn    /* 20 */ 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
711ae349f5Scvs2svn    /* 28 */ 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
721ae349f5Scvs2svn    /* 30 */ 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
731ae349f5Scvs2svn    /* 38 */ 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
741ae349f5Scvs2svn    /* 40 */ 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
751ae349f5Scvs2svn    /* 48 */ 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
761ae349f5Scvs2svn    /* 50 */ 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
771ae349f5Scvs2svn    /* 58 */ 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
781ae349f5Scvs2svn    /* 60 */ 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
791ae349f5Scvs2svn    /* 68 */ 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
801ae349f5Scvs2svn    /* 70 */ 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
811ae349f5Scvs2svn    /* 78 */ 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
821ae349f5Scvs2svn    /* 80 */ 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
831ae349f5Scvs2svn    /* 88 */ 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
841ae349f5Scvs2svn    /* 90 */ 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
851ae349f5Scvs2svn    /* 98 */ 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
861ae349f5Scvs2svn    /* a0 */ 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
871ae349f5Scvs2svn    /* a8 */ 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
881ae349f5Scvs2svn    /* b0 */ 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
891ae349f5Scvs2svn    /* b8 */ 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
901ae349f5Scvs2svn    /* c0 */ 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
911ae349f5Scvs2svn    /* c8 */ 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
921ae349f5Scvs2svn    /* d0 */ 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
931ae349f5Scvs2svn    /* d8 */ 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
941ae349f5Scvs2svn    /* e0 */ 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
951ae349f5Scvs2svn    /* e8 */ 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
961ae349f5Scvs2svn    /* f0 */ 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
971ae349f5Scvs2svn    /* f8 */ 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
981ae349f5Scvs2svn };
991ae349f5Scvs2svn 
1001ae349f5Scvs2svn void
101643f4904SBrian Somers hdlc_Init(struct hdlc *hdlc, struct lcp *lcp)
1021ae349f5Scvs2svn {
10363258dccSBrian Somers   memset(hdlc, '\0', sizeof(struct hdlc));
104643f4904SBrian Somers   hdlc->lqm.owner = lcp;
1051ae349f5Scvs2svn }
1061ae349f5Scvs2svn 
1071ae349f5Scvs2svn /*
1081ae349f5Scvs2svn  *  HDLC FCS computation. Read RFC 1171 Appendix B and CCITT X.25 section
1091ae349f5Scvs2svn  *  2.27 for further details.
1101ae349f5Scvs2svn  */
1111ae349f5Scvs2svn inline u_short
112dd7e2610SBrian Somers hdlc_Fcs(u_short fcs, u_char * cp, int len)
1131ae349f5Scvs2svn {
1141ae349f5Scvs2svn   while (len--)
1151ae349f5Scvs2svn     fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
1161ae349f5Scvs2svn   return (fcs);
1171ae349f5Scvs2svn }
1181ae349f5Scvs2svn 
1191ae349f5Scvs2svn static inline u_short
1201ae349f5Scvs2svn HdlcFcsBuf(u_short fcs, struct mbuf *m)
1211ae349f5Scvs2svn {
1221ae349f5Scvs2svn   int len;
1231ae349f5Scvs2svn   u_char *pos, *end;
1241ae349f5Scvs2svn 
125dd7e2610SBrian Somers   len = mbuf_Length(m);
1261ae349f5Scvs2svn   pos = MBUF_CTOP(m);
1271ae349f5Scvs2svn   end = pos + m->cnt;
1281ae349f5Scvs2svn   while (len--) {
1291ae349f5Scvs2svn     fcs = (fcs >> 8) ^ fcstab[(fcs ^ *pos++) & 0xff];
1301ae349f5Scvs2svn     if (pos == end && len) {
1311ae349f5Scvs2svn       m = m->next;
1321ae349f5Scvs2svn       pos = MBUF_CTOP(m);
1331ae349f5Scvs2svn       end = pos + m->cnt;
1341ae349f5Scvs2svn     }
1351ae349f5Scvs2svn   }
1361ae349f5Scvs2svn   return (fcs);
1371ae349f5Scvs2svn }
1381ae349f5Scvs2svn 
1391ae349f5Scvs2svn void
140dd7e2610SBrian Somers hdlc_Output(struct link *l, int pri, u_short proto, struct mbuf *bp)
1411ae349f5Scvs2svn {
1428c07a7b2SBrian Somers   struct physical *p = link2physical(l);
1431ae349f5Scvs2svn   struct mbuf *mhp, *mfcs;
1441ae349f5Scvs2svn   u_char *cp;
1451ae349f5Scvs2svn   u_short fcs;
1461ae349f5Scvs2svn 
147dd7e2610SBrian Somers   if (!p || physical_IsSync(p))
1481ae349f5Scvs2svn     mfcs = NULL;
1491ae349f5Scvs2svn   else
150dd7e2610SBrian Somers     mfcs = mbuf_Alloc(2, MB_HDLCOUT);
1511ae349f5Scvs2svn 
152dd7e2610SBrian Somers   mhp = mbuf_Alloc(4, MB_HDLCOUT);
1531ae349f5Scvs2svn   mhp->cnt = 0;
1541ae349f5Scvs2svn   cp = MBUF_CTOP(mhp);
155673903ecSBrian Somers   if (p && (proto == PROTO_LCP || l->lcp.his_acfcomp == 0)) {
1561ae349f5Scvs2svn     *cp++ = HDLC_ADDR;
1571ae349f5Scvs2svn     *cp++ = HDLC_UI;
1581ae349f5Scvs2svn     mhp->cnt += 2;
1591ae349f5Scvs2svn   }
1601ae349f5Scvs2svn 
1611ae349f5Scvs2svn   /*
1621ae349f5Scvs2svn    * If possible, compress protocol field.
1631ae349f5Scvs2svn    */
164673903ecSBrian Somers   if (l->lcp.his_protocomp && (proto & 0xff00) == 0) {
1651ae349f5Scvs2svn     *cp++ = proto;
1661ae349f5Scvs2svn     mhp->cnt++;
1671ae349f5Scvs2svn   } else {
1681ae349f5Scvs2svn     *cp++ = proto >> 8;
1691ae349f5Scvs2svn     *cp = proto & 0377;
1701ae349f5Scvs2svn     mhp->cnt += 2;
1711ae349f5Scvs2svn   }
1728c07a7b2SBrian Somers 
1731ae349f5Scvs2svn   mhp->next = bp;
174673903ecSBrian Somers 
175673903ecSBrian Somers   if (!p) {
176673903ecSBrian Somers     /*
177673903ecSBrian Somers      * This is where we multiplex the data over our available physical
178673903ecSBrian Somers      * links.  We don't frame our logical link data.  Instead we wait
179673903ecSBrian Somers      * for the logical link implementation to chop our data up and pile
180673903ecSBrian Somers      * it into the physical links by re-calling this function with the
181673903ecSBrian Somers      * encapsulated fragments.
182673903ecSBrian Somers      */
183673903ecSBrian Somers     link_Output(l, pri, mhp);
184673903ecSBrian Somers     return;
185673903ecSBrian Somers   }
186673903ecSBrian Somers 
187673903ecSBrian Somers   /* Tack mfcs onto the end, then set bp back to the start of the data */
1881ae349f5Scvs2svn   while (bp->next != NULL)
1891ae349f5Scvs2svn     bp = bp->next;
1901ae349f5Scvs2svn   bp->next = mfcs;
1911ae349f5Scvs2svn   bp = mhp->next;
1921ae349f5Scvs2svn 
193dd7e2610SBrian Somers   p->hdlc.lqm.OutOctets += mbuf_Length(mhp) + 1;
194879ed6faSBrian Somers   p->hdlc.lqm.OutPackets++;
1951ae349f5Scvs2svn 
1961ae349f5Scvs2svn   if (proto == PROTO_LQR) {
197879ed6faSBrian Somers     /* Overwrite the entire packet */
198879ed6faSBrian Somers     struct lqrdata lqr;
199879ed6faSBrian Somers 
2003b0f8d2eSBrian Somers     lqr.MagicNumber = p->link.lcp.want_magic;
201879ed6faSBrian Somers     lqr.LastOutLQRs = p->hdlc.lqm.lqr.peer.PeerOutLQRs;
202879ed6faSBrian Somers     lqr.LastOutPackets = p->hdlc.lqm.lqr.peer.PeerOutPackets;
203879ed6faSBrian Somers     lqr.LastOutOctets = p->hdlc.lqm.lqr.peer.PeerOutOctets;
204879ed6faSBrian Somers     lqr.PeerInLQRs = p->hdlc.lqm.lqr.SaveInLQRs;
205879ed6faSBrian Somers     lqr.PeerInPackets = p->hdlc.lqm.SaveInPackets;
206879ed6faSBrian Somers     lqr.PeerInDiscards = p->hdlc.lqm.SaveInDiscards;
207879ed6faSBrian Somers     lqr.PeerInErrors = p->hdlc.lqm.SaveInErrors;
208879ed6faSBrian Somers     lqr.PeerInOctets = p->hdlc.lqm.SaveInOctets;
209879ed6faSBrian Somers     lqr.PeerOutPackets = p->hdlc.lqm.OutPackets;
210879ed6faSBrian Somers     lqr.PeerOutOctets = p->hdlc.lqm.OutOctets;
211879ed6faSBrian Somers     if (p->hdlc.lqm.lqr.peer.LastOutLQRs == p->hdlc.lqm.lqr.OutLQRs) {
212879ed6faSBrian Somers       /*
213879ed6faSBrian Somers        * only increment if it's the first time or we've got a reply
214879ed6faSBrian Somers        * from the last one
215879ed6faSBrian Somers        */
216879ed6faSBrian Somers       lqr.PeerOutLQRs = ++p->hdlc.lqm.lqr.OutLQRs;
217dd7e2610SBrian Somers       lqr_Dump(l->name, "Output", &lqr);
218879ed6faSBrian Somers     } else {
219879ed6faSBrian Somers       lqr.PeerOutLQRs = p->hdlc.lqm.lqr.OutLQRs;
220dd7e2610SBrian Somers       lqr_Dump(l->name, "Output (again)", &lqr);
221879ed6faSBrian Somers     }
222dd7e2610SBrian Somers     lqr_ChangeOrder(&lqr, (struct lqrdata *)MBUF_CTOP(bp));
2231ae349f5Scvs2svn   }
2248c07a7b2SBrian Somers 
2258c07a7b2SBrian Somers   if (mfcs) {
2261ae349f5Scvs2svn     mfcs->cnt = 0;
2271ae349f5Scvs2svn     fcs = HdlcFcsBuf(INITFCS, mhp);
2281ae349f5Scvs2svn     fcs = ~fcs;
2291ae349f5Scvs2svn     cp = MBUF_CTOP(mfcs);
2301ae349f5Scvs2svn     *cp++ = fcs & 0377;		/* Low byte first!! */
2311ae349f5Scvs2svn     *cp++ = fcs >> 8;
2321ae349f5Scvs2svn     mfcs->cnt = 2;
2331ae349f5Scvs2svn   }
2341ae349f5Scvs2svn 
235dd7e2610SBrian Somers   log_DumpBp(LogHDLC, "hdlc_Output", mhp);
2368c07a7b2SBrian Somers 
2378c07a7b2SBrian Somers   link_ProtocolRecord(l, proto, PROTO_OUT);
238dd7e2610SBrian Somers   log_Printf(LogDEBUG, "hdlc_Output: proto = 0x%04x\n", proto);
2391ae349f5Scvs2svn 
240dd7e2610SBrian Somers   if (physical_IsSync(p))
2418c07a7b2SBrian Somers     link_Output(l, pri, mhp);          /* Send it raw */
2421ae349f5Scvs2svn   else
2436140ba11SBrian Somers     async_Output(pri, mhp, proto, p);
2441ae349f5Scvs2svn }
2451ae349f5Scvs2svn 
2461ae349f5Scvs2svn /* Check out the latest ``Assigned numbers'' rfc (rfc1700.txt) */
2471ae349f5Scvs2svn static struct {
2481ae349f5Scvs2svn   u_short from;
2491ae349f5Scvs2svn   u_short to;
2501ae349f5Scvs2svn   const char *name;
2511ae349f5Scvs2svn } protocols[] = {
2521ae349f5Scvs2svn   { 0x0001, 0x0001, "Padding Protocol" },
2531ae349f5Scvs2svn   { 0x0003, 0x001f, "reserved (transparency inefficient)" },
2541ae349f5Scvs2svn   { 0x0021, 0x0021, "Internet Protocol" },
2551ae349f5Scvs2svn   { 0x0023, 0x0023, "OSI Network Layer" },
2561ae349f5Scvs2svn   { 0x0025, 0x0025, "Xerox NS IDP" },
2571ae349f5Scvs2svn   { 0x0027, 0x0027, "DECnet Phase IV" },
2581ae349f5Scvs2svn   { 0x0029, 0x0029, "Appletalk" },
2591ae349f5Scvs2svn   { 0x002b, 0x002b, "Novell IPX" },
2601ae349f5Scvs2svn   { 0x002d, 0x002d, "Van Jacobson Compressed TCP/IP" },
2611ae349f5Scvs2svn   { 0x002f, 0x002f, "Van Jacobson Uncompressed TCP/IP" },
2621ae349f5Scvs2svn   { 0x0031, 0x0031, "Bridging PDU" },
2631ae349f5Scvs2svn   { 0x0033, 0x0033, "Stream Protocol (ST-II)" },
2641ae349f5Scvs2svn   { 0x0035, 0x0035, "Banyan Vines" },
2651ae349f5Scvs2svn   { 0x0037, 0x0037, "reserved (until 1993)" },
2661ae349f5Scvs2svn   { 0x0039, 0x0039, "AppleTalk EDDP" },
2671ae349f5Scvs2svn   { 0x003b, 0x003b, "AppleTalk SmartBuffered" },
2681ae349f5Scvs2svn   { 0x003d, 0x003d, "Multi-Link" },
2691ae349f5Scvs2svn   { 0x003f, 0x003f, "NETBIOS Framing" },
2701ae349f5Scvs2svn   { 0x0041, 0x0041, "Cisco Systems" },
2711ae349f5Scvs2svn   { 0x0043, 0x0043, "Ascom Timeplex" },
2721ae349f5Scvs2svn   { 0x0045, 0x0045, "Fujitsu Link Backup and Load Balancing (LBLB)" },
2731ae349f5Scvs2svn   { 0x0047, 0x0047, "DCA Remote Lan" },
2741ae349f5Scvs2svn   { 0x0049, 0x0049, "Serial Data Transport Protocol (PPP-SDTP)" },
2751ae349f5Scvs2svn   { 0x004b, 0x004b, "SNA over 802.2" },
2761ae349f5Scvs2svn   { 0x004d, 0x004d, "SNA" },
2771ae349f5Scvs2svn   { 0x004f, 0x004f, "IP6 Header Compression" },
2781ae349f5Scvs2svn   { 0x0051, 0x0051, "KNX Bridging Data" },
2791ae349f5Scvs2svn   { 0x0053, 0x0053, "Encryption" },
2801ae349f5Scvs2svn   { 0x0055, 0x0055, "Individual Link Encryption" },
2811ae349f5Scvs2svn   { 0x006f, 0x006f, "Stampede Bridging" },
2821ae349f5Scvs2svn   { 0x0071, 0x0071, "BAP Bandwidth Allocation Protocol" },
2831ae349f5Scvs2svn   { 0x0073, 0x0073, "MP+ Protocol" },
2841ae349f5Scvs2svn   { 0x007d, 0x007d, "reserved (Control Escape)" },
2851ae349f5Scvs2svn   { 0x007f, 0x007f, "reserved (compression inefficient)" },
2861ae349f5Scvs2svn   { 0x00cf, 0x00cf, "reserved (PPP NLPID)" },
2871ae349f5Scvs2svn   { 0x00fb, 0x00fb, "compression on single link in multilink group" },
2881ae349f5Scvs2svn   { 0x00fd, 0x00fd, "1st choice compression" },
2891ae349f5Scvs2svn   { 0x00ff, 0x00ff, "reserved (compression inefficient)" },
2901ae349f5Scvs2svn   { 0x0200, 0x02ff, "(compression inefficient)" },
2911ae349f5Scvs2svn   { 0x0201, 0x0201, "802.1d Hello Packets" },
2921ae349f5Scvs2svn   { 0x0203, 0x0203, "IBM Source Routing BPDU" },
2931ae349f5Scvs2svn   { 0x0205, 0x0205, "DEC LANBridge100 Spanning Tree" },
2941ae349f5Scvs2svn   { 0x0207, 0x0207, "Cisco Discovery Protocol" },
2951ae349f5Scvs2svn   { 0x0209, 0x0209, "Netcs Twin Routing" },
2961ae349f5Scvs2svn   { 0x0231, 0x0231, "Luxcom" },
2971ae349f5Scvs2svn   { 0x0233, 0x0233, "Sigma Network Systems" },
2981ae349f5Scvs2svn   { 0x0235, 0x0235, "Apple Client Server Protocol" },
2991ae349f5Scvs2svn   { 0x1e00, 0x1eff, "(compression inefficient)" },
3001ae349f5Scvs2svn   { 0x4001, 0x4001, "Cray Communications Control Protocol" },
3011ae349f5Scvs2svn   { 0x4003, 0x4003, "CDPD Mobile Network Registration Protocol" },
3021ae349f5Scvs2svn   { 0x4021, 0x4021, "Stacker LZS" },
3031ae349f5Scvs2svn   { 0x8001, 0x801f, "Not Used - reserved" },
3041ae349f5Scvs2svn   { 0x8021, 0x8021, "Internet Protocol Control Protocol" },
3051ae349f5Scvs2svn   { 0x8023, 0x8023, "OSI Network Layer Control Protocol" },
3061ae349f5Scvs2svn   { 0x8025, 0x8025, "Xerox NS IDP Control Protocol" },
3071ae349f5Scvs2svn   { 0x8027, 0x8027, "DECnet Phase IV Control Protocol" },
3081ae349f5Scvs2svn   { 0x8029, 0x8029, "Appletalk Control Protocol" },
3091ae349f5Scvs2svn   { 0x802b, 0x802b, "Novell IPX Control Protocol" },
3101ae349f5Scvs2svn   { 0x802d, 0x802d, "reserved" },
3111ae349f5Scvs2svn   { 0x802f, 0x802f, "reserved" },
3121ae349f5Scvs2svn   { 0x8031, 0x8031, "Bridging NCP" },
3131ae349f5Scvs2svn   { 0x8033, 0x8033, "Stream Protocol Control Protocol" },
3141ae349f5Scvs2svn   { 0x8035, 0x8035, "Banyan Vines Control Protocol" },
3151ae349f5Scvs2svn   { 0x8037, 0x8037, "reserved till 1993" },
3161ae349f5Scvs2svn   { 0x8039, 0x8039, "reserved" },
3171ae349f5Scvs2svn   { 0x803b, 0x803b, "reserved" },
3181ae349f5Scvs2svn   { 0x803d, 0x803d, "Multi-Link Control Protocol" },
3191ae349f5Scvs2svn   { 0x803f, 0x803f, "NETBIOS Framing Control Protocol" },
3201ae349f5Scvs2svn   { 0x8041, 0x8041, "Cisco Systems Control Protocol" },
3211ae349f5Scvs2svn   { 0x8043, 0x8043, "Ascom Timeplex" },
3221ae349f5Scvs2svn   { 0x8045, 0x8045, "Fujitsu LBLB Control Protocol" },
3231ae349f5Scvs2svn   { 0x8047, 0x8047, "DCA Remote Lan Network Control Protocol (RLNCP)" },
3241ae349f5Scvs2svn   { 0x8049, 0x8049, "Serial Data Control Protocol (PPP-SDCP)" },
3251ae349f5Scvs2svn   { 0x804b, 0x804b, "SNA over 802.2 Control Protocol" },
3261ae349f5Scvs2svn   { 0x804d, 0x804d, "SNA Control Protocol" },
3271ae349f5Scvs2svn   { 0x804f, 0x804f, "IP6 Header Compression Control Protocol" },
3281ae349f5Scvs2svn   { 0x8051, 0x8051, "KNX Bridging Control Protocol" },
3291ae349f5Scvs2svn   { 0x8053, 0x8053, "Encryption Control Protocol" },
3301ae349f5Scvs2svn   { 0x8055, 0x8055, "Individual Link Encryption Control Protocol" },
3311ae349f5Scvs2svn   { 0x806f, 0x806f, "Stampede Bridging Control Protocol" },
3321ae349f5Scvs2svn   { 0x8073, 0x8073, "MP+ Control Protocol" },
3331ae349f5Scvs2svn   { 0x8071, 0x8071, "BACP Bandwidth Allocation Control Protocol" },
3341ae349f5Scvs2svn   { 0x807d, 0x807d, "Not Used - reserved" },
3351ae349f5Scvs2svn   { 0x80cf, 0x80cf, "Not Used - reserved" },
3361ae349f5Scvs2svn   { 0x80fb, 0x80fb, "compression on single link in multilink group control" },
3371ae349f5Scvs2svn   { 0x80fd, 0x80fd, "Compression Control Protocol" },
3381ae349f5Scvs2svn   { 0x80ff, 0x80ff, "Not Used - reserved" },
3391ae349f5Scvs2svn   { 0x8207, 0x8207, "Cisco Discovery Protocol Control" },
3401ae349f5Scvs2svn   { 0x8209, 0x8209, "Netcs Twin Routing" },
3411ae349f5Scvs2svn   { 0x8235, 0x8235, "Apple Client Server Protocol Control" },
3421ae349f5Scvs2svn   { 0xc021, 0xc021, "Link Control Protocol" },
3431ae349f5Scvs2svn   { 0xc023, 0xc023, "Password Authentication Protocol" },
3441ae349f5Scvs2svn   { 0xc025, 0xc025, "Link Quality Report" },
3451ae349f5Scvs2svn   { 0xc027, 0xc027, "Shiva Password Authentication Protocol" },
3461ae349f5Scvs2svn   { 0xc029, 0xc029, "CallBack Control Protocol (CBCP)" },
3471ae349f5Scvs2svn   { 0xc081, 0xc081, "Container Control Protocol" },
3481ae349f5Scvs2svn   { 0xc223, 0xc223, "Challenge Handshake Authentication Protocol" },
3491ae349f5Scvs2svn   { 0xc225, 0xc225, "RSA Authentication Protocol" },
3501ae349f5Scvs2svn   { 0xc227, 0xc227, "Extensible Authentication Protocol" },
3511ae349f5Scvs2svn   { 0xc26f, 0xc26f, "Stampede Bridging Authorization Protocol" },
3521ae349f5Scvs2svn   { 0xc281, 0xc281, "Proprietary Authentication Protocol" },
3531ae349f5Scvs2svn   { 0xc283, 0xc283, "Proprietary Authentication Protocol" },
3541ae349f5Scvs2svn   { 0xc481, 0xc481, "Proprietary Node ID Authentication Protocol" }
3551ae349f5Scvs2svn };
3561ae349f5Scvs2svn 
3571ae349f5Scvs2svn #define NPROTOCOLS (sizeof protocols/sizeof protocols[0])
3581ae349f5Scvs2svn 
35963258dccSBrian Somers const char *
36063258dccSBrian Somers hdlc_Protocol2Nam(u_short proto)
3611ae349f5Scvs2svn {
3621ae349f5Scvs2svn   int f;
3631ae349f5Scvs2svn 
3641ae349f5Scvs2svn   for (f = 0; f < NPROTOCOLS; f++)
3651ae349f5Scvs2svn     if (proto >= protocols[f].from && proto <= protocols[f].to)
3661ae349f5Scvs2svn       return protocols[f].name;
3671ae349f5Scvs2svn     else if (proto < protocols[f].from)
3681ae349f5Scvs2svn       break;
3691ae349f5Scvs2svn   return "unrecognised protocol";
3701ae349f5Scvs2svn }
3711ae349f5Scvs2svn 
3723b0f8d2eSBrian Somers void
3733b0f8d2eSBrian Somers hdlc_DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp,
3747a6f8720SBrian Somers                   struct link *l)
3751ae349f5Scvs2svn {
3768c07a7b2SBrian Somers   struct physical *p = link2physical(l);
3771ae349f5Scvs2svn   u_char *cp;
3781ae349f5Scvs2svn 
379dd7e2610SBrian Somers   log_Printf(LogDEBUG, "DecodePacket: proto = 0x%04x\n", proto);
3801ae349f5Scvs2svn 
381ee6c193fSBrian Somers   /* decompress everything.  CCP needs uncompressed data too */
3823b0f8d2eSBrian Somers   if ((bp = ccp_Decompress(&l->ccp, &proto, bp)) == NULL)
3831ae349f5Scvs2svn     return;
3841ae349f5Scvs2svn 
3851ae349f5Scvs2svn   switch (proto) {
3861ae349f5Scvs2svn   case PROTO_LCP:
387dd7e2610SBrian Somers     lcp_Input(&l->lcp, bp);
3881ae349f5Scvs2svn     break;
3891ae349f5Scvs2svn   case PROTO_PAP:
3908c07a7b2SBrian Somers     if (p)
391dd7e2610SBrian Somers       pap_Input(bundle, bp, p);
3928c07a7b2SBrian Somers     else {
393dd7e2610SBrian Somers       log_Printf(LogERROR, "DecodePacket: PAP: Not a physical link !\n");
394dd7e2610SBrian Somers       mbuf_Free(bp);
3958c07a7b2SBrian Somers     }
3961ae349f5Scvs2svn     break;
3971ae349f5Scvs2svn   case PROTO_LQR:
398879ed6faSBrian Somers     if (p) {
399879ed6faSBrian Somers       p->hdlc.lqm.lqr.SaveInLQRs++;
400dd7e2610SBrian Somers       lqr_Input(p, bp);
401879ed6faSBrian Somers     } else {
402dd7e2610SBrian Somers       log_Printf(LogERROR, "DecodePacket: LQR: Not a physical link !\n");
403dd7e2610SBrian Somers       mbuf_Free(bp);
4048c07a7b2SBrian Somers     }
4051ae349f5Scvs2svn     break;
4061ae349f5Scvs2svn   case PROTO_CHAP:
4078c07a7b2SBrian Somers     if (p)
408dd7e2610SBrian Somers       chap_Input(bundle, bp, p);
4098c07a7b2SBrian Somers     else {
410dd7e2610SBrian Somers       log_Printf(LogERROR, "DecodePacket: CHAP: Not a physical link !\n");
411dd7e2610SBrian Somers       mbuf_Free(bp);
4128c07a7b2SBrian Somers     }
4131ae349f5Scvs2svn     break;
4141ae349f5Scvs2svn   case PROTO_VJUNCOMP:
4151ae349f5Scvs2svn   case PROTO_VJCOMP:
416dd7e2610SBrian Somers     bp = vj_Input(&bundle->ncp.ipcp, bp, proto);
4178c07a7b2SBrian Somers     if (bp == NULL)
4181ae349f5Scvs2svn       break;
4191ae349f5Scvs2svn     /* fall down */
4201ae349f5Scvs2svn   case PROTO_IP:
421dd7e2610SBrian Somers     ip_Input(bundle, bp);
4221ae349f5Scvs2svn     break;
4231ae349f5Scvs2svn   case PROTO_IPCP:
424dd7e2610SBrian Somers     ipcp_Input(&bundle->ncp.ipcp, bp);
4251ae349f5Scvs2svn     break;
4261ae349f5Scvs2svn   case PROTO_CCP:
427dd7e2610SBrian Somers     ccp_Input(&l->ccp, bundle, bp);
4281ae349f5Scvs2svn     break;
4293b0f8d2eSBrian Somers   case PROTO_MP:
4303b0f8d2eSBrian Somers     if (bundle->ncp.mp.active) {
4313b0f8d2eSBrian Somers       if (p)
4323b0f8d2eSBrian Somers         mp_Input(&bundle->ncp.mp, bp, p);
4333b0f8d2eSBrian Somers       else {
434dd7e2610SBrian Somers         log_Printf(LogERROR, "DecodePacket: MP inside MP ?!\n");
435dd7e2610SBrian Somers         mbuf_Free(bp);
4363b0f8d2eSBrian Somers       }
4373b0f8d2eSBrian Somers       break;
4383b0f8d2eSBrian Somers     }
4393b0f8d2eSBrian Somers     /* Fall through */
4401ae349f5Scvs2svn   default:
441dd7e2610SBrian Somers     log_Printf(LogPHASE, "%s protocol 0x%04x (%s)\n",
4423b0f8d2eSBrian Somers               proto == PROTO_MP ? "Unexpected" : "Unknown",
44363258dccSBrian Somers               proto, hdlc_Protocol2Nam(proto));
4441ae349f5Scvs2svn     bp->offset -= 2;
4451ae349f5Scvs2svn     bp->cnt += 2;
4461ae349f5Scvs2svn     cp = MBUF_CTOP(bp);
4473b0f8d2eSBrian Somers     lcp_SendProtoRej(&l->lcp, cp, bp->cnt);
4483b0f8d2eSBrian Somers     if (p) {
449879ed6faSBrian Somers       p->hdlc.lqm.SaveInDiscards++;
45063258dccSBrian Somers       p->hdlc.stats.unknownproto++;
4513b0f8d2eSBrian Somers     }
452dd7e2610SBrian Somers     mbuf_Free(bp);
4531ae349f5Scvs2svn     break;
4541ae349f5Scvs2svn   }
4551ae349f5Scvs2svn }
4561ae349f5Scvs2svn 
4571ae349f5Scvs2svn void
458dd7e2610SBrian Somers hdlc_Input(struct bundle *bundle, struct mbuf * bp, struct physical *physical)
4591ae349f5Scvs2svn {
4601ae349f5Scvs2svn   u_short fcs, proto;
4611ae349f5Scvs2svn   u_char *cp, addr, ctrl;
4621ae349f5Scvs2svn 
463dd7e2610SBrian Somers   log_DumpBp(LogHDLC, "hdlc_Input:", bp);
464dd7e2610SBrian Somers   if (physical_IsSync(physical))
4651ae349f5Scvs2svn     fcs = GOODFCS;
4661ae349f5Scvs2svn   else
467dd7e2610SBrian Somers     fcs = hdlc_Fcs(INITFCS, MBUF_CTOP(bp), bp->cnt);
468879ed6faSBrian Somers   physical->hdlc.lqm.SaveInOctets += bp->cnt + 1;
4691ae349f5Scvs2svn 
470dd7e2610SBrian Somers   log_Printf(LogDEBUG, "hdlc_Input: fcs = %04x (%s)\n",
4711ae349f5Scvs2svn 	    fcs, (fcs == GOODFCS) ? "good" : "bad");
4721ae349f5Scvs2svn   if (fcs != GOODFCS) {
473879ed6faSBrian Somers     physical->hdlc.lqm.SaveInErrors++;
474dd7e2610SBrian Somers     log_Printf(LogDEBUG, "hdlc_Input: Bad FCS\n");
47563258dccSBrian Somers     physical->hdlc.stats.badfcs++;
476dd7e2610SBrian Somers     mbuf_Free(bp);
4771ae349f5Scvs2svn     return;
4781ae349f5Scvs2svn   }
479dd7e2610SBrian Somers   if (!physical_IsSync(physical))
4801ae349f5Scvs2svn     bp->cnt -= 2;		/* discard FCS part */
4811ae349f5Scvs2svn 
4821ae349f5Scvs2svn   if (bp->cnt < 2) {		/* XXX: raise this bar ? */
483dd7e2610SBrian Somers     mbuf_Free(bp);
4841ae349f5Scvs2svn     return;
4851ae349f5Scvs2svn   }
4861ae349f5Scvs2svn   cp = MBUF_CTOP(bp);
4871ae349f5Scvs2svn 
4883b0f8d2eSBrian Somers   if (!physical->link.lcp.want_acfcomp) {
4891ae349f5Scvs2svn     /*
4901ae349f5Scvs2svn      * We expect that packet is not compressed.
4911ae349f5Scvs2svn      */
4921ae349f5Scvs2svn     addr = *cp++;
4931ae349f5Scvs2svn     if (addr != HDLC_ADDR) {
494879ed6faSBrian Somers       physical->hdlc.lqm.SaveInErrors++;
49563258dccSBrian Somers       physical->hdlc.stats.badaddr++;
496dd7e2610SBrian Somers       log_Printf(LogDEBUG, "hdlc_Input: addr %02x\n", *cp);
497dd7e2610SBrian Somers       mbuf_Free(bp);
4981ae349f5Scvs2svn       return;
4991ae349f5Scvs2svn     }
5001ae349f5Scvs2svn     ctrl = *cp++;
5011ae349f5Scvs2svn     if (ctrl != HDLC_UI) {
502879ed6faSBrian Somers       physical->hdlc.lqm.SaveInErrors++;
50363258dccSBrian Somers       physical->hdlc.stats.badcommand++;
504dd7e2610SBrian Somers       log_Printf(LogDEBUG, "hdlc_Input: %02x\n", *cp);
505dd7e2610SBrian Somers       mbuf_Free(bp);
5061ae349f5Scvs2svn       return;
5071ae349f5Scvs2svn     }
5081ae349f5Scvs2svn     bp->offset += 2;
5091ae349f5Scvs2svn     bp->cnt -= 2;
5101ae349f5Scvs2svn   } else if (cp[0] == HDLC_ADDR && cp[1] == HDLC_UI) {
5111ae349f5Scvs2svn 
5121ae349f5Scvs2svn     /*
5131ae349f5Scvs2svn      * We can receive compressed packet, but peer still send uncompressed
5141ae349f5Scvs2svn      * packet to me.
5151ae349f5Scvs2svn      */
5161ae349f5Scvs2svn     cp += 2;
5171ae349f5Scvs2svn     bp->offset += 2;
5181ae349f5Scvs2svn     bp->cnt -= 2;
5191ae349f5Scvs2svn   }
5203b0f8d2eSBrian Somers   if (physical->link.lcp.want_protocomp) {
5211ae349f5Scvs2svn     proto = 0;
5221ae349f5Scvs2svn     cp--;
5231ae349f5Scvs2svn     do {
5241ae349f5Scvs2svn       cp++;
5251ae349f5Scvs2svn       bp->offset++;
5261ae349f5Scvs2svn       bp->cnt--;
5271ae349f5Scvs2svn       proto = proto << 8;
5281ae349f5Scvs2svn       proto += *cp;
5291ae349f5Scvs2svn     } while (!(proto & 1));
5301ae349f5Scvs2svn   } else {
5311ae349f5Scvs2svn     proto = *cp++ << 8;
5321ae349f5Scvs2svn     proto |= *cp++;
5331ae349f5Scvs2svn     bp->offset += 2;
5341ae349f5Scvs2svn     bp->cnt -= 2;
5351ae349f5Scvs2svn   }
5361ae349f5Scvs2svn 
537dd7e2610SBrian Somers   link_ProtocolRecord(&physical->link, proto, PROTO_IN);
538879ed6faSBrian Somers   physical->hdlc.lqm.SaveInPackets++;
5391ae349f5Scvs2svn 
540dd7e2610SBrian Somers   hdlc_DecodePacket(bundle, proto, bp, &physical->link);
5411ae349f5Scvs2svn }
54242d4d396SBrian Somers 
54342d4d396SBrian Somers /*
54442d4d396SBrian Somers  *  Detect a HDLC frame
54542d4d396SBrian Somers  */
54642d4d396SBrian Somers 
54742d4d396SBrian Somers static const char *FrameHeaders[] = {
54842d4d396SBrian Somers   "\176\377\003\300\041",
54942d4d396SBrian Somers   "\176\377\175\043\300\041",
55042d4d396SBrian Somers   "\176\177\175\043\100\041",
55142d4d396SBrian Somers   "\176\175\337\175\043\300\041",
55242d4d396SBrian Somers   "\176\175\137\175\043\100\041",
55342d4d396SBrian Somers   NULL,
55442d4d396SBrian Somers };
55542d4d396SBrian Somers 
55642d4d396SBrian Somers u_char *
557dd7e2610SBrian Somers hdlc_Detect(struct physical *physical, u_char *cp, int n)
55842d4d396SBrian Somers {
559cdbbb6b5SBrian Somers   const char *fp, **hp;
560cdbbb6b5SBrian Somers   char *ptr;
56142d4d396SBrian Somers 
56242d4d396SBrian Somers   cp[n] = '\0';			/* be sure to null terminated */
56342d4d396SBrian Somers   ptr = NULL;
56442d4d396SBrian Somers   for (hp = FrameHeaders; *hp; hp++) {
56542d4d396SBrian Somers     fp = *hp;
566dd7e2610SBrian Somers     if (physical_IsSync(physical))
56742d4d396SBrian Somers       fp++;
56842d4d396SBrian Somers     ptr = strstr((char *) cp, fp);
56942d4d396SBrian Somers     if (ptr)
57042d4d396SBrian Somers       break;
57142d4d396SBrian Somers   }
57242d4d396SBrian Somers   return (u_char *)ptr;
57342d4d396SBrian Somers }
57463258dccSBrian Somers 
57563258dccSBrian Somers int
57663258dccSBrian Somers hdlc_ReportStatus(struct cmdargs const *arg)
57763258dccSBrian Somers {
578b6217683SBrian Somers   struct hdlc *hdlc = &arg->cx->physical->hdlc;
579b6217683SBrian Somers 
5806e7cdde1SBrian Somers   prompt_Printf(arg->prompt, "%s HDLC level errors:\n", arg->cx->name);
581b6217683SBrian Somers   prompt_Printf(arg->prompt, " Bad Frame Check Sequence fields: %u\n",
582b6217683SBrian Somers 	        hdlc->stats.badfcs);
583b6217683SBrian Somers   prompt_Printf(arg->prompt, " Bad address (!= 0x%02x) fields:    %u\n",
584b6217683SBrian Somers 	        HDLC_ADDR, hdlc->stats.badaddr);
585b6217683SBrian Somers   prompt_Printf(arg->prompt, " Bad command (!= 0x%02x) fields:    %u\n",
586b6217683SBrian Somers 	        HDLC_UI, hdlc->stats.badcommand);
587b6217683SBrian Somers   prompt_Printf(arg->prompt, " Unrecognised protocol fields:    %u\n",
588b6217683SBrian Somers 	        hdlc->stats.unknownproto);
58963258dccSBrian Somers   return 0;
59063258dccSBrian Somers }
59163258dccSBrian Somers 
59263258dccSBrian Somers static void
59363258dccSBrian Somers hdlc_ReportTime(void *v)
59463258dccSBrian Somers {
59563258dccSBrian Somers   /* Moan about HDLC errors */
59663258dccSBrian Somers   struct hdlc *hdlc = (struct hdlc *)v;
59763258dccSBrian Somers 
598dd7e2610SBrian Somers   timer_Stop(&hdlc->ReportTimer);
59963258dccSBrian Somers 
60063258dccSBrian Somers   if (memcmp(&hdlc->laststats, &hdlc->stats, sizeof hdlc->stats)) {
601dd7e2610SBrian Somers     log_Printf(LogPHASE,
602147613eaSBrian Somers               "%s: HDLC errors -> FCS: %u, ADDR: %u, COMD: %u, PROTO: %u\n",
603147613eaSBrian Somers               hdlc->lqm.owner->fsm.link->name,
60463258dccSBrian Somers 	      hdlc->stats.badfcs - hdlc->laststats.badfcs,
60563258dccSBrian Somers               hdlc->stats.badaddr - hdlc->laststats.badaddr,
60663258dccSBrian Somers               hdlc->stats.badcommand - hdlc->laststats.badcommand,
60763258dccSBrian Somers               hdlc->stats.unknownproto - hdlc->laststats.unknownproto);
60863258dccSBrian Somers     hdlc->laststats = hdlc->stats;
60963258dccSBrian Somers   }
61063258dccSBrian Somers 
611dd7e2610SBrian Somers   timer_Start(&hdlc->ReportTimer);
61263258dccSBrian Somers }
61363258dccSBrian Somers 
61463258dccSBrian Somers void
61563258dccSBrian Somers hdlc_StartTimer(struct hdlc *hdlc)
61663258dccSBrian Somers {
617dd7e2610SBrian Somers   timer_Stop(&hdlc->ReportTimer);
61863258dccSBrian Somers   hdlc->ReportTimer.load = 60 * SECTICKS;
61963258dccSBrian Somers   hdlc->ReportTimer.arg = hdlc;
62063258dccSBrian Somers   hdlc->ReportTimer.func = hdlc_ReportTime;
6213b0f8d2eSBrian Somers   hdlc->ReportTimer.name = "hdlc";
622dd7e2610SBrian Somers   timer_Start(&hdlc->ReportTimer);
62363258dccSBrian Somers }
62463258dccSBrian Somers 
62563258dccSBrian Somers void
62663258dccSBrian Somers hdlc_StopTimer(struct hdlc *hdlc)
62763258dccSBrian Somers {
628dd7e2610SBrian Somers   timer_Stop(&hdlc->ReportTimer);
62963258dccSBrian Somers }
630