ccp.h revision 46686
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: ccp.h,v 1.20 1999/02/26 21:28:07 brian Exp $
19 *
20 *	TODO:
21 */
22
23#define	CCP_MAXCODE	CODE_RESETACK
24
25#define	TY_OUI		0	/* OUI */
26#define	TY_PRED1	1	/* Predictor type 1 */
27#define	TY_PRED2	2	/* Predictor type 2 */
28#define	TY_PUDDLE	3	/* Puddle Jumper */
29#define	TY_HWPPC	16	/* Hewlett-Packard PPC */
30#define	TY_STAC		17	/* Stac Electronics LZS */
31#define	TY_MSPPC	18	/* Microsoft PPC */
32#define	TY_GAND		19	/* Gandalf FZA */
33#define	TY_V42BIS	20	/* V.42bis compression */
34#define	TY_BSD		21	/* BSD LZW Compress */
35#define	TY_PPPD_DEFLATE	24	/* Deflate (gzip) - (mis) numbered by pppd */
36#define	TY_DEFLATE	26	/* Deflate (gzip) - rfc 1979 */
37
38#define CCP_NEG_DEFLATE		0
39#define CCP_NEG_PRED1		1
40#define CCP_NEG_DEFLATE24	2
41#define CCP_NEG_TOTAL		3
42
43struct mbuf;
44struct link;
45
46struct ccp_config {
47  struct {
48    struct {
49      int winsize;
50    } in, out;
51  } deflate;
52  struct fsm_retry fsm;	/* How often/frequently to resend requests */
53  unsigned neg[CCP_NEG_TOTAL];
54};
55
56struct ccp_opt {
57  struct ccp_opt *next;
58  int algorithm;
59  struct lcp_opt val;
60};
61
62struct ccp {
63  struct fsm fsm;		/* The finite state machine */
64
65  int his_proto;		/* peer's compression protocol */
66  int my_proto;			/* our compression protocol */
67
68  int reset_sent;		/* If != -1, ignore compressed 'till ack */
69  int last_reset;		/* We can receive more (dups) w/ this id */
70
71  struct {
72    int algorithm;		/* Algorithm in use */
73    void *state;		/* Returned by implementations Init() */
74    struct lcp_opt opt;		/* Set by implementations OptInit() */
75  } in;
76
77  struct {
78    int algorithm;		/* Algorithm in use */
79    void *state;		/* Returned by implementations Init() */
80    struct ccp_opt *opt;	/* Set by implementations OptInit() */
81  } out;
82
83  u_int32_t his_reject;		/* Request codes rejected by peer */
84  u_int32_t my_reject;		/* Request codes I have rejected */
85
86  u_long uncompout, compout;	/* Outgoing bytes before/after compression */
87  u_long uncompin, compin;	/* Incoming bytes after/before decompression */
88
89  struct ccp_config cfg;
90};
91
92#define fsm2ccp(fp) (fp->proto == PROTO_CCP ? (struct ccp *)fp : NULL)
93
94struct ccp_algorithm {
95  int id;
96  int Neg;					/* ccp_config neg array item */
97  const char *(*Disp)(struct lcp_opt *);	/* Use result immediately !  */
98  struct {
99    int (*Set)(struct lcp_opt *, const struct ccp_config *);
100    void *(*Init)(struct lcp_opt *);
101    void (*Term)(void *);
102    void (*Reset)(void *);
103    struct mbuf *(*Read)(void *, struct ccp *, u_short *, struct mbuf *);
104    void (*DictSetup)(void *, struct ccp *, u_short, struct mbuf *);
105  } i;
106  struct {
107    void (*OptInit)(struct lcp_opt *, const struct ccp_config *);
108    int (*Set)(struct lcp_opt *);
109    void *(*Init)(struct lcp_opt *);
110    void (*Term)(void *);
111    void (*Reset)(void *);
112    struct mbuf *(*Write)(void *, struct ccp *, struct link *, int, u_short *,
113                          struct mbuf *);
114  } o;
115};
116
117extern void ccp_Init(struct ccp *, struct bundle *, struct link *,
118                     const struct fsm_parent *);
119extern void ccp_Setup(struct ccp *);
120
121extern void ccp_SendResetReq(struct fsm *);
122extern struct mbuf *ccp_Input(struct bundle *, struct link *, struct mbuf *);
123extern int ccp_ReportStatus(struct cmdargs const *);
124extern u_short ccp_Proto(struct ccp *);
125extern void ccp_SetupCallbacks(struct ccp *);
126extern int ccp_SetOpenMode(struct ccp *);
127
128extern struct layer ccplayer;
129