Lines Matching +full:no +full:- +full:wp

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
53 #define DEFLATE_CHUNK_LEN (1536 - sizeof(struct mbuf))
60 state->seqno = 0; in DeflateResetOutput()
61 state->uncomp_rec = 0; in DeflateResetOutput()
62 deflateReset(&state->cx); in DeflateResetOutput()
73 u_char *wp, *rp; in DeflateOutput() local
83 mi->m_next = mp; in DeflateOutput()
87 mi->m_len = 1; in DeflateOutput()
91 mi->m_len = 2; in DeflateOutput()
96 mo->m_len = 2; in DeflateOutput()
97 wp = MBUF_CTOP(mo); in DeflateOutput()
98 *wp++ = state->seqno >> 8; in DeflateOutput()
99 *wp++ = state->seqno & 0377; in DeflateOutput()
100 log_Printf(LogDEBUG, "DeflateOutput: Seq %d\n", state->seqno); in DeflateOutput()
101 state->seqno++; in DeflateOutput()
104 state->cx.next_out = wp; in DeflateOutput()
105 state->cx.avail_out = DEFLATE_CHUNK_LEN - 2; in DeflateOutput()
106 state->cx.next_in = MBUF_CTOP(mi); in DeflateOutput()
107 state->cx.avail_in = mi->m_len; in DeflateOutput()
112 if ((res = deflate(&state->cx, flush)) != Z_OK) { in DeflateOutput()
116 res, state->cx.msg ? state->cx.msg : ""); in DeflateOutput()
119 state->seqno--; in DeflateOutput()
120 return mp; /* Our dictionary's probably dead now :-( */ in DeflateOutput()
123 if (flush == Z_SYNC_FLUSH && state->cx.avail_out != 0) in DeflateOutput()
126 if (state->cx.avail_in == 0 && mi->m_next != NULL) { in DeflateOutput()
127 mi = mi->m_next; in DeflateOutput()
128 state->cx.next_in = MBUF_CTOP(mi); in DeflateOutput()
129 state->cx.avail_in = mi->m_len; in DeflateOutput()
130 if (mi->m_next == NULL) in DeflateOutput()
134 if (state->cx.avail_out == 0) { in DeflateOutput()
135 mo->m_next = m_get(DEFLATE_CHUNK_LEN, MB_CCPOUT); in DeflateOutput()
136 olen += (mo->m_len = DEFLATE_CHUNK_LEN); in DeflateOutput()
137 mo = mo->m_next; in DeflateOutput()
138 mo->m_len = 0; in DeflateOutput()
139 state->cx.next_out = MBUF_CTOP(mo); in DeflateOutput()
140 state->cx.avail_out = DEFLATE_CHUNK_LEN; in DeflateOutput()
144 olen += (mo->m_len = DEFLATE_CHUNK_LEN - state->cx.avail_out); in DeflateOutput()
145 olen -= 4; /* exclude the trailing EMPTY_BLOCK */ in DeflateOutput()
156 ccp->uncompout += ilen; in DeflateOutput()
157 ccp->compout += ilen; /* We measure this stuff too */ in DeflateOutput()
169 for (len = mo->m_len; len < olen; mo = mo->m_next, len += mo->m_len) in DeflateOutput()
171 mo->m_len -= len - olen; in DeflateOutput()
172 if (mo->m_next != NULL) { in DeflateOutput()
173 m_freem(mo->m_next); in DeflateOutput()
174 mo->m_next = NULL; in DeflateOutput()
177 ccp->uncompout += ilen; in DeflateOutput()
178 ccp->compout += olen; in DeflateOutput()
192 state->seqno = 0; in DeflateResetInput()
193 state->uncomp_rec = 0; in DeflateResetInput()
194 inflateReset(&state->cx); in DeflateResetInput()
203 u_char *wp; in DeflateInput() local
215 if (seq != state->seqno) { in DeflateInput()
216 if (seq <= state->uncomp_rec) in DeflateInput()
218 * So the peer's started at zero again - fine ! If we're wrong, in DeflateInput()
222 state->seqno = seq; in DeflateInput()
225 seq, state->seqno); in DeflateInput()
227 ccp_SendResetReq(&ccp->fsm); in DeflateInput()
231 state->seqno++; in DeflateInput()
232 state->uncomp_rec = 0; in DeflateInput()
238 wp = MBUF_CTOP(mo); in DeflateInput()
239 wp[0] = '\0'; in DeflateInput()
246 state->cx.next_in = MBUF_CTOP(mi); in DeflateInput()
247 state->cx.avail_in = mi->m_len; in DeflateInput()
248 state->cx.next_out = wp + 1; in DeflateInput()
249 state->cx.avail_out = 1; in DeflateInput()
250 ilen += mi->m_len; in DeflateInput()
252 flush = mi->m_next ? Z_NO_FLUSH : Z_SYNC_FLUSH; in DeflateInput()
257 if ((res = inflate(&state->cx, flush)) != Z_OK) { in DeflateInput()
261 res, state->cx.msg ? state->cx.msg : ""); in DeflateInput()
264 ccp_SendResetReq(&ccp->fsm); in DeflateInput()
268 if (flush == Z_SYNC_FLUSH && state->cx.avail_out != 0) in DeflateInput()
271 if (state->cx.avail_in == 0 && mi && (mi = m_free(mi)) != NULL) { in DeflateInput()
273 state->cx.next_in = MBUF_CTOP(mi); in DeflateInput()
274 ilen += (state->cx.avail_in = mi->m_len); in DeflateInput()
275 if (mi->m_next == NULL) in DeflateInput()
279 if (state->cx.avail_out == 0) { in DeflateInput()
282 if (!(wp[1] & 1)) { in DeflateInput()
284 wp[0] = wp[1]; in DeflateInput()
285 state->cx.next_out--; in DeflateInput()
286 state->cx.avail_out = DEFLATE_CHUNK_LEN-1; in DeflateInput()
288 state->cx.avail_out = DEFLATE_CHUNK_LEN-2; in DeflateInput()
291 olen += (mo->m_len = DEFLATE_CHUNK_LEN); in DeflateInput()
292 mo->m_next = m_get(DEFLATE_CHUNK_LEN, MB_CCPIN); in DeflateInput()
293 mo = mo->m_next; in DeflateInput()
294 state->cx.next_out = MBUF_CTOP(mo); in DeflateInput()
295 state->cx.avail_out = DEFLATE_CHUNK_LEN; in DeflateInput()
306 ccp_SendResetReq(&ccp->fsm); in DeflateInput()
310 olen += (mo->m_len = DEFLATE_CHUNK_LEN - state->cx.avail_out); in DeflateInput()
312 *proto = ((u_short)wp[0] << 8) | wp[1]; in DeflateInput()
313 mo_head->m_offset += 2; in DeflateInput()
314 mo_head->m_len -= 2; in DeflateInput()
315 olen -= 2; in DeflateInput()
317 ccp->compin += ilen; in DeflateInput()
318 ccp->uncompin += olen; in DeflateInput()
327 state->cx.next_out = garbage; in DeflateInput()
328 state->cx.avail_out = sizeof garbage; in DeflateInput()
329 state->cx.next_in = EMPTY_BLOCK; in DeflateInput()
330 state->cx.avail_in = sizeof EMPTY_BLOCK; in DeflateInput()
331 inflate(&state->cx, Z_SYNC_FLUSH); in DeflateInput()
345 log_Printf(LogDEBUG, "DeflateDictSetup: Got seq %d\n", state->seqno); in DeflateDictSetup()
352 mi_head->m_next = mi; in DeflateDictSetup()
358 mi->m_len = 6; in DeflateDictSetup()
363 mi->m_len = 7; in DeflateDictSetup()
372 state->cx.next_in = rp; in DeflateDictSetup()
373 state->cx.avail_in = mi->m_len; in DeflateDictSetup()
374 state->cx.next_out = garbage; in DeflateDictSetup()
375 state->cx.avail_out = sizeof garbage; in DeflateDictSetup()
380 if ((res = inflate(&state->cx, flush)) != Z_OK) { in DeflateDictSetup()
386 res, state->cx.msg ? state->cx.msg : ""); in DeflateDictSetup()
388 state->cx.avail_in, state->cx.avail_out); in DeflateDictSetup()
389 ccp_SendResetReq(&ccp->fsm); in DeflateDictSetup()
394 if (flush == Z_SYNC_FLUSH && state->cx.avail_out != 0) in DeflateDictSetup()
397 if (state->cx.avail_in == 0 && mi && (mi = mi->m_next) != NULL) { in DeflateDictSetup()
399 state->cx.next_in = MBUF_CTOP(mi); in DeflateDictSetup()
400 state->cx.avail_in = mi->m_len; in DeflateDictSetup()
401 if (mi->m_next == NULL) in DeflateDictSetup()
405 if (state->cx.avail_out == 0) { in DeflateDictSetup()
406 if (state->cx.avail_in == 0) in DeflateDictSetup()
412 * When we subsequently call it with no more input, it gives in DeflateDictSetup()
413 * us Z_BUF_ERROR :-( It seems pretty safe to ignore this in DeflateDictSetup()
420 state->cx.next_out = garbage; in DeflateDictSetup()
421 state->cx.avail_out = sizeof garbage; in DeflateDictSetup()
425 ccp->compin += len; in DeflateDictSetup()
426 ccp->uncompin += len; in DeflateDictSetup()
428 state->seqno++; in DeflateDictSetup()
429 state->uncomp_rec++; in DeflateDictSetup()
438 sprintf(disp, "win %d", (o->data[0]>>4) + 8); in DeflateDispOpts()
446 o->hdr.len = 4; in DeflateInitOptsOutput()
447 o->data[0] = ((cfg->deflate.out.winsize - 8) << 4) + 8; in DeflateInitOptsOutput()
448 o->data[1] = '\0'; in DeflateInitOptsOutput()
455 if (o->hdr.len != 4 || (o->data[0] & 15) != 8 || o->data[1] != '\0') in DeflateSetOptsOutput()
458 if ((o->data[0] >> 4) + 8 > 15) { in DeflateSetOptsOutput()
459 o->data[0] = ((15 - 8) << 4) + 8; in DeflateSetOptsOutput()
472 if (o->hdr.len != 4 || (o->data[0] & 15) != 8 || o->data[1] != '\0') in DeflateSetOptsInput()
475 want = (o->data[0] >> 4) + 8; in DeflateSetOptsInput()
476 if (cfg->deflate.in.winsize == 0) { in DeflateSetOptsInput()
478 o->data[0] = ((15 - 8) << 4) + 8; in DeflateSetOptsInput()
480 } else if (want != cfg->deflate.in.winsize) { in DeflateSetOptsInput()
481 o->data[0] = ((cfg->deflate.in.winsize - 8) << 4) + 8; in DeflateSetOptsInput()
495 state->winsize = (o->data[0] >> 4) + 8; in DeflateInitInput()
496 state->cx.zalloc = NULL; in DeflateInitInput()
497 state->cx.opaque = NULL; in DeflateInitInput()
498 state->cx.zfree = NULL; in DeflateInitInput()
499 state->cx.next_out = NULL; in DeflateInitInput()
500 if (inflateInit2(&state->cx, -state->winsize) == Z_OK) in DeflateInitInput()
518 state->winsize = (o->data[0] >> 4) + 8; in DeflateInitOutput()
519 state->cx.zalloc = NULL; in DeflateInitOutput()
520 state->cx.opaque = NULL; in DeflateInitOutput()
521 state->cx.zfree = NULL; in DeflateInitOutput()
522 state->cx.next_in = NULL; in DeflateInitOutput()
523 if (deflateInit2(&state->cx, Z_DEFAULT_COMPRESSION, 8, in DeflateInitOutput()
524 -state->winsize, 8, Z_DEFAULT_STRATEGY) == Z_OK) in DeflateInitOutput()
540 inflateEnd(&state->cx); in DeflateTermInput()
549 deflateEnd(&state->cx); in DeflateTermOutput()