diff options
author | brian <brian@FreeBSD.org> | 1998-01-10 01:55:11 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1998-01-10 01:55:11 +0000 |
commit | e0d5cac89839c8ee905983e98064022932b8ccb8 (patch) | |
tree | c3e0aee50601f692156073c8c2ce5e0fb0e2aca3 /usr.sbin/ppp/deflate.c | |
parent | bf1b24637d5c06e5fc72dd85eaa43f135d74f5eb (diff) | |
download | FreeBSD-src-e0d5cac89839c8ee905983e98064022932b8ccb8.zip FreeBSD-src-e0d5cac89839c8ee905983e98064022932b8ccb8.tar.gz |
Implement Reset{Req,Ack} properly, as per rfc 1962.
(I completely mis-read the rfc last time 'round!)
This means:
o Better CCP/WARN Reset diagnostics.
o After we've sent a REQ and before we've received an ACK, we drop
incoming compressed data and send another REQ.
o Before sending an ACK, re-sequence all pending PRI_NORMAL data in
the modem queue so that pending packets won't get to the peer
*after* the ResetAck.
o Send ACKs with the `identifier' from the REQ frame.
o After we've received a correct ACK, duplicate ACKs are ok (and will
reset our history).
o Incorrect ACKs (not matching the last REQ) are moaned about and dropped.
Also,
o Calculate the correct FCS after compressing a packet. DEFLATE
*may* produce an mbuf with more than a single link in the chain,
but HdlcOutput didn't know how to calculate the FCS :-(
o Make `struct fsm'::reqid a u_char, not an int.
This fix will prevent us from sending id `255' 2,000,000,000 times
before wrapping to `0' for another 2,000,000,000 sends :-/
o Bump the version number a little.
The end result: DEFLATE now works over an unreliable link layer.
I can txfr a 1.5Mb kernel over a (rather bad) null-modem
cable at an average of 21679 bytes per second using rcp.
Repeat after me: Don't test compression using a loopback ppp/tcp setup as
we never lose packets and therefore never have to reset!
Diffstat (limited to 'usr.sbin/ppp/deflate.c')
-rw-r--r-- | usr.sbin/ppp/deflate.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c index 3adf2e9..1897d3a 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: deflate.c,v 1.4 1997/12/21 12:11:04 brian Exp $ + * $Id: deflate.c,v 1.5 1997/12/28 02:17:06 brian Exp $ */ #include <sys/param.h> @@ -50,7 +50,7 @@ /* Our state */ struct deflate_state { u_short seqno; - int dodgy_seqno; + int uncomp_rec; z_stream cx; }; @@ -66,7 +66,7 @@ static void DeflateResetOutput(void) { OutputState.seqno = 0; - OutputState.dodgy_seqno = 0; + OutputState.uncomp_rec = 0; deflateReset(&OutputState.cx); LogPrintf(LogCCP, "Deflate: Output channel reset\n"); } @@ -192,7 +192,7 @@ static void DeflateResetInput(void) { InputState.seqno = 0; - InputState.dodgy_seqno = 0; + InputState.uncomp_rec = 0; inflateReset(&InputState.cx); LogPrintf(LogCCP, "Deflate: Input channel reset\n"); } @@ -214,7 +214,12 @@ DeflateInput(u_short *proto, struct mbuf *mi) seq = (hdr[0] << 8) + hdr[1]; LogPrintf(LogDEBUG, "DeflateInput: Seq %d\n", seq); if (seq != InputState.seqno) { - if (InputState.dodgy_seqno && seq < InputState.seqno) + if (seq <= InputState.uncomp_rec) + /* + * So the peer's started at zero again - fine ! If we're wrong, + * inflate() will fail. This is better than getting into a loop + * trying to get a ResetReq to a busy sender. + */ InputState.seqno = seq; else { LogPrintf(LogERROR, "DeflateInput: Seq error: Got %d, expected %d\n", @@ -225,7 +230,7 @@ DeflateInput(u_short *proto, struct mbuf *mi) } } InputState.seqno++; - InputState.dodgy_seqno = 0; + InputState.uncomp_rec = 0; /* Allocate an output mbuf */ mo_head = mo = mballoc(DEFLATE_CHUNK_LEN, MB_IPIN); @@ -420,6 +425,7 @@ DeflateDictSetup(u_short proto, struct mbuf *mi) CcpInfo.uncompin += len; InputState.seqno++; + InputState.uncomp_rec++; mbfree(mi_head); /* lose our allocated ``head'' buf */ } @@ -533,13 +539,6 @@ 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; } |