diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:19:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:20:17 +0000 |
commit | a64a253794ac64cb40befee54db53bde17dd0d49 (patch) | |
tree | c1024acc5f6e508814b944d99f112259bb28b1be /collectors/node.d.plugin/node_modules/net-snmp.js | |
parent | New upstream version 1.10.0+dfsg (diff) | |
download | netdata-a64a253794ac64cb40befee54db53bde17dd0d49.tar.xz netdata-a64a253794ac64cb40befee54db53bde17dd0d49.zip |
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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") |