net-snmp 3.9.4 → 3.9.6
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 +8 -0
- package/index.js +11 -22
- package/lib/mib.js +33 -31
- package/package.json +1 -1
package/README.md
CHANGED
@@ -3293,6 +3293,14 @@ Example programs are included under the module's `example` directory.
|
|
3293
3293
|
|
3294
3294
|
* Fix syntax constraints tokenization and fix applying of size constraints
|
3295
3295
|
|
3296
|
+
## Version 3.9.5 - 30/05/2023
|
3297
|
+
|
3298
|
+
* Normalize whitespace parsing for OBJECT IDENTIFIER value
|
3299
|
+
|
3300
|
+
## Version 3.9.6 - 30/05/2023
|
3301
|
+
|
3302
|
+
* Add type constraint support for textual conventions
|
3303
|
+
|
3296
3304
|
# License
|
3297
3305
|
|
3298
3306
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/index.js
CHANGED
@@ -88,22 +88,6 @@ ObjectType.Integer32 = ObjectType.Integer;
|
|
88
88
|
ObjectType.Counter32 = ObjectType.Counter;
|
89
89
|
ObjectType.Gauge32 = ObjectType.Gauge;
|
90
90
|
ObjectType.Unsigned32 = ObjectType.Gauge32;
|
91
|
-
// SNMPv2-TC
|
92
|
-
ObjectType.AutonomousType = ObjectType["OBJECT IDENTIFIER"];
|
93
|
-
ObjectType.DateAndTime = ObjectType["OCTET STRING"];
|
94
|
-
ObjectType.DisplayString = ObjectType["OCTET STRING"];
|
95
|
-
ObjectType.InstancePointer = ObjectType["OBJECT IDENTIFIER"];
|
96
|
-
ObjectType.MacAddress = ObjectType["OCTET STRING"];
|
97
|
-
ObjectType.PhysAddress = ObjectType["OCTET STRING"];
|
98
|
-
ObjectType.RowPointer = ObjectType["OBJECT IDENTIFIER"];
|
99
|
-
ObjectType.RowStatus = ObjectType.INTEGER;
|
100
|
-
ObjectType.StorageType = ObjectType.INTEGER;
|
101
|
-
ObjectType.TestAndIncr = ObjectType.INTEGER;
|
102
|
-
ObjectType.TimeStamp = ObjectType.TimeTicks;
|
103
|
-
ObjectType.TruthValue = ObjectType.INTEGER;
|
104
|
-
ObjectType.TAddress = ObjectType["OCTET STRING"];
|
105
|
-
ObjectType.TDomain = ObjectType["OBJECT IDENTIFIER"];
|
106
|
-
ObjectType.VariablePointer = ObjectType["OBJECT IDENTIFIER"];
|
107
91
|
|
108
92
|
var PduType = {
|
109
93
|
160: "GetRequest",
|
@@ -3174,7 +3158,7 @@ ModuleStore.prototype.getSyntaxTypes = function () {
|
|
3174
3158
|
if ( mibEntry.MACRO == "TEXTUAL-CONVENTION" ) {
|
3175
3159
|
if ( mibEntry.SYNTAX && ! syntaxTypes[mibEntry.ObjectName] ) {
|
3176
3160
|
if ( typeof mibEntry.SYNTAX == "object" ) {
|
3177
|
-
syntaxTypes[mibEntry.ObjectName] =
|
3161
|
+
syntaxTypes[mibEntry.ObjectName] = mibEntry.SYNTAX;
|
3178
3162
|
} else {
|
3179
3163
|
syntaxTypes[mibEntry.ObjectName] = syntaxTypes[mibEntry.SYNTAX];
|
3180
3164
|
}
|
@@ -3239,7 +3223,7 @@ ModuleStore.prototype.getProvidersForModule = function (moduleName) {
|
|
3239
3223
|
var defVal = mibEntry["DEFVAL"];
|
3240
3224
|
|
3241
3225
|
if ( syntax ) {
|
3242
|
-
constraintsResults = ModuleStore.getConstraintsFromSyntax (syntax);
|
3226
|
+
constraintsResults = ModuleStore.getConstraintsFromSyntax (syntax, syntaxTypes);
|
3243
3227
|
syntax = constraintsResults.syntax;
|
3244
3228
|
constraints = constraintsResults.constraints;
|
3245
3229
|
|
@@ -3269,7 +3253,7 @@ ModuleStore.prototype.getProvidersForModule = function (moduleName) {
|
|
3269
3253
|
maxAccess = (typeof mibEntry["MAX-ACCESS"] != "undefined" ? mibEntry["MAX-ACCESS"] : (access ? AccessToMaxAccess[access] : "not-accessible"));
|
3270
3254
|
defVal = mibEntry["DEFVAL"];
|
3271
3255
|
|
3272
|
-
constraintsResults = ModuleStore.getConstraintsFromSyntax (syntax);
|
3256
|
+
constraintsResults = ModuleStore.getConstraintsFromSyntax (syntax, syntaxTypes);
|
3273
3257
|
syntax = constraintsResults.syntax;
|
3274
3258
|
constraints = constraintsResults.constraints;
|
3275
3259
|
|
@@ -3349,11 +3333,14 @@ ModuleStore.prototype.getProvidersForModule = function (moduleName) {
|
|
3349
3333
|
}
|
3350
3334
|
} else if ( mibEntry.MACRO == "OBJECT-TYPE" ) {
|
3351
3335
|
// OBJECT-TYPE entries not in a table are scalars
|
3336
|
+
let scalarType = syntaxTypes[syntax];
|
3337
|
+
if (typeof scalarType === 'object')
|
3338
|
+
scalarType = syntaxTypes[Object.keys(scalarType)[0]];
|
3352
3339
|
var scalarDefinition = {
|
3353
3340
|
name: mibEntry.ObjectName,
|
3354
3341
|
type: MibProviderType.Scalar,
|
3355
3342
|
oid: mibEntry.OID,
|
3356
|
-
scalarType:
|
3343
|
+
scalarType: scalarType,
|
3357
3344
|
maxAccess: MaxAccess[maxAccess]
|
3358
3345
|
};
|
3359
3346
|
|
@@ -3379,9 +3366,11 @@ ModuleStore.prototype.loadBaseModules = function () {
|
|
3379
3366
|
this.parser.Serialize ();
|
3380
3367
|
};
|
3381
3368
|
|
3382
|
-
ModuleStore.getConstraintsFromSyntax = function (syntax) {
|
3369
|
+
ModuleStore.getConstraintsFromSyntax = function (syntax, syntaxTypes) {
|
3383
3370
|
let constraints;
|
3384
|
-
|
3371
|
+
if ( typeof syntaxTypes[syntax] === 'object' ) {
|
3372
|
+
syntax = syntaxTypes[syntax];
|
3373
|
+
}
|
3385
3374
|
// detect INTEGER ranges, OCTET STRING sizes, and INTEGER enumerations
|
3386
3375
|
if ( typeof syntax == "object" ) {
|
3387
3376
|
let firstSyntaxKey = syntax[Object.keys(syntax)[0]];
|
package/lib/mib.js
CHANGED
@@ -60,7 +60,7 @@ var MIB = function (dir) {
|
|
60
60
|
var R = this.RowIndex;
|
61
61
|
var C = this.ColumnIndex;
|
62
62
|
|
63
|
-
if (!this.Table[FileName][R]) {
|
63
|
+
if (!this.Table[FileName][R] || C === 0) {
|
64
64
|
this.Table[FileName][R] = Object.defineProperty([], "line", {
|
65
65
|
enumerable: false,
|
66
66
|
value: row + 1
|
@@ -143,11 +143,14 @@ var MIB = function (dir) {
|
|
143
143
|
}
|
144
144
|
},
|
145
145
|
ParseLine: function (FileName, line, row) {
|
146
|
-
|
147
|
-
|
146
|
+
let len = line.length;
|
147
|
+
if (line[len - 1] === '\r')
|
148
|
+
--len;
|
149
|
+
for (var i = 0; i < len; i++) {
|
148
150
|
var char = line.charAt(i);
|
149
151
|
this.ParseChar(FileName, char, row, i);
|
150
152
|
}
|
153
|
+
this.ParseChar(FileName, '\n', row, len);
|
151
154
|
},
|
152
155
|
ParseChar: function (FileName, char, row, column) {
|
153
156
|
switch (char) {
|
@@ -310,7 +313,7 @@ var MIB = function (dir) {
|
|
310
313
|
lastGoodDeclaration = row;
|
311
314
|
break;
|
312
315
|
default:
|
313
|
-
if (symbol.
|
316
|
+
if (symbol.startsWith('--')) {//REMOVE COMMENTS
|
314
317
|
//console.log(ModuleName, symbol);
|
315
318
|
addSymbol = false;
|
316
319
|
} else {
|
@@ -364,7 +367,7 @@ var MIB = function (dir) {
|
|
364
367
|
Object[Symbols[i - 2]] = {};
|
365
368
|
Object[Symbols[i - 2]]['ObjectName'] = Symbols[i - 2];
|
366
369
|
Object[Symbols[i - 2]]['ModuleName'] = ModuleName;
|
367
|
-
Object[Symbols[i - 2]]['OBJECT IDENTIFIER'] = Symbols[i + 1].replace("{", "").replace("}", "").trim();
|
370
|
+
Object[Symbols[i - 2]]['OBJECT IDENTIFIER'] = Symbols[i + 1].replace("{", "").replace("}", "").trim().replace(/\s+/, " ");
|
368
371
|
if (Object[Symbols[i - 2]]['OBJECT IDENTIFIER'] == '0 0') {
|
369
372
|
Object[Symbols[i - 2]]['OID'] = '0.0';
|
370
373
|
Object[Symbols[i - 2]]['NameSpace'] = 'null';
|
@@ -524,7 +527,7 @@ var MIB = function (dir) {
|
|
524
527
|
}
|
525
528
|
Object[Symbols[r - 1]]['ObjectName'] = Symbols[r - 1];
|
526
529
|
Object[Symbols[r - 1]]['ModuleName'] = ModuleName;
|
527
|
-
Object[Symbols[r - 1]]['OBJECT IDENTIFIER'] = Symbols[i + 1].replace("{", "").replace("}", "").trim();
|
530
|
+
Object[Symbols[r - 1]]['OBJECT IDENTIFIER'] = Symbols[i + 1].replace("{", "").replace("}", "").trim().replace(/\s+/, " ");
|
528
531
|
|
529
532
|
if (Object[Symbols[r - 1]]['OBJECT IDENTIFIER'] == '0 0') {
|
530
533
|
Object[Symbols[r - 1]]['OID'] = '0.0';
|
@@ -670,35 +673,34 @@ var MIB = function (dir) {
|
|
670
673
|
},
|
671
674
|
BuildObject: function (Object, ObjectName, macro, i, Symbols) {
|
672
675
|
|
673
|
-
var
|
674
|
-
var m =
|
675
|
-
var
|
676
|
-
var
|
677
|
-
var
|
676
|
+
var syntaxKeyword = Symbols.indexOf('SYNTAX', i);
|
677
|
+
var m = syntaxKeyword - i;
|
678
|
+
var c1 = syntaxKeyword + 1;
|
679
|
+
var SYNTAX = Symbols[c1];
|
680
|
+
var val = Symbols[c1 + 1];
|
678
681
|
|
679
682
|
if (this.MACROS.indexOf(macro) > -1 && m < 10) {
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
}
|
688
|
-
val = val.replace("{", "").replace("}", "").split(",");
|
689
|
-
|
690
|
-
Object[ObjectName]['SYNTAX'] = {};
|
691
|
-
Object[ObjectName]['SYNTAX'][SYNTAX] = {};
|
683
|
+
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(",");
|
692
690
|
|
693
|
-
|
694
|
-
|
695
|
-
}
|
696
|
-
}
|
697
|
-
break;
|
698
|
-
default:
|
699
|
-
Object[ObjectName]['SYNTAX'] = SYNTAX;
|
700
|
-
break;
|
691
|
+
Object[ObjectName]['SYNTAX'] = {};
|
692
|
+
Object[ObjectName]['SYNTAX'][SYNTAX] = {};
|
701
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
|
+
}
|
698
|
+
} else if (val[0] === '(') {
|
699
|
+
const key = val.startsWith('(SIZE')? 'sizes' : 'ranges';
|
700
|
+
Object[ObjectName]['SYNTAX'] = {};
|
701
|
+
Object[ObjectName]['SYNTAX'][SYNTAX] = { [key]: this.GetRanges(val) };
|
702
|
+
} else {
|
703
|
+
Object[ObjectName]['SYNTAX'] = SYNTAX;
|
702
704
|
}
|
703
705
|
}
|
704
706
|
},
|