aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2012-12-25 12:02:39 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2012-12-25 12:02:39 +0000
commit4aa19ce98fc4b641b151d2d4a981a88c30ebe570 (patch)
treeb2990db0e269b3cf0bbc3f3371624dc9f92fc67a /text2pcap.c
parentb98d44d71ffa954c070253b9a7017af4cae889f2 (diff)
Fix bugs I introduced. Now
od -Ax -tx1 -v stream | text2pcap -m1460 -T1234,1234 - stream.pcap does work again. svn path=/trunk/; revision=46734
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/text2pcap.c b/text2pcap.c
index aa50fc220e..3acc6dedae 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -401,7 +401,7 @@ write_byte (const char *str)
num = parse_num(str, FALSE);
packet_buf[curr_offset] = (unsigned char) num;
curr_offset ++;
- if (curr_offset >= max_offset) /* packet full */
+ if (curr_offset - header_length >= max_offset) /* packet full */
start_new_packet();
}
@@ -414,7 +414,7 @@ write_bytes(const char bytes[], unsigned long nbytes)
{
unsigned long i;
- if (curr_offset + nbytes < max_offset) {
+ if (curr_offset + nbytes < MAX_PACKET) {
for (i = 0; i < nbytes; i++) {
packet_buf[curr_offset] = bytes[i];
curr_offset++;
@@ -752,7 +752,7 @@ write_current_packet (void)
num_packets_written ++;
}
- packet_start += curr_offset;
+ packet_start += curr_offset - header_length;
curr_offset = header_length;
return;
}
@@ -1074,12 +1074,12 @@ parse_token (token_t token, char *str)
break;
case T_OFFSET:
num = parse_num(str, TRUE);
- if (num==0) {
+ if (num == 0) {
/* New packet starts here */
start_new_packet();
packet_start = 0;
state = READ_OFFSET;
- } else if ((num - packet_start) != curr_offset) {
+ } else if ((num - packet_start) != curr_offset - header_length) {
/*
* The offset we read isn't the one we expected.
* This may only mean that we mistakenly interpreted
@@ -1094,7 +1094,7 @@ parse_token (token_t token, char *str)
state = READ_OFFSET;
} else {
/* Bad offset; switch to INIT state */
- if (debug>=1)
+ if (debug >= 1)
fprintf(stderr, "Inconsistent offset. Expecting %0lX, got %0lX. Ignoring rest of packet\n",
curr_offset, num);
write_current_packet();