Lines Matching +full:no +full:- +full:wp
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Carsten Bormann <cabo@cs.tu-berlin.de>
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
53 * It builds a sliding hash sum of the previous 3-and-a-bit characters
58 #define HASH(state, x) state->hash = (state->hash << 4) ^ (x)
77 if (state->dict[state->hash] == *source) { in compress()
78 flags |= bitmask; /* Guess was right - don't output */ in compress()
80 state->dict[state->hash] = *source; in compress()
84 len--; in compress()
88 return (dest - orgdest); in compress()
94 while (len--) { in SyncTable()
95 *dest++ = state->dict[state->hash] = *source; in SyncTable()
109 len--; in decompress()
112 *dest = state->dict[state->hash]; /* Guess correct */ in decompress()
115 break; /* we seem to be really done -- cabo */ in decompress()
116 state->dict[state->hash] = *source; /* Guess wrong */ in decompress()
118 len--; in decompress()
123 return (dest - orgdest); in decompress()
137 state->hash = 0; in Pred1ResetInput()
138 memset(state->dict, '\0', sizeof state->dict); in Pred1ResetInput()
146 state->hash = 0; in Pred1ResetOutput()
147 memset(state->dict, '\0', sizeof state->dict); in Pred1ResetOutput()
179 u_char *cp, *wp, *hp; in Pred1Output() local
186 hp = wp = MBUF_CTOP(mwp); in Pred1Output()
188 *wp++ = *cp++ = orglen >> 8; in Pred1Output()
189 *wp++ = *cp++ = orglen & 0377; in Pred1Output()
192 mbuf_Read(bp, cp, orglen - 2); in Pred1Output()
196 len = compress(state, bufp + 2, wp, orglen); in Pred1Output()
197 log_Printf(LogDEBUG, "Pred1Output: orglen (%d) --> len (%d)\n", orglen, len); in Pred1Output()
198 ccp->uncompout += orglen; in Pred1Output()
201 wp += len; in Pred1Output()
202 ccp->compout += len; in Pred1Output()
204 memcpy(wp, bufp + 2, orglen); in Pred1Output()
205 wp += orglen; in Pred1Output()
206 ccp->compout += orglen; in Pred1Output()
209 *wp++ = fcs & 0377; in Pred1Output()
210 *wp++ = fcs >> 8; in Pred1Output()
211 mwp->m_len = wp - MBUF_CTOP(mwp); in Pred1Output()
222 struct mbuf *wp; in Pred1Input() local
226 wp = m_get(MAX_MRU + 2, MB_CCPIN); in Pred1Input()
229 pp = bufp = MBUF_CTOP(wp); in Pred1Input()
234 ccp->uncompin += len & 0x7fff; in Pred1Input()
236 len1 = decompress(state, cp, pp, olen - 4); in Pred1Input()
237 ccp->compin += olen; in Pred1Input()
241 fsm_Reopen(&ccp->fsm); in Pred1Input()
243 m_freem(wp); in Pred1Input()
246 cp += olen - 4; in Pred1Input()
250 fsm_Reopen(&ccp->fsm); in Pred1Input()
251 m_freem(wp); in Pred1Input()
255 ccp->compin += len; in Pred1Input()
262 fcs = hdlc_Fcs(bufp, wp->m_len = pp - bufp); in Pred1Input()
264 wp->m_offset += 2; /* skip length */ in Pred1Input()
265 wp->m_len -= 4; /* skip length & CRC */ in Pred1Input()
266 pp = MBUF_CTOP(wp); in Pred1Input()
269 wp->m_offset++; in Pred1Input()
270 wp->m_len--; in Pred1Input()
272 wp->m_offset += 2; in Pred1Input()
273 wp->m_len -= 2; in Pred1Input()
277 return wp; in Pred1Input()
282 log_Printf(LogCCP, "%s: Bad %scompressed CRC-16\n", in Pred1Input()
283 ccp->fsm.link->name, pre); in Pred1Input()
284 fsm_Reopen(&ccp->fsm); in Pred1Input()
285 m_freem(wp); in Pred1Input()
308 o->hdr.len = 2; in Pred1InitOptsOutput()
315 if (o->hdr.len != 2) { in Pred1SetOpts()
316 o->hdr.len = 2; in Pred1SetOpts()