1 /*
2  * lcp.h - Link Control Protocol definitions.
3  *
4  * Copyright (c) 2000 by Sun Microsystems, Inc.
5  * All rights reserved.
6  *
7  * Copyright (c) 1989 Carnegie Mellon University.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that the above copyright notice and this paragraph are
12  * duplicated in all such forms and that any documentation,
13  * advertising materials, and other materials related to such
14  * distribution and use acknowledge that the software was developed
15  * by Carnegie Mellon University.  The name of the
16  * University may not be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
20  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21  *
22  * $Id: lcp.h,v 1.15 2000/04/04 07:06:51 paulus Exp $
23  */
24 
25 #ifndef __LCP_H_
26 #define __LCP_H_
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 /*
33  * Options.
34  */
35 #define CI_MRU		1	/* Maximum Receive Unit */
36 #define CI_ASYNCMAP	2	/* Async Control Character Map */
37 #define CI_AUTHTYPE	3	/* Authentication Type */
38 #define CI_QUALITY	4	/* Quality Protocol */
39 #define CI_MAGICNUMBER	5	/* Magic Number */
40 #define CI_PCOMPRESSION	7	/* Protocol Field Compression */
41 #define CI_ACCOMPRESSION 8	/* Address/Control Field Compression */
42 #define CI_FCSALTERN	9	/* FCS Alternatives */
43 #define CI_NUMBERED	11	/* Numbered Mode */
44 #define CI_CALLBACK	13	/* callback */
45 #define CI_MRRU		17	/* max reconstructed receive unit; multilink */
46 #define CI_SSNHF	18	/* short sequence numbers for multilink */
47 #define CI_EPDISC	19	/* endpoint discriminator */
48 #define CI_LINKDISC	23	/* Link Discriminator (BACP) */
49 #define CI_COBS		25	/* Consistent Overhead Byte Stuffing */
50 #define CI_PFXELISION	26	/* Prefix Elision */
51 #define CI_MPHDRFMT	27	/* Multilink Header Format */
52 #define CI_I18N		28	/* Internationalization */
53 #define CI_SDL		29	/* Simple Data Link */
54 #define CI_MUXING	30	/* PPP Muxing */
55 
56 /*
57  * LCP-specific packet types.
58  */
59 #define CODE_PROTREJ		8	/* Protocol Reject */
60 #define CODE_ECHOREQ		9	/* Echo Request */
61 #define CODE_ECHOREP		10	/* Echo Reply */
62 #define CODE_DISCREQ		11	/* Discard Request */
63 #define CODE_IDENT		12	/* Identification */
64 #define CODE_TIMEREMAIN		13	/* Time Remaining */
65 
66 /*
67  * Callback operation field values
68  */
69 #define CBOP_AUTH	0	/* Location determined by user auth */
70 #define CBOP_DIALSTR	1	/* Dialing string */
71 #define CBOP_LOCATION	2	/* Location identifier */
72 #define CBOP_E164	3	/* E.164 number */
73 #define CBOP_X500	4	/* X.500 distinguished name */
74 #define CBOP_CBCP	6	/* Use callback control protocol */
75 
76 /* FCS-Alternatives bits (RFC 1570) */
77 #define	FCSALT_NULL	1	/* None for network data; default otherwise */
78 #define	FCSALT_16	2	/* CRC-16 */
79 #define	FCSALT_32	4	/* CRC-32 */
80 
81 /* An endpoint discriminator, used with multilink. */
82 #define MAX_ENDP_LEN    20      /* maximum length of discriminator value */
83 struct epdisc {
84     unsigned char       class;
85     unsigned char       length;
86     unsigned char       value[MAX_ENDP_LEN];
87 };
88 
89 /* values for epdisc.class */
90 #define EPD_NULL	0	/* null discriminator, no data */
91 #define EPD_LOCAL	1
92 #define EPD_IP		2
93 #define EPD_MAC		3
94 #define EPD_MAGIC	4
95 #define EPD_PHONENUM	5
96 
97 /*
98  * The state of options is described by an lcp_options structure.
99  *
100  * We encode CHAP/MS-CHAP/MS-CHAPv2 options as Booleans.  This is done
101  * so that we can represent the choices of requiring or refusing each
102  * separately.  The chap_mdtype value can't do that.
103  */
104 typedef struct lcp_options {
105     bool passive;		/* Don't die if we don't get a response */
106     bool silent;		/* Wait for the other end to start first */
107     bool restart;		/* Restart vs. exit after close */
108     bool neg_mru;		/* Negotiate the MRU? */
109     bool neg_asyncmap;		/* Negotiate the async map? */
110     bool neg_upap;		/* Ask for UPAP authentication? */
111     bool neg_chap;		/* Ask for CHAP authentication? */
112     bool neg_mschap;		/* Ask for MS-CHAPv1 authentication? */
113     bool neg_mschapv2;		/* Ask for MS-CHAPv2 authentication? */
114     bool neg_magicnumber;	/* Ask for magic number? */
115     bool neg_pcompression;	/* HDLC Protocol Field Compression? */
116     bool neg_accompression;	/* HDLC Address/Control Field Compression? */
117     bool neg_lqr;		/* Negotiate use of Link Quality Reports */
118     bool neg_cbcp;		/* Negotiate use of CBCP */
119     bool neg_mrru;		/* negotiate multilink MRRU */
120 #ifdef MUX_FRAME
121     u_int32_t pppmux;           /* Negotiate for PPP Multiplexing option */
122 #endif
123     bool neg_ssnhf;		/* negotiate short sequence numbers */
124     bool neg_endpoint;		/* negotiate endpoint discriminator */
125     bool neg_fcs;		/* negotiate FCS alternatives */
126     int  mru;			/* Value of MRU */
127     int	 mrru;			/* Value of MRRU, and multilink enable */
128     u_char chap_mdtype;		/* which MD type (hashing algorithm) */
129     u_char fcs_type;		/* selected FCS type(s) */
130     u_int32_t asyncmap;		/* Value of async map */
131     u_int32_t magicnumber;
132     int  numloops;		/* Number of loops during magic number neg. */
133     u_int32_t lqr_period;	/* Reporting period for LQR 1/100ths second */
134     struct epdisc endpoint;	/* endpoint discriminator */
135 } lcp_options;
136 
137 /*
138  * The structure passed to lcp_settimeremaining(), holds the unit
139  * number of the link being timed, and the time remaining for that
140  * connection.
141  */
142 struct lcp_timer {
143     int unit;
144     u_int32_t tr;
145 };
146 
147 extern fsm lcp_fsm[];
148 extern lcp_options lcp_wantoptions[];
149 extern lcp_options lcp_gotoptions[];
150 extern lcp_options lcp_allowoptions[];
151 extern lcp_options lcp_hisoptions[];
152 extern u_int32_t xmit_accm[][8];
153 
154 void lcp_open __P((int));
155 void lcp_close __P((int, char *));
156 void lcp_lowerup __P((int));
157 void lcp_lowerdown __P((int));
158 void lcp_sprotrej __P((int, u_char *, int));	/* send protocol reject */
159 void lcp_settimeremaining __P((int, u_int32_t, u_int32_t));
160 
161 /*
162  * Procedures exported from multilink.c
163  */
164 extern char *epdisc_to_str __P((struct epdisc *));
165 				/* string from endpoint discriminator */
166 extern int  str_to_epdisc __P((struct epdisc *, char *));
167 				/* endpt discriminator from str */
168 
169 extern struct protent lcp_protent;
170 
171 /* Default number of times we receive our magic number from the peer
172    before deciding the link is looped-back. */
173 #define DEFLOOPBACKFAIL	10
174 
175 #ifdef	__cplusplus
176 }
177 #endif
178 
179 #endif /* __LCP_H_ */
180