[SNMP4J] SNMP4J-AgentX and shared tables
Frank Fock
fock at agentpp.com
Thu Feb 15 01:05:36 CET 2007
Hi Peder,
Many thanks for providing these fixes. I have fixes
these and additional missing setSessionAttributes
for the 1.0 release scheduled for next week.
Best regards,
Frank
Peder Toftegaard Olsen wrote:
> Hi,
>
>
>
> With the aid of SNMP4J-AgentX I am working on an AgentX subagent utilizing
> shared tables. During the development I have run into some problems with
> index allocation (using ANY_INDEX) and registration of rows.
>
>
>
> The problems have manifested themselves as - and were solved as described:
>
>
>
> * NPE's: Missing instantiation of VariableBinding.
>
> * noOpen errors received from the master agent (NET-SNMP v. 5.4): Missing
> setSessionAttributes.
>
> * Not setting allocated index: Use resp.getVariableBindings() instead of
> vbs.
>
> * AgentXSharedMOTableSupport.allocateIndex() returning AGENTX_DISCONNECT on
> success: Return AGENTX_SUCCESS on success.
>
>
>
> Below is a proposed patch to SNMP4J-AgentX which has solved my problems.
>
>
>
>
>
> Best regards
>
>
>
> Peder Toftegaard Olsen
>
> Senior Software Architect
>
> Mobilethink A/S
>
>
>
>
>
> Unified patch for SNMP4J-AgentX 1.0RC1:
>
>
>
> --- org/snmp4j/agent/agentx/subagent/AgentXSharedMOTableSupport.java
> Fri Nov 24 01:22:34 2006
>
> +++ org/snmp4j/agent/agentx/subagent/AgentXSharedMOTableSupport.java
> Tue Feb 06 11:07:40 2007
>
> @@ -162,6 +162,7 @@
>
> if (oid == null) {
>
> throw new IllegalArgumentException("Sub-index "+i+" has no OID");
>
> }
>
> + vbs[i] = new VariableBinding();
>
> vbs[i].setOid(oid);
>
> vbs[i].setVariable(indexValues[i]);
>
> }
>
> @@ -169,6 +170,7 @@
>
> if (indexAllocationMode != 0) {
>
> pdu.addFlag(indexAllocationMode);
>
> }
>
> + pdu.setSessionAttributes(session);
>
> try {
>
> AgentXResponseEvent response =
>
> agentX.send(pdu, session.createAgentXTarget(),
>
> @@ -176,8 +178,9 @@
>
> if (response.getResponse() != null) {
>
> AgentXResponsePDU resp = response.getResponse();
>
> if (resp.getErrorStatus() == AgentXProtocol.AGENTX_SUCCESS) {
>
> - OID index = indexDef.getIndexOID(getVariables(vbs));
>
> + OID index =
> indexDef.getIndexOID(getVariables(resp.getVariableBindings()));
>
> allocatedIndex.setValue(index.getValue());
>
> + return AgentXProtocol.AGENTX_SUCCESS;
>
> }
>
> else {
>
> return resp.getErrorStatus();
>
> @@ -250,6 +253,7 @@
>
> (byte)(table.getOID().size()+1),
>
> table.getColumn(table.getColumnCount()-1).
>
> getColumnID());
>
> + pdu.setSessionAttributes(session);
>
> try {
>
> AgentXResponseEvent resp =
>
> agentX.send(pdu, session.createAgentXTarget(),
>
> --- org/snmp4j/agent/agentx/subagent/AgentXSubagent.java Fri Feb 02
> 00:42:04 2007
>
> +++ org/snmp4j/agent/agentx/subagent/AgentXSubagent.java Tue Feb 06
> 10:59:34 2007
>
> @@ -388,6 +388,7 @@
>
> new AgentXUnregisterPDU(context, region.getLowerBound(), t,
>
> region.getRangeSubID(),
>
> region.getUpperBoundSubID());
>
> + pdu.setSessionAttributes(session);
>
> AgentXResponseEvent event =
>
> agentX.send(pdu, new AgentXTarget(session.getPeer().getAddress(),
>
> this.timeout),
>
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list