net-snmp 3.9.7 → 3.9.9

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.
@@ -0,0 +1 @@
1
+ github: [markabrahams]
package/README.md CHANGED
@@ -3305,6 +3305,14 @@ Example programs are included under the module's `example` directory.
3305
3305
 
3306
3306
  * Add tolerance for reading malformed 32-bit unsigned integers
3307
3307
 
3308
+ ## Version 3.9.8 - 13/01/2024
3309
+
3310
+ * Fix subtree callback termination
3311
+
3312
+ ## Version 3.9.9 - 17/01/2024
3313
+
3314
+ * Add SMIv1 integer enumeration support
3315
+
3308
3316
  # License
3309
3317
 
3310
3318
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
package/example/test.js CHANGED
@@ -1,54 +1,27 @@
1
- /* eslint-disable no-unused-vars */
1
+ const snmp = require("../");
2
2
 
3
- var snmp = require ("../");
4
- var getopts = require ("getopts");
3
+ const store = snmp.createModuleStore();
5
4
 
6
- var options = getopts(process.argv.slice(2));
7
- var providers;
8
- var mibDir = '/var/tmp/mibs/';
5
+ //store.loadFromFile("/var/tmp/mibs/CISCO-SMI.mib");
6
+ //store.loadFromFile("/var/tmp/mibs/CISCO-TC.mib");
7
+ //store.loadFromFile("/home/mark/snmp/test/CISCO-CONFIG-MAN-MIB.MIB");
8
+ store.loadFromFile("/home/mark/snmp/test/smiv1.mib");
9
+ // store.loadFromFile("/home/mark/snmp/test/smiv2.mib");
9
10
 
10
- var counter64 = function (num) {
11
- var buf = Buffer.alloc (4);
12
- buf.writeUInt32BE (num);
13
- return buf;
14
- };
11
+ const mod1 = store.getModule("SMIv1-TEST-MIB");
12
+ // const mod2 = store.getModule("SMIv2-TEST-MIB");
15
13
 
16
- var snmpOptions = {
17
- disableAuthorization: options.n,
18
- port: options.p,
19
- engineID: options.e,
20
- debug: options.d
21
- };
14
+ // Object.keys(mod1)
15
+ // .forEach(key => console.log(key));
22
16
 
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
- };
17
+ console.log(JSON.stringify(mod1, null, 2));
18
+ // console.log(JSON.stringify(mod2, null, 2));
30
19
 
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));
20
+ //const mod = store.getModule("CISCO-CONFIG-MAN-MIB");
21
+ //console.log(mod);
22
+ //console.log(JSON.stringify(mod.ccmHistoryEventTerminalUser, null, 2));
23
+ //console.log(JSON.stringify(mod.ciscoConfigManCTIDNotifyGroup, null, 2));
24
+ //console.log(JSON.stringify(mod.ciscoConfigManCTIDObjectGroup, null, 2));
25
+ //console.log(JSON.stringify(mod.HistoryEventMedium, null, 2));
26
+ //console.log(JSON.stringify(mod.ccmHistoryRunningLastChanged, null, 2));
27
+ //console.log(JSON.stringify(mod.ccmHistoryRunningLastSaved, null, 2));
package/index.js CHANGED
@@ -2296,8 +2296,11 @@ function subtreeCb (req, varbinds) {
2296
2296
  }
2297
2297
  }
2298
2298
 
2299
- if (varbinds.length > 0)
2300
- req.feedCb (varbinds);
2299
+ if (varbinds.length > 0) {
2300
+ if (req.feedCb (varbinds)) {
2301
+ done = 1;
2302
+ }
2303
+ }
2301
2304
 
2302
2305
  if (done)
2303
2306
  return true;
package/lib/mib.js CHANGED
@@ -679,22 +679,10 @@ var MIB = function (dir) {
679
679
  var SYNTAX = Symbols[c1];
680
680
  var val = Symbols[c1 + 1];
681
681
 
682
+ // Normal MACROs
682
683
  if (this.MACROS.indexOf(macro) > -1 && m < 10) {
683
684
  if (val[0] === "{") {
684
- c1++;
685
- while (Symbols[c1].indexOf("}") == -1) {
686
- c1++;
687
- val += Symbols[c1].trim();
688
- }
689
- val = val.replace("{", "").replace("}", "").split(",");
690
-
691
- Object[ObjectName]['SYNTAX'] = {};
692
- Object[ObjectName]['SYNTAX'][SYNTAX] = {};
693
-
694
- for (var TC = 0; TC < val.length; TC++) {
695
- let openParenSplit = val[TC].split(/\s*\(\s*/);
696
- Object[ObjectName]['SYNTAX'][SYNTAX][openParenSplit[1].replace(/\s*\)\s*$/, '')] = openParenSplit[0].trimStart();
697
- }
685
+ this.BuildObjectEnumeration(Object, ObjectName, c1, SYNTAX, val, Symbols);
698
686
  } else if (val[0] === '(') {
699
687
  const key = val.startsWith('(SIZE')? 'sizes' : 'ranges';
700
688
  Object[ObjectName]['SYNTAX'] = {};
@@ -702,6 +690,28 @@ var MIB = function (dir) {
702
690
  } else {
703
691
  Object[ObjectName]['SYNTAX'] = SYNTAX;
704
692
  }
693
+ // SMIv1 INTEGER enumerations
694
+ } else if ( Symbols[i + 1] == 'INTEGER' ) {
695
+ c1 = i + 1;
696
+ SYNTAX = 'INTEGER';
697
+ val = Symbols[c1 + 1];
698
+ if ( val[0] === '{' ) {
699
+ this.BuildObjectEnumeration(Object, ObjectName, c1, SYNTAX, val, Symbols);
700
+ }
701
+ }
702
+ },
703
+ BuildObjectEnumeration: function (Object, ObjectName, c1, SYNTAX, val, Symbols) {
704
+ c1++;
705
+ while (Symbols[c1].indexOf("}") == -1) {
706
+ c1++;
707
+ val += Symbols[c1].trim();
708
+ }
709
+ val = val.replace("{", "").replace("}", "").split(",");
710
+ Object[ObjectName]['SYNTAX'] = {};
711
+ Object[ObjectName]['SYNTAX'][SYNTAX] = {};
712
+ for (var TC = 0; TC < val.length; TC++) {
713
+ let openParenSplit = val[TC].split(/\s*\(\s*/);
714
+ Object[ObjectName]['SYNTAX'][SYNTAX][openParenSplit[1].replace(/\s*\)\s*$/, '')] = openParenSplit[0].trimStart();
705
715
  }
706
716
  },
707
717
  GetSummary: function (callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.9.7",
3
+ "version": "3.9.9",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {