[SNMP4J] CommandResponder responding to walk

Frank Fock fock at agentpp.com
Fri Oct 16 00:57:46 CEST 2009


Hi Torsten,

Almost all of your questions are answered by
RFC 3416 section 4.2.2.

The transport mapping for the response has to be
set to ensure that you use the same mapping to
send the response as which has received the
request.

Why are you trying to implement your own agent
from scratch? Why not using SNMP4J-Agent?

There are a lot of issues with the code below
that you will have to resolve...

Regards,
Frank

Torsten Curdt wrote:
> Hey,
> 
> I've got a ComandResponder and some problems with supporting a GETNEXT.
> 
> First off: IIUC the response of a GETNEXT should include the following
> OID but the value of the original OID. Is that correct?
> 
>   public void processPdu(CommandResponderEvent pRequest) {
> 
>     final PDU requestPdu = pRequest.getPDU();
> 
>     if (requestPdu == null) {
>       return;
>     }
> 
>     System.out.println("request PDU" + requestPdu);
> 
>     try {
> 
>       final PDU responsePdu = new PDU(requestPdu);
>       responsePdu.setType(PDU.RESPONSE);
> 
>       if (requestPdu.getType() == PDU.GET) {
> 
>         for(VariableBinding binding : responsePdu.toArray()) {
>             final OID oid = binding.getOid();
>             final Variable variable = resolver.getVariableForOid(oid);
>             binding.setVariable(variable);
>           }
> 
>       } else if (requestPdu.getType() == PDU.GETNEXT) {
> 
>         for(VariableBinding binding : responsePdu.toArray()) {
>             final OID oid = binding.getOid().successor();
>             final Variable variable =
> resolver.getVariableForOid(binding.getOid());
>             binding.setOid(oid);
>             binding.setVariable(variable);
>           }
> 
>       } else {
> 
>       }
> 
>       System.out.println("response PDU" + responsePdu);
> 
>       pRequest.getStateReference().setTransportMapping(pRequest.getTransportMapping());
>       pRequest.getMessageDispatcher().returnResponsePdu(
>           pRequest.getMessageProcessingModel(),
>           pRequest.getSecurityModel(),
>           pRequest.getSecurityName(),
>           pRequest.getSecurityLevel(),
>           responsePdu,
>           pRequest.getMaxSizeResponsePDU(),
>           pRequest.getStateReference(),
>           new StatusInformation()
>           );
> 
> //    pRequest.setProcessed(true);
> 
>       System.out.println("done");
> 
>     } catch (Exception e) {
>       e.printStackTrace();
>     }
>   }
> 
> Now what I am wondering is:
> 
> - How do I signal an "end of walk" when there are no further OIDs to traverse?
> - Is "successor" really the right way to do this? It seems to just add
> ".0". Wouldn't I need to check the tree what is the real next node?
> - Do I need to set "pRequest.setProcessed"?
> - Why would one need to copy the transport mapping like this
> "pRequest.getStateReference().setTransportMapping(pRequest.getTransportMapping());"
> as I've found it in some examples on the web?
> 
> cheers
> --
> Torsten
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.snmp4j.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list