net-snmp 3.11.2 → 3.12.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 +27 -13
- package/index.js +64 -38
- package/package.json +1 -1
package/README.md
CHANGED
@@ -67,11 +67,11 @@ for each shown in this table:
|
|
67
67
|
|
68
68
|
| Application | Common Use | Documentation |
|
69
69
|
| ----------- | ---------- | ------------- |
|
70
|
-
| Command Generator | NMS / SNMP tools | [
|
71
|
-
| Command Responder | SNMP agents | [
|
72
|
-
| Notification Originator | SNMP agents / NMS-to-NMS notifications | [
|
73
|
-
| Notification Receiver | NMS | [
|
74
|
-
| Proxy Forwarder | SNMP agents | [Forwarder Module](#forwarder-module) |
|
70
|
+
| Command Generator | NMS / SNMP tools | [Application: Command & Notification Generator](#application-command--notification-generator) |
|
71
|
+
| Command Responder | SNMP agents | [Application: SNMP Agent](#application-snmp-agent) |
|
72
|
+
| Notification Originator | SNMP agents / NMS-to-NMS notifications | [Application: Command & Notification Generator](#application-command--notification-generator) |
|
73
|
+
| Notification Receiver | NMS | [Application: Notification Receiver](#application-notification-receiver) |
|
74
|
+
| Proxy Forwarder | SNMP agents | [Agent Forwarder Module](#agent-forwarder-module) |
|
75
75
|
|
76
76
|
# Features
|
77
77
|
|
@@ -531,7 +531,7 @@ then it will produce a `ProcessingError` containing:
|
|
531
531
|
* a `buffer` containing the packet contents, and
|
532
532
|
* an `error` containing the original error encountered during processing.
|
533
533
|
|
534
|
-
#
|
534
|
+
# Application: Command & Notification Generator
|
535
535
|
|
536
536
|
This library provides a `Session` class to provide support for building
|
537
537
|
"Command Generator" and "Notification Originator" SNMP applications.
|
@@ -1448,7 +1448,7 @@ var maxRepetitions = 20;
|
|
1448
1448
|
session.walk (oid, maxRepetitions, feedCb, doneCb);
|
1449
1449
|
```
|
1450
1450
|
|
1451
|
-
#
|
1451
|
+
# Application: Notification Receiver
|
1452
1452
|
|
1453
1453
|
RFC 3413 classifies a "Notification Receiver" SNMP application that receives
|
1454
1454
|
"Notification-Class" PDUs. Notifications include both SNMP traps and informs.
|
@@ -1510,6 +1510,9 @@ an object, possibly empty, and can contain the following fields:
|
|
1510
1510
|
addresses
|
1511
1511
|
* `includeAuthentication` - adds the community (v1/2c) or user name (v3) information
|
1512
1512
|
to the notification callback - defaults to `false`
|
1513
|
+
* `sockets` - an array of objects containing triples of `transport`, `address` and `port` that
|
1514
|
+
can be used to specify multiple socket listeners. This option overrides any individual
|
1515
|
+
`transport`, `address` and `port` options.
|
1513
1516
|
|
1514
1517
|
The `callback` parameter is a callback function of the form
|
1515
1518
|
`function (error, notification)`. On an error condition, the `notification`
|
@@ -1555,7 +1558,7 @@ to the receiver. See the `Authorizer` section for further details.
|
|
1555
1558
|
|
1556
1559
|
Closes the receiver's listening socket, ending the operation of the receiver.
|
1557
1560
|
|
1558
|
-
#
|
1561
|
+
# Application: SNMP Agent
|
1559
1562
|
|
1560
1563
|
The SNMP agent responds to all four "request class" PDUs relevant to a Command Responder
|
1561
1564
|
application:
|
@@ -1565,7 +1568,7 @@ application:
|
|
1565
1568
|
* **GetBulkRequest** - request a series of "next" OID instances in the MIB tree
|
1566
1569
|
* **SetRequest** - set values for specified OIDs
|
1567
1570
|
|
1568
|
-
The agent sends a **GetResponse** PDU to all four request PDU types, in conformance
|
1571
|
+
The agent sends a **GetResponse** PDU to all four request PDU types, in conformance with RFC 3416.
|
1569
1572
|
|
1570
1573
|
The agent - like the notification receiver - maintains an `Authorizer` instance
|
1571
1574
|
to control access to the agent, details of which are in the [Authorizer Module](#authorizer-module)
|
@@ -1625,6 +1628,9 @@ an object, possibly empty, and can contain the following fields:
|
|
1625
1628
|
* `transport` - the transport family to use - defaults to `udp4`
|
1626
1629
|
* `address` - the IP address to bind to - default to `null`, which means bind to all IP
|
1627
1630
|
addresses
|
1631
|
+
* `sockets` - an array of objects containing triples of `transport`, `address` and `port` that
|
1632
|
+
can be used to specify multiple socket listeners. This option overrides any individual
|
1633
|
+
`transport`, `address` and `port` options.
|
1628
1634
|
|
1629
1635
|
The `mib` parameter is optional, and sets the agent's singleton `Mib` instance.
|
1630
1636
|
If not supplied, the agent creates itself a new empty `Mib` singleton. If supplied,
|
@@ -2391,7 +2397,7 @@ methods `Mib.setScalarDefaultValue` and `Mib.setTableRowDefaultValues`
|
|
2391
2397
|
may be used to conveniently add defaults after the MIB files are
|
2392
2398
|
loaded.
|
2393
2399
|
|
2394
|
-
#
|
2400
|
+
# Application: Module Store
|
2395
2401
|
|
2396
2402
|
The library supports MIB parsing by providing an interface to a `ModuleStore` instance into which
|
2397
2403
|
you can load MIB modules from files, and fetch the resulting JSON MIB module representations.
|
@@ -2501,7 +2507,7 @@ var namedOid = store.translate ('1.3.6.1.2.1.1.1', snmp.OidFormat.path);
|
|
2501
2507
|
=> 'iso.org.dod.internet.mgmt.mib-2.system.sysDescr'
|
2502
2508
|
```
|
2503
2509
|
|
2504
|
-
# Forwarder Module
|
2510
|
+
# Agent Forwarder Module
|
2505
2511
|
|
2506
2512
|
An `Agent` instance, when created, in turn creates an instance of the `Forwarder` class.
|
2507
2513
|
There is no direct API call to create a `Forwarder` instance; this creation is the
|
@@ -2523,7 +2529,7 @@ forwarder.addProxy({
|
|
2523
2529
|
level: snmp.SecurityLevel.authNoPriv,
|
2524
2530
|
authProtocol: snmp.AuthProtocols.sha,
|
2525
2531
|
authKey: "quarryandgravel"
|
2526
|
-
}
|
2532
|
+
}
|
2527
2533
|
});
|
2528
2534
|
```
|
2529
2535
|
|
@@ -2577,7 +2583,7 @@ Returns an object containing a list of all registered proxies, keyed by context
|
|
2577
2583
|
|
2578
2584
|
Prints a dump of all proxy definitions to the console.
|
2579
2585
|
|
2580
|
-
#
|
2586
|
+
# Application: AgentX Subagent
|
2581
2587
|
|
2582
2588
|
The AgentX subagent implements the functionality specified in RFC 2741 to become a "subagent"
|
2583
2589
|
of an AgentX "master agent". The goal of AgentX is to extend the functionality of an existing
|
@@ -3371,6 +3377,14 @@ Example programs are included under the module's `example` directory.
|
|
3371
3377
|
|
3372
3378
|
* Add provider to MIB request
|
3373
3379
|
|
3380
|
+
## Version 3.12.0 - 28/06/2024
|
3381
|
+
|
3382
|
+
* Add multiple socket listener support for agent and receiver
|
3383
|
+
|
3384
|
+
## Version 3.12.1 - 21/08/2024
|
3385
|
+
|
3386
|
+
* Fix SNMPv1 session walk infinite loop condition
|
3387
|
+
|
3374
3388
|
# License
|
3375
3389
|
|
3376
3390
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/index.js
CHANGED
@@ -2617,6 +2617,9 @@ function walkCb (req, error, varbinds) {
|
|
2617
2617
|
if (! done)
|
2618
2618
|
oid = varbinds[0][varbinds[0].length - 1].oid;
|
2619
2619
|
} else {
|
2620
|
+
if (varbinds[0].type == ObjectType.EndOfMibView) {
|
2621
|
+
done = 1;
|
2622
|
+
}
|
2620
2623
|
if (! done) {
|
2621
2624
|
if (req.feedCb (varbinds)) {
|
2622
2625
|
done = 1;
|
@@ -2709,7 +2712,7 @@ Session.prototype.onProxyResponse = function (req, message) {
|
|
2709
2712
|
message.pdu.contextEngineID = message.msgSecurityParameters.msgAuthoritativeEngineID;
|
2710
2713
|
message.pdu.contextName = this.proxy.context;
|
2711
2714
|
message.pdu.id = req.proxiedPduId;
|
2712
|
-
this.proxy.listener.send (message, req.proxiedRinfo);
|
2715
|
+
this.proxy.listener.send (message, req.proxiedRinfo, req.proxiedSocket);
|
2713
2716
|
};
|
2714
2717
|
|
2715
2718
|
Session.create = function (target, community, options) {
|
@@ -2765,27 +2768,50 @@ Engine.prototype.generateEngineID = function() {
|
|
2765
2768
|
var Listener = function (options, receiver) {
|
2766
2769
|
this.receiver = receiver;
|
2767
2770
|
this.callback = receiver.onMsg;
|
2768
|
-
this.
|
2769
|
-
this.port = options.port || 161;
|
2770
|
-
this.address = options.address;
|
2771
|
+
// this.transport = options.transport || 'udp4';
|
2772
|
+
// this.port = options.port || 161;
|
2773
|
+
// this.address = options.address;
|
2771
2774
|
this.disableAuthorization = options.disableAuthorization || false;
|
2775
|
+
if ( options.sockets ) {
|
2776
|
+
this.socketOptions = options.sockets;
|
2777
|
+
} else {
|
2778
|
+
this.socketOptions = [
|
2779
|
+
{
|
2780
|
+
transport: options.transport,
|
2781
|
+
address: options.address,
|
2782
|
+
port: options.port
|
2783
|
+
}
|
2784
|
+
];
|
2785
|
+
}
|
2786
|
+
for ( const socketOption of this.socketOptions ) {
|
2787
|
+
socketOption.transport = socketOption.transport || 'udp4';
|
2788
|
+
socketOption.address = socketOption.address || null;
|
2789
|
+
socketOption.port = socketOption.port || 161;
|
2790
|
+
}
|
2772
2791
|
};
|
2773
2792
|
|
2774
2793
|
Listener.prototype.startListening = function () {
|
2775
2794
|
var me = this;
|
2776
|
-
this.
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2795
|
+
this.sockets = {};
|
2796
|
+
for ( const socketOptions of this.socketOptions ) {
|
2797
|
+
const socket = dgram.createSocket (socketOptions.transport);
|
2798
|
+
socket.on ("error", me.receiver.callback);
|
2799
|
+
socket.bind (socketOptions.port, socketOptions.address);
|
2800
|
+
socket.on ("message", me.callback.bind (me.receiver, socket));
|
2801
|
+
const socketKey = socketOptions.transport + ':' + socketOptions.address + ':' + socketOptions.port;
|
2802
|
+
if ( this.sockets[socketKey] ) {
|
2803
|
+
throw new Error ("Duplicate socket exists for " + socketKey);
|
2804
|
+
}
|
2805
|
+
this.sockets[socketKey] = socket;
|
2806
|
+
}
|
2780
2807
|
};
|
2781
2808
|
|
2782
|
-
Listener.prototype.send = function (message, rinfo) {
|
2809
|
+
Listener.prototype.send = function (message, rinfo, socket) {
|
2783
2810
|
// var me = this;
|
2784
2811
|
|
2785
2812
|
var buffer = message.toBuffer ();
|
2786
2813
|
|
2787
|
-
|
2788
|
-
function (error, bytes) {
|
2814
|
+
socket.send (buffer, 0, buffer.length, rinfo.port, rinfo.address, function (error, bytes) {
|
2789
2815
|
if (error) {
|
2790
2816
|
// me.callback (error);
|
2791
2817
|
console.error ("Error sending: " + error.message);
|
@@ -2803,7 +2829,7 @@ Listener.formatCallbackData = function (pdu, rinfo) {
|
|
2803
2829
|
delete pdu.maxRepetitions;
|
2804
2830
|
return {
|
2805
2831
|
pdu: pdu,
|
2806
|
-
rinfo: rinfo
|
2832
|
+
rinfo: rinfo
|
2807
2833
|
};
|
2808
2834
|
};
|
2809
2835
|
|
@@ -2857,8 +2883,8 @@ Listener.processIncoming = function (buffer, authorizer, callback) {
|
|
2857
2883
|
};
|
2858
2884
|
|
2859
2885
|
Listener.prototype.close = function () {
|
2860
|
-
|
2861
|
-
|
2886
|
+
for ( const socket of Object.values(this.sockets) ) {
|
2887
|
+
socket.close ();
|
2862
2888
|
}
|
2863
2889
|
};
|
2864
2890
|
|
@@ -3052,7 +3078,6 @@ SimpleAccessControlModel.prototype.isAccessAllowed = function (securityModel, se
|
|
3052
3078
|
|
3053
3079
|
var Receiver = function (options, callback) {
|
3054
3080
|
DEBUG = options.debug;
|
3055
|
-
this.listener = new Listener (options, this);
|
3056
3081
|
this.authorizer = new Authorizer (options);
|
3057
3082
|
this.engine = new Engine (options.engineID);
|
3058
3083
|
|
@@ -3074,7 +3099,7 @@ Receiver.prototype.getAuthorizer = function () {
|
|
3074
3099
|
return this.authorizer;
|
3075
3100
|
};
|
3076
3101
|
|
3077
|
-
Receiver.prototype.onMsg = function (buffer, rinfo) {
|
3102
|
+
Receiver.prototype.onMsg = function (socket, buffer, rinfo) {
|
3078
3103
|
|
3079
3104
|
let message;
|
3080
3105
|
|
@@ -3102,7 +3127,7 @@ Receiver.prototype.onMsg = function (buffer, rinfo) {
|
|
3102
3127
|
return;
|
3103
3128
|
}
|
3104
3129
|
let reportMessage = message.createReportResponseMessage (this.engine, this.context);
|
3105
|
-
this.listener.send (reportMessage, rinfo);
|
3130
|
+
this.listener.send (reportMessage, rinfo, socket);
|
3106
3131
|
return;
|
3107
3132
|
}
|
3108
3133
|
|
@@ -3114,7 +3139,7 @@ Receiver.prototype.onMsg = function (buffer, rinfo) {
|
|
3114
3139
|
message.pdu.type = PduType.GetResponse;
|
3115
3140
|
message.buffer = null;
|
3116
3141
|
message.setReportable (false);
|
3117
|
-
this.listener.send (message, rinfo);
|
3142
|
+
this.listener.send (message, rinfo, socket);
|
3118
3143
|
message.pdu.type = PduType.InformRequest;
|
3119
3144
|
this.callback (null, this.formatCallbackData (message, rinfo) );
|
3120
3145
|
} else {
|
@@ -4646,7 +4671,7 @@ Agent.prototype.tableRowStatusHandlerInternal = function (createRequest) {
|
|
4646
4671
|
return missingDefVal ? undefined : values;
|
4647
4672
|
};
|
4648
4673
|
|
4649
|
-
Agent.prototype.onMsg = function (buffer, rinfo) {
|
4674
|
+
Agent.prototype.onMsg = function (socket, buffer, rinfo) {
|
4650
4675
|
|
4651
4676
|
let message;
|
4652
4677
|
|
@@ -4665,22 +4690,22 @@ Agent.prototype.onMsg = function (buffer, rinfo) {
|
|
4665
4690
|
if ( message.version == Version3 && message.pdu.type == PduType.GetRequest &&
|
4666
4691
|
! message.hasAuthoritativeEngineID() && message.isReportable () ) {
|
4667
4692
|
let reportMessage = message.createReportResponseMessage (this.engine, this.context);
|
4668
|
-
this.listener.send (reportMessage, rinfo);
|
4693
|
+
this.listener.send (reportMessage, rinfo, socket);
|
4669
4694
|
return;
|
4670
4695
|
}
|
4671
4696
|
|
4672
4697
|
// Request processing
|
4673
4698
|
// debug (JSON.stringify (message.pdu, null, 2));
|
4674
4699
|
if ( message.pdu.contextName && message.pdu.contextName != "" ) {
|
4675
|
-
this.onProxyRequest (message, rinfo);
|
4700
|
+
this.onProxyRequest (socket, message, rinfo);
|
4676
4701
|
} else if ( message.pdu.type == PduType.GetRequest ) {
|
4677
|
-
this.getRequest (message, rinfo);
|
4702
|
+
this.getRequest (socket, message, rinfo);
|
4678
4703
|
} else if ( message.pdu.type == PduType.SetRequest ) {
|
4679
|
-
this.setRequest (message, rinfo);
|
4704
|
+
this.setRequest (socket, message, rinfo);
|
4680
4705
|
} else if ( message.pdu.type == PduType.GetNextRequest ) {
|
4681
|
-
this.getNextRequest (message, rinfo);
|
4706
|
+
this.getNextRequest (socket, message, rinfo);
|
4682
4707
|
} else if ( message.pdu.type == PduType.GetBulkRequest ) {
|
4683
|
-
this.getBulkRequest (message, rinfo);
|
4708
|
+
this.getBulkRequest (socket, message, rinfo);
|
4684
4709
|
} else {
|
4685
4710
|
this.callback (new RequestInvalidError ("Unexpected PDU type " +
|
4686
4711
|
message.pdu.type + " (" + PduType[message.pdu.type] + ")"));
|
@@ -4911,7 +4936,7 @@ Agent.prototype.isAllowed = function (pduType, provider, instanceNode) {
|
|
4911
4936
|
}
|
4912
4937
|
};
|
4913
4938
|
|
4914
|
-
Agent.prototype.request = function (requestMessage, rinfo) {
|
4939
|
+
Agent.prototype.request = function (socket, requestMessage, rinfo) {
|
4915
4940
|
var me = this;
|
4916
4941
|
var varbindsCompleted = 0;
|
4917
4942
|
var requestPdu = requestMessage.pdu;
|
@@ -5206,7 +5231,7 @@ Agent.prototype.request = function (requestMessage, rinfo) {
|
|
5206
5231
|
}
|
5207
5232
|
me.setSingleVarbind (responsePdu, savedIndex, responseVarbind);
|
5208
5233
|
if ( ++varbindsCompleted == varbindsLength) {
|
5209
|
-
me.sendResponse.call (me, rinfo, requestMessage, responsePdu);
|
5234
|
+
me.sendResponse.call (me, socket, rinfo, requestMessage, responsePdu);
|
5210
5235
|
}
|
5211
5236
|
};
|
5212
5237
|
})(i);
|
@@ -5218,12 +5243,12 @@ Agent.prototype.request = function (requestMessage, rinfo) {
|
|
5218
5243
|
}
|
5219
5244
|
};
|
5220
5245
|
|
5221
|
-
Agent.prototype.getRequest = function (requestMessage, rinfo) {
|
5222
|
-
this.request (requestMessage, rinfo);
|
5246
|
+
Agent.prototype.getRequest = function (socket, requestMessage, rinfo) {
|
5247
|
+
this.request (socket, requestMessage, rinfo);
|
5223
5248
|
};
|
5224
5249
|
|
5225
|
-
Agent.prototype.setRequest = function (requestMessage, rinfo) {
|
5226
|
-
this.request (requestMessage, rinfo);
|
5250
|
+
Agent.prototype.setRequest = function (socket, requestMessage, rinfo) {
|
5251
|
+
this.request (socket, requestMessage, rinfo);
|
5227
5252
|
};
|
5228
5253
|
|
5229
5254
|
Agent.prototype.addGetNextVarbind = function (targetVarbinds, startOid) {
|
@@ -5263,7 +5288,7 @@ Agent.prototype.addGetNextVarbind = function (targetVarbinds, startOid) {
|
|
5263
5288
|
return getNextNode;
|
5264
5289
|
};
|
5265
5290
|
|
5266
|
-
Agent.prototype.getNextRequest = function (requestMessage, rinfo) {
|
5291
|
+
Agent.prototype.getNextRequest = function (socket, requestMessage, rinfo) {
|
5267
5292
|
var requestPdu = requestMessage.pdu;
|
5268
5293
|
var varbindsLength = requestPdu.varbinds.length;
|
5269
5294
|
var getNextVarbinds = [];
|
@@ -5273,10 +5298,10 @@ Agent.prototype.getNextRequest = function (requestMessage, rinfo) {
|
|
5273
5298
|
}
|
5274
5299
|
|
5275
5300
|
requestMessage.pdu.varbinds = getNextVarbinds;
|
5276
|
-
this.request (requestMessage, rinfo);
|
5301
|
+
this.request (socket, requestMessage, rinfo);
|
5277
5302
|
};
|
5278
5303
|
|
5279
|
-
Agent.prototype.getBulkRequest = function (requestMessage, rinfo) {
|
5304
|
+
Agent.prototype.getBulkRequest = function (socket, requestMessage, rinfo) {
|
5280
5305
|
var requestPdu = requestMessage.pdu;
|
5281
5306
|
var requestVarbinds = requestPdu.varbinds;
|
5282
5307
|
var getBulkVarbinds = [];
|
@@ -5310,20 +5335,20 @@ Agent.prototype.getBulkRequest = function (requestMessage, rinfo) {
|
|
5310
5335
|
}
|
5311
5336
|
|
5312
5337
|
requestMessage.pdu.varbinds = getBulkVarbinds;
|
5313
|
-
this.request (requestMessage, rinfo);
|
5338
|
+
this.request (socket, requestMessage, rinfo);
|
5314
5339
|
};
|
5315
5340
|
|
5316
5341
|
Agent.prototype.setSingleVarbind = function (responsePdu, index, responseVarbind) {
|
5317
5342
|
responsePdu.varbinds[index] = responseVarbind;
|
5318
5343
|
};
|
5319
5344
|
|
5320
|
-
Agent.prototype.sendResponse = function (rinfo, requestMessage, responsePdu) {
|
5345
|
+
Agent.prototype.sendResponse = function (socket, rinfo, requestMessage, responsePdu) {
|
5321
5346
|
var responseMessage = requestMessage.createResponseForRequest (responsePdu);
|
5322
|
-
this.listener.send (responseMessage, rinfo);
|
5347
|
+
this.listener.send (responseMessage, rinfo, socket);
|
5323
5348
|
this.callback (null, Listener.formatCallbackData (responseMessage.pdu, rinfo) );
|
5324
5349
|
};
|
5325
5350
|
|
5326
|
-
Agent.prototype.onProxyRequest = function (message, rinfo) {
|
5351
|
+
Agent.prototype.onProxyRequest = function (socket, message, rinfo) {
|
5327
5352
|
var contextName = message.pdu.contextName;
|
5328
5353
|
var proxy;
|
5329
5354
|
var proxiedPduId;
|
@@ -5358,6 +5383,7 @@ Agent.prototype.onProxyRequest = function (message, rinfo) {
|
|
5358
5383
|
req.proxiedPduId = proxiedPduId;
|
5359
5384
|
req.proxiedUser = proxiedUser;
|
5360
5385
|
req.proxiedEngine = this.engine;
|
5386
|
+
req.proxiedSocket = socket;
|
5361
5387
|
proxy.session.send (req);
|
5362
5388
|
}
|
5363
5389
|
};
|