Skip to content

Commit

Permalink
* Added LLC support for ARP and IPv6 decoding.
Browse files Browse the repository at this point in the history
  • Loading branch information
coffeegist committed Feb 4, 2016
1 parent fff6919 commit d904abb
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions decode/llc_packet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var IPv4 = require("./ipv4");
var IPv6 = require("./ipv6");
var ARP = require("./arp");

function LogicalLinkControl(emitter) {
this.emitter = emitter;
Expand Down Expand Up @@ -28,10 +30,21 @@ LogicalLinkControl.prototype.decode = function (raw_packet, offset) {
];
this.type = raw_packet.readUInt16BE(offset); offset += 2;

switch (this.type) {
case 0x0800: // IPv4
this.payload = new IPv4(this.emitter).decode(raw_packet, offset);
break;
if (this.ethertype < 1536) {
// this packet is actually some 802.3 type without an ethertype
this.ethertype = 0;
} else {
switch (this.type) {
case 0x0800: // IPv4
this.payload = new IPv4(this.emitter).decode(raw_packet, offset);
break;
case 0x0806: // ARP
this.payload = new ARP(this.emitter).decode(raw_packet, offset);
break;
case 0x86dd: // IPv6
this.payload = new IPv6(this.emitter).decode(raw_packet, offset);
break;
}
}
} else {
this._error = "Unknown LLC types: DSAP: " + this.dsap + ", SSAP: " + this.ssap;
Expand Down

0 comments on commit d904abb

Please sign in to comment.