summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/deflate.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-12-28 02:17:06 +0000
committerbrian <brian@FreeBSD.org>1997-12-28 02:17:06 +0000
commit02739ba22b04044c41093fcccb060ade5fd414dd (patch)
tree39d3e843aba48ad8f802b19504013fc267a011ec /usr.sbin/ppp/deflate.c
parent79c9bcac97df39be3ffff3d2ecc334c25c182e34 (diff)
downloadFreeBSD-src-02739ba22b04044c41093fcccb060ade5fd414dd.zip
FreeBSD-src-02739ba22b04044c41093fcccb060ade5fd414dd.tar.gz
Allow initial sequence numbers less than what we're expecting.
When CCP is originally negotiated, the only thing we can be sure about is that we've started adding data to the inflate dictionary either before or at the same time as the peer. This is ok, 'cos DEFLATE is a `sliding window' compressor.
Diffstat (limited to 'usr.sbin/ppp/deflate.c')
-rw-r--r--usr.sbin/ppp/deflate.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c
index 6ef6e98..3adf2e9 100644
--- a/usr.sbin/ppp/deflate.c
+++ b/usr.sbin/ppp/deflate.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: deflate.c,v 1.4 1997/12/21 12:11:04 brian Exp $
*/
#include <sys/param.h>
@@ -50,6 +50,7 @@
/* Our state */
struct deflate_state {
u_short seqno;
+ int dodgy_seqno;
z_stream cx;
};
@@ -65,6 +66,7 @@ static void
DeflateResetOutput(void)
{
OutputState.seqno = 0;
+ OutputState.dodgy_seqno = 0;
deflateReset(&OutputState.cx);
LogPrintf(LogCCP, "Deflate: Output channel reset\n");
}
@@ -190,6 +192,7 @@ static void
DeflateResetInput(void)
{
InputState.seqno = 0;
+ InputState.dodgy_seqno = 0;
inflateReset(&InputState.cx);
LogPrintf(LogCCP, "Deflate: Input channel reset\n");
}
@@ -211,13 +214,18 @@ DeflateInput(u_short *proto, struct mbuf *mi)
seq = (hdr[0] << 8) + hdr[1];
LogPrintf(LogDEBUG, "DeflateInput: Seq %d\n", seq);
if (seq != InputState.seqno) {
- LogPrintf(LogERROR, "DeflateInput: Seq error: Got %d, expected %d\n",
- seq, InputState.seqno);
- pfree(mi_head);
- CcpSendResetReq(&CcpFsm);
- return NULL;
+ if (InputState.dodgy_seqno && seq < InputState.seqno)
+ InputState.seqno = seq;
+ else {
+ LogPrintf(LogERROR, "DeflateInput: Seq error: Got %d, expected %d\n",
+ seq, InputState.seqno);
+ pfree(mi_head);
+ CcpSendResetReq(&CcpFsm);
+ return NULL;
+ }
}
InputState.seqno++;
+ InputState.dodgy_seqno = 0;
/* Allocate an output mbuf */
mo_head = mo = mballoc(DEFLATE_CHUNK_LEN, MB_IPIN);
@@ -525,6 +533,13 @@ DeflateInitInput(void)
if (inflateInit2(&InputState.cx, -iWindowSize) != Z_OK)
return 0;
DeflateResetInput();
+ /*
+ * When we begin, we may start adding to our dictionary before the
+ * peer does. If `dodgy_seqno' is set, we'll allow the peer to send
+ * us a seqno that's too small and just adjust seqno accordingly -
+ * deflate is a sliding window compressor !
+ */
+ InputState.dodgy_seqno = 1;
return 1;
}
OpenPOWER on IntegriCloud