xref: /freebsd/usr.sbin/ppp/lcp.h (revision 380a989b3223d455375b4fae70fd0b9bdd43bafb)
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  * $Id: lcp.h,v 1.18 1998/06/27 23:48:48 brian Exp $
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   struct callback his_callback;	/* Peer wants callback ? */
50   unsigned his_shortseq : 1;	/* Peer would like only 12bit seqs (MP) */
51   unsigned his_protocomp : 1;	/* Does peer do Protocol field compression */
52   unsigned his_acfcomp : 1;	/* Does peer do addr & cntrl fld compression */
53 
54   u_short want_mru;		/* Our maximum packet size */
55   u_short want_mrru;		/* Our maximum reassembled packet size (MP) */
56   u_int32_t want_accmap;	/* Our async char control map */
57   u_int32_t want_magic;		/* Our magic number */
58   u_int32_t want_lqrperiod;	/* Our LQR frequency (100ths of seconds) */
59   u_short want_auth;		/* We want this type of authentication */
60   struct callback want_callback;/* We want callback ? */
61   unsigned want_shortseq : 1;	/* I'd like only 12bit seqs (MP) */
62   unsigned want_protocomp : 1;	/* Do we do protocol field compression */
63   unsigned want_acfcomp : 1;	/* Do we do addr & cntrl fld compression */
64 
65   u_int32_t his_reject;		/* Request codes rejected by peer */
66   u_int32_t my_reject;		/* Request codes I have rejected */
67 
68   u_short auth_iwait;		/* I must authenticate to the peer */
69   u_short auth_ineed;		/* I require that the peer authenticates */
70 
71   int LcpFailedMagic;		/* Number of `magic is same' errors */
72 
73   struct {
74     u_short mru;		/* Preferred MRU value */
75     u_int32_t accmap;		/* Initial ACCMAP value */
76     int openmode;		/* when to start CFG REQs */
77     u_int32_t lqrperiod;	/* LQR frequency (seconds) */
78     u_int fsmretry;		/* FSM retry frequency */
79 
80     unsigned acfcomp : 2;	/* Address & Control Field Compression neg */
81     unsigned chap : 2;		/* Challenge Handshake Authentication proto */
82     unsigned lqr : 2;		/* Link Quality Report */
83     unsigned pap : 2;		/* Password Authentication protocol */
84     unsigned protocomp : 2;	/* Protocol field compression */
85   } cfg;
86 };
87 
88 #define	LCP_MAXCODE	CODE_DISCREQ
89 #define	LCP_MINMPCODE	CODE_CODEREJ
90 
91 #define	TY_MRU		1	/* Maximum-Receive-Unit */
92 #define	TY_ACCMAP	2	/* Async-Control-Character-Map */
93 #define	TY_AUTHPROTO	3	/* Authentication-Protocol */
94 #define	TY_QUALPROTO	4	/* Quality-Protocol */
95 #define	TY_MAGICNUM	5	/* Magic-Number */
96 #define	TY_RESERVED	6	/* RESERVED */
97 #define	TY_PROTOCOMP	7	/* Protocol-Field-Compression */
98 #define	TY_ACFCOMP	8	/* Address-and-Control-Field-Compression */
99 #define	TY_FCSALT	9	/* FCS-Alternatives */
100 #define	TY_SDP		10	/* Self-Describing-Padding */
101 #define	TY_CALLBACK	13	/* Callback */
102 #define	TY_CFRAMES	15	/* Compound-frames */
103 #define	TY_MRRU		17	/* Max Reconstructed Receive Unit (MP) */
104 #define	TY_SHORTSEQ	18	/* Want short seqs (12bit) please (see mp.h) */
105 #define	TY_ENDDISC	19	/* Endpoint discriminator */
106 
107 #define MAX_LCP_OPT_LEN 20
108 struct lcp_opt {
109   u_char id;
110   u_char len;
111   u_char data[MAX_LCP_OPT_LEN-2];
112 };
113 
114 #define INC_LCP_OPT(ty, length, o)                    \
115   do {                                                \
116     (o)->id = (ty);                                   \
117     (o)->len = (length);                              \
118     (o) = (struct lcp_opt *)((char *)(o) + (length)); \
119   } while (0)
120 
121 struct mbuf;
122 struct link;
123 struct physical;
124 struct bundle;
125 struct cmdargs;
126 
127 #define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL)
128 
129 extern void lcp_Init(struct lcp *, struct bundle *, struct link *,
130                      const struct fsm_parent *);
131 extern void lcp_Setup(struct lcp *, int);
132 
133 extern void lcp_SendProtoRej(struct lcp *, u_char *, int);
134 extern int lcp_ReportStatus(struct cmdargs const *);
135 extern void lcp_Input(struct lcp *, struct mbuf *);
136 extern void lcp_SetupCallbacks(struct lcp *);
137