120469Smpp/*- 220469Smpp * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 320469Smpp * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 420469Smpp * Internet Initiative Japan, Inc (IIJ) 520469Smpp * All rights reserved. 620469Smpp * 720469Smpp * Redistribution and use in source and binary forms, with or without 820469Smpp * modification, are permitted provided that the following conditions 920469Smpp * are met: 1020469Smpp * 1. Redistributions of source code must retain the above copyright 1120469Smpp * notice, this list of conditions and the following disclaimer. 1220469Smpp * 2. Redistributions in binary form must reproduce the above copyright 1320469Smpp * notice, this list of conditions and the following disclaimer in the 1420469Smpp * documentation and/or other materials provided with the distribution. 1520469Smpp * 1620469Smpp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1720469Smpp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1820469Smpp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1920469Smpp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2020469Smpp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2120469Smpp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2220469Smpp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2320469Smpp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2420469Smpp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2520469Smpp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2620469Smpp * SUCH DAMAGE. 2720469Smpp * 2820469Smpp * $FreeBSD: releng/11.0/usr.sbin/ppp/hdlc.h 134789 2004-09-05 01:46:52Z brian $ 2920469Smpp */ 3020469Smpp 3120469Smpp/* 3220469Smpp * Definition for Async HDLC 3320469Smpp */ 3420469Smpp#define HDLC_SYN 0x7e /* SYNC character */ 3520469Smpp#define HDLC_ESC 0x7d /* Escape character */ 3620469Smpp#define HDLC_XOR 0x20 /* Modifier value */ 3720469Smpp 3823466Sjmg#define HDLC_ADDR 0xff 3950476Speter#define HDLC_UI 0x03 4023466Sjmg/* 41212827Sgjb * Definition for HDLC Frame Check Sequence 4277042Sru */ 4377042Sru#define INITFCS 0xffff /* Initial value for FCS computation */ 4420469Smpp#define GOODFCS 0xf0b8 /* Good FCS value */ 4577042Sru 46107788Sru#define DEF_MRU 1500 4720469Smpp#define MAX_MRU 2048 48131479Sru#define MIN_MRU 296 4977042Sru 50131479Sru#define DEF_MTU 0 /* whatever peer says */ 5120469Smpp#define MAX_MTU 2048 52107788Sru#define MIN_MTU 296 5368962Sru 5420469Smppstruct physical; 55107788Srustruct link; 5620469Smppstruct lcp; 5760407Schrisstruct bundle; 5820469Smppstruct mbuf; 59107788Srustruct cmdargs; 6020469Smpp 6120469Smppstruct hdlc { 6220469Smpp struct pppTimer ReportTimer; 6320469Smpp 6420469Smpp struct { 6520469Smpp int badfcs; 6620469Smpp int badaddr; 6720469Smpp int badcommand; 6820469Smpp int unknownproto; 6920469Smpp } laststats, stats; 7020469Smpp 7120469Smpp struct { 7220469Smpp struct lcp *owner; /* parent LCP */ 7320469Smpp struct pppTimer timer; /* When to send */ 7420469Smpp int method; /* bit-mask for LQM_* from lqr.h */ 7520469Smpp 7620469Smpp u_int32_t ifOutUniPackets; /* Packets sent by me */ 7720469Smpp u_int32_t ifOutOctets; /* Octets sent by me */ 7820469Smpp u_int32_t ifInUniPackets; /* Packets received from peer */ 7920469Smpp u_int32_t ifInDiscards; /* Discards */ 8020469Smpp u_int32_t ifInErrors; /* Errors */ 8120469Smpp u_int32_t ifInOctets; /* Octets received from peer (unused) */ 8220469Smpp 8320469Smpp struct { 8420469Smpp u_int32_t InGoodOctets; /* Good octets received from peer */ 8579727Sschweikh u_int32_t OutLQRs; /* LQRs sent by me */ 8620469Smpp u_int32_t InLQRs; /* LQRs received from peer */ 8720469Smpp 8820469Smpp struct lqrsavedata Save; /* Our last LQR */ 8920469Smpp struct lqrsavedata prevSave; /* Our last-but-one LQR (analysis) */ 90212827Sgjb 91212827Sgjb struct lqrdata peer; /* Last LQR from peer */ 92212827Sgjb int peer_timeout; /* peers max lqr timeout */ 93212827Sgjb int resent; /* Resent last packet `resent' times */ 94212827Sgjb } lqr; 95212827Sgjb 96212827Sgjb struct { 97212827Sgjb u_int32_t seq_sent; /* last echo sent */ 98212827Sgjb u_int32_t seq_recv; /* last echo received */ 99208028Suqs } echo; 100208028Suqs } lqm; 101208028Suqs}; 102208028Suqs 103164464Srodrigc 104233648Seadlerextern void hdlc_Init(struct hdlc *, struct lcp *); 105164464Srodrigcextern void hdlc_StartTimer(struct hdlc *); 106164464Srodrigcextern void hdlc_StopTimer(struct hdlc *); 107164464Srodrigcextern int hdlc_ReportStatus(struct cmdargs const *); 108164464Srodrigcextern const char *hdlc_Protocol2Nam(u_short); 109164464Srodrigcextern void hdlc_DecodePacket(struct bundle *, u_short, struct mbuf *, 11020469Smpp struct link *); 111212827Sgjb 112164464Srodrigcextern u_short hdlc_Fcs(u_char *, size_t); 11320469Smppextern int hdlc_Detect(u_char const **, unsigned, int); 11420469Smpp#define hdlc_WrapperOctets() (2) 11579727Sschweikh 116107788Sruextern struct layer hdlclayer; 11749831Smpp