Skip to content

Commit

Permalink
xsum fix
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidgraham committed Apr 24, 2014
1 parent eacb0f1 commit b16fead
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/proto-preprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ preprocess_frame(const unsigned char *px, unsigned length, unsigned link_type,
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;
Expand Down
1 change: 1 addition & 0 deletions src/proto-preprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 10 additions & 0 deletions src/templ-pkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit b16fead

Please sign in to comment.