|
@@ -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")
|