summaryrefslogtreecommitdiffstats
path: root/node.d/node_modules
diff options
context:
space:
mode:
Diffstat (limited to 'node.d/node_modules')
-rw-r--r--node.d/node_modules/net-snmp.js63
1 files changed, 27 insertions, 36 deletions
diff --git a/node.d/node_modules/net-snmp.js b/node.d/node_modules/net-snmp.js
index 6fbd4e721..de5926104 100644
--- a/node.d/node_modules/net-snmp.js
+++ b/node.d/node_modules/net-snmp.js
@@ -12,7 +12,7 @@ var util = require ("util");
function _expandConstantObject (object) {
var keys = [];
- for (key in object)
+ for (var key in object)
keys.push (key);
for (var i = 0; i < keys.length; i++)
object[object[keys[i]]] = parseInt (keys[i]);
@@ -133,12 +133,9 @@ util.inherits (RequestTimedOutError, Error);
**/
function isVarbindError (varbind) {
- if (varbind.type == ObjectType.NoSuchObject
- || varbind.type == ObjectType.NoSuchInstance
- || varbind.type == ObjectType.EndOfMibView)
- return true;
- else
- return false;
+ return !!(varbind.type == ObjectType.NoSuchObject
+ || varbind.type == ObjectType.NoSuchInstance
+ || varbind.type == ObjectType.EndOfMibView);
}
function varbindError (varbind) {
@@ -216,6 +213,8 @@ function readInt (buffer) {
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 + "'");
@@ -225,8 +224,6 @@ function readUint (buffer, isSigned) {
length = 4;
}
- value = 0, signedBitSet = false;
-
for (var i = 0; i < length; i++) {
value *= 256;
value += buffer.readByte ();
@@ -246,10 +243,6 @@ function readUint (buffer, isSigned) {
function readUint64 (buffer) {
var value = buffer.readString (ObjectType.Counter64, true);
- if (value.length > 8)
- throw new RequestInvalidError ("64 bit unsigned integer too long '"
- + value.length + "'")
-
return value;
}
@@ -327,9 +320,6 @@ function writeUint (buffer, type, value) {
}
function writeUint64 (buffer, value) {
- if (value.length > 8)
- throw new RequestInvalidError ("64 bit unsigned integer too long '"
- + value.length + "'")
buffer.writeBuffer (value, ObjectType.Counter64);
}
@@ -381,7 +371,7 @@ function writeVarbinds (buffer, varbinds) {
}
buffer.endSequence ();
- };
+ }
buffer.endSequence ();
}
@@ -549,7 +539,7 @@ var ResponseMessage = function (buffer) {
throw new ResponseInvalidError ("Unknown PDU type '" + type
+ "' in response");
}
-}
+};
/*****************************************************************************
** Session class definition
@@ -599,7 +589,7 @@ var Session = function (target, community, options) {
this.dgram.on ("error", me.onError.bind (me));
if (this.sourceAddress || this.sourcePort)
- req.dgram.bind (this.sourcePort, this.sourceAddress);
+ this.dgram.bind (this.sourcePort, this.sourceAddress);
};
util.inherits (Session, events.EventEmitter);
@@ -607,15 +597,16 @@ util.inherits (Session, events.EventEmitter);
Session.prototype.close = function () {
this.dgram.close ();
return this;
-}
+};
Session.prototype.cancelRequests = function (error) {
+ var id;
for (id in this.reqs) {
var req = this.reqs[id];
this.unregisterRequest (req.id);
req.responseCb (error);
}
-}
+};
function _generateId () {
return Math.floor (Math.random () + Math.random () * 10000000)
@@ -645,7 +636,7 @@ Session.prototype.get = function (oids, responseCb) {
req.responseCb (null, varbinds);
}
- };
+ }
var pduVarbinds = [];
@@ -747,7 +738,7 @@ Session.prototype.getBulk = function () {
}
req.responseCb (null, varbinds);
- };
+ }
var pduVarbinds = [];
@@ -796,7 +787,7 @@ Session.prototype.getNext = function (oids, responseCb) {
req.responseCb (null, varbinds);
}
- };
+ }
var pduVarbinds = [];
@@ -813,7 +804,7 @@ Session.prototype.getNext = function (oids, responseCb) {
};
Session.prototype.inform = function () {
- var typeOrOid = arguments[0];;
+ var typeOrOid = arguments[0];
var varbinds, options = {}, responseCb;
/**
@@ -865,7 +856,7 @@ Session.prototype.inform = function () {
req.responseCb (null, varbinds);
}
- };
+ }
if (typeof typeOrOid != "string")
typeOrOid = "1.3.6.1.6.3.1.1.5." + (typeOrOid + 1);
@@ -1029,7 +1020,7 @@ Session.prototype.set = function (varbinds, responseCb) {
req.responseCb (null, varbinds);
}
- };
+ }
var pduVarbinds = [];
@@ -1049,7 +1040,7 @@ Session.prototype.set = function (varbinds, responseCb) {
Session.prototype.simpleGet = function (pduClass, feedCb, varbinds,
responseCb, options) {
- var req = {}
+ var req = {};
try {
var id = _generateId ();
@@ -1116,7 +1107,7 @@ Session.prototype.subtree = function () {
this.walk (oid, maxRepetitions, subtreeCb.bind (me, req), doneCb);
return this;
-}
+};
function tableColumnsResponseCb (req, error) {
if (error) {
@@ -1143,7 +1134,7 @@ function tableColumnsFeedCb (req, varbinds) {
return true;
}
- var oid = varbinds[i].oid.replace (req.rowOid, "")
+ var oid = varbinds[i].oid.replace (req.rowOid, "");
if (oid && oid != varbinds[i].oid) {
var match = oid.match (/^(\d+)\.(.+)$/);
if (match && match[1] > 0) {
@@ -1187,7 +1178,7 @@ Session.prototype.tableColumns = function () {
}
return this;
-}
+};
function tableResponseCb (req, error) {
if (error)
@@ -1205,7 +1196,7 @@ function tableFeedCb (req, varbinds) {
return true;
}
- var oid = varbinds[i].oid.replace (req.rowOid, "")
+ var oid = varbinds[i].oid.replace (req.rowOid, "");
if (oid && oid != varbinds[i].oid) {
var match = oid.match (/^(\d+)\.(.+)$/);
if (match && match[1] > 0) {
@@ -1243,7 +1234,7 @@ Session.prototype.table = function () {
tableResponseCb.bind (me, req));
return this;
-}
+};
Session.prototype.trap = function () {
var req = {};
@@ -1430,7 +1421,7 @@ Session.prototype.walk = function () {
this.getNext ([oid], walkCb.bind (me, req));
return this;
-}
+};
/*****************************************************************************
** Exports
@@ -1438,8 +1429,8 @@ Session.prototype.walk = function () {
exports.Session = Session;
-exports.createSession = function (target, community, version, options) {
- return new Session (target, community, version, options);
+exports.createSession = function (target, community, options) {
+ return new Session (target, community, options);
};
exports.isVarbindError = isVarbindError;