MFC: Fix comments.
[dragonfly.git] / usr.sbin / ppp / ccp.h
blob93e57c7d861c64402593b2b5c8d58bd188622ec1
1 /*-
2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org>
3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp>
4 * Internet Initiative Japan, Inc (IIJ)
5 * All rights reserved.
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.
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.
28 * $FreeBSD: src/usr.sbin/ppp/ccp.h,v 1.22.2.5 2002/09/01 02:12:23 brian Exp $
29 * $DragonFly: src/usr.sbin/ppp/ccp.h,v 1.2 2003/06/17 04:30:00 dillon Exp $
32 #define CCP_MAXCODE CODE_RESETACK
34 #define TY_OUI 0 /* OUI */
35 #define TY_PRED1 1 /* Predictor type 1 */
36 #define TY_PRED2 2 /* Predictor type 2 */
37 #define TY_PUDDLE 3 /* Puddle Jumper */
38 #define TY_HWPPC 16 /* Hewlett-Packard PPC */
39 #define TY_STAC 17 /* Stac Electronics LZS */
40 #define TY_MSPPC 18 /* Microsoft PPC */
41 #define TY_MPPE 18 /* Microsoft PPE */
42 #define TY_GAND 19 /* Gandalf FZA */
43 #define TY_V42BIS 20 /* V.42bis compression */
44 #define TY_BSD 21 /* BSD LZW Compress */
45 #define TY_PPPD_DEFLATE 24 /* Deflate (gzip) - (mis) numbered by pppd */
46 #define TY_DEFLATE 26 /* Deflate (gzip) - rfc 1979 */
48 #define CCP_NEG_DEFLATE 0
49 #define CCP_NEG_PRED1 1
50 #define CCP_NEG_DEFLATE24 2
51 #ifndef NODES
52 #define CCP_NEG_MPPE 3
53 #define CCP_NEG_TOTAL 4
54 #else
55 #define CCP_NEG_TOTAL 3
56 #endif
58 #ifndef NODES
59 enum mppe_negstate {
60 MPPE_ANYSTATE,
61 MPPE_STATELESS,
62 MPPE_STATEFUL
64 #endif
66 struct mbuf;
67 struct link;
69 struct ccp_config {
70 struct {
71 struct {
72 int winsize;
73 } in, out;
74 } deflate;
75 #ifndef NODES
76 struct {
77 int keybits;
78 enum mppe_negstate state;
79 unsigned required : 1;
80 } mppe;
81 #endif
82 struct fsm_retry fsm; /* How often/frequently to resend requests */
83 unsigned neg[CCP_NEG_TOTAL];
86 struct ccp_opt {
87 struct ccp_opt *next;
88 int algorithm;
89 struct fsm_opt val;
92 struct ccp {
93 struct fsm fsm; /* The finite state machine */
95 int his_proto; /* peer's compression protocol */
96 int my_proto; /* our compression protocol */
98 int reset_sent; /* If != -1, ignore compressed 'till ack */
99 int last_reset; /* We can receive more (dups) w/ this id */
101 struct {
102 int algorithm; /* Algorithm in use */
103 void *state; /* Returned by implementations Init() */
104 struct fsm_opt opt; /* Set by implementation's OptInit() */
105 } in;
107 struct {
108 int algorithm; /* Algorithm in use */
109 void *state; /* Returned by implementations Init() */
110 struct ccp_opt *opt; /* Set by implementation's OptInit() */
111 } out;
113 u_int32_t his_reject; /* Request codes rejected by peer */
114 u_int32_t my_reject; /* Request codes I have rejected */
116 u_long uncompout, compout; /* Outgoing bytes before/after compression */
117 u_long uncompin, compin; /* Incoming bytes after/before decompression */
119 struct ccp_config cfg;
122 #define fsm2ccp(fp) (fp->proto == PROTO_CCP ? (struct ccp *)fp : NULL)
124 struct ccp_algorithm {
125 int id;
126 int Neg; /* ccp_config neg array item */
127 const char *(*Disp)(struct fsm_opt *); /* Use result immediately ! */
128 int (*Usable)(struct fsm *); /* Ok to negotiate ? */
129 int (*Required)(struct fsm *); /* Must negotiate ? */
130 struct {
131 int (*Set)(struct bundle *, struct fsm_opt *, const struct ccp_config *);
132 void *(*Init)(struct bundle *, struct fsm_opt *);
133 void (*Term)(void *);
134 void (*Reset)(void *);
135 struct mbuf *(*Read)(void *, struct ccp *, u_short *, struct mbuf *);
136 void (*DictSetup)(void *, struct ccp *, u_short, struct mbuf *);
137 } i;
138 struct {
139 int MTUOverhead;
140 void (*OptInit)(struct bundle *, struct fsm_opt *,
141 const struct ccp_config *);
142 int (*Set)(struct bundle *, struct fsm_opt *, const struct ccp_config *);
143 void *(*Init)(struct bundle *, struct fsm_opt *);
144 void (*Term)(void *);
145 int (*Reset)(void *);
146 struct mbuf *(*Write)(void *, struct ccp *, struct link *, int, u_short *,
147 struct mbuf *);
148 } o;
151 extern void ccp_Init(struct ccp *, struct bundle *, struct link *,
152 const struct fsm_parent *);
153 extern void ccp_Setup(struct ccp *);
154 extern int ccp_Required(struct ccp *);
155 extern int ccp_MTUOverhead(struct ccp *);
157 extern void ccp_SendResetReq(struct fsm *);
158 extern struct mbuf *ccp_Input(struct bundle *, struct link *, struct mbuf *);
159 extern int ccp_ReportStatus(struct cmdargs const *);
160 extern u_short ccp_Proto(struct ccp *);
161 extern void ccp_SetupCallbacks(struct ccp *);
162 extern int ccp_SetOpenMode(struct ccp *);
163 extern int ccp_DefaultUsable(struct fsm *);
164 extern int ccp_DefaultRequired(struct fsm *);
166 extern struct layer ccplayer;