lcp.h revision 50479
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: head/usr.sbin/ppp/lcp.h 50479 1999-08-28 01:35:59Z peter $
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
34struct 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
41struct 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  } cfg;
91};
92
93#define	LCP_MAXCODE	CODE_DISCREQ
94#define	LCP_MINMPCODE	CODE_CODEREJ
95
96#define	TY_MRU		1	/* Maximum-Receive-Unit */
97#define	TY_ACCMAP	2	/* Async-Control-Character-Map */
98#define	TY_AUTHPROTO	3	/* Authentication-Protocol */
99#define	TY_QUALPROTO	4	/* Quality-Protocol */
100#define	TY_MAGICNUM	5	/* Magic-Number */
101#define	TY_RESERVED	6	/* RESERVED */
102#define	TY_PROTOCOMP	7	/* Protocol-Field-Compression */
103#define	TY_ACFCOMP	8	/* Address-and-Control-Field-Compression */
104#define	TY_FCSALT	9	/* FCS-Alternatives */
105#define	TY_SDP		10	/* Self-Describing-Padding */
106#define	TY_CALLBACK	13	/* Callback */
107#define	TY_CFRAMES	15	/* Compound-frames */
108#define	TY_MRRU		17	/* Max Reconstructed Receive Unit (MP) */
109#define	TY_SHORTSEQ	18	/* Want short seqs (12bit) please (see mp.h) */
110#define	TY_ENDDISC	19	/* Endpoint discriminator */
111
112#define MAX_LCP_OPT_LEN 20
113struct lcp_opt {
114  u_char id;
115  u_char len;
116  u_char data[MAX_LCP_OPT_LEN-2];
117};
118
119#define INC_LCP_OPT(ty, length, o)                    \
120  do {                                                \
121    (o)->id = (ty);                                   \
122    (o)->len = (length);                              \
123    (o) = (struct lcp_opt *)((char *)(o) + (length)); \
124  } while (0)
125
126struct mbuf;
127struct link;
128struct bundle;
129struct cmdargs;
130
131#define fsm2lcp(fp) (fp->proto == PROTO_LCP ? (struct lcp *)fp : NULL)
132
133extern void lcp_Init(struct lcp *, struct bundle *, struct link *,
134                     const struct fsm_parent *);
135extern void lcp_Setup(struct lcp *, int);
136
137extern void lcp_SendProtoRej(struct lcp *, u_char *, int);
138extern int lcp_ReportStatus(struct cmdargs const *);
139extern struct mbuf *lcp_Input(struct bundle *, struct link *, struct mbuf *);
140extern void lcp_SetupCallbacks(struct lcp *);
141