ccp.h revision 46686
1133359Sobrien/* 2133359Sobrien * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 3133359Sobrien * 4186690Sobrien * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 5133359Sobrien * 6133359Sobrien * Redistribution and use in source and binary forms are permitted 7133359Sobrien * provided that the above copyright notice and this paragraph are 8133359Sobrien * duplicated in all such forms and that any documentation, 9133359Sobrien * advertising materials, and other materials related to such 10133359Sobrien * distribution and use acknowledge that the software was developed 11133359Sobrien * by the Internet Initiative Japan. The name of the 12133359Sobrien * IIJ may not be used to endorse or promote products derived 13133359Sobrien * from this software without specific prior written permission. 14186690Sobrien * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 15133359Sobrien * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 16133359Sobrien * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 17133359Sobrien * 18133359Sobrien * $Id: ccp.h,v 1.20 1999/02/26 21:28:07 brian Exp $ 19133359Sobrien * 20133359Sobrien * TODO: 21133359Sobrien */ 22133359Sobrien 23133359Sobrien#define CCP_MAXCODE CODE_RESETACK 24133359Sobrien 25133359Sobrien#define TY_OUI 0 /* OUI */ 26133359Sobrien#define TY_PRED1 1 /* Predictor type 1 */ 27133359Sobrien#define TY_PRED2 2 /* Predictor type 2 */ 28133359Sobrien#define TY_PUDDLE 3 /* Puddle Jumper */ 29191736Sobrien#define TY_HWPPC 16 /* Hewlett-Packard PPC */ 30191736Sobrien#define TY_STAC 17 /* Stac Electronics LZS */ 31192348Sdelphij#define TY_MSPPC 18 /* Microsoft PPC */ 32191736Sobrien#define TY_GAND 19 /* Gandalf FZA */ 33191736Sobrien#define TY_V42BIS 20 /* V.42bis compression */ 34133359Sobrien#define TY_BSD 21 /* BSD LZW Compress */ 35133359Sobrien#define TY_PPPD_DEFLATE 24 /* Deflate (gzip) - (mis) numbered by pppd */ 36133359Sobrien#define TY_DEFLATE 26 /* Deflate (gzip) - rfc 1979 */ 37133359Sobrien 38133359Sobrien#define CCP_NEG_DEFLATE 0 39133359Sobrien#define CCP_NEG_PRED1 1 40133359Sobrien#define CCP_NEG_DEFLATE24 2 41133359Sobrien#define CCP_NEG_TOTAL 3 42186690Sobrien 43169942Sobrienstruct mbuf; 44186690Sobrienstruct link; 45133359Sobrien 46133359Sobrienstruct ccp_config { 47133359Sobrien struct { 48133359Sobrien struct { 49133359Sobrien int winsize; 50133359Sobrien } in, out; 51133359Sobrien } deflate; 52133359Sobrien struct fsm_retry fsm; /* How often/frequently to resend requests */ 53133359Sobrien unsigned neg[CCP_NEG_TOTAL]; 54133359Sobrien}; 55133359Sobrien 56133359Sobrienstruct ccp_opt { 57133359Sobrien struct ccp_opt *next; 58133359Sobrien int algorithm; 59133359Sobrien struct lcp_opt val; 60133359Sobrien}; 61133359Sobrien 62133359Sobrienstruct ccp { 63133359Sobrien struct fsm fsm; /* The finite state machine */ 64186690Sobrien 65186690Sobrien int his_proto; /* peer's compression protocol */ 66186690Sobrien int my_proto; /* our compression protocol */ 67186690Sobrien 68186690Sobrien int reset_sent; /* If != -1, ignore compressed 'till ack */ 69186690Sobrien int last_reset; /* We can receive more (dups) w/ this id */ 70186690Sobrien 71186690Sobrien struct { 72186690Sobrien int algorithm; /* Algorithm in use */ 73133359Sobrien void *state; /* Returned by implementations Init() */ 74133359Sobrien struct lcp_opt opt; /* Set by implementations OptInit() */ 75133359Sobrien } in; 76186690Sobrien 77175296Sobrien struct { 78175296Sobrien int algorithm; /* Algorithm in use */ 79175296Sobrien void *state; /* Returned by implementations Init() */ 80133359Sobrien struct ccp_opt *opt; /* Set by implementations OptInit() */ 81159764Sobrien } out; 82159764Sobrien 83159764Sobrien u_int32_t his_reject; /* Request codes rejected by peer */ 84159764Sobrien u_int32_t my_reject; /* Request codes I have rejected */ 85133359Sobrien 86133359Sobrien u_long uncompout, compout; /* Outgoing bytes before/after compression */ 87133359Sobrien u_long uncompin, compin; /* Incoming bytes after/before decompression */ 88133359Sobrien 89186690Sobrien struct ccp_config cfg; 90133359Sobrien}; 91186690Sobrien 92186690Sobrien#define fsm2ccp(fp) (fp->proto == PROTO_CCP ? (struct ccp *)fp : NULL) 93133359Sobrien 94133359Sobrienstruct ccp_algorithm { 95133359Sobrien int id; 96133359Sobrien int Neg; /* ccp_config neg array item */ 97186690Sobrien const char *(*Disp)(struct lcp_opt *); /* Use result immediately ! */ 98133359Sobrien struct { 99133359Sobrien int (*Set)(struct lcp_opt *, const struct ccp_config *); 100186690Sobrien void *(*Init)(struct lcp_opt *); 101186690Sobrien void (*Term)(void *); 102139368Sobrien void (*Reset)(void *); 103186690Sobrien struct mbuf *(*Read)(void *, struct ccp *, u_short *, struct mbuf *); 104186690Sobrien void (*DictSetup)(void *, struct ccp *, u_short, struct mbuf *); 105139368Sobrien } i; 106191736Sobrien struct { 107133359Sobrien void (*OptInit)(struct lcp_opt *, const struct ccp_config *); 108133359Sobrien int (*Set)(struct lcp_opt *); 109169962Sobrien void *(*Init)(struct lcp_opt *); 110169962Sobrien void (*Term)(void *); 111133359Sobrien void (*Reset)(void *); 112186690Sobrien struct mbuf *(*Write)(void *, struct ccp *, struct link *, int, u_short *, 113139368Sobrien struct mbuf *); 114139368Sobrien } o; 115133359Sobrien}; 116133359Sobrien 117133359Sobrienextern void ccp_Init(struct ccp *, struct bundle *, struct link *, 118133359Sobrien const struct fsm_parent *); 119133359Sobrienextern void ccp_Setup(struct ccp *); 120133359Sobrien 121133359Sobrienextern void ccp_SendResetReq(struct fsm *); 122133359Sobrienextern struct mbuf *ccp_Input(struct bundle *, struct link *, struct mbuf *); 123133359Sobrienextern int ccp_ReportStatus(struct cmdargs const *); 124133359Sobrienextern u_short ccp_Proto(struct ccp *); 125133359Sobrienextern void ccp_SetupCallbacks(struct ccp *); 126133359Sobrienextern int ccp_SetOpenMode(struct ccp *); 127133359Sobrien 128133359Sobrienextern struct layer ccplayer; 129133359Sobrien