Commit a9e89bd0 authored by Robert Ricci's avatar Robert Ricci

Fix a bug I introduced with a careless copy and paste - I was copying

an int in twice.

Also fix another bug (masked by the previous) I introduced into
census()
parent 52dcfd48
......@@ -195,15 +195,13 @@ struct PacketInfo
{
size_t census(void)
{
// packetTime+packetLength
size_t result = sizeof(int)*(2 +1 ) +
sizeof(short)*(0 +0 ) +
sizeof(char)*(0 +0 ) +
// packetTime + packetLength
size_t result = sizeof(int)*(2+1) +
sizeof(struct tcp_info) +
sizeof(struct ip) + sizeof(struct tcphdr)
+ sizeof(unsigned char) /* bufferFull */
+ sizeof(unsigned char) /* packetType */
+ sizeof(struct Order); /* elab */
+ sizeof(unsigned char) + sizeof(int) + 2*sizeof(short); /* elab */
// Size for ipOptions and tcpOptions.
result += sizeof(unsigned int)*2;
......
......@@ -452,9 +452,8 @@ void replayWritePacket(PacketInfo * packet)
packetBuffer = static_cast<char*>(malloc(head.size));
//logWrite(REPLAY,"Making a packet buffer of size %d",head.size);
char* endptr = savePacket(& packetBuffer[0], *packet);
// savePacket returns the pointer to the last byte written, so we have to
// subtract 1 to find out how many bytes were written
int writtensize = (endptr - packetBuffer - 1);
// find out how many bytes were written
int writtensize = (endptr - packetBuffer);
if (writtensize != head.size) {
logWrite(ERROR,"replayWritePacket(): Made packet save buffer of size "
"%d, but wrote %d", head.size, writtensize);
......
......@@ -101,12 +101,11 @@ char * savePacket(char * buffer, PacketInfo const & value)
// Save packet time
//logWrite(REPLAY, "Saving timestamps at byte %i",
// pos - buffer);
// pos - buffer);
pos = saveInt(pos, value.packetTime.getTimeval()->tv_sec);
pos = saveInt(pos, value.packetTime.getTimeval()->tv_usec);
// Save packet length
// Bytes 8 - 11
//logWrite(REPLAY, "Saving length at byte %i",
// pos - buffer);
pos = saveInt(pos, value.packetLength);
......@@ -151,12 +150,11 @@ char * savePacket(char * buffer, PacketInfo const & value)
//logWrite(REPLAY, "Saving tcp_info at byte %i",
// pos - buffer);
pos = saveInt(pos, value.packetLength);
memcpy(pos, kernel, sizeof(struct tcp_info));
pos += sizeof(struct tcp_info);
// Save IP header
//logWrite(REPLAY, "Saving IP hader at byte %i",
//logWrite(REPLAY, "Saving IP header at byte %i",
// pos - buffer);
memcpy(pos, value.ip, sizeof(struct ip));
pos += sizeof(struct ip);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment