hdlc.h revision 131327
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: head/usr.sbin/ppp/hdlc.h 131327 2004-06-30 12:24:56Z brian $ 296059Samurai */ 306059Samurai 316059Samurai/* 326059Samurai * Definition for Async HDLC 336059Samurai */ 3428679Sbrian#define HDLC_SYN 0x7e /* SYNC character */ 3528679Sbrian#define HDLC_ESC 0x7d /* Escape character */ 3628679Sbrian#define HDLC_XOR 0x20 /* Modifier value */ 376059Samurai 386059Samurai#define HDLC_ADDR 0xff 396059Samurai#define HDLC_UI 0x03 406059Samurai/* 416059Samurai * Definition for HDLC Frame Check Sequence 426059Samurai */ 4328679Sbrian#define INITFCS 0xffff /* Initial value for FCS computation */ 4428679Sbrian#define GOODFCS 0xf0b8 /* Good FCS value */ 456059Samurai 466059Samurai#define DEF_MRU 1500 4755272Sbrian#define MAX_MRU 2048 486059Samurai#define MIN_MRU 296 496059Samurai 5026326Sbrian#define DEF_MTU 0 /* whatever peer says */ 5155272Sbrian#define MAX_MTU 2048 5226326Sbrian#define MIN_MTU 296 5326326Sbrian 5436285Sbrianstruct physical; 5536285Sbrianstruct link; 5636285Sbrianstruct lcp; 5736285Sbrianstruct bundle; 5836285Sbrianstruct mbuf; 5936285Sbrianstruct cmdargs; 606059Samurai 6136285Sbrianstruct hdlc { 6236285Sbrian struct pppTimer ReportTimer; 6336285Sbrian 6436285Sbrian struct { 6536285Sbrian int badfcs; 6636285Sbrian int badaddr; 6736285Sbrian int badcommand; 6836285Sbrian int unknownproto; 6936285Sbrian } laststats, stats; 7036285Sbrian 7136285Sbrian struct { 7236285Sbrian struct lcp *owner; /* parent LCP */ 7336285Sbrian struct pppTimer timer; /* When to send */ 7436285Sbrian int method; /* bit-mask for LQM_* from lqr.h */ 7536285Sbrian 76131327Sbrian u_int32_t ifOutUniPackets; /* Packets sent by me */ 77131327Sbrian u_int32_t ifOutOctets; /* Octets sent by me */ 78131327Sbrian u_int32_t ifInUniPackets; /* Packets received from peer */ 79131327Sbrian u_int32_t ifInDiscards; /* Discards */ 80131327Sbrian u_int32_t ifInErrors; /* Errors */ 81131327Sbrian u_int32_t ifInOctets; /* Octets received from peer (unused) */ 8236285Sbrian 8336285Sbrian struct { 84131327Sbrian u_int32_t InGoodOctets; /* Good octets received from peer */ 8536285Sbrian u_int32_t OutLQRs; /* LQRs sent by me */ 86131327Sbrian u_int32_t InLQRs; /* LQRs received from peer */ 87131327Sbrian 88131327Sbrian struct lqrsavedata Save; /* Our last LQR */ 89131327Sbrian struct lqrsavedata prevSave; /* Our last-but-one LQR (analysis) */ 90131327Sbrian 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 11246686Sbrianextern u_short hdlc_Fcs(u_char *, size_t); 11345264Sbrianextern int hdlc_Detect(u_char const **, int, int); 11446686Sbrianextern int hdlc_WrapperOctets(struct lcp *, u_short); 11546686Sbrian 11646686Sbrianextern struct layer hdlclayer; 117