net-snmp 3.5.0 → 3.5.4
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 -10
- package/README.md +16 -0
- package/example/test.js +52 -19
- package/index.js +15 -4
- package/lib/mib.js +4 -1
- package/package.json +1 -1
package/.vscode/launch.json
CHANGED
@@ -259,16 +259,7 @@
|
|
259
259
|
],
|
260
260
|
"program": "${workspaceFolder}/example/test.js",
|
261
261
|
"args": [
|
262
|
-
"-
|
263
|
-
"-v", "3",
|
264
|
-
"-l", "authPriv",
|
265
|
-
"-u", "test256",
|
266
|
-
"-a", "sha",
|
267
|
-
"-A", "maybeitsok",
|
268
|
-
"-x", "aes256b",
|
269
|
-
"-X", "maybeitsok",
|
270
|
-
"127.0.0.1",
|
271
|
-
"1.3.6.1.2.1.1.1.0"
|
262
|
+
"-p", "1161"
|
272
263
|
]
|
273
264
|
},
|
274
265
|
{
|
package/README.md
CHANGED
@@ -3134,6 +3134,22 @@ Example programs are included under the module's `example` directory.
|
|
3134
3134
|
|
3135
3135
|
* Add engineID option to v3 session
|
3136
3136
|
|
3137
|
+
## Version 3.5.1 - 28/02/2021
|
3138
|
+
|
3139
|
+
* Fix MIB parsing of sized integers without whitespace
|
3140
|
+
|
3141
|
+
## Version 3.5.2 - 02/03/2021
|
3142
|
+
|
3143
|
+
* Fix MIB table index handling of Buffer type
|
3144
|
+
|
3145
|
+
## Version 3.5.3 - 22/08/2021
|
3146
|
+
|
3147
|
+
* Fix error with empty varbind array in walk
|
3148
|
+
|
3149
|
+
## Version 3.5.4 - 24/08/2021
|
3150
|
+
|
3151
|
+
* Align accessible-for-notify row cell behaviour with not-accessible behaviour
|
3152
|
+
|
3137
3153
|
# License
|
3138
3154
|
|
3139
3155
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/example/test.js
CHANGED
@@ -1,21 +1,54 @@
|
|
1
|
-
|
2
|
-
// Copyright 2013 Stephen Vickers
|
1
|
+
/* eslint-disable no-unused-vars */
|
3
2
|
|
4
3
|
var snmp = require ("../");
|
5
|
-
var
|
6
|
-
|
7
|
-
var
|
8
|
-
var
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
4
|
+
var getopts = require ("getopts");
|
5
|
+
|
6
|
+
var options = getopts(process.argv.slice(2));
|
7
|
+
var providers;
|
8
|
+
var mibDir = '/var/tmp/mibs/';
|
9
|
+
|
10
|
+
var counter64 = function (num) {
|
11
|
+
var buf = Buffer.alloc (4);
|
12
|
+
buf.writeUInt32BE (num);
|
13
|
+
return buf;
|
14
|
+
};
|
15
|
+
|
16
|
+
var snmpOptions = {
|
17
|
+
disableAuthorization: options.n,
|
18
|
+
port: options.p,
|
19
|
+
engineID: options.e,
|
20
|
+
debug: options.d
|
21
|
+
};
|
22
|
+
|
23
|
+
var callback = function (error, data) {
|
24
|
+
if ( error ) {
|
25
|
+
console.error (error);
|
26
|
+
} else {
|
27
|
+
console.log (data.pdu.varbinds[0].oid);
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
var store = snmp.createModuleStore ();
|
32
|
+
var agent = snmp.createAgent (snmpOptions, callback);
|
33
|
+
var mib = agent.getMib ();
|
34
|
+
|
35
|
+
var authorizer = agent.getAuthorizer ();
|
36
|
+
authorizer.addCommunity ("public");
|
37
|
+
|
38
|
+
// IF-MIB load and providers registration
|
39
|
+
store.loadFromFile (mibDir + "IPv6-TC.mib");
|
40
|
+
store.loadFromFile (mibDir + "IPv6-MIB.mib");
|
41
|
+
providers = store.getProvidersForModule ("IPV6-MIB");
|
42
|
+
mib.registerProviders (providers);
|
43
|
+
|
44
|
+
// agent.getMib ().dumpProviders ();
|
45
|
+
|
46
|
+
// mib.dump ();
|
47
|
+
|
48
|
+
var modules = store.getModules (true);
|
49
|
+
var one = store.getModule ("IPV6-MIB");
|
50
|
+
var names = store.getModuleNames (true);
|
51
|
+
|
52
|
+
// console.log("All modules: ", JSON.stringify(modules, '', 2));
|
53
|
+
console.log("Modules: ", names);
|
54
|
+
console.log("Single module definition: ", JSON.stringify(one, '', 2));
|
package/index.js
CHANGED
@@ -2641,7 +2641,12 @@ function walkCb (req, error, varbinds) {
|
|
2641
2641
|
}
|
2642
2642
|
}
|
2643
2643
|
|
2644
|
-
if (
|
2644
|
+
if ( ! varbinds.length ) {
|
2645
|
+
req.doneCb(null);
|
2646
|
+
return;
|
2647
|
+
}
|
2648
|
+
|
2649
|
+
if (this.version == Version2c || this.version == Version3) {
|
2645
2650
|
for (var i = varbinds[0].length; i > 0; i--) {
|
2646
2651
|
if (varbinds[0][i - 1].type == ObjectType.EndOfMibView) {
|
2647
2652
|
varbinds[0].pop ();
|
@@ -4081,7 +4086,13 @@ Mib.prototype.getOidAddressFromValue = function (value, indexPart) {
|
|
4081
4086
|
oidComponents = value.split (".");
|
4082
4087
|
break;
|
4083
4088
|
case ObjectType.OctetString:
|
4084
|
-
|
4089
|
+
if ( value instanceof Buffer ) {
|
4090
|
+
// Buffer
|
4091
|
+
oidComponents = Array.prototype.slice.call (value);
|
4092
|
+
} else {
|
4093
|
+
// string
|
4094
|
+
oidComponents = [...value].map (c => c.charCodeAt());
|
4095
|
+
}
|
4085
4096
|
break;
|
4086
4097
|
case ObjectType.IpAddress:
|
4087
4098
|
return value.split (".");
|
@@ -4192,8 +4203,8 @@ Mib.prototype.addTableRow = function (table, row) {
|
|
4192
4203
|
for ( var i = 0; i < provider.tableColumns.length ; i++ ) {
|
4193
4204
|
var column = provider.tableColumns[i];
|
4194
4205
|
var isColumnIndex = provider.tableIndex.some ( indexPart => indexPart.columnNumber == column.number );
|
4195
|
-
// prevent not-accessible index entries from being added as columns in the row
|
4196
|
-
if ( ! isColumnIndex || column.maxAccess
|
4206
|
+
// prevent not-accessible and accessible-for-notify index entries from being added as columns in the row
|
4207
|
+
if ( ! isColumnIndex || ! (column.maxAccess === MaxAccess['not-accessible'] || column.maxAccess === MaxAccess['accessible-for-notify']) ) {
|
4197
4208
|
instanceAddress = providerNode.address.concat (column.number).concat (instance);
|
4198
4209
|
this.addNodesForAddress (instanceAddress);
|
4199
4210
|
instanceNode = this.lookup (instanceAddress);
|
package/lib/mib.js
CHANGED
@@ -168,7 +168,10 @@ var MIB = function (dir) {
|
|
168
168
|
this.CharBuffer.inGroup++;
|
169
169
|
}
|
170
170
|
}
|
171
|
-
if (this.CharBuffer.
|
171
|
+
if (this.CharBuffer.builder == 'INTEGER') {
|
172
|
+
this.CharBuffer.Fill(FileName, row, column);
|
173
|
+
this.CharBuffer.Append(char);
|
174
|
+
} else if (this.CharBuffer.isComment || ((this.CharBuffer.isOID || this.CharBuffer.nested > 0) && (!this.CharBuffer.isList || this.CharBuffer.inGroup > 0))) {
|
172
175
|
this.CharBuffer.Append(char);
|
173
176
|
} else {
|
174
177
|
this.CharBuffer.Fill(FileName, row, column);
|