Don't needlessly recalculate the direction
This commit is contained in:
20
packet.cpp
20
packet.cpp
@@ -169,12 +169,22 @@ Packet::Packet (in6_addr m_sip, unsigned short m_sport, in6_addr m_dip, unsigned
|
|||||||
hashstring = NULL;
|
hashstring = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet * Packet::newInverted () {
|
direction invert(direction dir) {
|
||||||
/* TODO if this is a bottleneck, we can calculate the direction */
|
if (dir == dir_incoming)
|
||||||
if (sa_family == AF_INET)
|
return dir_outgoing;
|
||||||
return new Packet (dip, dport, sip, sport, len, time, dir_unknown);
|
else if (dir == dir_outgoing)
|
||||||
|
return dir_incoming;
|
||||||
else
|
else
|
||||||
return new Packet (dip6, dport, sip6, sport, len, time, dir_unknown);
|
return dir_unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
Packet * Packet::newInverted () {
|
||||||
|
direction new_direction = invert(dir);
|
||||||
|
|
||||||
|
if (sa_family == AF_INET)
|
||||||
|
return new Packet (dip, dport, sip, sport, len, time, new_direction);
|
||||||
|
else
|
||||||
|
return new Packet (dip6, dport, sip6, sport, len, time, new_direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* constructs returns a new Packet() structure with the same contents as this one */
|
/* constructs returns a new Packet() structure with the same contents as this one */
|
||||||
|
|||||||
Reference in New Issue
Block a user