net-snmp 3.10.0 → 3.10.1

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/README.md CHANGED
@@ -2486,7 +2486,7 @@ call.
2486
2486
  Takes an OID in one of the three supported formats (the library automatically detects the given OID's format):
2487
2487
  - **OidFormat.oid** - canonical (numerical) OID format e.g. 1.3.6.1.2.1.1.1
2488
2488
  - **OidFormat.path** - named OID path format e.g. iso.org.dod.internet.mgmt.mib-2.system.sysDescr
2489
- - **OidFormat.module** - module-qualified format e.g. RFC1158-MIB::sysDescr
2489
+ - **OidFormat.module** - module-qualified format e.g. SNMPv2-MIB::sysDescr
2490
2490
 
2491
2491
  Returns the given OID translated to the provided destination format - also one of the above three formats.
2492
2492
 
@@ -3343,6 +3343,10 @@ Example programs are included under the module's `example` directory.
3343
3343
 
3344
3344
  * Add numeric/named OID translate function
3345
3345
 
3346
+ ## Version 3.10.1 - 30/01/2024
3347
+
3348
+ * Fix table column type in provider definition with column type constraints
3349
+
3346
3350
  # License
3347
3351
 
3348
3352
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
@@ -190,8 +190,13 @@ var tableProvider = {
190
190
  number: 2,
191
191
  name: "ifDescr",
192
192
  type: snmp.ObjectType.OctetString,
193
- maxAccess: snmp.MaxAccess['read-write'],
194
- defVal: "Hello world!"
193
+ maxAccess: snmp.MaxAccess['read-write'],
194
+ constraints: {
195
+ sizes: [
196
+ { min: 1, max: 255 },
197
+ ]
198
+ },
199
+ defVal: "Hello world!"
195
200
  },
196
201
  {
197
202
  number: 3,
package/example/test.js CHANGED
@@ -2,20 +2,18 @@ const snmp = require("../");
2
2
 
3
3
  const store = snmp.createModuleStore();
4
4
 
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");
5
+ store.loadFromFile("/var/tmp/mibs/IANAifType-MIB.mib");
6
+ store.loadFromFile("/var/tmp/mibs/IF-MIB.mib");
10
7
 
11
- const mod1 = store.getModule("SMIv1-TEST-MIB");
12
- // const mod2 = store.getModule("SMIv2-TEST-MIB");
8
+ // const mod = store.getModule("IF-MIB");
13
9
 
14
- // Object.keys(mod1)
15
- // .forEach(key => console.log(key));
10
+ //Object.keys(mod)
11
+ // .forEach(key => console.log(key));
12
+
13
+ //console.log(JSON.stringify(mod, null, 2));
14
+ const provs = store.getProvidersForModule('IF-MIB');
15
+ console.log(JSON.stringify(provs, null, 2));
16
16
 
17
- console.log(JSON.stringify(mod1, null, 2));
18
- // console.log(JSON.stringify(mod2, null, 2));
19
17
 
20
18
  //const mod = store.getModule("CISCO-CONFIG-MAN-MIB");
21
19
  //console.log(mod);
@@ -25,23 +23,3 @@ console.log(JSON.stringify(mod1, null, 2));
25
23
  //console.log(JSON.stringify(mod.HistoryEventMedium, null, 2));
26
24
  //console.log(JSON.stringify(mod.ccmHistoryRunningLastChanged, null, 2));
27
25
  //console.log(JSON.stringify(mod.ccmHistoryRunningLastSaved, null, 2));
28
-
29
- // console.log(JSON.stringify(store.translations.moduleToOid, null, 2));
30
- // console.log(JSON.stringify(store.translations.moduleToPath, null, 2));
31
- // console.log(JSON.stringify(store.translations.oidToPath, null, 2));
32
- // console.log(JSON.stringify(store.translations.oidToModule, null, 2));
33
- // console.log(JSON.stringify(store.translations.pathToOid, null, 2));
34
- // console.log(JSON.stringify(store.translations.pathToModule, null, 2));
35
-
36
- console.log('iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTraps.warmStart => ' + store.translate('iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTraps.warmStart', 'oid'));
37
- console.log('iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTraps.warmStart => ' + store.translate('iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTraps.warmStart', 'module'));
38
- console.log('iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTraps.warmStart => ' + store.translate('iso.org.dod.internet.snmpV2.snmpModules.snmpMIB.snmpMIBObjects.snmpTraps.warmStart', 'path'));
39
- console.log('1.3.6.1.2.1.1.1 => ' + store.translate('1.3.6.1.2.1.1.1', 'oid'));
40
- console.log('1.3.6.1.2.1.1.1 => ' + store.translate('1.3.6.1.2.1.1.1', 'module'));
41
- console.log('1.3.6.1.2.1.1.1 => ' + store.translate('1.3.6.1.2.1.1.1', 'path'));
42
- console.log('RFC1158-MIB::sysDescr => ' + store.translate('RFC1158-MIB::sysDescr', snmp.OidFormat.oid));
43
- console.log('SNMPv2-MIB::sysDescr => ' + store.translate('SNMPv2-MIB::sysDescr', snmp.OidFormat.oid));
44
- console.log('RFC1158-MIB::sysDescr => ' + store.translate('SNMPv2-MIB::sysDescr', snmp.OidFormat.path));
45
- console.log('RFC1158-MIB::sysDescr => ' + store.translate('SNMPv2-MIB::sysDescr', snmp.OidFormat.module));
46
-
47
- // console.log('RFC1158-MIB::ipAdEntReasmMaxSize => ' + store.translate('RFC1158-MIB::ipAdEntReasmMaxSizesz', snmp.OidFormat.oid));
package/index.js CHANGED
@@ -3350,10 +3350,14 @@ ModuleStore.prototype.getProvidersForModule = function (moduleName) {
3350
3350
  }
3351
3351
  } else if ( parentOid == currentTableProvider.name ) {
3352
3352
  // table column
3353
+ let columnType = syntaxTypes[syntax];
3354
+ if (typeof columnType === 'object') {
3355
+ columnType = syntaxTypes[Object.keys(columnType)[0]];
3356
+ }
3353
3357
  var columnDefinition = {
3354
3358
  number: parseInt (mibEntry["OBJECT IDENTIFIER"].split (" ")[1]),
3355
3359
  name: mibEntry.ObjectName,
3356
- type: syntaxTypes[syntax],
3360
+ type: columnType,
3357
3361
  maxAccess: MaxAccess[maxAccess]
3358
3362
  };
3359
3363
  if ( constraints ) {
@@ -3388,8 +3392,9 @@ ModuleStore.prototype.getProvidersForModule = function (moduleName) {
3388
3392
  } else if ( mibEntry.MACRO == "OBJECT-TYPE" ) {
3389
3393
  // OBJECT-TYPE entries not in a table are scalars
3390
3394
  let scalarType = syntaxTypes[syntax];
3391
- if (typeof scalarType === 'object')
3395
+ if (typeof scalarType === 'object') {
3392
3396
  scalarType = syntaxTypes[Object.keys(scalarType)[0]];
3397
+ }
3393
3398
  var scalarDefinition = {
3394
3399
  name: mibEntry.ObjectName,
3395
3400
  type: MibProviderType.Scalar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.10.0",
3
+ "version": "3.10.1",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {