Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] error handling #246

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##Disclaimer
## Disclaimer
node_pcap is currently being heavily refactored much of the documentation is out of date. If you installed node_pcap from npm go to [v2.0.1](https://github.com/mranney/node_pcap/commit/6e4d56671c54e0cf690f72b92554a538244bd1b6). Thanks for your patience and contributions as we work on the next major version of node_pcap.

node_pcap
Expand Down
2 changes: 1 addition & 1 deletion decode/ethernet_packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ EthernetPacket.prototype.decode = function (raw_packet, offset) {
this.payload = "need to implement LLDP";
break;
default:
console.log("node_pcap: EthernetFrame() - Don't know how to decode ethertype " + this.ethertype);
this.emitter.emit("warning", "node_pcap: EthernetFrame() - Don't know how to decode ethertype " + this.ethertype);
}
}

Expand Down
2 changes: 1 addition & 1 deletion decode/pcap_packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PcapPacket.prototype.decode = function (packet_with_header) {
this.payload = new SLLPacket(this.emitter).decode(buf, 0);
break;
default:
console.log("node_pcap: PcapPacket.decode - Don't yet know how to decode link type " + this.link_type);
this.emitter.emit("warning", "node_pcap: PcapPacket.decode - Don't yet know how to decode link type " + this.link_type);
}

return this;
Expand Down
2 changes: 1 addition & 1 deletion decode/sll_packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SLLPacket.prototype.decode = function (raw_packet, offset) {
this.payload = "need to implement LLDP";
break;
default:
console.log("node_pcap: SLLPacket() - Don't know how to decode ethertype " + this.ethertype);
this.emitter.emit("warning", "node_pcap: SLLPacket() - Don't know how to decode ethertype " + this.ethertype);
}
}

Expand Down
5 changes: 3 additions & 2 deletions decode/tcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ TCPOptions.prototype.decode = function (raw_packet, offset, len) {
offset += 8;
break;
default:
console.log("Invalid TCP SACK option length " + raw_packet[offset + 1]);
this.emitter.emit("warning", "Invalid TCP SACK option length " + raw_packet[offset + 1]);
offset = end_offset;
}
break;
Expand All @@ -147,7 +147,8 @@ TCPOptions.prototype.decode = function (raw_packet, offset, len) {
offset += raw_packet.readUInt8(offset + 1);
break;
default:
throw new Error("Don't know how to process TCP option " + raw_packet[offset]);
this.emitter.emit("warning", "Don't know how to process TCP option " + raw_packet[offset]);
offset = end_offset;
}
}

Expand Down