| 406 | } |
| 407 | |
| 408 | int |
| 409 | sl_uncompress_tcp(u_char **bufp, int len, u_int type, struct slcompress *comp) |
| 410 | { |
| 411 | u_char *hdr, *cp; |
| 412 | int hlen, vjlen; |
| 413 | |
| 414 | cp = bufp? *bufp: NULL; |
| 415 | vjlen = sl_uncompress_tcp_core(cp, len, len, type, comp, &hdr, &hlen); |
| 416 | if (vjlen < 0) |
| 417 | return (0); /* error */ |
| 418 | if (vjlen == 0) |
| 419 | return (len); /* was uncompressed already */ |
| 420 | |
| 421 | cp += vjlen; |
| 422 | len -= vjlen; |
| 423 | |
| 424 | /* |
| 425 | * At this point, cp points to the first byte of data in the |
| 426 | * packet. If we're not aligned on a 4-byte boundary, copy the |
| 427 | * data down so the ip & tcp headers will be aligned. Then back up |
| 428 | * cp by the tcp/ip header length to make room for the reconstructed |
| 429 | * header (we assume the packet we were handed has enough space to |
| 430 | * prepend 128 bytes of header). |
| 431 | */ |
| 432 | if ((intptr_t)cp & 3) { |
| 433 | if (len > 0) |
| 434 | BCOPY(cp, ((intptr_t)cp &~ 3), len); |
| 435 | cp = (u_char *)((intptr_t)cp &~ 3); |
| 436 | } |
| 437 | cp -= hlen; |
| 438 | len += hlen; |
| 439 | BCOPY(hdr, cp, hlen); |
| 440 | |
| 441 | *bufp = cp; |
| 442 | return (len); |
| 443 | } |
| 444 | |
| 445 | /* |
| 446 | * Uncompress a packet of total length total_len. The first buflen |
no test coverage detected