hdlc.h revision 55272
16059Samurai/* 26059Samurai * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 36059Samurai * 46059Samurai * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 56059Samurai * 66059Samurai * Redistribution and use in source and binary forms are permitted 76059Samurai * provided that the above copyright notice and this paragraph are 86059Samurai * duplicated in all such forms and that any documentation, 96059Samurai * advertising materials, and other materials related to such 106059Samurai * distribution and use acknowledge that the software was developed 116059Samurai * by the Internet Initiative Japan. The name of the 126059Samurai * IIJ may not be used to endorse or promote products derived 136059Samurai * from this software without specific prior written permission. 146059Samurai * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 156059Samurai * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 166059Samurai * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 176059Samurai * 1850479Speter * $FreeBSD: head/usr.sbin/ppp/hdlc.h 55272 1999-12-30 13:27:15Z brian $ 196059Samurai * 206059Samurai * TODO: 216059Samurai */ 226059Samurai 236059Samurai/* 246059Samurai * Definition for Async HDLC 256059Samurai */ 2628679Sbrian#define HDLC_SYN 0x7e /* SYNC character */ 2728679Sbrian#define HDLC_ESC 0x7d /* Escape character */ 2828679Sbrian#define HDLC_XOR 0x20 /* Modifier value */ 296059Samurai 306059Samurai#define HDLC_ADDR 0xff 316059Samurai#define HDLC_UI 0x03 326059Samurai/* 336059Samurai * Definition for HDLC Frame Check Sequence 346059Samurai */ 3528679Sbrian#define INITFCS 0xffff /* Initial value for FCS computation */ 3628679Sbrian#define GOODFCS 0xf0b8 /* Good FCS value */ 376059Samurai 386059Samurai#define DEF_MRU 1500 3955272Sbrian#define MAX_MRU 2048 406059Samurai#define MIN_MRU 296 416059Samurai 4226326Sbrian#define DEF_MTU 0 /* whatever peer says */ 4355272Sbrian#define MAX_MTU 2048 4426326Sbrian#define MIN_MTU 296 4526326Sbrian 4636285Sbrianstruct physical; 4736285Sbrianstruct link; 4836285Sbrianstruct lcp; 4936285Sbrianstruct bundle; 5036285Sbrianstruct mbuf; 5136285Sbrianstruct cmdargs; 526059Samurai 5336285Sbrianstruct hdlc { 5436285Sbrian struct pppTimer ReportTimer; 5536285Sbrian 5636285Sbrian struct { 5736285Sbrian int badfcs; 5836285Sbrian int badaddr; 5936285Sbrian int badcommand; 6036285Sbrian int unknownproto; 6136285Sbrian } laststats, stats; 6236285Sbrian 6336285Sbrian struct { 6436285Sbrian struct lcp *owner; /* parent LCP */ 6536285Sbrian struct pppTimer timer; /* When to send */ 6636285Sbrian int method; /* bit-mask for LQM_* from lqr.h */ 6736285Sbrian 6836285Sbrian u_int32_t OutPackets; /* Packets sent by me */ 6936285Sbrian u_int32_t OutOctets; /* Octets sent by me */ 7036285Sbrian u_int32_t SaveInPackets; /* Packets received from peer */ 7136285Sbrian u_int32_t SaveInDiscards; /* Discards */ 7236285Sbrian u_int32_t SaveInErrors; /* Errors */ 7336285Sbrian u_int32_t SaveInOctets; /* Octets received from peer */ 7436285Sbrian 7536285Sbrian struct { 7636285Sbrian u_int32_t OutLQRs; /* LQRs sent by me */ 7736285Sbrian u_int32_t SaveInLQRs; /* LQRs received from peer */ 7836285Sbrian struct lqrdata peer; /* Last LQR from peer */ 7936285Sbrian int peer_timeout; /* peers max lqr timeout */ 8036285Sbrian int resent; /* Resent last packet `resent' times */ 8136285Sbrian } lqr; 8236285Sbrian 8336285Sbrian struct { 8436285Sbrian u_int32_t seq_sent; /* last echo sent */ 8536285Sbrian u_int32_t seq_recv; /* last echo received */ 8636285Sbrian } echo; 8736285Sbrian } lqm; 8836285Sbrian}; 8936285Sbrian 9036285Sbrian 9136285Sbrianextern void hdlc_Init(struct hdlc *, struct lcp *); 9236285Sbrianextern void hdlc_StartTimer(struct hdlc *); 9336285Sbrianextern void hdlc_StopTimer(struct hdlc *); 9436285Sbrianextern int hdlc_ReportStatus(struct cmdargs const *); 9536285Sbrianextern const char *hdlc_Protocol2Nam(u_short); 9636285Sbrianextern void hdlc_DecodePacket(struct bundle *, u_short, struct mbuf *, 9736285Sbrian struct link *); 9836285Sbrian 9946686Sbrianextern u_short hdlc_Fcs(u_char *, size_t); 10045264Sbrianextern int hdlc_Detect(u_char const **, int, int); 10146686Sbrianextern int hdlc_WrapperOctets(struct lcp *, u_short); 10246686Sbrian 10346686Sbrianextern struct layer hdlclayer; 104