Skip to content

Commit aa4aeab

Browse files
committed
Merge pull request node-pcap#1 from king-jam/lldp
Additional files/formats added
2 parents 53c150f + ac5e360 commit aa4aeab

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed

decode/lldp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LLDP.prototype.decode = function (raw_packet, offset) {
1616
this.ttlTLV = new TLV(this.emitter).decode (raw_packet, offset);
1717
offset += getTlvLength(raw_packet, offset);
1818
while(raw_packet.readUInt16BE(offset, true) != 0) {
19-
this.optionalTlv.push(new TLV(this.emitter).decode (raw_packet, offset));
19+
this.push(new TLV(this.emitter).decode (raw_packet, offset));
2020
offset += getTlvLength(raw_packet, offset);
2121
}
2222

decode/lldp/lldp_tlv.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TLV.prototype.decode = function (raw_packet, offset) {
1616
if(TlvDecoder == undefined) {
1717
this.payload = "Unknown";
1818
} else {
19-
this.payload = new TlvDecoder().decode(raw_packet, offset, tlvLength);
19+
this.payload = new TlvDecoder().decode(raw_packet, offset+2);
2020
}
2121
return this;
2222
}

decode/lldp/organization.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var orgs = require("./oui/oui_types");
2+
3+
function ORG() {
4+
this.orgId = undefined;
5+
this.payload = undefined;
6+
}
7+
8+
ORG.prototype.decode = function (raw_packet, offset) {
9+
// https://en.wikipedia.org/wiki/Type-length-value
10+
// https://en.wikipedia.org/wiki/Link_Layer_Discovery_Protocol
11+
this.orgId = ((raw_packet.readUInt16BE(offset, true) << 8) || (raw_packet.readUInt16BE(offset+2, true) & 0xff00 >> 8));
12+
var OrgDecoder = orgs[this.orgId];
13+
if(OrgDecoder == undefined) {
14+
this.payload = "Unknown";
15+
} else {
16+
this.payload = new OrgDecoder().decode(raw_packet, offset+3);
17+
}
18+
19+
return this;
20+
}
21+
22+
module.exports = ORG;

decode/lldp/oui/8021_private.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function IEEE_8021_PRIVATE() {
2+
this.orgSubType = undefined;
3+
this.payload = undefined;
4+
}
5+
6+
IEEE_8021_PRIVATE.prototype.decode = function (raw_packet, offset) {
7+
// https://en.wikipedia.org/wiki/Type-length-value
8+
// https://en.wikipedia.org/wiki/Link_Layer_Discovery_Protocol
9+
this.orgSubType = (raw_packet.readUInt16BE(offset, true) & 0x00ff);
10+
var OrgDecoder = orgs[this.orgId];
11+
if(OrgDecoder == undefined) {
12+
this.payload = "Unknown";
13+
} else {
14+
this.payload = new OrgDecoder().decode(raw_packet, offset+3);
15+
}
16+
17+
return this;
18+
}
19+
20+
module.exports = IEEE_8021_PRIVATE;

decode/lldp/oui/oui_types.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var ouis = {};
2+
3+
module.exports = oui_types;
4+
5+
var oui_ieee_8021_private = 0x0080c2;
6+
var oui_ieee_8023_private = 0x00120f;
7+
8+
function init(){
9+
ouis[oui_ieee_8021_private] = require("./8021_private");
10+
//ouis[oui_ieee_8023_private] = require("./8023_private");
11+
ouis[oui_ieee_8023_private] = undefined;
12+
}
13+
init();

0 commit comments

Comments
 (0)