net-snmp 3.15.0 → 3.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +1 -0
- package/README.md +8 -0
- package/example/option-parser.js +4 -0
- package/example/snmp-get.js +5 -0
- package/index.js +30 -7
- package/lib/mib.js +0 -2
- package/package.json +1 -1
package/.vscode/launch.json
CHANGED
package/README.md
CHANGED
@@ -3416,6 +3416,14 @@ Example programs are included under the module's `example` directory.
|
|
3416
3416
|
|
3417
3417
|
* Change return of undefined or null MIB values to NoSuchInstance
|
3418
3418
|
|
3419
|
+
## Version 3.15.1 - 12/10/2024
|
3420
|
+
|
3421
|
+
* Fix bundler failure due to unnecessary string length assignment
|
3422
|
+
|
3423
|
+
## Version 3.15.2 - 03/12/2024
|
3424
|
+
|
3425
|
+
* Change return of non-existing OIDs under table from NoSuchObject to NoSuchInstance
|
3426
|
+
|
3419
3427
|
# License
|
3420
3428
|
|
3421
3429
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/example/option-parser.js
CHANGED
@@ -9,6 +9,7 @@ var user;
|
|
9
9
|
var session;
|
10
10
|
var nonRepeaters;
|
11
11
|
var maxRepetitions;
|
12
|
+
var sourcePort;
|
12
13
|
var oids;
|
13
14
|
var varbinds;
|
14
15
|
var columns;
|
@@ -44,6 +45,7 @@ if ( snmpOptions.version == snmp.Version3 ) {
|
|
44
45
|
|
45
46
|
nonRepeaters = options.o;
|
46
47
|
maxRepetitions = options.r;
|
48
|
+
sourcePort = options.s;
|
47
49
|
|
48
50
|
if (options._.length < 2) {
|
49
51
|
console.log ("usage: " + process.argv[1] + " [<options>] <target> <oid>");
|
@@ -77,6 +79,8 @@ if ( command.includes('snmp-trap') || command.includes('snmp-inform') || command
|
|
77
79
|
snmpOptions.port = options.p;
|
78
80
|
}
|
79
81
|
|
82
|
+
snmpOptions.sourcePort = sourcePort;
|
83
|
+
|
80
84
|
if ( snmpOptions.version == snmp.Version3 ) {
|
81
85
|
session = snmp.createV3Session (target, user, snmpOptions);
|
82
86
|
} else {
|
package/example/snmp-get.js
CHANGED
package/index.js
CHANGED
@@ -4493,6 +4493,18 @@ Mib.prototype.deleteTableRow = function (table, rowIndex) {
|
|
4493
4493
|
return true;
|
4494
4494
|
};
|
4495
4495
|
|
4496
|
+
Mib.prototype.getAncestorProviderFromOid = function (oid) {
|
4497
|
+
const address = Mib.convertOidToAddress (oid);
|
4498
|
+
for ( let i = address.length - 1 ; i >= 0 ; i-- ) {
|
4499
|
+
const oidToCheck = address.slice(0, i).join('.');
|
4500
|
+
const provider = this.providersByOid[oidToCheck];
|
4501
|
+
if ( provider ) {
|
4502
|
+
return provider;
|
4503
|
+
}
|
4504
|
+
}
|
4505
|
+
return null;
|
4506
|
+
};
|
4507
|
+
|
4496
4508
|
Mib.prototype.dump = function (options) {
|
4497
4509
|
if ( ! options ) {
|
4498
4510
|
options = {};
|
@@ -4993,13 +5005,24 @@ Agent.prototype.request = function (socket, requestMessage, rinfo) {
|
|
4993
5005
|
operation: requestPdu.type,
|
4994
5006
|
oid: requestPdu.varbinds[i].oid
|
4995
5007
|
});
|
4996
|
-
|
4997
|
-
|
4998
|
-
|
4999
|
-
|
5000
|
-
|
5001
|
-
|
5002
|
-
|
5008
|
+
const ancestorProvider = this.mib.getAncestorProviderFromOid(requestPdu.varbinds[i].oid);
|
5009
|
+
if ( ancestorProvider ) {
|
5010
|
+
handlers[i] = function getNsiHandler (mibRequestForNsi) {
|
5011
|
+
mibRequestForNsi.done ({
|
5012
|
+
errorStatus: ErrorStatus.NoError,
|
5013
|
+
type: ObjectType.NoSuchInstance,
|
5014
|
+
value: null
|
5015
|
+
});
|
5016
|
+
};
|
5017
|
+
} else {
|
5018
|
+
handlers[i] = function getNsoHandler (mibRequestForNso) {
|
5019
|
+
mibRequestForNso.done ({
|
5020
|
+
errorStatus: ErrorStatus.NoError,
|
5021
|
+
type: ObjectType.NoSuchObject,
|
5022
|
+
value: null
|
5023
|
+
});
|
5024
|
+
};
|
5025
|
+
}
|
5003
5026
|
} else {
|
5004
5027
|
providerNode = this.mib.getProviderNodeForInstance (instanceNode);
|
5005
5028
|
if ( ! providerNode || instanceNode.value === undefined ) {
|
package/lib/mib.js
CHANGED
@@ -48,14 +48,12 @@ var MIB = function (dir) {
|
|
48
48
|
column = (column - this.builder.length);
|
49
49
|
var symbol = this.builder.toString().trim();
|
50
50
|
this.builder = "";
|
51
|
-
this.builder.length = 0;
|
52
51
|
if (!this.Table[FileName]) {
|
53
52
|
this.Table[FileName] = [];
|
54
53
|
} else if (this.PreviousRow < row) {
|
55
54
|
this.RowIndex++;
|
56
55
|
this.ColumnIndex = 0;
|
57
56
|
this.PreviousRow = row;
|
58
|
-
|
59
57
|
}
|
60
58
|
var R = this.RowIndex;
|
61
59
|
var C = this.ColumnIndex;
|