1 /* 2 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 3 * 4 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 5 * 6 * Redistribution and use in source and binary forms are permitted 7 * provided that the above copyright notice and this paragraph are 8 * duplicated in all such forms and that any documentation, 9 * advertising materials, and other materials related to such 10 * distribution and use acknowledge that the software was developed 11 * by the Internet Initiative Japan. The name of the 12 * IIJ may not be used to endorse or promote products derived 13 * from this software without specific prior written permission. 14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17 * 18 * $FreeBSD$ 19 * 20 * TODO: 21 */ 22 23 /* callback::opmask values */ 24 #define CALLBACK_AUTH (0) 25 #define CALLBACK_DIALSTRING (1) /* Don't do this */ 26 #define CALLBACK_LOCATION (2) /* Don't do this */ 27 #define CALLBACK_E164 (3) 28 #define CALLBACK_NAME (4) /* Don't do this */ 29 #define CALLBACK_CBCP (6) 30 #define CALLBACK_NONE (14) /* No callback is ok */ 31 32 #define CALLBACK_BIT(n) ((n) < 0 ? 0 : 1 << (n)) 33 34 struct callback { 35 int opmask; /* want these types of callback */ 36 char msg[SCRIPT_LEN]; /* with this data (E.164) */ 37 }; 38 39 #define REJECTED(p, x) ((p)->his_reject & (1<<(x))) 40 41 struct lcp { 42 struct fsm fsm; /* The finite state machine */ 43 u_int16_t his_mru; /* Peers maximum packet size */ 44 u_int16_t his_mrru; /* Peers maximum reassembled packet size (MP) */ 45 u_int32_t his_accmap; /* Peeers async char control map */ 46 u_int32_t his_magic; /* Peers magic number */ 47 u_int32_t his_lqrperiod; /* Peers LQR frequency (100ths of seconds) */ 48 u_short his_auth; /* Peer wants this type of authentication */ 49 u_char his_authtype; /* Fifth octet of REQ/NAK/REJ */ 50 struct callback his_callback; /* Peer wants callback ? */ 51 unsigned his_shortseq : 1; /* Peer would like only 12bit seqs (MP) */ 52 unsigned his_protocomp : 1; /* Does peer do Protocol field compression */ 53 unsigned his_acfcomp : 1; /* Does peer do addr & cntrl fld compression */ 54 55 u_short want_mru; /* Our maximum packet size */ 56 u_short want_mrru; /* Our maximum reassembled packet size (MP) */ 57 u_int32_t want_accmap; /* Our async char control map */ 58 u_int32_t want_magic; /* Our magic number */ 59 u_int32_t want_lqrperiod; /* Our LQR frequency (100ths of seconds) */ 60 u_short want_auth; /* We want this type of authentication */ 61 u_char want_authtype; /* Fifth octet of REQ/NAK/REJ */ 62 struct callback want_callback;/* We want callback ? */ 63 unsigned want_shortseq : 1; /* I'd like only 12bit seqs (MP) */ 64 unsigned want_protocomp : 1; /* Do we do protocol field compression */ 65 unsigned want_acfcomp : 1; /* Do we do addr & cntrl fld compression */ 66 67 u_int32_t his_reject; /* Request codes rejected by peer */ 68 u_int32_t my_reject; /* Request codes I have rejected */ 69 70 u_short auth_iwait; /* I must authenticate to the peer */ 71 u_short auth_ineed; /* I require that the peer authenticates */ 72 73 int LcpFailedMagic; /* Number of `magic is same' errors */ 74 75 struct { 76 u_short mru; /* Preferred MRU value */ 77 u_int32_t accmap; /* Initial ACCMAP value */ 78 int openmode; /* when to start CFG REQs */ 79 u_int32_t lqrperiod; /* LQR frequency (seconds) */ 80 struct fsm_retry fsm; /* How often/frequently to resend requests */ 81 unsigned acfcomp : 2; /* Address & Control Field Compression neg */ 82 unsigned chap05 : 2; /* Challenge Handshake Authentication proto */ 83 #ifdef HAVE_DES 84 unsigned chap80nt : 2; /* Microsoft (NT) CHAP */ 85 unsigned chap80lm : 2; /* Microsoft (LANMan) CHAP */ 86 #endif 87 unsigned lqr : 2; /* Link Quality Report */ 88 unsigned pap : 2; /* Password Authentication protocol */ 89 unsigned protocomp : 2; /* Protocol field compression */ 90 char ident[DEF_MRU - 7]; /* SendIdentification() data */ 91 } cfg; 92 }; 93 94 #define LCP_MAXCODE CODE_IDENT 95 #define LCP_MINMPCODE CODE_CODEREJ 96 97 #define TY_MRU 1 /* Maximum-Receive-Unit */ 98 #define TY_ACCMAP 2 /* Async-Control-Character-Map */ 99 #define TY_AUTHPROTO 3 /* Authentication-Protocol */ 100 #define TY_QUALPROTO 4 /* Quality-Protocol */ 101 #define TY_MAGICNUM 5 /* Magic-Number */ 102 #define TY_RESERVED 6 /* RESERVED */ 103 #define TY_PROTOCOMP 7 /* Protocol-Field-Compression */ 104 #define TY_ACFCOMP 8 /* Address-and-Control-Field-Compression */ 105 #define TY_FCSALT 9 /* FCS-Alternatives */ 106 #define TY_SDP 10 /* Self-Describing-Padding */ 107 #define TY_CALLBACK 13 /* Callback */ 108 #define TY_CFRAMES 15 /* Compound-frames */ 109 #define TY_MRRU 17 /* Max Reconstructed Receive Unit (MP) */ 110 #define TY_SHORTSEQ 18 /* Want short seqs (12bit) please (see mp.h) */ 111 #define TY_ENDDISC 19 /* Endpoint discriminator */ 112 113 #define MAX_LCP_OPT_LEN 20 114 struct lcp_opt { 115 u_char id; 116 u_char len; 117 u_char data[MAX_LCP_OPT_LEN-2]; 118 }; 119 120 #define INC_LCP_OPT(ty, length, o) \ 121 do { \ 122 (o)->id = (ty); \ 123 (o)->len = (length); \ 124 (o) = (struct lcp_opt *)((char *)(o) + (length)); \ 125 } while (0) 126 127 struct mbuf; 128 struct link; 129 struct bundle; 130 struct cmdargs; 131 132 #define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL) 133 134 extern void lcp_Init(struct lcp *, struct bundle *, struct link *, 135 const struct fsm_parent *); 136 extern void lcp_Setup(struct lcp *, int); 137 138 extern void lcp_SendProtoRej(struct lcp *, u_char *, int); 139 extern int lcp_SendIdentification(struct lcp *); 140 extern void lcp_RecvIdentification(struct lcp *, char *); 141 extern int lcp_ReportStatus(struct cmdargs const *); 142 extern struct mbuf *lcp_Input(struct bundle *, struct link *, struct mbuf *); 143 extern void lcp_SetupCallbacks(struct lcp *); 144