178189Sbrian/*- 2330449Seadler * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3330449Seadler * 478189Sbrian * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 578189Sbrian * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 678189Sbrian * Internet Initiative Japan, Inc (IIJ) 778189Sbrian * All rights reserved. 86059Samurai * 978189Sbrian * Redistribution and use in source and binary forms, with or without 1078189Sbrian * modification, are permitted provided that the following conditions 1178189Sbrian * are met: 1278189Sbrian * 1. Redistributions of source code must retain the above copyright 1378189Sbrian * notice, this list of conditions and the following disclaimer. 1478189Sbrian * 2. Redistributions in binary form must reproduce the above copyright 1578189Sbrian * notice, this list of conditions and the following disclaimer in the 1678189Sbrian * documentation and/or other materials provided with the distribution. 176059Samurai * 1878189Sbrian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1978189Sbrian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2078189Sbrian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2178189Sbrian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2278189Sbrian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2378189Sbrian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2478189Sbrian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2578189Sbrian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2678189Sbrian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2778189Sbrian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2878189Sbrian * SUCH DAMAGE. 296059Samurai * 3050479Speter * $FreeBSD: stable/11/usr.sbin/ppp/hdlc.h 330449 2018-03-05 07:26:05Z eadler $ 316059Samurai */ 326059Samurai 336059Samurai/* 346059Samurai * Definition for Async HDLC 356059Samurai */ 3628679Sbrian#define HDLC_SYN 0x7e /* SYNC character */ 3728679Sbrian#define HDLC_ESC 0x7d /* Escape character */ 3828679Sbrian#define HDLC_XOR 0x20 /* Modifier value */ 396059Samurai 406059Samurai#define HDLC_ADDR 0xff 416059Samurai#define HDLC_UI 0x03 426059Samurai/* 436059Samurai * Definition for HDLC Frame Check Sequence 446059Samurai */ 4528679Sbrian#define INITFCS 0xffff /* Initial value for FCS computation */ 4628679Sbrian#define GOODFCS 0xf0b8 /* Good FCS value */ 476059Samurai 486059Samurai#define DEF_MRU 1500 4955272Sbrian#define MAX_MRU 2048 506059Samurai#define MIN_MRU 296 516059Samurai 5226326Sbrian#define DEF_MTU 0 /* whatever peer says */ 5355272Sbrian#define MAX_MTU 2048 5426326Sbrian#define MIN_MTU 296 5526326Sbrian 5636285Sbrianstruct physical; 5736285Sbrianstruct link; 5836285Sbrianstruct lcp; 5936285Sbrianstruct bundle; 6036285Sbrianstruct mbuf; 6136285Sbrianstruct cmdargs; 626059Samurai 6336285Sbrianstruct hdlc { 6436285Sbrian struct pppTimer ReportTimer; 6536285Sbrian 6636285Sbrian struct { 6736285Sbrian int badfcs; 6836285Sbrian int badaddr; 6936285Sbrian int badcommand; 7036285Sbrian int unknownproto; 7136285Sbrian } laststats, stats; 7236285Sbrian 7336285Sbrian struct { 7436285Sbrian struct lcp *owner; /* parent LCP */ 7536285Sbrian struct pppTimer timer; /* When to send */ 7636285Sbrian int method; /* bit-mask for LQM_* from lqr.h */ 7736285Sbrian 78131327Sbrian u_int32_t ifOutUniPackets; /* Packets sent by me */ 79131327Sbrian u_int32_t ifOutOctets; /* Octets sent by me */ 80131327Sbrian u_int32_t ifInUniPackets; /* Packets received from peer */ 81131327Sbrian u_int32_t ifInDiscards; /* Discards */ 82131327Sbrian u_int32_t ifInErrors; /* Errors */ 83131327Sbrian u_int32_t ifInOctets; /* Octets received from peer (unused) */ 8436285Sbrian 8536285Sbrian struct { 86131327Sbrian u_int32_t InGoodOctets; /* Good octets received from peer */ 8736285Sbrian u_int32_t OutLQRs; /* LQRs sent by me */ 88131327Sbrian u_int32_t InLQRs; /* LQRs received from peer */ 89131327Sbrian 90131327Sbrian struct lqrsavedata Save; /* Our last LQR */ 91131327Sbrian struct lqrsavedata prevSave; /* Our last-but-one LQR (analysis) */ 92131327Sbrian 9336285Sbrian struct lqrdata peer; /* Last LQR from peer */ 9436285Sbrian int peer_timeout; /* peers max lqr timeout */ 9536285Sbrian int resent; /* Resent last packet `resent' times */ 9636285Sbrian } lqr; 9736285Sbrian 9836285Sbrian struct { 9936285Sbrian u_int32_t seq_sent; /* last echo sent */ 10036285Sbrian u_int32_t seq_recv; /* last echo received */ 10136285Sbrian } echo; 10236285Sbrian } lqm; 10336285Sbrian}; 10436285Sbrian 10536285Sbrian 10636285Sbrianextern void hdlc_Init(struct hdlc *, struct lcp *); 10736285Sbrianextern void hdlc_StartTimer(struct hdlc *); 10836285Sbrianextern void hdlc_StopTimer(struct hdlc *); 10936285Sbrianextern int hdlc_ReportStatus(struct cmdargs const *); 11036285Sbrianextern const char *hdlc_Protocol2Nam(u_short); 11136285Sbrianextern void hdlc_DecodePacket(struct bundle *, u_short, struct mbuf *, 11236285Sbrian struct link *); 11336285Sbrian 11446686Sbrianextern u_short hdlc_Fcs(u_char *, size_t); 115134789Sbrianextern int hdlc_Detect(u_char const **, unsigned, int); 116134789Sbrian#define hdlc_WrapperOctets() (2) 11746686Sbrian 11846686Sbrianextern struct layer hdlclayer; 119