summaryrefslogtreecommitdiffstats
path: root/collectors/node.d.plugin/node_modules/net-snmp.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--collectors/node.d.plugin/node_modules/net-snmp.js (renamed from node.d/node_modules/net-snmp.js)16
1 files changed, 12 insertions, 4 deletions
diff --git a/node.d/node_modules/net-snmp.js b/collectors/node.d.plugin/node_modules/net-snmp.js
index ac9a8d350..484597dcb 100644
--- a/node.d/node_modules/net-snmp.js
+++ b/collectors/node.d.plugin/node_modules/net-snmp.js
@@ -1,5 +1,6 @@
// Copyright 2013 Stephen Vickers <stephen.vickers.sv@gmail.com>
+// SPDX-License-Identifier: MIT
var ber = require ("asn1-ber").Ber;
var dgram = require ("dgram");
@@ -577,6 +578,10 @@ var Session = function (target, community, options) {
? parseInt(options.sourcePort)
: undefined;
+ this.idBitsSize = (options && options.idBitsSize)
+ ? parseInt(options.idBitsSize)
+ : 32;
+
this.reqs = {};
this.reqCount = 0;
@@ -608,8 +613,11 @@ Session.prototype.cancelRequests = function (error) {
}
};
-function _generateId () {
- return Math.floor (Math.random () + Math.random () * 10000000)
+function _generateId (bitSize) {
+ if (bitSize === 16) {
+ return Math.floor(Math.random() * 10000) % 65535;
+ }
+ return Math.floor(Math.random() * 100000000) % 4294967295;
}
Session.prototype.get = function (oids, responseCb) {
@@ -1043,7 +1051,7 @@ Session.prototype.simpleGet = function (pduClass, feedCb, varbinds,
var req = {};
try {
- var id = _generateId ();
+ var id = _generateId (this.idBitsSize);
var pdu = new pduClass (id, varbinds, options);
var message = new RequestMessage (this.version, this.community, pdu);
@@ -1289,7 +1297,7 @@ Session.prototype.trap = function () {
pduVarbinds.push (varbind);
}
- var id = _generateId ();
+ var id = _generateId (this.idBitsSize);
if (this.version == Version2c) {
if (typeof typeOrOid != "string")