/** * Constructs a new trap information instance that contains the sending * agent, the community string, and the Protocol Data Unit. * * @param agent * The sending agent's address * @param community * The community string from the SNMP packet. * @param pdu * The encapsulated Protocol Data Unit. */ public Snmp4JV2TrapInformation(InetAddress agent, String community, PDU pdu) { super(agent, community); m_pdu = pdu; m_pduTypeString = PDU.getTypeString(m_pdu.getType()); }
protected boolean is2PC() { return (source.getPDU().getType() == PDU.SET); }
/** * Constructs a new trap information instance that contains the sending * agent, the community string, and the Protocol Data Unit. * * @param agent * The sending agent's address * @param community * The community string from the SNMP packet. * @param pdu * The encapsulated Protocol Data Unit. */ public Snmp4JV2TrapInformation(InetAddress agent, String community, PDU pdu) { super(agent, community); m_pdu = pdu; m_pduTypeString = PDU.getTypeString(m_pdu.getType()); }
protected boolean is2PC() { return (requestEvent.getPDU().getType() == PDU.SET); }
/** * Constructs a new trap information instance that contains the sending * agent, the community string, and the Protocol Data Unit. * * @param agent * The sending agent's address * @param community * The community string from the SNMP packet. * @param pdu * The encapsulated Protocol Data Unit. * @param trapProcessor The trap processor used to process the trap data * */ public Snmp4JV2TrapInformation(InetAddress agent, String community, PDU pdu, TrapProcessor trapProcessor) { super(agent, community, trapProcessor); m_pdu = pdu; m_pduTypeString = PDU.getTypeString(m_pdu.getType()); }
public boolean isBulkRequest() { return (source.getPDU().getType() == PDU.GETBULK); }
@Override public void processPdu(CommandResponderEvent e) { PDU pdu = e.getPDU(); if (pdu != null){ if (pdu instanceof PDUv1){ processPDUv1((PDUv1)pdu); } else if (pdu instanceof ScopedPDU) { processScopedPDU((ScopedPDU)pdu); } else if (pdu instanceof PDU){ processPDUv2c(pdu); } else { log.warn("Unknown PDU type: " + PDU.getTypeString(pdu.getType())); } } }
public boolean isBulkRequest() { return (requestEvent.getPDU().getType() == PDU.GETBULK); }
/** * This method will be called whenever a pdu is received on the given port * specified in the listen() method */ public synchronized void processPdu(CommandResponderEvent cmdRespEvent) { System.out.println("Received PDU..."); PDU pdu = cmdRespEvent.getPDU(); if (pdu != null) { System.out.println("Trap Type = " + pdu.getType()); System.out.println("Variables = " + pdu.getVariableBindings()); } } }
public SubRequest nextSubRequest() { if (!hasNext()) { throw new NoSuchElementException(); } if ((requestEvent.getPDU().getType() == PDU.GETBULK) && (cursor >= subrequests.size())) { while (cursor >= subrequests.size()) { addRepeaterSubRequest(); } } SubRequest sreq = (SubRequest) subrequests.get(cursor); cursor += increment; return sreq; }
public int getViewType() { return getViewType(requestEvent.getPDU().getType()); }
public int getViewType() { return getViewType(source.getPDU().getType()); }
public SnmpRequest.SnmpSubRequest next() { if (!hasNext()) { throw new NoSuchElementException(); } if ((source.getPDU().getType() == PDU.GETBULK) && (cursor >= subrequests.size()) && (source.getPDU().getMaxRepetitions() > 0)) { while (cursor >= subrequests.size()) { addRepeaterSubRequest(); } } SnmpRequest.SnmpSubRequest sreq = subrequests.get(cursor); cursor += increment; return sreq; }
public boolean isPhaseComplete() { if (errorStatus == SnmpConstants.SNMP_ERROR_SUCCESS) { initSubRequests(); for (Iterator it = subrequests.iterator(); it.hasNext(); ) { SubRequest subreq = (SubRequest) it.next(); RequestStatus status = subreq.getStatus(); if (status.getErrorStatus() != SnmpConstants.SNMP_ERROR_SUCCESS) { return true; } else if (!status.isPhaseComplete()) { return false; } } } if (requestEvent.getPDU().getType() == PDU.GETBULK) { SnmpSubRequestIterator it = new SnmpSubRequestIterator(subrequests.size(), 1); return !it.hasNext(); } return true; }
protected void dispatchCommand(CommandResponderEvent command, CoexistenceInfo cinfo) { RequestHandler<SnmpRequest> handler = getHandler(command.getPDU().getType()); if (handler != null) { processRequest(command, cinfo, handler); } else { sendUnknownPDUHandlersReport(command); } }
protected void dispatchCommand(CommandResponderEvent command, CoexistenceInfo cinfo) { RequestHandler handler = getHandler(command.getPDU().getType()); if (handler != null) { processRequest(command, cinfo, handler); } else { sendUnknownPDUHandlersReport(command); } }
protected void reprocessRequest(MOServer server, SnmpRequest req) { RequestHandler<SnmpRequest> handler = getHandler(req.getSource().getPDU().getType()); if (handler != null) { req.resetProcessedStatus(); req.incReprocessCounter(); processRequest(server, handler, req); } else { sendUnknownPDUHandlersReport(req.getSource()); } }
protected void reprocessRequest(MOServer server, SnmpRequest req) { RequestHandler handler = getHandler(req.getInitiatingEvent().getPDU().getType()); if (handler != null) { req.resetProcessedStatus(); req.incReprocessCounter(); processRequest(server, handler, req); } else { sendUnknownPDUHandlersReport(req.getInitiatingEvent()); } }
private void walk(Target target, OID rootOID, OID startOID, Object userObject, TreeListener listener) { PDU request = pduFactory.createPDU(target); request.add(new VariableBinding(startOID)); if (target.getVersion() == SnmpConstants.version1) { request.setType(PDU.GETNEXT); } else if (request.getType() != PDU.GETNEXT) { request.setType(PDU.GETBULK); request.setMaxRepetitions(maxRepetitions); } TreeRequest treeRequest = new TreeRequest(listener, rootOID, target, userObject, request); treeRequest.send(); }