net-snmp 3.11.0 → 3.11.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 +4 -0
- package/index.js +35 -34
- package/package.json +1 -1
package/README.md
CHANGED
@@ -3363,6 +3363,10 @@ Example programs are included under the module's `example` directory.
|
|
3363
3363
|
|
3364
3364
|
* Fix parent object retrieval to respect MIB module imports
|
3365
3365
|
|
3366
|
+
## Version 3.11.1 - 30/03/2024
|
3367
|
+
|
3368
|
+
* Add error status and index handling to AgentX subagent
|
3369
|
+
|
3366
3370
|
# License
|
3367
3371
|
|
3368
3372
|
Copyright (c) 2020 Mark Abrahams <mark@abrahams.co.nz>
|
package/index.js
CHANGED
@@ -5506,6 +5506,19 @@ AgentXPdu.prototype.readHeader = function (buffer) {
|
|
5506
5506
|
this.payloadLength = buffer.readUInt32BE ();
|
5507
5507
|
};
|
5508
5508
|
|
5509
|
+
AgentXPdu.prototype.getResponsePduForRequest = function () {
|
5510
|
+
const responsePdu = AgentXPdu.createFromVariables({
|
5511
|
+
pduType: AgentXPduType.Response,
|
5512
|
+
sessionID: this.sessionID,
|
5513
|
+
transactionID: this.transactionID,
|
5514
|
+
packetID: this.packetID,
|
5515
|
+
sysUpTime: 0,
|
5516
|
+
error: 0,
|
5517
|
+
index: 0
|
5518
|
+
});
|
5519
|
+
return responsePdu;
|
5520
|
+
};
|
5521
|
+
|
5509
5522
|
AgentXPdu.createFromVariables = function (vars) {
|
5510
5523
|
var pdu = new AgentXPdu ();
|
5511
5524
|
pdu.flags = vars.flags ? vars.flags | 0x10 : 0x10; // set NETWORK_BYTE_ORDER to big endian
|
@@ -6040,13 +6053,14 @@ Subagent.prototype.response = function (pdu) {
|
|
6040
6053
|
};
|
6041
6054
|
|
6042
6055
|
Subagent.prototype.request = function (pdu, requestVarbinds) {
|
6043
|
-
|
6044
|
-
|
6045
|
-
|
6046
|
-
|
6047
|
-
|
6048
|
-
|
6049
|
-
|
6056
|
+
const me = this;
|
6057
|
+
const varbindsLength = requestVarbinds.length;
|
6058
|
+
const responseVarbinds = [];
|
6059
|
+
const responsePdu = pdu.getResponsePduForRequest ();
|
6060
|
+
let varbindsCompleted = 0;
|
6061
|
+
|
6062
|
+
for ( let i = 0; i < varbindsLength; i++ ) {
|
6063
|
+
const requestVarbind = requestVarbinds[i];
|
6050
6064
|
var instanceNode = this.mib.lookup (requestVarbind.oid);
|
6051
6065
|
var providerNode;
|
6052
6066
|
var mibRequest;
|
@@ -6097,14 +6111,21 @@ Subagent.prototype.request = function (pdu, requestVarbinds) {
|
|
6097
6111
|
}
|
6098
6112
|
|
6099
6113
|
(function (savedIndex) {
|
6100
|
-
var responseVarbind;
|
6101
6114
|
mibRequest.done = function (error) {
|
6115
|
+
let responseVarbind;
|
6102
6116
|
if ( error ) {
|
6103
6117
|
responseVarbind = {
|
6104
6118
|
oid: mibRequest.oid,
|
6105
6119
|
type: error.type || ObjectType.Null,
|
6106
6120
|
value: error.value || null
|
6107
6121
|
};
|
6122
|
+
if ( (typeof responsePdu.errorStatus == "undefined" || responsePdu.errorStatus == ErrorStatus.NoError) && error.errorStatus != ErrorStatus.NoError ) {
|
6123
|
+
responsePdu.error = error.errorStatus;
|
6124
|
+
responsePdu.index = savedIndex + 1;
|
6125
|
+
}
|
6126
|
+
if ( error.errorStatus != ErrorStatus.NoError ) {
|
6127
|
+
responseVarbind.errorStatus = error.errorStatus;
|
6128
|
+
}
|
6108
6129
|
} else {
|
6109
6130
|
if ( pdu.pduType == AgentXPduType.TestSet ) {
|
6110
6131
|
// more tests?
|
@@ -6130,9 +6151,9 @@ Subagent.prototype.request = function (pdu, requestVarbinds) {
|
|
6130
6151
|
if ( ++varbindsCompleted == varbindsLength) {
|
6131
6152
|
if ( pdu.pduType == AgentXPduType.TestSet || pdu.pduType == AgentXPduType.CommitSet
|
6132
6153
|
|| pdu.pduType == AgentXPduType.UndoSet) {
|
6133
|
-
me.
|
6154
|
+
me.sendResponse.call (me, responsePdu);
|
6134
6155
|
} else {
|
6135
|
-
me.
|
6156
|
+
me.sendResponse.call (me, responsePdu, responseVarbinds);
|
6136
6157
|
}
|
6137
6158
|
}
|
6138
6159
|
};
|
@@ -6234,30 +6255,10 @@ Subagent.prototype.getBulkRequest = function (pdu) {
|
|
6234
6255
|
this.request (pdu, getBulkVarbinds);
|
6235
6256
|
};
|
6236
6257
|
|
6237
|
-
Subagent.prototype.
|
6238
|
-
|
6239
|
-
|
6240
|
-
|
6241
|
-
transactionID: requestPdu.transactionID,
|
6242
|
-
packetID: requestPdu.packetID,
|
6243
|
-
sysUpTime: 0,
|
6244
|
-
error: 0,
|
6245
|
-
index: 0,
|
6246
|
-
varbinds: varbinds
|
6247
|
-
});
|
6248
|
-
this.sendPdu (pdu, null);
|
6249
|
-
};
|
6250
|
-
|
6251
|
-
Subagent.prototype.sendSetResponse = function (setPdu) {
|
6252
|
-
var responsePdu = AgentXPdu.createFromVariables ({
|
6253
|
-
pduType: AgentXPduType.Response,
|
6254
|
-
sessionID: setPdu.sessionID,
|
6255
|
-
transactionID: setPdu.transactionID,
|
6256
|
-
packetID: setPdu.packetID,
|
6257
|
-
sysUpTime: 0,
|
6258
|
-
error: 0,
|
6259
|
-
index: 0,
|
6260
|
-
});
|
6258
|
+
Subagent.prototype.sendResponse = function (responsePdu, varbinds) {
|
6259
|
+
if ( varbinds ) {
|
6260
|
+
responsePdu.varbinds = varbinds;
|
6261
|
+
}
|
6261
6262
|
this.sendPdu (responsePdu, null);
|
6262
6263
|
};
|
6263
6264
|
|