net-snmp 3.20.1 → 3.21.0

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
@@ -1663,7 +1663,7 @@ an object, possibly empty, and can contain the following fields:
1663
1663
  * `sockets` - an array of objects containing triples of `transport`, `address` and `port` that
1664
1664
  can be used to specify multiple socket listeners. This option overrides any individual
1665
1665
  `transport`, `address` and `port` options.
1666
- * `mibOptions` - an MIB options object that is passed to the `Mib` instance - see the MIB section
1666
+ * `mibOptions` - a MIB options object that is passed to the `Mib` instance - see the MIB section
1667
1667
  for further details on this - defaults to the empty object.
1668
1668
 
1669
1669
  The `mib` parameter is optional, and sets the agent's singleton `Mib` instance.
@@ -2689,7 +2689,9 @@ var options = {
2689
2689
  master: "localhost",
2690
2690
  masterPort: 705,
2691
2691
  timeout: 0,
2692
- description: "Node net-snmp AgentX sub-agent"
2692
+ description: "Node net-snmp AgentX sub-agent",
2693
+ mibOptions: {},
2694
+ mib: undefined
2693
2695
  };
2694
2696
 
2695
2697
  subagent = snmp.createSubagent (options);
@@ -2704,6 +2706,12 @@ The `options` parameter is a mandatory object, possibly empty, and can contain t
2704
2706
  * `timeout` - set the session-wide timeout on the master agent - defaults to 0, which
2705
2707
  means no session-wide timeout is set.
2706
2708
  * `description` - a textual description of the subagent.
2709
+ * `mibOptions` - n MIB options object that is passed to the `Mib` instance - see the MIB section
2710
+ for further details on this - defaults to the empty object.
2711
+ * `mib` - sets the agent's singleton `Mib` instance. If not supplied, the agent creates itself
2712
+ a new empty `Mib` singleton. If supplied, the `Mib` instance needs to be created and populated as
2713
+ per the [Mib Module](#mib-module) section.
2714
+
2707
2715
 
2708
2716
  ## subagent.getMib ()
2709
2717
 
@@ -3509,6 +3517,10 @@ Example programs are included under the module's `example` directory.
3509
3517
 
3510
3518
  * Update documentation with compatibility note on DES and recent Node.js versions
3511
3519
 
3520
+ # Version 3.21.0 - 26/04/2025
3521
+
3522
+ * Add AgentX subagent mib and mibOptions on initialization
3523
+
3512
3524
  # License
3513
3525
 
3514
3526
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
package/index.js CHANGED
@@ -1400,6 +1400,7 @@ Encryption.encryptPduDes = function (scopedPdu, privProtocol, privPassword, auth
1400
1400
  iv[i] = preIv[i] ^ salt[i];
1401
1401
  }
1402
1402
 
1403
+
1403
1404
  if (scopedPdu.length % des.BLOCK_LENGTH == 0) {
1404
1405
  paddedScopedPdu = scopedPdu;
1405
1406
  } else {
@@ -2040,7 +2041,7 @@ var Session = function (target, authenticator, options) {
2040
2041
 
2041
2042
  this.dgram = dgram.createSocket (this.transport);
2042
2043
  this.dgram.unref();
2043
-
2044
+
2044
2045
  var me = this;
2045
2046
  this.dgram.on ("message", me.onMsg.bind (me));
2046
2047
  this.dgram.on ("close", me.onClose.bind (me));
@@ -2268,7 +2269,7 @@ Session.prototype.inform = function () {
2268
2269
 
2269
2270
  /**
2270
2271
  ** Support the following signatures:
2271
- **
2272
+ **
2272
2273
  ** typeOrOid, varbinds, options, callback
2273
2274
  ** typeOrOid, varbinds, callback
2274
2275
  ** typeOrOid, options, callback
@@ -2346,7 +2347,7 @@ Session.prototype.inform = function () {
2346
2347
  };
2347
2348
  pduVarbinds.push (varbind);
2348
2349
  }
2349
-
2350
+
2350
2351
  options.port = this.trapPort;
2351
2352
 
2352
2353
  this.simpleGet (InformRequestPdu, feedCb, pduVarbinds, responseCb, options);
@@ -2466,7 +2467,7 @@ Session.prototype.registerRequest = function (req) {
2466
2467
  Session.prototype.send = function (req, noWait) {
2467
2468
  try {
2468
2469
  var me = this;
2469
-
2470
+
2470
2471
  var buffer = req.message.toBuffer ();
2471
2472
 
2472
2473
  this.dgram.send (buffer, 0, buffer.length, req.port, this.target,
@@ -2484,7 +2485,7 @@ Session.prototype.send = function (req, noWait) {
2484
2485
  } catch (error) {
2485
2486
  req.responseCb (error);
2486
2487
  }
2487
-
2488
+
2488
2489
  return this;
2489
2490
  };
2490
2491
 
@@ -2736,7 +2737,7 @@ Session.prototype.trap = function () {
2736
2737
 
2737
2738
  /**
2738
2739
  ** Support the following signatures:
2739
- **
2740
+ **
2740
2741
  ** typeOrOid, varbinds, options, callback
2741
2742
  ** typeOrOid, varbinds, agentAddr, callback
2742
2743
  ** typeOrOid, varbinds, callback
@@ -2779,7 +2780,7 @@ Session.prototype.trap = function () {
2779
2780
  };
2780
2781
  pduVarbinds.push (varbind);
2781
2782
  }
2782
-
2783
+
2783
2784
  var id = _generateId (this.idBitsSize);
2784
2785
 
2785
2786
  if (this.version == Version2c || this.version == Version3 ) {
@@ -3070,7 +3071,7 @@ Listener.prototype.startListening = function () {
3070
3071
 
3071
3072
  Listener.prototype.send = function (message, rinfo, socket) {
3072
3073
  // var me = this;
3073
-
3074
+
3074
3075
  var buffer = message.toBuffer ();
3075
3076
 
3076
3077
  socket.send (buffer, 0, buffer.length, rinfo.port, rinfo.address, function (error, bytes) {
@@ -3678,7 +3679,7 @@ ModuleStore.prototype.getProvidersForModule = function (moduleName) {
3678
3679
  // (See lib/mibs/SNMPv2-TC.mib#L186.)
3679
3680
  if ( syntax == "RowStatus" &&
3680
3681
  "IMPORTS" in mibModule &&
3681
- Array.isArray(mibModule.IMPORTS["SNMPv2-TC"]) &&
3682
+ Array.isArray(mibModule.IMPORTS["SNMPv2-TC"]) &&
3682
3683
  mibModule.IMPORTS["SNMPv2-TC"].includes("RowStatus") ) {
3683
3684
 
3684
3685
  // Mark this column as being rowStatus
@@ -4027,7 +4028,7 @@ MibNode.prototype.getNextInstanceNode = function () {
4027
4028
  childrenAddresses = Object.keys (node.children).sort ( (a, b) => a - b);
4028
4029
  node = node.children[childrenAddresses[0]];
4029
4030
  if ( ! node ) {
4030
- // unexpected
4031
+ // unexpected
4031
4032
  return null;
4032
4033
  }
4033
4034
  }
@@ -4690,7 +4691,7 @@ Mib.prototype.getTableCells = function (table, byRows, includeInstances) {
4690
4691
  } else {
4691
4692
  return data;
4692
4693
  }
4693
-
4694
+
4694
4695
  };
4695
4696
 
4696
4697
  Mib.prototype.getTableSingleCell = function (table, columnNumber, rowIndex) {
@@ -5088,7 +5089,7 @@ Agent.prototype.tryCreateInstance = function (varbind, requestType) {
5088
5089
  typeof rowStatusColumn == "number" &&
5089
5090
  column === rowStatusColumn ) {
5090
5091
 
5091
- if ( (varbind.value === RowStatus["createAndGo"] || varbind.value === RowStatus["createAndWait"]) &&
5092
+ if ( (varbind.value === RowStatus["createAndGo"] || varbind.value === RowStatus["createAndWait"]) &&
5092
5093
  provider.createHandler !== null ) {
5093
5094
 
5094
5095
  // The create handler will return an array
@@ -5572,7 +5573,7 @@ Agent.prototype.getBulkRequest = function (socket, requestMessage, rinfo) {
5572
5573
  }
5573
5574
 
5574
5575
  if ( requestPdu.nonRepeaters < requestVarbinds.length ) {
5575
-
5576
+
5576
5577
  for (var v = requestPdu.nonRepeaters ; v < requestVarbinds.length ; v++ ) {
5577
5578
  startOid.push (requestVarbinds[v].oid);
5578
5579
  }
@@ -5784,7 +5785,7 @@ AgentXPdu.prototype.readHeader = function (buffer) {
5784
5785
  this.version = buffer.readUInt8 ();
5785
5786
  this.pduType = buffer.readUInt8 ();
5786
5787
  this.flags = buffer.readUInt8 ();
5787
- buffer.readUInt8 (); // reserved byte
5788
+ buffer.readUInt8 (); // reserved byte
5788
5789
  this.sessionID = buffer.readUInt32BE ();
5789
5790
  this.transactionID = buffer.readUInt32BE ();
5790
5791
  this.packetID = buffer.readUInt32BE ();
@@ -5854,7 +5855,7 @@ AgentXPdu.createFromVariables = function (vars) {
5854
5855
  + "' in created PDU");
5855
5856
 
5856
5857
  }
5857
-
5858
+
5858
5859
  return pdu;
5859
5860
  };
5860
5861
 
@@ -6089,7 +6090,7 @@ AgentXPdu.packetID = 1;
6089
6090
 
6090
6091
  var Subagent = function (options) {
6091
6092
  DEBUG = options.debug;
6092
- this.mib = new Mib ();
6093
+ this.mib = options?.mib ?? new Mib (options?.mibOptions);
6093
6094
  this.master = options.master || 'localhost';
6094
6095
  this.masterPort = options.masterPort || 705;
6095
6096
  this.timeout = options.timeout || 0;
package/lib/mib.js CHANGED
@@ -655,7 +655,7 @@ const MIB = function (dir) {
655
655
  if (unresolvedObjects.length > 0) {
656
656
  for (const unresolved of unresolvedObjects) {
657
657
  const obj = this.Modules[ModuleName][unresolved];
658
-
658
+
659
659
  const { oidString, nameString, unresolvedObject } = this.getOidAndNamePaths(obj['OBJECT IDENTIFIER'], unresolved, ModuleName);
660
660
  this.Modules[ModuleName][unresolved].NameSpace = nameString;
661
661
  this.Modules[ModuleName][unresolved].OID = oidString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.20.1",
3
+ "version": "3.21.0",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {