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