Skip to content
Open
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
40 changes: 40 additions & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,46 @@ module.exports.parse = function(msg, rinfo) {
offset = readIp(msg, offset, p, 'subnetAddress');
break;
}
case 125: { // https://tools.ietf.org/html/rfc3925
// may be used in any packets where "other" options are allowed
if(p.options.dhcpMessageType != 6) {
p.options.VIVendorSpecificInformation = {};
var len = msg.readUInt8(offset++),
vendoropts = msg.slice(offset, offset + len),
vendorpointer = 0,
position = 0;
while (vendorpointer + 4 + 1 < vendoropts.length) {
var enterprisenumber = vendoropts.readUInt32BE(vendorpointer),
dataLen = vendoropts.readUInt8(vendorpointer + 4),
dataEnd = vendorpointer + 4 + 1 + dataLen,
vendordata = vendoropts.slice(vendorpointer + 4 + 1, dataEnd);
vendorpointer = dataEnd;
// Enterprise Number SHOULD only occur once
p.options.VIVendorSpecificInformation[enterprisenumber] = {
position: position++,
vandordatalength: dataLen,
subOptions: []
};
vendorDataPointer = 0;
// option-data field MUST be encoded as a sequence of code/length/value fields
while (vendorDataPointer + 1 < vendordata.length) {
var subOptionCode = vendordata.readUInt8(vendorDataPointer),
subOptionLength = vendordata.readUInt8(vendorDataPointer + 1),
subOptionStart = vendorDataPointer + 1 + 1,
subOptionData = vendordata.slice(subOptionStart, subOptionStart + subOptionLength);
vendorDataPointer = subOptionStart + subOptionLength;
// Option codes 0 and 255 have no pre-defined interpretation or format
p.options.VIVendorSpecificInformation[enterprisenumber].subOptions.push({
subOptionCode: subOptionCode,
subOptionLength: subOptionLength,
subOptionData: subOptionData
});
}
}
offset+=len;
break;
}
}
default: {
var len = msg.readUInt8(offset++);
console.log('Unhandled DHCP option ' + code + '/' + len + 'b');
Expand Down