xref: /dflybsd-src/usr.sbin/ppp/lcp.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*-
286d7f5d3SJohn Marino  * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
386d7f5d3SJohn Marino  *          based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
486d7f5d3SJohn Marino  *                           Internet Initiative Japan, Inc (IIJ)
586d7f5d3SJohn Marino  * All rights reserved.
686d7f5d3SJohn Marino  *
786d7f5d3SJohn Marino  * Redistribution and use in source and binary forms, with or without
886d7f5d3SJohn Marino  * modification, are permitted provided that the following conditions
986d7f5d3SJohn Marino  * are met:
1086d7f5d3SJohn Marino  * 1. Redistributions of source code must retain the above copyright
1186d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer.
1286d7f5d3SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
1386d7f5d3SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
1486d7f5d3SJohn Marino  *    documentation and/or other materials provided with the distribution.
1586d7f5d3SJohn Marino  *
1686d7f5d3SJohn Marino  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1786d7f5d3SJohn Marino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1886d7f5d3SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1986d7f5d3SJohn Marino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2086d7f5d3SJohn Marino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2186d7f5d3SJohn Marino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2286d7f5d3SJohn Marino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2386d7f5d3SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2486d7f5d3SJohn Marino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2586d7f5d3SJohn Marino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2686d7f5d3SJohn Marino  * SUCH DAMAGE.
2786d7f5d3SJohn Marino  *
2886d7f5d3SJohn Marino  * $FreeBSD: src/usr.sbin/ppp/lcp.h,v 1.23.2.6 2002/09/01 02:12:28 brian Exp $
2986d7f5d3SJohn Marino  * $DragonFly: src/usr.sbin/ppp/lcp.h,v 1.2 2003/06/17 04:30:00 dillon Exp $
3086d7f5d3SJohn Marino  */
3186d7f5d3SJohn Marino 
3286d7f5d3SJohn Marino /* callback::opmask values */
3386d7f5d3SJohn Marino #define CALLBACK_AUTH		(0)
3486d7f5d3SJohn Marino #define CALLBACK_DIALSTRING	(1)	/* Don't do this */
3586d7f5d3SJohn Marino #define CALLBACK_LOCATION	(2)	/* Don't do this */
3686d7f5d3SJohn Marino #define CALLBACK_E164		(3)
3786d7f5d3SJohn Marino #define CALLBACK_NAME		(4)	/* Don't do this */
3886d7f5d3SJohn Marino #define CALLBACK_CBCP		(6)
3986d7f5d3SJohn Marino #define CALLBACK_NONE		(14)	/* No callback is ok */
4086d7f5d3SJohn Marino 
4186d7f5d3SJohn Marino #define CALLBACK_BIT(n) ((n) < 0 ? 0 : 1 << (n))
4286d7f5d3SJohn Marino 
4386d7f5d3SJohn Marino struct callback {
4486d7f5d3SJohn Marino   int opmask;			/* want these types of callback */
4586d7f5d3SJohn Marino   char msg[SCRIPT_LEN];		/* with this data (E.164) */
4686d7f5d3SJohn Marino };
4786d7f5d3SJohn Marino 
4886d7f5d3SJohn Marino #define	REJECTED(p, x)	((p)->his_reject & (1<<(x)))
4986d7f5d3SJohn Marino 
5086d7f5d3SJohn Marino struct lcp {
5186d7f5d3SJohn Marino   struct fsm fsm;		/* The finite state machine */
5286d7f5d3SJohn Marino   u_int16_t his_mru;		/* Peers maximum packet size */
5386d7f5d3SJohn Marino   u_int16_t his_mrru;		/* Peers maximum reassembled packet size (MP) */
5486d7f5d3SJohn Marino   u_int32_t his_accmap;		/* Peeers async char control map */
5586d7f5d3SJohn Marino   u_int32_t his_magic;		/* Peers magic number */
5686d7f5d3SJohn Marino   u_int32_t his_lqrperiod;	/* Peers LQR frequency (100ths of seconds) */
5786d7f5d3SJohn Marino   u_short his_auth;		/* Peer wants this type of authentication */
5886d7f5d3SJohn Marino   u_char his_authtype;		/* Fifth octet of REQ/NAK/REJ */
5986d7f5d3SJohn Marino   struct callback his_callback;	/* Peer wants callback ? */
6086d7f5d3SJohn Marino   unsigned his_shortseq : 1;	/* Peer would like only 12bit seqs (MP) */
6186d7f5d3SJohn Marino   unsigned his_protocomp : 1;	/* Does peer do Protocol field compression */
6286d7f5d3SJohn Marino   unsigned his_acfcomp : 1;	/* Does peer do addr & cntrl fld compression */
6386d7f5d3SJohn Marino   unsigned mru_req : 1;		/* Has the peer requested an MRU */
6486d7f5d3SJohn Marino 
6586d7f5d3SJohn Marino   u_short want_mru;		/* Our maximum packet size */
6686d7f5d3SJohn Marino   u_short want_mrru;		/* Our maximum reassembled packet size (MP) */
6786d7f5d3SJohn Marino   u_int32_t want_accmap;	/* Our async char control map */
6886d7f5d3SJohn Marino   u_int32_t want_magic;		/* Our magic number */
6986d7f5d3SJohn Marino   u_int32_t want_lqrperiod;	/* Our LQR frequency (100ths of seconds) */
7086d7f5d3SJohn Marino   u_short want_auth;		/* We want this type of authentication */
7186d7f5d3SJohn Marino   u_char want_authtype;		/* Fifth octet of REQ/NAK/REJ */
7286d7f5d3SJohn Marino   struct callback want_callback;/* We want callback ? */
7386d7f5d3SJohn Marino   unsigned want_shortseq : 1;	/* I'd like only 12bit seqs (MP) */
7486d7f5d3SJohn Marino   unsigned want_protocomp : 1;	/* Do we do protocol field compression */
7586d7f5d3SJohn Marino   unsigned want_acfcomp : 1;	/* Do we do addr & cntrl fld compression */
7686d7f5d3SJohn Marino 
7786d7f5d3SJohn Marino   u_int32_t his_reject;		/* Request codes rejected by peer */
7886d7f5d3SJohn Marino   u_int32_t my_reject;		/* Request codes I have rejected */
7986d7f5d3SJohn Marino 
8086d7f5d3SJohn Marino   u_short auth_iwait;		/* I must authenticate to the peer */
8186d7f5d3SJohn Marino   u_short auth_ineed;		/* I require that the peer authenticates */
8286d7f5d3SJohn Marino 
8386d7f5d3SJohn Marino   int LcpFailedMagic;		/* Number of `magic is same' errors */
8486d7f5d3SJohn Marino 
8586d7f5d3SJohn Marino   struct {
8686d7f5d3SJohn Marino     u_short mru;		/* Preferred MRU value */
8786d7f5d3SJohn Marino     u_short max_mru;		/* Preferred MRU value */
8886d7f5d3SJohn Marino     u_short mtu;		/* Preferred MTU */
8986d7f5d3SJohn Marino     u_short max_mtu;		/* Preferred MTU */
9086d7f5d3SJohn Marino     u_int32_t accmap;		/* Initial ACCMAP value */
9186d7f5d3SJohn Marino     int openmode;		/* when to start CFG REQs */
9286d7f5d3SJohn Marino     u_int32_t lqrperiod;	/* LQR frequency (seconds) */
9386d7f5d3SJohn Marino     struct fsm_retry fsm;	/* How often/frequently to resend requests */
9486d7f5d3SJohn Marino     unsigned acfcomp : 2;	/* Address & Control Field Compression neg */
9586d7f5d3SJohn Marino     unsigned chap05 : 2;	/* Challenge Handshake Authentication proto */
9686d7f5d3SJohn Marino #ifndef NODES
9786d7f5d3SJohn Marino     unsigned chap80nt : 2;	/* Microsoft (NT) CHAP */
9886d7f5d3SJohn Marino     unsigned chap80lm : 2;	/* Microsoft (LANMan) CHAP */
9986d7f5d3SJohn Marino     unsigned chap81 : 2;	/* Microsoft CHAP v2 */
10086d7f5d3SJohn Marino #endif
10186d7f5d3SJohn Marino     unsigned lqr : 2;		/* Link Quality Report */
10286d7f5d3SJohn Marino     unsigned pap : 2;		/* Password Authentication protocol */
10386d7f5d3SJohn Marino     unsigned protocomp : 2;	/* Protocol field compression */
10486d7f5d3SJohn Marino     char ident[DEF_MRU - 7];	/* SendIdentification() data */
10586d7f5d3SJohn Marino   } cfg;
10686d7f5d3SJohn Marino };
10786d7f5d3SJohn Marino 
10886d7f5d3SJohn Marino #define	LCP_MAXCODE	CODE_IDENT
10986d7f5d3SJohn Marino #define	LCP_MINMPCODE	CODE_CODEREJ
11086d7f5d3SJohn Marino 
11186d7f5d3SJohn Marino #define	TY_MRU		1	/* Maximum-Receive-Unit */
11286d7f5d3SJohn Marino #define	TY_ACCMAP	2	/* Async-Control-Character-Map */
11386d7f5d3SJohn Marino #define	TY_AUTHPROTO	3	/* Authentication-Protocol */
11486d7f5d3SJohn Marino #define	TY_QUALPROTO	4	/* Quality-Protocol */
11586d7f5d3SJohn Marino #define	TY_MAGICNUM	5	/* Magic-Number */
11686d7f5d3SJohn Marino #define	TY_RESERVED	6	/* RESERVED */
11786d7f5d3SJohn Marino #define	TY_PROTOCOMP	7	/* Protocol-Field-Compression */
11886d7f5d3SJohn Marino #define	TY_ACFCOMP	8	/* Address-and-Control-Field-Compression */
11986d7f5d3SJohn Marino #define	TY_FCSALT	9	/* FCS-Alternatives */
12086d7f5d3SJohn Marino #define	TY_SDP		10	/* Self-Describing-Padding */
12186d7f5d3SJohn Marino #define	TY_CALLBACK	13	/* Callback */
12286d7f5d3SJohn Marino #define	TY_CFRAMES	15	/* Compound-frames */
12386d7f5d3SJohn Marino #define	TY_MRRU		17	/* Max Reconstructed Receive Unit (MP) */
12486d7f5d3SJohn Marino #define	TY_SHORTSEQ	18	/* Want short seqs (12bit) please (see mp.h) */
12586d7f5d3SJohn Marino #define	TY_ENDDISC	19	/* Endpoint discriminator */
12686d7f5d3SJohn Marino 
12786d7f5d3SJohn Marino struct mbuf;
12886d7f5d3SJohn Marino struct link;
12986d7f5d3SJohn Marino struct bundle;
13086d7f5d3SJohn Marino struct cmdargs;
13186d7f5d3SJohn Marino 
13286d7f5d3SJohn Marino #define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL)
13386d7f5d3SJohn Marino 
13486d7f5d3SJohn Marino extern void lcp_Init(struct lcp *, struct bundle *, struct link *,
13586d7f5d3SJohn Marino                      const struct fsm_parent *);
13686d7f5d3SJohn Marino extern void lcp_Setup(struct lcp *, int);
13786d7f5d3SJohn Marino 
13886d7f5d3SJohn Marino extern void lcp_SendProtoRej(struct lcp *, u_char *, int);
13986d7f5d3SJohn Marino extern int lcp_SendIdentification(struct lcp *);
14086d7f5d3SJohn Marino extern void lcp_RecvIdentification(struct lcp *, char *);
14186d7f5d3SJohn Marino extern int lcp_ReportStatus(struct cmdargs const *);
14286d7f5d3SJohn Marino extern struct mbuf *lcp_Input(struct bundle *, struct link *, struct mbuf *);
14386d7f5d3SJohn Marino extern void lcp_SetupCallbacks(struct lcp *);
144