Skip to content

Commit

Permalink
Change includedLength to capturedLength
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Kunkle committed Jan 5, 2012
1 parent a5ee5ea commit af69cf2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -51,7 +51,7 @@ event listener would look something like
{
timestampSeconds: 1254722767,
timestampMicroseconds: 492060,
includedLength: 76,
capturedLength: 76,
originalLength: 76
}

Expand All @@ -69,7 +69,7 @@ the header fields and packet data.
header: {
timestampSeconds: 1254722767,
timestampMicroseconds: 492060,
includedLength: 76,
capturedLength: 76,
originalLength: 76
},

Expand Down
8 changes: 4 additions & 4 deletions lib/pcap-parser.js
Expand Up @@ -62,7 +62,7 @@ function parsePacketHeader() {
var header = {
timestampSeconds: buffer.readUInt32LE(0, true),
timestampMicroseconds: buffer.readUInt32LE(4, true),
includedLength: buffer.readUInt32LE(8, true),
capturedLength: buffer.readUInt32LE(8, true),
originalLength: buffer.readUInt32LE(12, true)
};

Expand All @@ -79,16 +79,16 @@ function parsePacketHeader() {
function parsePacketBody() {
var buffer = this.buffer;

if (buffer.length >= this.currentPacketHeader.includedLength) {
var data = buffer.slice(0, this.currentPacketHeader.includedLength);
if (buffer.length >= this.currentPacketHeader.capturedLength) {
var data = buffer.slice(0, this.currentPacketHeader.capturedLength);

this.emit('packetData', data);
this.emit('packet', {
header: this.currentPacketHeader,
data: data
});

this.buffer = buffer.slice(this.currentPacketHeader.includedLength);
this.buffer = buffer.slice(this.currentPacketHeader.capturedLength);
this.state = parsePacketHeader;
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -3,7 +3,7 @@
"description": "Packet capture (PCAP) parser for node",
"keywords": ["pcap", "parser"],
"homepage": "https://github.com/nearinfinity/node-pcap-parser",
"version": "0.0.1",
"version": "0.0.2",
"engines": { "node" : ">=0.6.0" },
"maintainers": [
{ "name": "Jeff Kunkle", "email": "jeff.kunkle@nearinfinity.com" },
Expand Down
4 changes: 2 additions & 2 deletions test/pcap-parser.js
Expand Up @@ -36,7 +36,7 @@ vows.describe('pcap-parser').addBatch({
assert.isNotNull(packetHeader);
assert.equal(packetHeader.timestampSeconds, 1254722767);
assert.equal(packetHeader.timestampMicroseconds, 492060);
assert.equal(packetHeader.includedLength, 76);
assert.equal(packetHeader.capturedLength, 76);
assert.equal(packetHeader.originalLength, 76);
}
},
Expand Down Expand Up @@ -66,7 +66,7 @@ vows.describe('pcap-parser').addBatch({
assert.equal(packet.data.length, 76);
assert.equal(packet.header.timestampSeconds, 1254722767);
assert.equal(packet.header.timestampMicroseconds, 492060);
assert.equal(packet.header.includedLength, 76);
assert.equal(packet.header.capturedLength, 76);
assert.equal(packet.header.originalLength, 76);
}
},
Expand Down

0 comments on commit af69cf2

Please sign in to comment.