Browse Source

updated net-snmp.js to latest version

Costa Tsaousis (ktsaou) 6 years ago
parent
commit
26c69b7ec1
1 changed files with 11 additions and 4 deletions
  1. 11 4
      node.d/node_modules/net-snmp.js

+ 11 - 4
node.d/node_modules/net-snmp.js

@@ -578,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;
 
@@ -609,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) {
@@ -1044,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);
 
@@ -1290,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")