Home | History | Annotate | Download | only in src
      1 /*-
      2  * Copyright (c) 1996 - 2001 Brian Somers <brian (at) Awfulhak.org>
      3  *          based on work by Toshiharu OHNO <tony-o (at) 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: src/usr.sbin/ppp/lcp.h,v 1.31.26.1 2010/12/21 17:10:29 kensmith Exp $
     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 
     42 struct 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 
     49 struct 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 echo : 1;		/* Send echo Requests */
    102     unsigned pap : 2;		/* Password Authentication protocol */
    103     unsigned protocomp : 2;	/* Protocol field compression */
    104     char ident[DEF_MRU - 7];	/* SendIdentification() data */
    105   } cfg;
    106 };
    107 
    108 #define	LCP_MAXCODE	CODE_IDENT
    109 #define	LCP_MINMPCODE	CODE_CODEREJ
    110 
    111 #define	TY_MRU		1	/* Maximum-Receive-Unit */
    112 #define	TY_ACCMAP	2	/* Async-Control-Character-Map */
    113 #define	TY_AUTHPROTO	3	/* Authentication-Protocol */
    114 #define	TY_QUALPROTO	4	/* Quality-Protocol */
    115 #define	TY_MAGICNUM	5	/* Magic-Number */
    116 #define	TY_RESERVED	6	/* RESERVED */
    117 #define	TY_PROTOCOMP	7	/* Protocol-Field-Compression */
    118 #define	TY_ACFCOMP	8	/* Address-and-Control-Field-Compression */
    119 #define	TY_FCSALT	9	/* FCS-Alternatives */
    120 #define	TY_SDP		10	/* Self-Describing-Padding */
    121 #define	TY_CALLBACK	13	/* Callback */
    122 #define	TY_CFRAMES	15	/* Compound-frames */
    123 #define	TY_MRRU		17	/* Max Reconstructed Receive Unit (MP) */
    124 #define	TY_SHORTSEQ	18	/* Want short seqs (12bit) please (see mp.h) */
    125 #define	TY_ENDDISC	19	/* Endpoint discriminator */
    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