X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppdump%2Fbsd-comp.c;h=9d45f0bf610d8aa3a1da7e6f0c2f254bb1745578;hb=b2c36e6c0e1655aea9b1b0a03a8160f42a26c884;hp=4ef5c7cb0b4a0c83dea740a3d84fa6a05f68deb9;hpb=1f32921b4018b34f7b05b2302f5946f58f48df61;p=ppp.git diff --git a/pppdump/bsd-comp.c b/pppdump/bsd-comp.c index 4ef5c7c..9d45f0b 100644 --- a/pppdump/bsd-comp.c +++ b/pppdump/bsd-comp.c @@ -38,12 +38,14 @@ */ /* - * $Id: bsd-comp.c,v 1.2 1999/04/01 07:26:30 paulus Exp $ + * $Id: bsd-comp.c,v 1.4 2004/01/17 05:47:55 carlsonj Exp $ */ #include +#include #include #include +#include #include "ppp_defs.h" #include "ppp-comp.h" @@ -122,15 +124,15 @@ struct bsd_db { #define BSD_OVHD 2 /* BSD compress overhead/packet */ #define BSD_INIT_BITS BSD_MIN_BITS -static void *bsd_decomp_alloc __P((u_char *options, int opt_len)); -static void bsd_free __P((void *state)); -static int bsd_decomp_init __P((void *state, u_char *options, int opt_len, - int unit, int hdrlen, int mru, int debug)); -static void bsd_incomp __P((void *state, u_char *dmsg, int len)); -static int bsd_decompress __P((void *state, u_char *cmp, int inlen, - u_char *dmp, int *outlen)); -static void bsd_reset __P((void *state)); -static void bsd_comp_stats __P((void *state, struct compstat *stats)); +static void *bsd_decomp_alloc(u_char *options, int opt_len); +static void bsd_free(void *state); +static int bsd_decomp_init(void *state, u_char *options, int opt_len, + int unit, int hdrlen, int mru, int debug); +static void bsd_incomp(void *state, u_char *dmsg, int len); +static int bsd_decompress(void *state, u_char *cmp, int inlen, + u_char *dmp, int *outlen); +static void bsd_reset(void *state); +static void bsd_comp_stats(void *state, struct compstat *stats); /* * Exported procedures. @@ -172,8 +174,7 @@ struct compressor ppp_bsd_compress = { * clear the dictionary */ static void -bsd_clear(db) - struct bsd_db *db; +bsd_clear(struct bsd_db *db) { db->clear_count++; db->max_ent = FIRST-1; @@ -198,8 +199,7 @@ bsd_clear(db) * must compute the same ratio. */ static int /* 1=output CLEAR */ -bsd_check(db) - struct bsd_db *db; +bsd_check(struct bsd_db *db) { u_int new_ratio; @@ -239,9 +239,7 @@ bsd_check(db) * Return statistics. */ static void -bsd_comp_stats(state, stats) - void *state; - struct compstat *stats; +bsd_comp_stats(void *state, struct compstat *stats) { struct bsd_db *db = (struct bsd_db *) state; u_int out; @@ -266,8 +264,7 @@ bsd_comp_stats(state, stats) * Reset state, as on a CCP ResetReq. */ static void -bsd_reset(state) - void *state; +bsd_reset(void *state) { struct bsd_db *db = (struct bsd_db *) state; @@ -280,9 +277,7 @@ bsd_reset(state) * Allocate space for a (de) compressor. */ static void * -bsd_alloc(options, opt_len, decomp) - u_char *options; - int opt_len, decomp; +bsd_alloc(u_char *options, int opt_len, int decomp) { int bits; u_int newlen, hsize, hshift, maxmaxcode; @@ -326,7 +321,7 @@ bsd_alloc(options, opt_len, decomp) db = (struct bsd_db *) malloc(newlen); if (!db) return NULL; - bzero(db, sizeof(*db) - sizeof(db->dict)); + memset(db, 0, sizeof(*db) - sizeof(db->dict)); if (!decomp) { db->lens = NULL; @@ -348,8 +343,7 @@ bsd_alloc(options, opt_len, decomp) } static void -bsd_free(state) - void *state; +bsd_free(void *state) { struct bsd_db *db = (struct bsd_db *) state; @@ -359,9 +353,7 @@ bsd_free(state) } static void * -bsd_decomp_alloc(options, opt_len) - u_char *options; - int opt_len; +bsd_decomp_alloc(u_char *options, int opt_len) { return bsd_alloc(options, opt_len, 1); } @@ -370,10 +362,8 @@ bsd_decomp_alloc(options, opt_len) * Initialize the database. */ static int -bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp) - struct bsd_db *db; - u_char *options; - int opt_len, unit, hdrlen, mru, debug, decomp; +bsd_init(struct bsd_db *db, u_char *options, int opt_len, int unit, + int hdrlen, int mru, int debug, int decomp) { int i; @@ -381,7 +371,7 @@ bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp) || options[0] != CI_BSD_COMPRESS || options[1] != CILEN_BSD_COMPRESS || BSD_VERSION(options[2]) != BSD_CURRENT_VERSION || BSD_NBITS(options[2]) != db->maxbits - || decomp && db->lens == NULL) + || (decomp && db->lens == NULL)) return 0; if (decomp) { @@ -407,10 +397,8 @@ bsd_init(db, options, opt_len, unit, hdrlen, mru, debug, decomp) } static int -bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug) - void *state; - u_char *options; - int opt_len, unit, hdrlen, mru, debug; +bsd_decomp_init(void *state, u_char *options, int opt_len, + int unit, int hdrlen, int mru, int debug) { return bsd_init((struct bsd_db *) state, options, opt_len, unit, hdrlen, mru, debug, 1); @@ -422,10 +410,7 @@ bsd_decomp_init(state, options, opt_len, unit, hdrlen, mru, debug) * incompressible data by pretending to compress the incoming data. */ static void -bsd_incomp(state, dmsg, mlen) - void *state; - u_char *dmsg; - int mlen; +bsd_incomp(void *state, u_char *dmsg, int mlen) { struct bsd_db *db = (struct bsd_db *) state; u_int hshift = db->hshift; @@ -542,10 +527,7 @@ bsd_incomp(state, dmsg, mlen) * compression, even though they are detected by inspecting the input. */ static int -bsd_decompress(state, cmsg, inlen, dmp, outlenp) - void *state; - u_char *cmsg, *dmp; - int inlen, *outlenp; +bsd_decompress(void *state, u_char *cmsg, int inlen, u_char *dmp, int *outlenp) { struct bsd_db *db = (struct bsd_db *) state; u_int max_ent = db->max_ent; @@ -554,11 +536,11 @@ bsd_decompress(state, cmsg, inlen, dmp, outlenp) u_int n_bits = db->n_bits; u_int tgtbitno = 32-n_bits; /* bitno when we have a code */ struct bsd_dict *dictp; - int explen, i, seq, len; + int explen, seq, len; u_int incode, oldcode, finchar; u_char *p, *rptr, *wptr; int ilen; - int dlen, space, codelen, extra; + int codelen, extra; rptr = cmsg; if (*rptr == 0) @@ -614,12 +596,12 @@ bsd_decompress(state, cmsg, inlen, dmp, outlenp) } if (incode > max_ent + 2 || incode > db->maxmaxcode - || incode > max_ent && oldcode == CLEAR) { + || (incode > max_ent && oldcode == CLEAR)) { if (db->debug) { printf("bsd_decomp%d: bad code 0x%x oldcode=0x%x ", db->unit, incode, oldcode); - printf("max_ent=0x%x dlen=%d seqno=%d\n", - max_ent, dlen, db->seqno); + printf("max_ent=0x%x seqno=%d\n", + max_ent, db->seqno); } return DECOMP_FATALERROR; /* probably a bug */ }