net-snmp 3.11.1 → 3.12.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 +27 -13
- package/index.js +62 -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
|
@@ -3367,6 +3373,14 @@ Example programs are included under the module's `example` directory.
|
|
3367
3373
|
|
3368
3374
|
* Add error status and index handling to AgentX subagent
|
3369
3375
|
|
3376
|
+
## Version 3.11.2 - 03/04/2024
|
3377
|
+
|
3378
|
+
* Add provider to MIB request
|
3379
|
+
|
3380
|
+
## Version 3.12.0 - 28/06/2024
|
3381
|
+
|
3382
|
+
* Add multiple socket listener support for agent and receiver
|
3383
|
+
|
3370
3384
|
# License
|
3371
3385
|
|
3372
3386
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/index.js
CHANGED
@@ -2709,7 +2709,7 @@ Session.prototype.onProxyResponse = function (req, message) {
|
|
2709
2709
|
message.pdu.contextEngineID = message.msgSecurityParameters.msgAuthoritativeEngineID;
|
2710
2710
|
message.pdu.contextName = this.proxy.context;
|
2711
2711
|
message.pdu.id = req.proxiedPduId;
|
2712
|
-
this.proxy.listener.send (message, req.proxiedRinfo);
|
2712
|
+
this.proxy.listener.send (message, req.proxiedRinfo, req.proxiedSocket);
|
2713
2713
|
};
|
2714
2714
|
|
2715
2715
|
Session.create = function (target, community, options) {
|
@@ -2765,27 +2765,50 @@ Engine.prototype.generateEngineID = function() {
|
|
2765
2765
|
var Listener = function (options, receiver) {
|
2766
2766
|
this.receiver = receiver;
|
2767
2767
|
this.callback = receiver.onMsg;
|
2768
|
-
this.
|
2769
|
-
this.port = options.port || 161;
|
2770
|
-
this.address = options.address;
|
2768
|
+
// this.transport = options.transport || 'udp4';
|
2769
|
+
// this.port = options.port || 161;
|
2770
|
+
// this.address = options.address;
|
2771
2771
|
this.disableAuthorization = options.disableAuthorization || false;
|
2772
|
+
if ( options.sockets ) {
|
2773
|
+
this.socketOptions = options.sockets;
|
2774
|
+
} else {
|
2775
|
+
this.socketOptions = [
|
2776
|
+
{
|
2777
|
+
transport: options.transport,
|
2778
|
+
address: options.address,
|
2779
|
+
port: options.port
|
2780
|
+
}
|
2781
|
+
];
|
2782
|
+
}
|
2783
|
+
for ( const socketOption of this.socketOptions ) {
|
2784
|
+
socketOption.transport = socketOption.transport || 'udp4';
|
2785
|
+
socketOption.address = socketOption.address || null;
|
2786
|
+
socketOption.port = socketOption.port || 161;
|
2787
|
+
}
|
2772
2788
|
};
|
2773
2789
|
|
2774
2790
|
Listener.prototype.startListening = function () {
|
2775
2791
|
var me = this;
|
2776
|
-
this.
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2792
|
+
this.sockets = {};
|
2793
|
+
for ( const socketOptions of this.socketOptions ) {
|
2794
|
+
const socket = dgram.createSocket (socketOptions.transport);
|
2795
|
+
socket.on ("error", me.receiver.callback);
|
2796
|
+
socket.bind (socketOptions.port, socketOptions.address);
|
2797
|
+
socket.on ("message", me.callback.bind (me.receiver, socket));
|
2798
|
+
const socketKey = socketOptions.transport + ':' + socketOptions.address + ':' + socketOptions.port;
|
2799
|
+
if ( this.sockets[socketKey] ) {
|
2800
|
+
throw new Error ("Duplicate socket exists for " + socketKey);
|
2801
|
+
}
|
2802
|
+
this.sockets[socketKey] = socket;
|
2803
|
+
}
|
2780
2804
|
};
|
2781
2805
|
|
2782
|
-
Listener.prototype.send = function (message, rinfo) {
|
2806
|
+
Listener.prototype.send = function (message, rinfo, socket) {
|
2783
2807
|
// var me = this;
|
2784
2808
|
|
2785
2809
|
var buffer = message.toBuffer ();
|
2786
2810
|
|
2787
|
-
|
2788
|
-
function (error, bytes) {
|
2811
|
+
socket.send (buffer, 0, buffer.length, rinfo.port, rinfo.address, function (error, bytes) {
|
2789
2812
|
if (error) {
|
2790
2813
|
// me.callback (error);
|
2791
2814
|
console.error ("Error sending: " + error.message);
|
@@ -2803,7 +2826,7 @@ Listener.formatCallbackData = function (pdu, rinfo) {
|
|
2803
2826
|
delete pdu.maxRepetitions;
|
2804
2827
|
return {
|
2805
2828
|
pdu: pdu,
|
2806
|
-
rinfo: rinfo
|
2829
|
+
rinfo: rinfo
|
2807
2830
|
};
|
2808
2831
|
};
|
2809
2832
|
|
@@ -2857,8 +2880,8 @@ Listener.processIncoming = function (buffer, authorizer, callback) {
|
|
2857
2880
|
};
|
2858
2881
|
|
2859
2882
|
Listener.prototype.close = function () {
|
2860
|
-
|
2861
|
-
|
2883
|
+
for ( const socket of Object.values(this.sockets) ) {
|
2884
|
+
socket.close ();
|
2862
2885
|
}
|
2863
2886
|
};
|
2864
2887
|
|
@@ -3052,7 +3075,6 @@ SimpleAccessControlModel.prototype.isAccessAllowed = function (securityModel, se
|
|
3052
3075
|
|
3053
3076
|
var Receiver = function (options, callback) {
|
3054
3077
|
DEBUG = options.debug;
|
3055
|
-
this.listener = new Listener (options, this);
|
3056
3078
|
this.authorizer = new Authorizer (options);
|
3057
3079
|
this.engine = new Engine (options.engineID);
|
3058
3080
|
|
@@ -3074,7 +3096,7 @@ Receiver.prototype.getAuthorizer = function () {
|
|
3074
3096
|
return this.authorizer;
|
3075
3097
|
};
|
3076
3098
|
|
3077
|
-
Receiver.prototype.onMsg = function (buffer, rinfo) {
|
3099
|
+
Receiver.prototype.onMsg = function (socket, buffer, rinfo) {
|
3078
3100
|
|
3079
3101
|
let message;
|
3080
3102
|
|
@@ -3102,7 +3124,7 @@ Receiver.prototype.onMsg = function (buffer, rinfo) {
|
|
3102
3124
|
return;
|
3103
3125
|
}
|
3104
3126
|
let reportMessage = message.createReportResponseMessage (this.engine, this.context);
|
3105
|
-
this.listener.send (reportMessage, rinfo);
|
3127
|
+
this.listener.send (reportMessage, rinfo, socket);
|
3106
3128
|
return;
|
3107
3129
|
}
|
3108
3130
|
|
@@ -3114,7 +3136,7 @@ Receiver.prototype.onMsg = function (buffer, rinfo) {
|
|
3114
3136
|
message.pdu.type = PduType.GetResponse;
|
3115
3137
|
message.buffer = null;
|
3116
3138
|
message.setReportable (false);
|
3117
|
-
this.listener.send (message, rinfo);
|
3139
|
+
this.listener.send (message, rinfo, socket);
|
3118
3140
|
message.pdu.type = PduType.InformRequest;
|
3119
3141
|
this.callback (null, this.formatCallbackData (message, rinfo) );
|
3120
3142
|
} else {
|
@@ -4537,6 +4559,7 @@ var MibRequest = function (requestDefinition) {
|
|
4537
4559
|
this.address = Mib.convertOidToAddress (requestDefinition.oid);
|
4538
4560
|
this.oid = this.address.join ('.');
|
4539
4561
|
this.providerNode = requestDefinition.providerNode;
|
4562
|
+
this.provider = this.providerNode ? this.providerNode.provider : null;
|
4540
4563
|
this.instanceNode = requestDefinition.instanceNode;
|
4541
4564
|
};
|
4542
4565
|
|
@@ -4645,7 +4668,7 @@ Agent.prototype.tableRowStatusHandlerInternal = function (createRequest) {
|
|
4645
4668
|
return missingDefVal ? undefined : values;
|
4646
4669
|
};
|
4647
4670
|
|
4648
|
-
Agent.prototype.onMsg = function (buffer, rinfo) {
|
4671
|
+
Agent.prototype.onMsg = function (socket, buffer, rinfo) {
|
4649
4672
|
|
4650
4673
|
let message;
|
4651
4674
|
|
@@ -4664,22 +4687,22 @@ Agent.prototype.onMsg = function (buffer, rinfo) {
|
|
4664
4687
|
if ( message.version == Version3 && message.pdu.type == PduType.GetRequest &&
|
4665
4688
|
! message.hasAuthoritativeEngineID() && message.isReportable () ) {
|
4666
4689
|
let reportMessage = message.createReportResponseMessage (this.engine, this.context);
|
4667
|
-
this.listener.send (reportMessage, rinfo);
|
4690
|
+
this.listener.send (reportMessage, rinfo, socket);
|
4668
4691
|
return;
|
4669
4692
|
}
|
4670
4693
|
|
4671
4694
|
// Request processing
|
4672
4695
|
// debug (JSON.stringify (message.pdu, null, 2));
|
4673
4696
|
if ( message.pdu.contextName && message.pdu.contextName != "" ) {
|
4674
|
-
this.onProxyRequest (message, rinfo);
|
4697
|
+
this.onProxyRequest (socket, message, rinfo);
|
4675
4698
|
} else if ( message.pdu.type == PduType.GetRequest ) {
|
4676
|
-
this.getRequest (message, rinfo);
|
4699
|
+
this.getRequest (socket, message, rinfo);
|
4677
4700
|
} else if ( message.pdu.type == PduType.SetRequest ) {
|
4678
|
-
this.setRequest (message, rinfo);
|
4701
|
+
this.setRequest (socket, message, rinfo);
|
4679
4702
|
} else if ( message.pdu.type == PduType.GetNextRequest ) {
|
4680
|
-
this.getNextRequest (message, rinfo);
|
4703
|
+
this.getNextRequest (socket, message, rinfo);
|
4681
4704
|
} else if ( message.pdu.type == PduType.GetBulkRequest ) {
|
4682
|
-
this.getBulkRequest (message, rinfo);
|
4705
|
+
this.getBulkRequest (socket, message, rinfo);
|
4683
4706
|
} else {
|
4684
4707
|
this.callback (new RequestInvalidError ("Unexpected PDU type " +
|
4685
4708
|
message.pdu.type + " (" + PduType[message.pdu.type] + ")"));
|
@@ -4910,7 +4933,7 @@ Agent.prototype.isAllowed = function (pduType, provider, instanceNode) {
|
|
4910
4933
|
}
|
4911
4934
|
};
|
4912
4935
|
|
4913
|
-
Agent.prototype.request = function (requestMessage, rinfo) {
|
4936
|
+
Agent.prototype.request = function (socket, requestMessage, rinfo) {
|
4914
4937
|
var me = this;
|
4915
4938
|
var varbindsCompleted = 0;
|
4916
4939
|
var requestPdu = requestMessage.pdu;
|
@@ -5205,7 +5228,7 @@ Agent.prototype.request = function (requestMessage, rinfo) {
|
|
5205
5228
|
}
|
5206
5229
|
me.setSingleVarbind (responsePdu, savedIndex, responseVarbind);
|
5207
5230
|
if ( ++varbindsCompleted == varbindsLength) {
|
5208
|
-
me.sendResponse.call (me, rinfo, requestMessage, responsePdu);
|
5231
|
+
me.sendResponse.call (me, socket, rinfo, requestMessage, responsePdu);
|
5209
5232
|
}
|
5210
5233
|
};
|
5211
5234
|
})(i);
|
@@ -5217,12 +5240,12 @@ Agent.prototype.request = function (requestMessage, rinfo) {
|
|
5217
5240
|
}
|
5218
5241
|
};
|
5219
5242
|
|
5220
|
-
Agent.prototype.getRequest = function (requestMessage, rinfo) {
|
5221
|
-
this.request (requestMessage, rinfo);
|
5243
|
+
Agent.prototype.getRequest = function (socket, requestMessage, rinfo) {
|
5244
|
+
this.request (socket, requestMessage, rinfo);
|
5222
5245
|
};
|
5223
5246
|
|
5224
|
-
Agent.prototype.setRequest = function (requestMessage, rinfo) {
|
5225
|
-
this.request (requestMessage, rinfo);
|
5247
|
+
Agent.prototype.setRequest = function (socket, requestMessage, rinfo) {
|
5248
|
+
this.request (socket, requestMessage, rinfo);
|
5226
5249
|
};
|
5227
5250
|
|
5228
5251
|
Agent.prototype.addGetNextVarbind = function (targetVarbinds, startOid) {
|
@@ -5262,7 +5285,7 @@ Agent.prototype.addGetNextVarbind = function (targetVarbinds, startOid) {
|
|
5262
5285
|
return getNextNode;
|
5263
5286
|
};
|
5264
5287
|
|
5265
|
-
Agent.prototype.getNextRequest = function (requestMessage, rinfo) {
|
5288
|
+
Agent.prototype.getNextRequest = function (socket, requestMessage, rinfo) {
|
5266
5289
|
var requestPdu = requestMessage.pdu;
|
5267
5290
|
var varbindsLength = requestPdu.varbinds.length;
|
5268
5291
|
var getNextVarbinds = [];
|
@@ -5272,10 +5295,10 @@ Agent.prototype.getNextRequest = function (requestMessage, rinfo) {
|
|
5272
5295
|
}
|
5273
5296
|
|
5274
5297
|
requestMessage.pdu.varbinds = getNextVarbinds;
|
5275
|
-
this.request (requestMessage, rinfo);
|
5298
|
+
this.request (socket, requestMessage, rinfo);
|
5276
5299
|
};
|
5277
5300
|
|
5278
|
-
Agent.prototype.getBulkRequest = function (requestMessage, rinfo) {
|
5301
|
+
Agent.prototype.getBulkRequest = function (socket, requestMessage, rinfo) {
|
5279
5302
|
var requestPdu = requestMessage.pdu;
|
5280
5303
|
var requestVarbinds = requestPdu.varbinds;
|
5281
5304
|
var getBulkVarbinds = [];
|
@@ -5309,20 +5332,20 @@ Agent.prototype.getBulkRequest = function (requestMessage, rinfo) {
|
|
5309
5332
|
}
|
5310
5333
|
|
5311
5334
|
requestMessage.pdu.varbinds = getBulkVarbinds;
|
5312
|
-
this.request (requestMessage, rinfo);
|
5335
|
+
this.request (socket, requestMessage, rinfo);
|
5313
5336
|
};
|
5314
5337
|
|
5315
5338
|
Agent.prototype.setSingleVarbind = function (responsePdu, index, responseVarbind) {
|
5316
5339
|
responsePdu.varbinds[index] = responseVarbind;
|
5317
5340
|
};
|
5318
5341
|
|
5319
|
-
Agent.prototype.sendResponse = function (rinfo, requestMessage, responsePdu) {
|
5342
|
+
Agent.prototype.sendResponse = function (socket, rinfo, requestMessage, responsePdu) {
|
5320
5343
|
var responseMessage = requestMessage.createResponseForRequest (responsePdu);
|
5321
|
-
this.listener.send (responseMessage, rinfo);
|
5344
|
+
this.listener.send (responseMessage, rinfo, socket);
|
5322
5345
|
this.callback (null, Listener.formatCallbackData (responseMessage.pdu, rinfo) );
|
5323
5346
|
};
|
5324
5347
|
|
5325
|
-
Agent.prototype.onProxyRequest = function (message, rinfo) {
|
5348
|
+
Agent.prototype.onProxyRequest = function (socket, message, rinfo) {
|
5326
5349
|
var contextName = message.pdu.contextName;
|
5327
5350
|
var proxy;
|
5328
5351
|
var proxiedPduId;
|
@@ -5357,6 +5380,7 @@ Agent.prototype.onProxyRequest = function (message, rinfo) {
|
|
5357
5380
|
req.proxiedPduId = proxiedPduId;
|
5358
5381
|
req.proxiedUser = proxiedUser;
|
5359
5382
|
req.proxiedEngine = this.engine;
|
5383
|
+
req.proxiedSocket = socket;
|
5360
5384
|
proxy.session.send (req);
|
5361
5385
|
}
|
5362
5386
|
};
|