Permalink
Browse files

Changes RST flag handling.

It can arrive when state machine is in any state, previous version failed for some dumps.
  • Loading branch information...
1 parent 15cc466 commit 041cc9689f0de95f8ed9bca54be6b563eeb33f71 @abkqz abkqz committed Apr 16, 2011
Showing with 12 additions and 6 deletions.
  1. +12 −6 pcap.js
View
@@ -1293,12 +1293,7 @@ TCP_tracker.prototype.track_states.SYN_SENT = function (packet, session) {
session.recv_isn = tcp.seqno;
session.recv_window_scale = tcp.options.window_scale || 1; // multiplier, not bit shift value
session.state = "SYN_RCVD";
- } else if (tcp.flags.rst) {
- session.state = "CLOSED";
- delete this.sessions[session.key];
- this.emit('reset', session, "recv"); // TODO - check which direction did the reset, probably recv
- } else {
-// console.log("Didn't get SYN-ACK packet from dst while handshaking: " + util.inspect(tcp, false, 4));
+ } else { // console.log("Didn't get SYN-ACK packet from dst while handshaking: " + util.inspect(tcp, false, 4));
}
};
@@ -1480,10 +1475,21 @@ TCP_tracker.prototype.track_states.CLOSED = function (packet, session) {
TCP_tracker.prototype.track_next = function (key, packet) {
var session = this.sessions[key];
+ var ip = packet.link.ip,
+ tcp = ip.tcp;
+
if (typeof session !== 'object') {
throw new Error("track_next: couldn't find session for " + key);
}
+ /* Reset can arrive at any time */
+ if (tcp.flags.rst) {
+ session.close_time = packet.pcap_header.time_ms;
+ session.state = "CLOSED";
+ delete this.sessions[session.key];
+ this.emit('reset', session, "recv"); // TODO - check which direction did the reset, probably recv
+ }
+
if (typeof this.track_states[session.state] === 'function') {
this.track_states[session.state].call(this, packet, session);
} else {

0 comments on commit 041cc96

Please sign in to comment.