net-snmp 3.9.2 → 3.9.3

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
@@ -655,7 +655,7 @@ for v1 and v2c.
655
655
 
656
656
  ## session.on ("close", callback)
657
657
 
658
- The `close` event is emitted by the session when the sessions underlying UDP
658
+ The `close` event is emitted by the session when the session's underlying UDP
659
659
  socket is closed.
660
660
 
661
661
  No arguments are passed to the callback.
@@ -665,7 +665,7 @@ in the failure of each outstanding request. The error passed back through to
665
665
  each request will be an instance of the `Error` class with the errors
666
666
  `message` attribute set to `Socket forcibly closed`.
667
667
 
668
- The following example prints a message to the console when a sessions
668
+ The following example prints a message to the console when a session's
669
669
  underlying UDP socket is closed:
670
670
 
671
671
  ```js
@@ -676,7 +676,7 @@ session.on ("close", function () {
676
676
 
677
677
  ## session.on ("error", callback)
678
678
 
679
- The `error` event is emitted by the session when the sessions underlying UDP
679
+ The `error` event is emitted by the session when the session's underlying UDP
680
680
  socket emits an error.
681
681
 
682
682
  The following arguments will be passed to the `callback` function:
@@ -685,7 +685,7 @@ The following arguments will be passed to the `callback` function:
685
685
  will contain a detailed error message.
686
686
 
687
687
  The following example prints a message to the console when an error occurs
688
- with a sessions underlying UDP socket, the session is then closed:
688
+ with a session's underlying UDP socket, the session is then closed:
689
689
 
690
690
  ```js
691
691
  session.on ("error", function (error) {
@@ -2704,6 +2704,40 @@ Sends a "ping" to the master agent using a `Ping` PDU, to confirm that the maste
2704
2704
  responsive. The supplied `callback` is called on reception of the subsequent
2705
2705
  `Response` PDU from the master to the `Ping` PDU.
2706
2706
 
2707
+ ## subagent.on ("close", callback)
2708
+
2709
+ The `close` event is emitted by the subagent when its underlying TCP socket is closed.
2710
+
2711
+ No arguments are passed to the callback.
2712
+
2713
+ The following example prints a message to the console when a subagent's
2714
+ underlying TCP socket is closed:
2715
+
2716
+ ```js
2717
+ subagent.on ("close", function () {
2718
+ console.log ("Subagent socket closed");
2719
+ });
2720
+ ```
2721
+
2722
+ ## subagent.on ("error", callback)
2723
+
2724
+ The `error` event is emitted by the subagent when its underlying TCP socket emits an error.
2725
+
2726
+ The following argument will be passed to the `callback` function:
2727
+
2728
+ * `error` - An instance of the `Error` class, the exposed `message` attribute
2729
+ will contain a detailed error message.
2730
+
2731
+ The following example prints a message to the console when an error occurs
2732
+ with a subagent's underlying TCP socket, and the subagent is then closed:
2733
+
2734
+ ```js
2735
+ subagent.on ("error", function (error) {
2736
+ console.log (error.toString ());
2737
+ subagent.close ();
2738
+ });
2739
+ ```
2740
+
2707
2741
 
2708
2742
  # Example Programs
2709
2743
 
@@ -3251,6 +3285,10 @@ Example programs are included under the module's `example` directory.
3251
3285
 
3252
3286
  * Fix MIB parsing of non-comments in descriptions and unmatched quotations
3253
3287
 
3288
+ ## Version 3.9.3 - 28/04/2023
3289
+
3290
+ * Add AgentX subagent "error" and "close" events
3291
+
3254
3292
  # License
3255
3293
 
3256
3294
  Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
@@ -66,6 +66,9 @@ agent.open(function (error, data) {
66
66
  agent.registerProvider (tableProvider, null);
67
67
  agent.getMib ().addTableRow ("smallIfTable", [1, "lo", 24]);
68
68
  agent.getMib ().addTableRow ("smallIfTable", [2, "eth0", 6]);
69
+ agent.on("close", function() {
70
+ console.log ("Subagent socket closed");
71
+ });
69
72
  }
70
73
  });
71
74
 
@@ -35,26 +35,12 @@ var mib = agent.getMib ();
35
35
  var authorizer = agent.getAuthorizer ();
36
36
  authorizer.addCommunity ("public");
37
37
 
38
-
39
38
  // IF-MIB load and providers registration
40
39
  store.loadFromFile (mibDir + "IANAifType-MIB.mib");
41
40
  store.loadFromFile (mibDir + "IF-MIB.mib");
42
41
  providers = store.getProvidersForModule ("IF-MIB");
43
42
  mib.registerProviders (providers);
44
43
 
45
- store.loadFromFile (mibDir + "SNMP-FRAMEWORK-MIB.mib");
46
- store.loadFromFile (mibDir + "INET-ADDRESS-MIB.mib");
47
- store.loadFromFile (mibDir + "CISCO-SMI.mib");
48
- store.loadFromFile (mibDir + "CISCO-TC.mib");
49
- store.loadFromFile (mibDir + "CISCO-LWAPP-TC-MIB.mib");
50
- store.loadFromFile (mibDir + "CISCO-LWAPP-WLAN-MIB.mib");
51
- store.loadFromFile (mibDir + "ENTITY-MIB.mib");
52
- store.loadFromFile (mibDir + "CISCO-LWAPP-RF-MIB.mib");
53
- store.loadFromFile (mibDir + "CISCO-LWAPP-AP-MIB.mib");
54
- store.loadFromFile (mibDir + "CISCO-LWAPP-DOT11-MIB.mib");
55
- store.loadFromFile (mibDir + "CISCO-LWAPP-REAP-MIB.mib");
56
- store.loadFromFile (mibDir + "CISCO-LWAPP-CDP-MIB.mib");
57
-
58
44
  // ifNumber
59
45
  // Scalar type - setScalarValue() and getScalarValue() are the entire API for these
60
46
  mib.setScalarValue ("ifNumber", 5);
package/index.js CHANGED
@@ -5708,6 +5708,16 @@ var Subagent = function (options) {
5708
5708
  this.setTransactions = {};
5709
5709
  };
5710
5710
 
5711
+ util.inherits (Subagent, events.EventEmitter);
5712
+
5713
+ Subagent.prototype.onClose = function () {
5714
+ this.emit ("close");
5715
+ };
5716
+
5717
+ Subagent.prototype.onError = function (error) {
5718
+ this.emit ("error", error);
5719
+ };
5720
+
5711
5721
  Subagent.prototype.getMib = function () {
5712
5722
  return this.mib;
5713
5723
  };
@@ -5720,9 +5730,8 @@ Subagent.prototype.connectSocket = function () {
5720
5730
  });
5721
5731
 
5722
5732
  this.socket.on ("data", me.onMsg.bind (me));
5723
- this.socket.on ("error", function (error) {
5724
- console.error (error);
5725
- });
5733
+ this.socket.on ("error", me.onError.bind (me));
5734
+ this.socket.on ("close", me.onClose.bind (me));
5726
5735
  };
5727
5736
 
5728
5737
  Subagent.prototype.open = function (callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "net-snmp",
3
- "version": "3.9.2",
3
+ "version": "3.9.3",
4
4
  "description": "JavaScript implementation of the Simple Network Management Protocol (SNMP)",
5
5
  "main": "index.js",
6
6
  "directories": {