net-snmp 3.14.1 → 3.15.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.
Files changed (3) hide show
  1. package/README.md +4 -0
  2. package/index.js +9 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -3412,6 +3412,10 @@ Example programs are included under the module's `example` directory.
3412
3412
 
3413
3413
  * Add RFC-1215 to base MIB modules to provide TRAP-TYPE macro
3414
3414
 
3415
+ ## Version 3.15.0 - 14/09/2024
3416
+
3417
+ * Change return of undefined or null MIB values to NoSuchInstance
3418
+
3415
3419
  # License
3416
3420
 
3417
3421
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
package/index.js CHANGED
@@ -3771,17 +3771,16 @@ MibNode.prototype.getNextInstanceNode = function () {
3771
3771
  var childrenAddresses;
3772
3772
 
3773
3773
  var node = this;
3774
- if ( this.value != null ) {
3775
- // Need upwards traversal first
3776
- node = this;
3774
+ // If we start on a leaf node, we need next (right) sibling or upwards traversal first
3775
+ if ( ! node.children || Object.keys (node.children).length === 0 ) {
3777
3776
  while ( node ) {
3778
3777
  siblingIndex = node.address.slice(-1)[0];
3779
3778
  node = node.parent;
3780
3779
  if ( ! node ) {
3781
- // end of MIB
3780
+ // End of MIB
3782
3781
  return null;
3783
3782
  } else {
3784
- // Move to next sibling
3783
+ // Move to next sibling if we are not last child
3785
3784
  childrenAddresses = Object.keys (node.children).sort ( (a, b) => a - b);
3786
3785
  var siblingPosition = childrenAddresses.indexOf(siblingIndex.toString());
3787
3786
  if ( siblingPosition + 1 < childrenAddresses.length ) {
@@ -3792,7 +3791,8 @@ MibNode.prototype.getNextInstanceNode = function () {
3792
3791
  }
3793
3792
  }
3794
3793
  while ( node ) {
3795
- if ( node.value != null ) {
3794
+ // Return if at leaf
3795
+ if ( ! node.children || Object.keys (node.children).length === 0 ) {
3796
3796
  return node;
3797
3797
  }
3798
3798
  // Descend to first child if not at leaf
@@ -5215,6 +5215,9 @@ Agent.prototype.request = function (socket, requestMessage, rinfo) {
5215
5215
  responseVarbind.type = mibRequests[savedIndex].instanceNode.valueType;
5216
5216
  }
5217
5217
  responseVarbind.value = mibRequests[savedIndex].instanceNode.value;
5218
+ if ( responseVarbind.value === undefined || responseVarbind.value === null ) {
5219
+ responseVarbind.type = ObjectType.NoSuchInstance;
5220
+ }
5218
5221
  }
5219
5222
  if ( providerNode && providerNode.provider && providerNode.provider.name ) {
5220
5223
  responseVarbind.providerName = providerNode.provider.name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.14.1",
3
+ "version": "3.15.0",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {