Comparing version 1.0.1 to 1.1.0
Changelog | ||
========= | ||
## v1.1.0 - January 13, 2013 | ||
Adds ability enable rfmon while opening sessions. | ||
## v1.0.1 - October 5, 2013 | ||
@@ -5,0 +9,0 @@ |
{ | ||
"name" : "pcap", | ||
"version" : "1.0.1", | ||
"version" : "1.1.0", | ||
"description" : "raw packet capture, decoding, and analysis", | ||
@@ -5,0 +5,0 @@ "author": "Matt Ranney <mjr@ranney.com>", |
32
pcap.js
@@ -25,3 +25,3 @@ /*global process require exports console */ | ||
Pcap.prototype.open = function (live, device, filter, buffer_size, pcap_output_filename) { | ||
Pcap.prototype.open = function (live, device, filter, buffer_size, pcap_output_filename, monitor) { | ||
var me = this; | ||
@@ -48,3 +48,3 @@ | ||
me.device_name = device || binding.default_device(); | ||
me.link_type = me.session.open_live(me.device_name, filter || "", me.buffer_size, pcap_output_filename || "", packet_ready); | ||
me.link_type = me.session.open_live(me.device_name, filter || "", me.buffer_size, pcap_output_filename || "", packet_ready, monitor || false); | ||
} else { | ||
@@ -93,7 +93,11 @@ me.device_name = device; | ||
Pcap.prototype.inject = function (data) { | ||
return this.session.inject(data); | ||
}; | ||
exports.Pcap = Pcap; | ||
exports.createSession = function (device, filter, buffer_size) { | ||
exports.createSession = function (device, filter, buffer_size, monitor) { | ||
var session = new Pcap(); | ||
session.open(true, device, filter, buffer_size); | ||
session.open(true, device, filter, buffer_size, null, monitor); | ||
return session; | ||
@@ -318,4 +322,4 @@ }; | ||
return ret; | ||
@@ -328,3 +332,3 @@ }; | ||
var types = {0:"HOST", 1:"BROADCAST", 2:"MULTICAST", 3:"OTHERHOST", 4:"OUTGOING"}; | ||
ret.sllPacketType = unpack.uint16(raw_packet, offset); offset+=2; | ||
@@ -334,7 +338,7 @@ ret.sllAddressType = types[unpack.uint16(raw_packet, offset)]; offset+=2; | ||
ret.sllSource = unpack.sll_addr(raw_packet, offset, sllAddressLength); | ||
ret.sllSource = unpack.sll_addr(raw_packet, offset, sllAddressLength); | ||
offset+=8; //address field is fixed to 8 bytes from witch addresslength bytes are used | ||
ret.sllProtocol = unpack.uint16(raw_packet, offset); offset+=2; | ||
switch (ret.sllProtocol) { | ||
@@ -398,2 +402,6 @@ case 0x800: // IPv4 | ||
var strength = raw_packet[22]; | ||
ret.strength = -Math.abs(265 - strength); | ||
switch(ret.subType) { | ||
@@ -753,7 +761,7 @@ case 8: // QoS Data | ||
ret.checksum = unpack.uint16(raw_packet, offset + 6); // 6, 7 | ||
ret.data_offset = offset + 8; | ||
ret.data_end = ret.length + ret.data_offset - 8; | ||
ret.data_bytes = ret.data_end - ret.data_offset; | ||
// Follow tcp pattern and don't make a copy of the data payload | ||
@@ -765,3 +773,3 @@ // Therefore its only valid for this pass throught the capture loop | ||
} | ||
if (ret.sport === 53 || ret.dport === 53) { | ||
@@ -768,0 +776,0 @@ ret.dns = decode.dns(raw_packet, offset + 8); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
308085
21
3566