Home | History | Annotate | Download | only in net

Lines Matching refs:state

61  * State for a Deflate (de)compressor.
80 static void z_comp_free(void *state);
81 static void z_decomp_free(void *state);
82 static int z_comp_init(void *state, u_char *options, int opt_len,
84 static int z_decomp_init(void *state, u_char *options, int opt_len,
86 static int z_compress(void *state, struct mbuf **mret,
88 static void z_incomp(void *state, struct mbuf *dmsg);
89 static int z_decompress(void *state, struct mbuf *cmp,
91 static void z_comp_reset(void *state);
92 static void z_decomp_reset(void *state);
93 static void z_comp_stats(void *state, struct compstat *stats);
154 struct deflate_state *state;
167 state = malloc(sizeof(struct deflate_state), M_DEVBUF, M_NOWAIT);
168 if (state == NULL)
171 state->strm.next_in = NULL;
172 state->strm.zalloc = zalloc;
173 state->strm.zfree = zfree;
174 if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
176 free(state, M_DEVBUF);
180 state->w_size = w_size;
181 memset(&state->stats, 0, sizeof(state->stats));
182 return (void *) state;
188 struct deflate_state *state = (struct deflate_state *) arg;
190 deflateEnd(&state->strm);
191 free(state, M_DEVBUF);
198 struct deflate_state *state = (struct deflate_state *) arg;
204 || DEFLATE_SIZE(options[2]) != state->w_size
208 state->seqno = 0;
209 state->unit = unit;
210 state->hdrlen = hdrlen;
211 state->debug = debug;
213 deflateReset(&state->strm);
221 struct deflate_state *state = (struct deflate_state *) arg;
223 state->seqno = 0;
224 deflateReset(&state->strm);
233 struct deflate_state *state = (struct deflate_state *) arg;
255 if (maxolen + state->hdrlen > MLEN)
258 if (state->hdrlen + PPP_HDRLEN + 2 < wspace) {
259 m->m_data += state->hdrlen;
260 wspace -= state->hdrlen;
272 wptr[0] = state->seqno >> 8;
273 wptr[1] = state->seqno;
275 state->strm.next_out = wptr;
276 state->strm.avail_out = wspace - (PPP_HDRLEN + 2);
278 state->strm.next_out = NULL;
279 state->strm.avail_out = 1000000;
283 ++state->seqno;
286 state->strm.next_in = rptr;
287 state->strm.avail_in = mtod(mp, u_char *) + mp->m_len - rptr;
292 r = deflate(&state->strm, flush);
295 r, (state->strm.msg? state->strm.msg: ""));
298 if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
300 if (state->strm.avail_in == 0 && mp != NULL) {
301 state->strm.next_in = mtod(mp, u_char *);
302 state->strm.avail_in = mp->m_len;
307 if (state->strm.avail_out == 0) {
317 state->strm.next_out = mtod(m, u_char *);
318 state->strm.avail_out = wspace = M_TRAILINGSPACE(m);
322 state->strm.next_out = NULL;
323 state->strm.avail_out = 1000000;
328 olen += (m->m_len = wspace - state->strm.avail_out);
334 state->stats.comp_bytes += olen;
335 state->stats.comp_packets++;
339 state->stats.inc_bytes += orig_len;
340 state->stats.inc_packets++;
343 state->stats.unc_bytes += orig_len;
344 state->stats.unc_packets++;
352 struct deflate_state *state = (struct deflate_state *) arg;
355 *stats = state->stats;
372 struct deflate_state *state;
385 state = malloc(sizeof(struct deflate_state), M_DEVBUF, M_NOWAIT);
386 if (state == NULL)
389 state->strm.next_out = NULL;
390 state->strm.zalloc = zalloc;
391 state->strm.zfree = zfree;
392 if (inflateInit2(&state->strm, -w_size) != Z_OK) {
393 free(state, M_DEVBUF);
397 state->w_size = w_size;
398 memset(&state->stats, 0, sizeof(state->stats));
399 return (void *) state;
405 struct deflate_state *state = (struct deflate_state *) arg;
407 inflateEnd(&state->strm);
408 free(state, M_DEVBUF);
415 struct deflate_state *state = (struct deflate_state *) arg;
421 || DEFLATE_SIZE(options[2]) != state->w_size
425 state->seqno = 0;
426 state->unit = unit;
427 state->hdrlen = hdrlen;
428 state->debug = debug;
429 state->mru = mru;
431 inflateReset(&state->strm);
439 struct deflate_state *state = (struct deflate_state *) arg;
441 state->seqno = 0;
442 inflateReset(&state->strm);
464 struct deflate_state *state = (struct deflate_state *) arg;
488 if (seq != state->seqno) {
489 if (state->debug)
491 state->unit, seq, state->seqno);
494 ++state->seqno;
505 if (state->hdrlen + PPP_HDRLEN < ospace) {
506 mo->m_data += state->hdrlen;
507 ospace -= state->hdrlen;
524 state->strm.next_in = rptr;
525 state->strm.avail_in = rlen;
529 state->strm.next_out = wptr + 3;
530 state->strm.avail_out = 1;
538 r = inflate(&state->strm, flush);
541 if (state->debug)
544 state->unit, r, (state->strm.msg? state->strm.msg: ""));
548 if (flush != Z_NO_FLUSH && state->strm.avail_out != 0)
550 if (state->strm.avail_in == 0 && mi != NULL) {
551 state->strm.next_in = mtod(mi, u_char *);
552 state->strm.avail_in = mi->m_len;
558 if (state->strm.avail_out == 0) {
560 state->strm.avail_out = ospace - PPP_HDRLEN;
564 --state->strm.next_out;
565 ++state->strm.avail_out;
579 state->strm.next_out = mtod(mo, u_char *);
580 state->strm.avail_out = ospace = M_TRAILINGSPACE(mo);
588 olen += (mo->m_len = ospace - state->strm.avail_out);
590 if (olen > state->mru + PPP_HDRLEN)
592 state->unit, olen, state->mru + PPP_HDRLEN);
595 state->stats.unc_bytes += olen;
596 state->stats.unc_packets++;
597 state->stats.comp_bytes += rlen;
598 state
610 struct deflate_state *state = (struct deflate_state *) arg;
622 ++state->seqno;
631 state->strm.next_in = rptr + 3;
632 state->strm.avail_in = rlen - 3;
634 --state->strm.next_in;
635 ++state->strm.avail_in;
638 r = inflateIncomp(&state->strm);
642 if (state->debug)
645 state->unit, r, (state->strm.msg? state->strm.msg: ""));
651 state->strm.next_in = mtod(mi, u_char *);
652 state->strm.avail_in = mi->m_len;
659 state->stats.inc_bytes += rlen;
660 state->stats.inc_packets++;
661 state->stats.unc_bytes += rlen;
662 state->stats.unc_packets++;