lcp.h revision 93418
1/*- 2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4 * Internet Initiative Japan, Inc (IIJ) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: head/usr.sbin/ppp/lcp.h 93418 2002-03-30 12:30:09Z brian $ 29 */ 30 31/* callback::opmask values */ 32#define CALLBACK_AUTH (0) 33#define CALLBACK_DIALSTRING (1) /* Don't do this */ 34#define CALLBACK_LOCATION (2) /* Don't do this */ 35#define CALLBACK_E164 (3) 36#define CALLBACK_NAME (4) /* Don't do this */ 37#define CALLBACK_CBCP (6) 38#define CALLBACK_NONE (14) /* No callback is ok */ 39 40#define CALLBACK_BIT(n) ((n) < 0 ? 0 : 1 << (n)) 41 42struct callback { 43 int opmask; /* want these types of callback */ 44 char msg[SCRIPT_LEN]; /* with this data (E.164) */ 45}; 46 47#define REJECTED(p, x) ((p)->his_reject & (1<<(x))) 48 49struct lcp { 50 struct fsm fsm; /* The finite state machine */ 51 u_int16_t his_mru; /* Peers maximum packet size */ 52 u_int16_t his_mrru; /* Peers maximum reassembled packet size (MP) */ 53 u_int32_t his_accmap; /* Peeers async char control map */ 54 u_int32_t his_magic; /* Peers magic number */ 55 u_int32_t his_lqrperiod; /* Peers LQR frequency (100ths of seconds) */ 56 u_short his_auth; /* Peer wants this type of authentication */ 57 u_char his_authtype; /* Fifth octet of REQ/NAK/REJ */ 58 struct callback his_callback; /* Peer wants callback ? */ 59 unsigned his_shortseq : 1; /* Peer would like only 12bit seqs (MP) */ 60 unsigned his_protocomp : 1; /* Does peer do Protocol field compression */ 61 unsigned his_acfcomp : 1; /* Does peer do addr & cntrl fld compression */ 62 unsigned mru_req : 1; /* Has the peer requested an MRU */ 63 64 u_short want_mru; /* Our maximum packet size */ 65 u_short want_mrru; /* Our maximum reassembled packet size (MP) */ 66 u_int32_t want_accmap; /* Our async char control map */ 67 u_int32_t want_magic; /* Our magic number */ 68 u_int32_t want_lqrperiod; /* Our LQR frequency (100ths of seconds) */ 69 u_short want_auth; /* We want this type of authentication */ 70 u_char want_authtype; /* Fifth octet of REQ/NAK/REJ */ 71 struct callback want_callback;/* We want callback ? */ 72 unsigned want_shortseq : 1; /* I'd like only 12bit seqs (MP) */ 73 unsigned want_protocomp : 1; /* Do we do protocol field compression */ 74 unsigned want_acfcomp : 1; /* Do we do addr & cntrl fld compression */ 75 76 u_int32_t his_reject; /* Request codes rejected by peer */ 77 u_int32_t my_reject; /* Request codes I have rejected */ 78 79 u_short auth_iwait; /* I must authenticate to the peer */ 80 u_short auth_ineed; /* I require that the peer authenticates */ 81 82 int LcpFailedMagic; /* Number of `magic is same' errors */ 83 84 struct { 85 u_short mru; /* Preferred MRU value */ 86 u_short max_mru; /* Preferred MRU value */ 87 u_short mtu; /* Preferred MTU */ 88 u_short max_mtu; /* Preferred MTU */ 89 u_int32_t accmap; /* Initial ACCMAP value */ 90 int openmode; /* when to start CFG REQs */ 91 u_int32_t lqrperiod; /* LQR frequency (seconds) */ 92 struct fsm_retry fsm; /* How often/frequently to resend requests */ 93 unsigned acfcomp : 2; /* Address & Control Field Compression neg */ 94 unsigned chap05 : 2; /* Challenge Handshake Authentication proto */ 95#ifndef NODES 96 unsigned chap80nt : 2; /* Microsoft (NT) CHAP */ 97 unsigned chap80lm : 2; /* Microsoft (LANMan) CHAP */ 98 unsigned chap81 : 2; /* Microsoft CHAP v2 */ 99#endif 100 unsigned lqr : 2; /* Link Quality Report */ 101 unsigned pap : 2; /* Password Authentication protocol */ 102 unsigned protocomp : 2; /* Protocol field compression */ 103 char ident[DEF_MRU - 7]; /* SendIdentification() data */ 104 } cfg; 105}; 106 107#define LCP_MAXCODE CODE_IDENT 108#define LCP_MINMPCODE CODE_CODEREJ 109 110#define TY_MRU 1 /* Maximum-Receive-Unit */ 111#define TY_ACCMAP 2 /* Async-Control-Character-Map */ 112#define TY_AUTHPROTO 3 /* Authentication-Protocol */ 113#define TY_QUALPROTO 4 /* Quality-Protocol */ 114#define TY_MAGICNUM 5 /* Magic-Number */ 115#define TY_RESERVED 6 /* RESERVED */ 116#define TY_PROTOCOMP 7 /* Protocol-Field-Compression */ 117#define TY_ACFCOMP 8 /* Address-and-Control-Field-Compression */ 118#define TY_FCSALT 9 /* FCS-Alternatives */ 119#define TY_SDP 10 /* Self-Describing-Padding */ 120#define TY_CALLBACK 13 /* Callback */ 121#define TY_CFRAMES 15 /* Compound-frames */ 122#define TY_MRRU 17 /* Max Reconstructed Receive Unit (MP) */ 123#define TY_SHORTSEQ 18 /* Want short seqs (12bit) please (see mp.h) */ 124#define TY_ENDDISC 19 /* Endpoint discriminator */ 125 126#define MAX_LCP_OPT_LEN 20 127struct lcp_opt { 128 u_char id; 129 u_char len; 130 u_char data[MAX_LCP_OPT_LEN-2]; 131}; 132 133#define INC_LCP_OPT(ty, length, o) \ 134 do { \ 135 (o)->id = (ty); \ 136 (o)->len = (length); \ 137 (o) = (struct lcp_opt *)((char *)(o) + (length)); \ 138 } while (0) 139 140struct mbuf; 141struct link; 142struct bundle; 143struct cmdargs; 144 145#define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL) 146 147extern void lcp_Init(struct lcp *, struct bundle *, struct link *, 148 const struct fsm_parent *); 149extern void lcp_Setup(struct lcp *, int); 150 151extern void lcp_SendProtoRej(struct lcp *, u_char *, int); 152extern int lcp_SendIdentification(struct lcp *); 153extern void lcp_RecvIdentification(struct lcp *, char *); 154extern int lcp_ReportStatus(struct cmdargs const *); 155extern struct mbuf *lcp_Input(struct bundle *, struct link *, struct mbuf *); 156extern void lcp_SetupCallbacks(struct lcp *); 157