Greetings,
We do have compiled some predefined MIB to get the java handlers and they working fine with OIDs that already exists in the given MIB. (i.e. 1.2.3.4.5.1 ) such as below
- public class XYZ extends SnmpAgent implements Runnable {
-
- ....
- this.Enabler__HTTPListener = new Enabler__HTTPRequestHandler(this);
- this.Enabler__HTTPListener.setEnabler__HTTPInterface(this.getEnabler__HTTPInstance());
- this.Enabler__HTTPListener.addRegistrationListener(this.hdlr);
- }
However this handler is created during the MIB Compilation and we need to introduce MIB changes that will not be available in the MIB.
I.e. if request oid STARTS WITH say 1.2.3.4.5.6 parse and respond it to programmatically.
the OID can extend to the depth even to 1.2.3.4.5.6.7.8.9 and I want to manage all of them myself programmatically without MIB code generation.
For this I introduced an extended version of PduRequestHandler (say PduRequestHandlerExtension) it
can catch the requests and I can parse the OID to find out if it needs special operation as below.
- /*@Override
- public void processSnmpPduRequest(final SnmpPduRequestEvent pduRequest) {
- final SnmpPDU pdu = pduRequest.getSnmpPDU();
- final Vector v = pdu.getVariableBindings();
- final SnmpVarBind varb = (SnmpVarBind) v.firstElement();
- SnmpOID oid=varb.getObjectID();
-
- if(! oid.toString().equals("1.2.3.4.5.6")){
- //Create my custom response
- @SuppressWarnings("unchecked")
- final long current = 15;
- final SnmpInt var0 = new SnmpInt(current);
- varb.setVariable(var0);
- pdu.setVariable(0, var0);
- pdu.setCommand(SnmpAPI.GET_RSP_MSG);
- pdu.setErrindex(0);
- pdu.setErrstat(0);
- } else {
- // Use the standart mechanism through the MIB compiler generated handlers ( Listeners)
- super.processSnmpPduRequest(pduRequest);
- }
I
The problem is even all the red code above is executed My Mib browser can not able to get a response for a request such as 1.2.3.4.5.6. The old blue code is working just fine and I can get responses appropriately.
What is missing above or can you suggest any direction for how we can introduce custom OID handlers ?
thanks
Onur Karadeli