updated to latest version of net-snmp
Costa Tsaousis (ktsaou) committed
Jun 20, 2017 at 23:32 UTC
a1392a88d91ca6b524ae0681dd004f2abd6fefda
1 file changed
+27
-36
node.d/node_modules/net-snmp.js
+27
-36
@@ -12,7 +12,7 @@ var util = require ("util");
12
13
function _expandConstantObject (object) {
14
var keys = [];
15
- for (key in object)
15
+ for (var key in object)
16
keys.push (key);
17
for (var i = 0; i < keys.length; i++)
18
object[object[keys[i]]] = parseInt (keys[i]);
@@ -133,12 +133,9 @@ util.inherits (RequestTimedOutError, Error);
133
**/
134
135
function isVarbindError (varbind) {
136
- if (varbind.type == ObjectType.NoSuchObject
137
- || varbind.type == ObjectType.NoSuchInstance
138
- || varbind.type == ObjectType.EndOfMibView)
139
- return true;
140
- else
141
- return false;
136
+ return !!(varbind.type == ObjectType.NoSuchObject
137
+ || varbind.type == ObjectType.NoSuchInstance
138
+ || varbind.type == ObjectType.EndOfMibView);
139
}
140
141
function varbindError (varbind) {
@@ -216,6 +213,8 @@ function readInt (buffer) {
213
function readUint (buffer, isSigned) {
214
buffer.readByte ();
215
var length = buffer.readByte ();
216
+ var value = 0;
217
+ var signedBitSet = false;
218
219
if (length > 5) {
220
throw new RangeError ("Integer too long '" + length + "'");
@@ -225,8 +224,6 @@ function readUint (buffer, isSigned) {
224
length = 4;
225
}
226
228
- value = 0, signedBitSet = false;
229
-
227
for (var i = 0; i < length; i++) {
228
value *= 256;
229
value += buffer.readByte ();
@@ -246,10 +243,6 @@ function readUint (buffer, isSigned) {
243
function readUint64 (buffer) {
244
var value = buffer.readString (ObjectType.Counter64, true);
245
249
- if (value.length > 8)
250
- throw new RequestInvalidError ("64 bit unsigned integer too long '"
251
- + value.length + "'")
252
-
246
return value;
247
}
248
@@ -327,9 +320,6 @@ function writeUint (buffer, type, value) {
320
}
321
322
function writeUint64 (buffer, value) {
330
- if (value.length > 8)
331
- throw new RequestInvalidError ("64 bit unsigned integer too long '"
332
- + value.length + "'")
323
buffer.writeBuffer (value, ObjectType.Counter64);
324
}
325
@@ -381,7 +371,7 @@ function writeVarbinds (buffer, varbinds) {
371
}
372
373
buffer.endSequence ();
384
- };
374
+ }
375
buffer.endSequence ();
376
}
377
@@ -549,7 +539,7 @@ var ResponseMessage = function (buffer) {
539
throw new ResponseInvalidError ("Unknown PDU type '" + type
540
+ "' in response");
541
}
552
-}
542
+};
543
544
/*****************************************************************************
545
** Session class definition
@@ -599,7 +589,7 @@ var Session = function (target, community, options) {
589
this.dgram.on ("error", me.onError.bind (me));
590
591
if (this.sourceAddress || this.sourcePort)
602
- req.dgram.bind (this.sourcePort, this.sourceAddress);
592
+ this.dgram.bind (this.sourcePort, this.sourceAddress);
593
};
594
595
util.inherits (Session, events.EventEmitter);
@@ -607,15 +597,16 @@ util.inherits (Session, events.EventEmitter);
597
Session.prototype.close = function () {
598
this.dgram.close ();
599
return this;
610
-}
600
+};
601
602
Session.prototype.cancelRequests = function (error) {
603
+ var id;
604
for (id in this.reqs) {
605
var req = this.reqs[id];
606
this.unregisterRequest (req.id);
607
req.responseCb (error);
608
}
618
-}
609
+};
610
611
function _generateId () {
612
return Math.floor (Math.random () + Math.random () * 10000000)
@@ -645,7 +636,7 @@ Session.prototype.get = function (oids, responseCb) {
636
637
req.responseCb (null, varbinds);
638
}
648
- };
639
+ }
640
641
var pduVarbinds = [];
642
@@ -747,7 +738,7 @@ Session.prototype.getBulk = function () {
738
}
739
740
req.responseCb (null, varbinds);
750
- };
741
+ }
742
743
var pduVarbinds = [];
744
@@ -796,7 +787,7 @@ Session.prototype.getNext = function (oids, responseCb) {
787
788
req.responseCb (null, varbinds);
789
}
799
- };
790
+ }
791
792
var pduVarbinds = [];
793
@@ -813,7 +804,7 @@ Session.prototype.getNext = function (oids, responseCb) {
804
};
805
806
Session.prototype.inform = function () {
816
- var typeOrOid = arguments[0];;
807
+ var typeOrOid = arguments[0];
808
var varbinds, options = {}, responseCb;
809
810
/**
@@ -865,7 +856,7 @@ Session.prototype.inform = function () {
856
857
req.responseCb (null, varbinds);
858
}
868
- };
859
+ }
860
861
if (typeof typeOrOid != "string")
862
typeOrOid = "1.3.6.1.6.3.1.1.5." + (typeOrOid + 1);
@@ -1029,7 +1020,7 @@ Session.prototype.set = function (varbinds, responseCb) {
1020
1021
req.responseCb (null, varbinds);
1022
}
1032
- };
1023
+ }
1024
1025
var pduVarbinds = [];
1026
@@ -1049,7 +1040,7 @@ Session.prototype.set = function (varbinds, responseCb) {
1040
1041
Session.prototype.simpleGet = function (pduClass, feedCb, varbinds,
1042
responseCb, options) {
1052
- var req = {}
1043
+ var req = {};
1044
1045
try {
1046
var id = _generateId ();
@@ -1116,7 +1107,7 @@ Session.prototype.subtree = function () {
1107
this.walk (oid, maxRepetitions, subtreeCb.bind (me, req), doneCb);
1108
1109
return this;
1119
-}
1110
+};
1111
1112
function tableColumnsResponseCb (req, error) {
1113
if (error) {
@@ -1143,7 +1134,7 @@ function tableColumnsFeedCb (req, varbinds) {
1134
return true;
1135
}
1136
1146
- var oid = varbinds[i].oid.replace (req.rowOid, "")
1137
+ var oid = varbinds[i].oid.replace (req.rowOid, "");
1138
if (oid && oid != varbinds[i].oid) {
1139
var match = oid.match (/^(\d+)\.(.+)$/);
1140
if (match && match[1] > 0) {
@@ -1187,7 +1178,7 @@ Session.prototype.tableColumns = function () {
1178
}
1179
1180
return this;
1190
-}
1181
+};
1182
1183
function tableResponseCb (req, error) {
1184
if (error)
@@ -1205,7 +1196,7 @@ function tableFeedCb (req, varbinds) {
1196
return true;
1197
}
1198
1208
- var oid = varbinds[i].oid.replace (req.rowOid, "")
1199
+ var oid = varbinds[i].oid.replace (req.rowOid, "");
1200
if (oid && oid != varbinds[i].oid) {
1201
var match = oid.match (/^(\d+)\.(.+)$/);
1202
if (match && match[1] > 0) {
@@ -1243,7 +1234,7 @@ Session.prototype.table = function () {
1234
tableResponseCb.bind (me, req));
1235
1236
return this;
1246
-}
1237
+};
1238
1239
Session.prototype.trap = function () {
1240
var req = {};
@@ -1430,7 +1421,7 @@ Session.prototype.walk = function () {
1421
this.getNext ([oid], walkCb.bind (me, req));
1422
1423
return this;
1433
-}
1424
+};
1425
1426
/*****************************************************************************
1427
** Exports
@@ -1438,8 +1429,8 @@ Session.prototype.walk = function () {
1429
1430
exports.Session = Session;
1431
1441
-exports.createSession = function (target, community, version, options) {
1442
- return new Session (target, community, version, options);
1432
+exports.createSession = function (target, community, options) {
1433
+ return new Session (target, community, options);
1434
};
1435
1436
exports.isVarbindError = isVarbindError;