Commit f38a9a88 authored by Robert Ricci's avatar Robert Ricci
Browse files

Bugfix - I misunderstood how TCP options were parsed into the Options

structure. SACK handling should now be fixed.
parent 5c564bc8
......@@ -221,24 +221,25 @@ void PacketSensor::localAck(PacketInfo * packet)
opt != packet->tcpOptions->end();
++opt) {
if (opt->type == TCPOPT_SACK) {
struct SACKOption *optheader = (struct SACKOption*)(opt->buffer);
/*
* Figure out how many regions there are in this option header. There
* are two octets for the 'kind' and length fields of the header, then
* two 4-octet sequence numbers for each region
* are are two 4-octet sequence numbers for each region
*/
int num_sacks = (optheader->length - 2) / 8;
if ((optheader->length - 2) % 8 == 0) {
logWrite(SENSOR,"Bad SACK header length: %i", (optheader->length));
int num_sacks = opt->length / 8;
logWrite(SENSOR,"SACK: length = %d num_sacks = %d", opt->length,
num_sacks);
if (opt->length % 8 != 0) {
logWrite(SENSOR,"Bad SACK header length: %i", (opt->length));
return;
}
const uint32_t *regions = reinterpret_cast<const uint32_t*>(opt->buffer);
for (int i = 0; i < num_sacks; i++) {
uint32_t start = ntohl(optheader->regions[i*2]);
uint32_t start = ntohl(regions[i*2]);
/*
* Like a reguar ACK, the 'end' is the first sequence number *after*
* the range
*/
uint32_t end = ntohl(optheader->regions[i*2 + 1]) - 1;
uint32_t end = ntohl(regions[i*2 + 1]) - 1;
ranges.push_back(rangepair(start, end));
logWrite(SENSOR_COMPLETE,"PacketSensor::localAck() found SACK "
"range %u to %u", start, end);
......
......@@ -36,12 +36,6 @@ private:
unsigned int totalLength;
Time timestamp;
};
struct SACKOption
{
unsigned char kind;
unsigned char length;
uint32_t regions[];
} __attribute__((__packed__));
typedef std::pair<uint32_t, uint32_t> rangepair;
typedef std::list<rangepair> rangelist;
......
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