com.sun.jmx.snmp.SnmpMessage Java Examples
The following examples show how to use
com.sun.jmx.snmp.SnmpMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SnmpAdaptorServer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #2
Source File: SnmpAdaptorServer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #3
Source File: SnmpAdaptorServer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #4
Source File: SnmpAdaptorServer.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #5
Source File: SnmpAdaptorServer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #6
Source File: SnmpAdaptorServer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #7
Source File: SnmpAdaptorServer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #8
Source File: SnmpAdaptorServer.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #9
Source File: SnmpAdaptorServer.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #10
Source File: SnmpAdaptorServer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #11
Source File: SnmpAdaptorServer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #12
Source File: SnmpAdaptorServer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #13
Source File: SnmpAdaptorServer.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #14
Source File: SnmpAdaptorServer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Send the specified message on trapSocket. */ private void sendTrapMessage(SnmpMessage msg) throws IOException, SnmpTooBigException { byte[] buffer = new byte[bufferSize] ; DatagramPacket packet = new DatagramPacket(buffer, buffer.length) ; int encodingLength = msg.encodeMessage(buffer) ; packet.setLength(encodingLength) ; packet.setAddress(msg.address) ; packet.setPort(msg.port) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sending trap to " + msg.address + ":" + msg.port); } trapSocket.send(packet) ; if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, dbgTag, "sendTrapMessage", "sent to " + msg.address + ":" + msg.port); } snmpOutTraps++; snmpOutPkts++; }
Example #15
Source File: SnmpInformRequest.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Sends the prepared PDU packet to the manager and updates the data structure * to expect a response. It acquires a lock on the socket to prevent a case * where a response arrives before this thread could insert the * request into the wait queue. * @exception IOException Signals that an I/O exception of some sort has occurred. */ final void sendPduPacket(byte[] buffer, int length) throws java.io.IOException { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpInformRequest.class.getName(), "sendPduPacket", "Send to peer. Peer/Port : " + address.getHostName() + "/" + port + ". Length = " + length + "\nDump : \n" + SnmpMessage.dumpHexBuffer(buffer,0, length)); } SnmpSocket theSocket = informSession.getSocket(); synchronized (theSocket) { theSocket.sendPacket(buffer, length, address, port); setRequestSentTime(System.currentTimeMillis()); } }
Example #16
Source File: SnmpInformRequest.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Sends the prepared PDU packet to the manager and updates the data structure * to expect a response. It acquires a lock on the socket to prevent a case * where a response arrives before this thread could insert the * request into the wait queue. * @exception IOException Signals that an I/O exception of some sort has occurred. */ final void sendPduPacket(byte[] buffer, int length) throws java.io.IOException { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpInformRequest.class.getName(), "sendPduPacket", "Send to peer. Peer/Port : " + address.getHostName() + "/" + port + ". Length = " + length + "\nDump : \n" + SnmpMessage.dumpHexBuffer(buffer,0, length)); } SnmpSocket theSocket = informSession.getSocket(); synchronized (theSocket) { theSocket.sendPacket(buffer, length, address, port); setRequestSentTime(System.currentTimeMillis()); } }
Example #17
Source File: SnmpResponseHandler.java From JDKSourceCode1.8 with MIT License | 4 votes |
public synchronized void processDatagram(DatagramPacket dgrm) { byte []data = dgrm.getData(); int datalen = dgrm.getLength(); if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpResponseHandler.class.getName(), "action", "processDatagram", "Received from " + dgrm.getAddress().toString() + " Length = " + datalen + "\nDump : \n" + SnmpMessage.dumpHexBuffer(data, 0, datalen)); } try { SnmpMessage msg = new SnmpMessage(); msg.decodeMessage(data, datalen); msg.address = dgrm.getAddress(); msg.port = dgrm.getPort(); // Retreive the PDU factory of the SNMP adaptor to decode the received inform response. // SnmpPduFactory pduFactory = adaptor.getPduFactory(); if (pduFactory == null) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. Unable to find the pdu factory of the SNMP adaptor server"); } } else { SnmpPduPacket snmpProt = (SnmpPduPacket)pduFactory.decodeSnmpPdu(msg); if (snmpProt == null) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. Pdu factory returned a null value"); } } else if (snmpProt instanceof SnmpPduRequest) { SnmpPduRequest pduReq = (SnmpPduRequest)snmpProt; SnmpInformRequest req = snmpq.removeRequest(pduReq.requestId) ; if (req != null) { req.invokeOnResponse(pduReq); } else { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. Unable to find corresponding for InformRequestId = " + pduReq.requestId); } } } else { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. The packet does not contain an inform response"); } } snmpProt = null ; } } catch (Exception e) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Exception while processsing", e); } } }
Example #18
Source File: SnmpInformRequest.java From JDKSourceCode1.8 with MIT License | 4 votes |
boolean sendPdu() { try { responsePdu = null; SnmpPduFactory pduFactory = adaptor.getPduFactory(); SnmpMessage msg = (SnmpMessage)pduFactory.encodeSnmpPdu((SnmpPduPacket)requestPdu, adaptor.getBufferSize().intValue()); if (msg == null) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "pdu factory returned a null value"); } throw new SnmpStatusException(snmpReqUnknownError); // This exception will caught hereafter and reported as an snmpReqUnknownError // FIXME: may be it's not the best behaviour ? } int maxPktSize = adaptor.getBufferSize().intValue(); byte[] encoding = new byte[maxPktSize]; int encodingLength = msg.encodeMessage(encoding); if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpInformRequest.class.getName(), "sendPdu", "Dump : \n" + msg.printMessage()); } sendPduPacket(encoding, encodingLength); return true; } catch (SnmpTooBigException ar) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "Got unexpected exception", ar); } setErrorStatusAndIndex(snmpReqPacketOverflow, ar.getVarBindCount()); requestPdu = null; reason = ar.getMessage(); if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "Packet Overflow while building inform request"); } } catch (java.io.IOException ioe) { setErrorStatusAndIndex(snmpReqSocketIOError, 0); reason = ioe.getMessage(); } catch (Exception e) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "Got unexpected exception", e); } setErrorStatusAndIndex(snmpReqUnknownError, 0); reason = e.getMessage(); } return false; }
Example #19
Source File: SnmpResponseHandler.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
public synchronized void processDatagram(DatagramPacket dgrm) { byte []data = dgrm.getData(); int datalen = dgrm.getLength(); if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpResponseHandler.class.getName(), "action", "processDatagram", "Received from " + dgrm.getAddress().toString() + " Length = " + datalen + "\nDump : \n" + SnmpMessage.dumpHexBuffer(data, 0, datalen)); } try { SnmpMessage msg = new SnmpMessage(); msg.decodeMessage(data, datalen); msg.address = dgrm.getAddress(); msg.port = dgrm.getPort(); // Retreive the PDU factory of the SNMP adaptor to decode the received inform response. // SnmpPduFactory pduFactory = adaptor.getPduFactory(); if (pduFactory == null) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. Unable to find the pdu factory of the SNMP adaptor server"); } } else { SnmpPduPacket snmpProt = (SnmpPduPacket)pduFactory.decodeSnmpPdu(msg); if (snmpProt == null) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. Pdu factory returned a null value"); } } else if (snmpProt instanceof SnmpPduRequest) { SnmpPduRequest pduReq = (SnmpPduRequest)snmpProt; SnmpInformRequest req = snmpq.removeRequest(pduReq.requestId) ; if (req != null) { req.invokeOnResponse(pduReq); } else { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. Unable to find corresponding for InformRequestId = " + pduReq.requestId); } } } else { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Dropping packet. The packet does not contain an inform response"); } } snmpProt = null ; } } catch (Exception e) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpResponseHandler.class.getName(), "processDatagram", "Exception while processsing", e); } } }
Example #20
Source File: SnmpInformRequest.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
boolean sendPdu() { try { responsePdu = null; SnmpPduFactory pduFactory = adaptor.getPduFactory(); SnmpMessage msg = (SnmpMessage)pduFactory.encodeSnmpPdu((SnmpPduPacket)requestPdu, adaptor.getBufferSize().intValue()); if (msg == null) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "pdu factory returned a null value"); } throw new SnmpStatusException(snmpReqUnknownError); // This exception will caught hereafter and reported as an snmpReqUnknownError // FIXME: may be it's not the best behaviour ? } int maxPktSize = adaptor.getBufferSize().intValue(); byte[] encoding = new byte[maxPktSize]; int encodingLength = msg.encodeMessage(encoding); if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINER)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINER, SnmpInformRequest.class.getName(), "sendPdu", "Dump : \n" + msg.printMessage()); } sendPduPacket(encoding, encodingLength); return true; } catch (SnmpTooBigException ar) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "Got unexpected exception", ar); } setErrorStatusAndIndex(snmpReqPacketOverflow, ar.getVarBindCount()); requestPdu = null; reason = ar.getMessage(); if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "Packet Overflow while building inform request"); } } catch (java.io.IOException ioe) { setErrorStatusAndIndex(snmpReqSocketIOError, 0); reason = ioe.getMessage(); } catch (Exception e) { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpInformRequest.class.getName(), "sendPdu", "Got unexpected exception", e); } setErrorStatusAndIndex(snmpReqUnknownError, 0); reason = e.getMessage(); } return false; }