diff options
author | brian <brian@cvs.openbsd.org> | 1999-03-30 07:57:39 +0000 |
---|---|---|
committer | brian <brian@cvs.openbsd.org> | 1999-03-30 07:57:39 +0000 |
commit | 243a5708eb2434eb0d8b307df4f525ed7891fb1a (patch) | |
tree | a775ee32168c558165a64405a79bd69e880125a3 /usr.sbin/ppp | |
parent | a362cea92d0b3ba742120dacea4a1a5121bb9acb (diff) |
Point at cs.slcs_u.csu_ip instead of the just-copied ``cp''
when recalculating the ip checksum. cp is not guaranteed to
be aligned. It now doesn't matter that cp isn't aligned as
the caller does another mbuf_Alloc() regardless.
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/ppp/slcompress.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/usr.sbin/ppp/ppp/slcompress.c b/usr.sbin/ppp/ppp/slcompress.c index 6420829af2e..ec2a5b328d6 100644 --- a/usr.sbin/ppp/ppp/slcompress.c +++ b/usr.sbin/ppp/ppp/slcompress.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: slcompress.c,v 1.2 1999/02/06 03:22:47 brian Exp $ + * $Id: slcompress.c,v 1.3 1999/03/30 07:57:38 brian Exp $ * * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: * - Initial distribution. @@ -447,13 +447,14 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type, struct slcompress *comp, case TYPE_COMPRESSED_TCP: break; } + /* We've got a compressed packet. */ slstat->sls_compressedin++; cp = *bufp; changes = *cp++; log_Printf(LogDEBUG, "compressed: changes = %02x\n", changes); - if (changes & NEW_C) { + if (changes & NEW_C) { /* * Make sure the state index is in range, then grab the state. If we have * a good state index, clear the 'discard' flag. @@ -465,7 +466,6 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type, struct slcompress *comp, comp->flags &= ~SLF_TOSS; comp->last_recv = *cp++; } else { - /* * this packet has an implicit state index. If we've had a line error * since the last time we got an explicit state index, we have to toss @@ -529,30 +529,20 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type, struct slcompress *comp, cs->cs_ip.ip_id, (u_long)ntohl(th->th_seq)); /* - * At this point, cp points to the first byte of data in the packet. If - * we're not aligned on a 4-byte boundary, copy the data down so the ip & - * tcp headers will be aligned. Then back up cp by the tcp/ip header - * length to make room for the reconstructed header (we assume the packet - * we were handed has enough space to prepend 128 bytes of header). Adjust - * the length to account for the new header & fill in the IP total length. + * At this point, cp points to the first byte of data in the packet. + * Back up cp by the tcp/ip header length to make room for the + * reconstructed header (we assume the packet we were handed has enough + * space to prepend 128 bytes of header). Adjust the length to account + * for the new header & fill in the IP total length. */ len -= (cp - *bufp); if (len < 0) - /* * we must have dropped some characters (crc should detect this but the * old slip framing won't) */ goto bad; -#ifdef notdef - if ((int) cp & 3) { - if (len > 0) - (void) bcopy(cp, (caddr_t) ((int) cp & ~3), len); - cp = (u_char *) ((int) cp & ~3); - } -#endif - cp -= cs->cs_hlen; len += cs->cs_hlen; cs->cs_ip.ip_len = htons(len); @@ -561,7 +551,7 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type, struct slcompress *comp, /* recompute the ip header checksum */ { - register u_short *bp = (u_short *) cp; + register u_short *bp = (u_short *)&cs->cs_ip; for (changes = 0; hlen > 0; hlen -= 2) changes += *bp++; |