Commit b16feadb authored by robertdavidgraham's avatar robertdavidgraham
Browse files

xsum fix

parent eacb0f14
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ parse_tcp:
        info->port_dst = ex16be(px+offset+2);
        info->app_offset = offset + tcp_length;
        info->app_length = length - info->app_offset;
        info->transport_length = length - info->transport_offset;
        assert(info->app_length < 2000);

        return 1;
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ struct PreprocessedInfo {
    const unsigned char *ip_src;
    const unsigned char *ip_dst;
    unsigned transport_offset;  /* 34 for normal Ethernet */
    unsigned transport_length;
    unsigned port_src;
    unsigned port_dst;

+10 −0
Original line number Diff line number Diff line
@@ -377,7 +377,9 @@ tcp_set_window(unsigned char *px, size_t px_length, unsigned window)
    if (offset + 20 > px_length)
        return;


    /* set the new window */
#if 0
    xsum = px[offset + 16] << 8 | px[offset + 17];
    xsum = (~xsum)&0xFFFF;
    xsum += window & 0xFFFF;
@@ -386,9 +388,17 @@ tcp_set_window(unsigned char *px, size_t px_length, unsigned window)
    xsum = ((xsum)&0xFFFF) + (xsum >> 16);
    xsum = ((xsum)&0xFFFF) + (xsum >> 16);
    xsum = (~xsum)&0xFFFF;
#endif

    px[offset + 14] = (unsigned char)(window>>8);
    px[offset + 15] = (unsigned char)(window>>0);
    px[offset + 16] = (unsigned char)(0);
    px[offset + 17] = (unsigned char)(0);


    xsum = ~tcp_checksum2(px, parsed.ip_offset, parsed.transport_offset,
                            parsed.transport_length);

    px[offset + 16] = (unsigned char)(xsum>>8);
    px[offset + 17] = (unsigned char)(xsum>>0);
}