summaryrefslogtreecommitdiffstats
path: root/collectors/node.d.plugin/node_modules
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/node.d.plugin/node_modules')
-rw-r--r--collectors/node.d.plugin/node_modules/asn1-ber.js7
-rw-r--r--collectors/node.d.plugin/node_modules/extend.js88
-rw-r--r--collectors/node.d.plugin/node_modules/lib/ber/errors.js10
-rw-r--r--collectors/node.d.plugin/node_modules/lib/ber/index.js18
-rw-r--r--collectors/node.d.plugin/node_modules/lib/ber/reader.js270
-rw-r--r--collectors/node.d.plugin/node_modules/lib/ber/types.js35
-rw-r--r--collectors/node.d.plugin/node_modules/lib/ber/writer.js318
-rw-r--r--collectors/node.d.plugin/node_modules/net-snmp.js3452
-rw-r--r--collectors/node.d.plugin/node_modules/netdata.js654
-rw-r--r--collectors/node.d.plugin/node_modules/pixl-xml.js607
10 files changed, 0 insertions, 5459 deletions
diff --git a/collectors/node.d.plugin/node_modules/asn1-ber.js b/collectors/node.d.plugin/node_modules/asn1-ber.js
deleted file mode 100644
index 55c8f688ee..0000000000
--- a/collectors/node.d.plugin/node_modules/asn1-ber.js
+++ /dev/null
@@ -1,7 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-var Ber = require('./lib/ber/index')
-
-exports.Ber = Ber
-exports.BerReader = Ber.Reader
-exports.BerWriter = Ber.Writer
diff --git a/collectors/node.d.plugin/node_modules/extend.js b/collectors/node.d.plugin/node_modules/extend.js
deleted file mode 100644
index 3cd2e9155c..0000000000
--- a/collectors/node.d.plugin/node_modules/extend.js
+++ /dev/null
@@ -1,88 +0,0 @@
-// https://github.com/justmoon/node-extend
-// SPDX-License-Identifier: MIT
-
-'use strict';
-
-var hasOwn = Object.prototype.hasOwnProperty;
-var toStr = Object.prototype.toString;
-
-var isArray = function isArray(arr) {
- if (typeof Array.isArray === 'function') {
- return Array.isArray(arr);
- }
-
- return toStr.call(arr) === '[object Array]';
-};
-
-var isPlainObject = function isPlainObject(obj) {
- if (!obj || toStr.call(obj) !== '[object Object]') {
- return false;
- }
-
- var hasOwnConstructor = hasOwn.call(obj, 'constructor');
- var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, 'isPrototypeOf');
- // Not own constructor property must be Object
- if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) {
- return false;
- }
-
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
- var key;
- for (key in obj) { /**/ }
-
- return typeof key === 'undefined' || hasOwn.call(obj, key);
-};
-
-module.exports = function extend() {
- var options, name, src, copy, copyIsArray, clone;
- var target = arguments[0];
- var i = 1;
- var length = arguments.length;
- var deep = false;
-
- // Handle a deep copy situation
- if (typeof target === 'boolean') {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- } else if ((typeof target !== 'object' && typeof target !== 'function') || target == null) {
- target = {};
- }
-
- for (; i < length; ++i) {
- options = arguments[i];
- // Only deal with non-null/undefined values
- if (options != null) {
- // Extend the base object
- for (name in options) {
- src = target[name];
- copy = options[name];
-
- // Prevent never-ending loop
- if (target !== copy) {
- // Recurse if we're merging plain objects or arrays
- if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
- if (copyIsArray) {
- copyIsArray = false;
- clone = src && isArray(src) ? src : [];
- } else {
- clone = src && isPlainObject(src) ? src : {};
- }
-
- // Never move original objects, clone them
- target[name] = extend(deep, clone, copy);
-
- // Don't bring in undefined values
- } else if (typeof copy !== 'undefined') {
- target[name] = copy;
- }
- }
- }
- }
- }
-
- // Return the modified object
- return target;
-};
diff --git a/collectors/node.d.plugin/node_modules/lib/ber/errors.js b/collectors/node.d.plugin/node_modules/lib/ber/errors.js
deleted file mode 100644
index 1c0df7b135..0000000000
--- a/collectors/node.d.plugin/node_modules/lib/ber/errors.js
+++ /dev/null
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-module.exports = {
- InvalidAsn1Error: function(msg) {
- var e = new Error()
- e.name = 'InvalidAsn1Error'
- e.message = msg || ''
- return e
- }
-}
diff --git a/collectors/node.d.plugin/node_modules/lib/ber/index.js b/collectors/node.d.plugin/node_modules/lib/ber/index.js
deleted file mode 100644
index eb69ec526a..0000000000
--- a/collectors/node.d.plugin/node_modules/lib/ber/index.js
+++ /dev/null
@@ -1,18 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-var errors = require('./errors')
-var types = require('./types')
-
-var Reader = require('./reader')
-var Writer = require('./writer')
-
-for (var t in types)
- if (types.hasOwnProperty(t))
- exports[t] = types[t]
-
-for (var e in errors)
- if (errors.hasOwnProperty(e))
- exports[e] = errors[e]
-
-exports.Reader = Reader
-exports.Writer = Writer
diff --git a/collectors/node.d.plugin/node_modules/lib/ber/reader.js b/collectors/node.d.plugin/node_modules/lib/ber/reader.js
deleted file mode 100644
index 06decf4b90..0000000000
--- a/collectors/node.d.plugin/node_modules/lib/ber/reader.js
+++ /dev/null
@@ -1,270 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-var assert = require('assert');
-
-var ASN1 = require('./types');
-var errors = require('./errors');
-
-
-///--- Globals
-
-var InvalidAsn1Error = errors.InvalidAsn1Error;
-
-
-
-///--- API
-
-function Reader(data) {
- if (!data || !Buffer.isBuffer(data))
- throw new TypeError('data must be a node Buffer');
-
- this._buf = data;
- this._size = data.length;
-
- // These hold the "current" state
- this._len = 0;
- this._offset = 0;
-}
-
-Object.defineProperty(Reader.prototype, 'length', {
- enumerable: true,
- get: function () { return (this._len); }
-});
-
-Object.defineProperty(Reader.prototype, 'offset', {
- enumerable: true,
- get: function () { return (this._offset); }
-});
-
-Object.defineProperty(Reader.prototype, 'remain', {
- get: function () { return (this._size - this._offset); }
-});
-
-Object.defineProperty(Reader.prototype, 'buffer', {
- get: function () { return (this._buf.slice(this._offset)); }
-});
-
-
-/**
- * Reads a single byte and advances offset; you can pass in `true` to make this
- * a "peek" operation (i.e., get the byte, but don't advance the offset).
- *
- * @param {Boolean} peek true means don't move offset.
- * @return {Number} the next byte, null if not enough data.
- */
-Reader.prototype.readByte = function(peek) {
- if (this._size - this._offset < 1)
- return null;
-
- var b = this._buf[this._offset] & 0xff;
-
- if (!peek)
- this._offset += 1;
-
- return b;
-};
-
-
-Reader.prototype.peek = function() {
- return this.readByte(true);
-};
-
-
-/**
- * Reads a (potentially) variable length off the BER buffer. This call is
- * not really meant to be called directly, as callers have to manipulate
- * the internal buffer afterwards.
- *
- * As a result of this call, you can call `Reader.length`, until the
- * next thing called that does a readLength.
- *
- * @return {Number} the amount of offset to advance the buffer.
- * @throws {InvalidAsn1Error} on bad ASN.1
- */
-Reader.prototype.readLength = function(offset) {
- if (offset === undefined)
- offset = this._offset;
-
- if (offset >= this._size)
- return null;
-
- var lenB = this._buf[offset++] & 0xff;
- if (lenB === null)
- return null;
-
- if ((lenB & 0x80) == 0x80) {
- lenB &= 0x7f;
-
- if (lenB == 0)
- throw InvalidAsn1Error('Indefinite length not supported');
-
- if (lenB > 4)
- throw InvalidAsn1Error('encoding too long');
-
- if (this._size - offset < lenB)
- return null;
-
- this._len = 0;
- for (var i = 0; i < lenB; i++)
- this._len = (this._len << 8) + (this._buf[offset++] & 0xff);
-
- } else {
- // Wasn't a variable length
- this._len = lenB;
- }
-
- return offset;
-};
-
-
-/**
- * Parses the next sequence in this BER buffer.
- *
- * To get the length of the sequence, call `Reader.length`.
- *
- * @return {Number} the sequence's tag.
- */
-Reader.prototype.readSequence = function(tag) {
- var seq = this.peek();
- if (seq === null)
- return null;
- if (tag !== undefined && tag !== seq)
- throw InvalidAsn1Error('Expected 0x' + tag.toString(16) +
- ': got 0x' + seq.toString(16));
-
- var o = this.readLength(this._offset + 1); // stored in `length`
- if (o === null)
- return null;
-
- this._offset = o;
- return seq;
-};
-
-
-Reader.prototype.readInt = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Integer;
-
- return this._readTag(ASN1.Integer);
-};
-
-
-Reader.prototype.readBoolean = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Boolean;
-
- return (this._readTag(tag) === 0 ? false : true);
-};
-
-
-Reader.prototype.readEnumeration = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Enumeration;
-
- return this._readTag(ASN1.Enumeration);
-};
-
-
-Reader.prototype.readString = function(tag, retbuf) {
- if (!tag)
- tag = ASN1.OctetString;
-
- var b = this.peek();
- if (b === null)
- return null;
-
- if (b !== tag)
- throw InvalidAsn1Error('Expected 0x' + tag.toString(16) +
- ': got 0x' + b.toString(16));
-
- var o = this.readLength(this._offset + 1); // stored in `length`
-
- if (o === null)
- return null;
-
- if (this.length > this._size - o)
- return null;
-
- this._offset = o;
-
- if (this.length === 0)
- return retbuf ? new Buffer(0) : '';
-
- var str = this._buf.slice(this._offset, this._offset + this.length);
- this._offset += this.length;
-
- return retbuf ? str : str.toString('utf8');
-};
-
-Reader.prototype.readOID = function(tag) {
- if (!tag)
- tag = ASN1.OID;
-
- var b = this.readString(tag, true);
- if (b === null)
- return null;
-
- var values = [];
- var value = 0;
-
- for (var i = 0; i < b.length; i++) {
- var byte = b[i] & 0xff;
-
- value <<= 7;
- value += byte & 0x7f;
- if ((byte & 0x80) == 0) {
- values.push(value >>> 0);
- value = 0;
- }
- }
-
- value = values.shift();
- values.unshift(value % 40);
- values.unshift((value / 40) >> 0);
-
- return values.join('.');
-};
-
-
-Reader.prototype._readTag = function(tag) {
- assert.ok(tag !== undefined);
-
- var b = this.peek();
-
- if (b === null)
- return null;
-
- if (b !== tag)
- throw InvalidAsn1Error('Expected 0x' + tag.toString(16) +
- ': got 0x' + b.toString(16));
-
- var o = this.readLength(this._offset + 1); // stored in `length`
- if (o === null)
- return null;
-
- if (this.length > 4)
- throw InvalidAsn1Error('Integer too long: ' + this.length);
-
- if (this.length > this._size - o)
- return null;
- this._offset = o;
-
- var fb = this._buf[this._offset];
- var value = 0;
-
- for (var i = 0; i < this.length; i++) {
- value <<= 8;
- value |= (this._buf[this._offset++] & 0xff);
- }
-
- if ((fb & 0x80) == 0x80 && i !== 4)
- value -= (1 << (i * 8));
-
- return value >> 0;
-};
-
-
-
-///--- Exported API
-
-module.exports = Reader;
diff --git a/collectors/node.d.plugin/node_modules/lib/ber/types.js b/collectors/node.d.plugin/node_modules/lib/ber/types.js
deleted file mode 100644
index 7519ddcf55..0000000000
--- a/collectors/node.d.plugin/node_modules/lib/ber/types.js
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-module.exports = {
- EOC: 0,
- Boolean: 1,
- Integer: 2,
- BitString: 3,
- OctetString: 4,
- Null: 5,
- OID: 6,
- ObjectDescriptor: 7,
- External: 8,
- Real: 9,
- Enumeration: 10,
- PDV: 11,
- Utf8String: 12,
- RelativeOID: 13,
- Sequence: 16,
- Set: 17,
- NumericString: 18,
- PrintableString: 19,
- T61String: 20,
- VideotexString: 21,
- IA5String: 22,
- UTCTime: 23,
- GeneralizedTime: 24,
- GraphicString: 25,
- VisibleString: 26,
- GeneralString: 28,
- UniversalString: 29,
- CharacterString: 30,
- BMPString: 31,
- Constructor: 32,
- Context: 128
-}
diff --git a/collectors/node.d.plugin/node_modules/lib/ber/writer.js b/collectors/node.d.plugin/node_modules/lib/ber/writer.js
deleted file mode 100644
index d3a718f14a..0000000000
--- a/collectors/node.d.plugin/node_modules/lib/ber/writer.js
+++ /dev/null
@@ -1,318 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-var assert = require('assert');
-var ASN1 = require('./types');
-var errors = require('./errors');
-
-
-///--- Globals
-
-var InvalidAsn1Error = errors.InvalidAsn1Error;
-
-var DEFAULT_OPTS = {
- size: 1024,
- growthFactor: 8
-};
-
-
-///--- Helpers
-
-function merge(from, to) {
- assert.ok(from);
- assert.equal(typeof(from), 'object');
- assert.ok(to);
- assert.equal(typeof(to), 'object');
-
- var keys = Object.getOwnPropertyNames(from);
- keys.forEach(function(key) {
- if (to[key])
- return;
-
- var value = Object.getOwnPropertyDescriptor(from, key);
- Object.defineProperty(to, key, value);
- });
-
- return to;
-}
-
-
-
-///--- API
-
-function Writer(options) {
- options = merge(DEFAULT_OPTS, options || {});
-
- this._buf = new Buffer(options.size || 1024);
- this._size = this._buf.length;
- this._offset = 0;
- this._options = options;
-
- // A list of offsets in the buffer where we need to insert
- // sequence tag/len pairs.
- this._seq = [];
-}
-
-Object.defineProperty(Writer.prototype, 'buffer', {
- get: function () {
- if (this._seq.length)
- throw new InvalidAsn1Error(this._seq.length + ' unended sequence(s)');
-
- return (this._buf.slice(0, this._offset));
- }
-});
-
-Writer.prototype.writeByte = function(b) {
- if (typeof(b) !== 'number')
- throw new TypeError('argument must be a Number');
-
- this._ensure(1);
- this._buf[this._offset++] = b;
-};
-
-
-Writer.prototype.writeInt = function(i, tag) {
- if (typeof(i) !== 'number')
- throw new TypeError('argument must be a Number');
- if (typeof(tag) !== 'number')
- tag = ASN1.Integer;
-
- var sz = 4;
-
- while ((((i & 0xff800000) === 0) || ((i & 0xff800000) === 0xff800000 >> 0)) &&
- (sz > 1)) {
- sz--;
- i <<= 8;
- }
-
- if (sz > 4)
- throw new InvalidAsn1Error('BER ints cannot be > 0xffffffff');
-
- this._ensure(2 + sz);
- this._buf[this._offset++] = tag;
- this._buf[this._offset++] = sz;
-
- while (sz-- > 0) {
- this._buf[this._offset++] = ((i & 0xff000000) >>> 24);
- i <<= 8;
- }
-
-};
-
-
-Writer.prototype.writeNull = function() {
- this.writeByte(ASN1.Null);
- this.writeByte(0x00);
-};
-
-
-Writer.prototype.writeEnumeration = function(i, tag) {
- if (typeof(i) !== 'number')
- throw new TypeError('argument must be a Number');
- if (typeof(tag) !== 'number')
- tag = ASN1.Enumeration;
-
- return this.writeInt(i, tag);
-};
-
-
-Writer.prototype.writeBoolean = function(b, tag) {
- if (typeof(b) !== 'boolean')
- throw new TypeError('argument must be a Boolean');
- if (typeof(tag) !== 'number')
- tag = ASN1.Boolean;
-
- this._ensure(3);
- this._buf[this._offset++] = tag;
- this._buf[this._offset++] = 0x01;
- this._buf[this._offset++] = b ? 0xff : 0x00;
-};
-
-
-Writer.prototype.writeString = function(s, tag) {
- if (typeof(s) !== 'string')
- throw new TypeError('argument must be a string (was: ' + typeof(s) + ')');
- if (typeof(tag) !== 'number')
- tag = ASN1.OctetString;
-
- var len = Buffer.byteLength(s);
- this.writeByte(tag);
- this.writeLength(len);
- if (len) {
- this._ensure(len);
- this._buf.write(s, this._offset);
- this._offset += len;
- }
-};
-
-
-Writer.prototype.writeBuffer = function(buf, tag) {
- if (!Buffer.isBuffer(buf))
- throw new TypeError('argument must be a buffer');
-
- // If no tag is specified we will assume `buf` already contains tag and length
- if (typeof(tag) === 'number') {
- this.writeByte(tag);
- this.writeLength(buf.length);
- }
-
- this._ensure(buf.length);
- buf.copy(this._buf, this._offset, 0, buf.length);
- this._offset += buf.length;
-};
-
-
-Writer.prototype.writeStringArray = function(strings, tag) {
- if (! (strings instanceof Array))
- throw new TypeError('argument must be an Array[String]');
-
- var self = this;
- strings.forEach(function(s) {
- self.writeString(s, tag);
- });
-};
-
-// This is really to solve DER cases, but whatever for now
-Writer.prototype.writeOID = function(s, tag) {
- if (typeof(s) !== 'string')
- throw new TypeError('argument must be a string');
- if (typeof(tag) !== 'number')
- tag = ASN1.OID;
-
- if (!/^([0-9]+\.){3,}[0-9]+$/.test(s))
- throw new Error('argument is not a valid OID string');
-
- function encodeOctet(bytes, octet) {
- if (octet < 128) {
- bytes.push(octet);
- } else if (octet < 16384) {
- bytes.push((octet >>> 7) | 0x80);
- bytes.push(octet & 0x7F);
- } else if (octet < 2097152) {
- bytes.push((octet >>> 14) | 0x80);
- bytes.push(((octet >>> 7) | 0x80) & 0xFF);
- bytes.push(octet & 0x7F);
- } else if (octet < 268435456) {
- bytes.push((octet >>> 21) | 0x80);
- bytes.push(((octet >>> 14) | 0x80) & 0xFF);
- bytes.push(((octet >>> 7) | 0x80) & 0xFF);
- bytes.push(octet & 0x7F);
- } else {
- bytes.push(((octet >>> 28) | 0x80) & 0xFF);
- bytes.push(((octet >>> 21) | 0x80) & 0xFF);
- bytes.push(((octet >>> 14) | 0x80) & 0xFF);
- bytes.push(((octet >>> 7) | 0x80) & 0xFF);
- bytes.push(octet & 0x7F);
- }
- }
-
- var tmp = s.split('.');
- var bytes = [];
- bytes.push(parseInt(tmp[0], 10) * 40 + parseInt(tmp[1], 10));
- tmp.slice(2).forEach(function(b) {
- encodeOctet(bytes, parseInt(b, 10));
- });
-
- var self = this;
- this._ensure(2 + bytes.length);
- this.writeByte(tag);
- this.writeLength(bytes.length);
- bytes.forEach(function(b) {
- self.writeByte(b);
- });
-};
-
-
-Writer.prototype.writeLength = function(len) {
- if (typeof(len) !== 'number')
- throw new TypeError('argument must be a Number');
-
- this._ensure(4);
-
- if (len <= 0x7f) {
- this._buf[this._offset++] = len;
- } else if (len <= 0xff) {
- this._buf[this._offset++] = 0x81;
- this._buf[this._offset++] = len;
- } else if (len <= 0xffff) {
- this._buf[this._offset++] = 0x82;
- this._buf[this._offset++] = len >> 8;
- this._buf[this._offset++] = len;
- } else if (len <= 0xffffff) {
- this._buf[this._offset++] = 0x83;
- this._buf[this._offset++] = len >> 16;
- this._buf[this._offset++] = len >> 8;
- this._buf[this._offset++] = len;
- } else {
- throw new InvalidAsn1Error('Length too long (> 4 bytes)');
- }
-};
-
-Writer.prototype.startSequence = function(tag) {
- if (typeof(tag) !== 'number')
- tag = ASN1.Sequence | ASN1.Constructor;
-
- this.writeByte(tag);
- this._seq.push(this._offset);
- this._ensure(3);
- this._offset += 3;
-};
-
-
-Writer.prototype.endSequence = function() {
- var seq = this._seq.pop();
- var start = seq + 3;
- var len = this._offset - start;
-
- if (len <= 0x7f) {
- this._shift(start, len, -2);
- this._buf[seq] = len;
- } else if (len <= 0xff) {
- this._shift(start, len, -1);
- this._buf[seq] = 0x81;
- this._buf[seq + 1] = len;
- } else if (len <= 0xffff) {
- this._buf[seq] = 0x82;
- this._buf[seq + 1] = len >> 8;
- this._buf[seq + 2] = len;
- } else if (len <= 0xffffff) {
- this._shift(start, len, 1);
- this._buf[seq] = 0x83;
- this._buf[seq + 1] = len >> 16;
- this._buf[seq + 2] = len >> 8;
- this._buf[seq + 3] = len;
- } else {
- throw new InvalidAsn1Error('Sequence too long');
- }
-};
-
-
-Writer.prototype._shift = function(start, len, shift) {
- assert.ok(start !== undefined);
- assert.ok(len !== undefined);
- assert.ok(shift);
-
- this._buf.copy(this._buf, start + shift, start, start + len);
- this._offset += shift;
-};
-
-Writer.prototype._ensure = function(len) {
- assert.ok(len);
-
- if (this._size - this._offset < len) {
- var sz = this._size * this._options.growthFactor;
- if (sz - this._offset < len)
- sz += len;
-
- var buf = new Buffer(sz);
-
- this._buf.copy(buf, 0, 0, this._offset);
- this._buf = buf;
- this._size = sz;
- }
-};
-
-
-
-///--- Exported API
-
-module.exports = Writer;
diff --git a/collectors/node.d.plugin/node_modules/net-snmp.js b/collectors/node.d.plugin/node_modules/net-snmp.js
deleted file mode 100644
index 6b5b754ea4..0000000000
--- a/collectors/node.d.plugin/node_modules/net-snmp.js
+++ /dev/null
@@ -1,3452 +0,0 @@
-// Copyright 2013 Stephen Vickers <stephen.vickers.sv@gmail.com>
-// SPDX-License-Identifier: MIT
-
-var ber = require("asn1-ber").Ber;
-var dgram = require("dgram");
-var events = require("events");
-var util = require("util");
-var crypto = require("crypto");
-
-var DEBUG = false;
-
-var MAX_INT32 = 2147483647;
-
-function debug(line) {
- if (DEBUG) {
- console.debug(line);
- }
-}
-
-/*****************************************************************************
- ** Constants
- **/
-
-
-function _expandConstantObject(object) {
- var keys = [];
- for (var key in object)
- keys.push(key);
- for (var i = 0; i < keys.length; i++)
- object[object[keys[i]]] = parseInt(keys[i]);
-}
-
-var ErrorStatus = {
- 0: "NoError",
- 1: "TooBig",
- 2: "NoSuchName",
- 3: "BadValue",
- 4: "ReadOnly",
- 5: "GeneralError",
- 6: "NoAccess",
- 7: "WrongType",
- 8: "WrongLength",
- 9: "WrongEncoding",
- 10: "WrongValue",
- 11: "NoCreation",
- 12: "InconsistentValue",
- 13: "ResourceUnavailable",
- 14: "CommitFailed",
- 15: "UndoFailed",
- 16: "AuthorizationError",
- 17: "NotWritable",
- 18: "InconsistentName"
-};
-
-_expandConstantObject(ErrorStatus);
-
-var ObjectType = {
- 1: "Boolean",
- 2: "Integer",
- 4: "OctetString",
- 5: "Null",
- 6: "OID",
- 64: "IpAddress",
- 65: "Counter",
- 66: "Gauge",
- 67: "TimeTicks",
- 68: "Opaque",
- 70: "Counter64",
- 128: "NoSuchObject",
- 129: "NoSuchInstance",
- 130: "EndOfMibView"
-};
-
-_expandConstantObject(ObjectType);
-
-ObjectType.Integer32 = ObjectType.Integer;
-ObjectType.Counter32 = ObjectType.Counter;
-ObjectType.Gauge32 = ObjectType.Gauge;
-ObjectType.Unsigned32 = ObjectType.Gauge32;
-
-var PduType = {
- 160: "GetRequest",
- 161: "GetNextRequest",
- 162: "GetResponse",
- 163: "SetRequest",
- 164: "Trap",
- 165: "GetBulkRequest",
- 166: "InformRequest",
- 167: "TrapV2",
- 168: "Report"
-};
-
-_expandConstantObject(PduType);
-
-var TrapType = {
- 0: "ColdStart",
- 1: "WarmStart",
- 2: "LinkDown",
- 3: "LinkUp",
- 4: "AuthenticationFailure",
- 5: "EgpNeighborLoss",
- 6: "EnterpriseSpecific"
-};
-
-_expandConstantObject(TrapType);
-
-var SecurityLevel = {
- 1: "noAuthNoPriv",
- 2: "authNoPriv",
- 3: "authPriv"
-};
-
-_expandConstantObject(SecurityLevel);
-
-var AuthProtocols = {
- "1": "none",
- "2": "md5",
- "3": "sha"
-};
-
-_expandConstantObject(AuthProtocols);
-
-var PrivProtocols = {
- "1": "none",
- "2": "des"
-};
-
-_expandConstantObject(PrivProtocols);
-
-var MibProviderType = {
- "1": "Scalar",
- "2": "Table"
-};
-
-_expandConstantObject(MibProviderType);
-
-var Version1 = 0;
-var Version2c = 1;
-var Version3 = 3;
-
-var Version = {
- "1": Version1,
- "2c": Version2c,
- "3": Version3
-};
-
-/*****************************************************************************
- ** Exception class definitions
- **/
-
-function ResponseInvalidError(message) {
- this.name = "ResponseInvalidError";
- this.message = message;
- Error.captureStackTrace(this, ResponseInvalidError);
-}
-
-util.inherits(ResponseInvalidError, Error);
-
-function RequestInvalidError(message) {
- this.name = "RequestInvalidError";
- this.message = message;
- Error.captureStackTrace(this, RequestInvalidError);
-}
-
-util.inherits(RequestInvalidError, Error);
-
-function RequestFailedError(message, status) {
- this.name = "RequestFailedError";
- this.message = message;
- this.status = status;
- Error.captureStackTrace(this, RequestFailedError);
-}
-
-util.inherits(RequestFailedError, Error);
-
-function RequestTimedOutError(message) {
- this.name = "RequestTimedOutError";
- this.message = message;
- Error.captureStackTrace(this, RequestTimedOutError);
-}
-
-util.inherits(RequestTimedOutError, Error);
-
-/*****************************************************************************
- ** OID and varbind helper functions
- **/
-
-function isVarbindError(varbind) {
- return !!(varbind.type == ObjectType.NoSuchObject
- || varbind.type == ObjectType.NoSuchInstance
- || varbind.type == ObjectType.EndOfMibView);
-}
-
-function varbindError(varbind) {
- return (ObjectType[varbind.type] || "NotAnError") + ": " + varbind.oid;
-}
-
-function oidFollowsOid(oidString, nextString) {
- var oid = {str: oidString, len: oidString.length, idx: 0};
- var next = {str: nextString, len: nextString.length, idx: 0};
- var dotCharCode = ".".charCodeAt(0);
-
- function getNumber(item) {
- var n = 0;
- if (item.idx >= item.len)
- return null;
- while (item.idx < item.len) {
- var charCode = item.str.charCodeAt(item.idx++);
- if (charCode == dotCharCode)
- return n;
- n = (n ? (n * 10) : n) + (charCode - 48);
- }
- return n;
- }
-
- while (1) {
- var oidNumber = getNumber(oid);
- var nextNumber = getNumber(next);
-
- if (oidNumber !== null) {
- if (nextNumber !== null) {
- if (nextNumber > oidNumber) {
- return true;
- } else if (nextNumber < oidNumber) {
- return false;
- }
- } else {
- return true;
- }
- } else {
- return true;
- }
- }
-}
-
-function oidInSubtree(oidString, nextString) {
- var oid = oidString.split(".");
- var next = nextString.split(".");
-
- if (oid.length > next.length)
- return false;
-
- for (var i = 0; i < oid.length; i++) {
- if (next[i] != oid[i])
- return false;
- }
-
- return true;
-}
-
-/**
- ** Some SNMP agents produce integers on the wire such as 00 ff ff ff ff.
- ** The ASN.1 BER parser we use throws an error when parsing this, which we
- ** believe is correct. So, we decided not to bother the "asn1" developer(s)
- ** with this, instead opting to work around it here.
- **
- ** If an integer is 5 bytes in length we check if the first byte is 0, and if so
- ** simply drop it and parse it like it was a 4 byte integer, otherwise throw
- ** an error since the integer is too large.
- **/
-
-function readInt(buffer) {
- return readUint(buffer, true);
-}
-
-function readIpAddress(buffer) {
- var bytes = buffer.readString(ObjectType.IpAddress, true);
- if (bytes.length != 4)
- throw new ResponseInvalidError("Length '" + bytes.length
- + "' of IP address '" + bytes.toString("hex")
- + "' is not 4");
- var value = bytes[0] + "." + bytes[1] + "." + bytes[2] + "." + bytes[3];
- return value;
-}
-
-function readUint(buffer, isSigned) {
- buffer.readByte();
- var length = buffer.readByte();
- var value = 0;
- var signedBitSet = false;
-
- if (length > 5) {
- throw new RangeError("Integer too long '" + length + "'");
- } else if (length == 5) {
- if (buffer.readByte() !== 0)
- throw new RangeError("Integer too long '" + length + "'");
- length = 4;
- }
-
- for (var i = 0; i < length; i++) {
- value *= 256;
- value += buffer.readByte();
-
- if (isSigned && i <= 0) {
- if ((value & 0x80) == 0x80)
- signedBitSet = true;
- }
- }
-
- if (signedBitSet)
- value -= (1 << (i * 8));
-
- return value;
-}
-
-function readUint64(buffer) {
- var value = buffer.readString(ObjectType.Counter64, true);
-
- return value;
-}
-
-function readVarbinds(buffer, varbinds) {
- buffer.readSequence();
-
- while (1) {
- buffer.readSequence();
- if (buffer.peek() != ObjectType.OID)
-