Package com.sun.jmx.snmp

Examples of com.sun.jmx.snmp.BerDecoder


     */
    public void decodeMessage(byte[] inputBytes, int byteCount)
        throws SnmpStatusException {

        try {
            BerDecoder bdec = new BerDecoder(inputBytes);
            bdec.openSequence();
            version = bdec.fetchInteger();
            bdec.openSequence();
            msgId = bdec.fetchInteger();
            msgMaxSize = bdec.fetchInteger();
            msgFlags = bdec.fetchOctetString()[0];
            msgSecurityModel =bdec.fetchInteger();
            bdec.closeSequence();
            msgSecurityParameters = bdec.fetchOctetString();
            if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
                bdec.openSequence();
                contextEngineId = bdec.fetchOctetString();
                contextName = bdec.fetchOctetString();
                data = bdec.fetchAny();
                dataLength = data.length;
                bdec.closeSequence();
            }
            else {
                encryptedPdu = bdec.fetchOctetString();
            }
            bdec.closeSequence() ;
        }
        catch(BerException x) {
            x.printStackTrace();
            throw new SnmpStatusException("Invalid encoding") ;
        }
View Full Code Here


     * Returns the associated request Id.
     * @param data The flat message.
     * @return The request Id.
     */
    public int getRequestId(byte[] data) throws SnmpStatusException {
        BerDecoder bdec = null;
        int msgId = 0;
        try {
            bdec = new BerDecoder(data);
            bdec.openSequence();
            bdec.fetchInteger();
            bdec.openSequence();
            msgId = bdec.fetchInteger();
        }catch(BerException x) {
            throw new SnmpStatusException("Invalid encoding") ;
        }
        try {
            bdec.closeSequence();
        }
        catch(BerException x) {
        }

        return msgId;
View Full Code Here

    public SnmpPdu decodeSnmpPdu()
        throws SnmpStatusException {

        SnmpScopedPduPacket pdu = null;

        BerDecoder bdec = new BerDecoder(data) ;
        try {
            int type = bdec.getTag() ;
            bdec.openSequence(type) ;
            switch(type) {

            case pduGetRequestPdu :
            case pduGetNextRequestPdu :
            case pduInformRequestPdu :
            case pduGetResponsePdu :
            case pduSetRequestPdu :
            case pduV2TrapPdu :
            case pduReportPdu :
                SnmpScopedPduRequest reqPdu = new SnmpScopedPduRequest() ;
                reqPdu.requestId = bdec.fetchInteger() ;
                reqPdu.setErrorStatus(bdec.fetchInteger());
                reqPdu.setErrorIndex(bdec.fetchInteger());
                pdu = reqPdu ;
                break ;

            case pduGetBulkRequestPdu :
                SnmpScopedPduBulk bulkPdu = new SnmpScopedPduBulk() ;
                bulkPdu.requestId = bdec.fetchInteger() ;
                bulkPdu.setNonRepeaters(bdec.fetchInteger());
                bulkPdu.setMaxRepetitions(bdec.fetchInteger());
                pdu = bulkPdu ;
                break ;
            default:
                throw new SnmpStatusException(snmpRspWrongEncoding) ;
            }
            pdu.type = type;
            pdu.varBindList = decodeVarBindList(bdec);
            bdec.closeSequence() ;
        } catch(BerException e) {
            if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
                SNMP_LOGGER.logp(Level.FINEST, SnmpV3Message.class.getName(),
                        "decodeSnmpPdu", "BerException", e);
            }
View Full Code Here

     */
    public void decodeMessage(byte[] inputBytes, int byteCount)
        throws SnmpStatusException {
 
        try {
            BerDecoder bdec = new BerDecoder(inputBytes);
            bdec.openSequence();
            version = bdec.fetchInteger();
      bdec.openSequence();
      msgId = bdec.fetchInteger();
      msgMaxSize = bdec.fetchInteger();
      msgFlags = bdec.fetchOctetString()[0];
      msgSecurityModel =bdec.fetchInteger();
      bdec.closeSequence();
      msgSecurityParameters = bdec.fetchOctetString();
      if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
    bdec.openSequence();
    contextEngineId = bdec.fetchOctetString();
    contextName = bdec.fetchOctetString();
    data = bdec.fetchAny();
    dataLength = data.length;
    bdec.closeSequence();
      }
      else {
    encryptedPdu = bdec.fetchOctetString();
      }
            bdec.closeSequence() ;
        }
        catch(BerException x) {
      x.printStackTrace();
            throw new SnmpStatusException("Invalid encoding") ;
        }
View Full Code Here

     * Returns the associated request Id.
     * @param data The flat message.
     * @return The request Id.
     */
    public int getRequestId(byte[] data) throws SnmpStatusException {
  BerDecoder bdec = null;
  int msgId = 0;
  try {
            bdec = new BerDecoder(data);
            bdec.openSequence();
            bdec.fetchInteger();
      bdec.openSequence();
      msgId = bdec.fetchInteger();
  }catch(BerException x) {
      throw new SnmpStatusException("Invalid encoding") ;
  }
  try {
      bdec.closeSequence();
  }
  catch(BerException x) {
  }
 
  return msgId;
View Full Code Here

    public SnmpPdu decodeSnmpPdu()
  throws SnmpStatusException {
 
  SnmpScopedPduPacket pdu = null;

        BerDecoder bdec = new BerDecoder(data) ;
        try {
            int type = bdec.getTag() ;
            bdec.openSequence(type) ;
            switch(type) {
     
            case pduGetRequestPdu :
            case pduGetNextRequestPdu :
            case pduInformRequestPdu :
            case pduGetResponsePdu :
            case pduSetRequestPdu :
            case pduV2TrapPdu :
            case pduReportPdu :
                SnmpScopedPduRequest reqPdu = new SnmpScopedPduRequest() ;
                reqPdu.requestId = bdec.fetchInteger() ;
                reqPdu.setErrorStatus(bdec.fetchInteger());
                reqPdu.setErrorIndex(bdec.fetchInteger());
                pdu = reqPdu ;
                break ;

            case pduGetBulkRequestPdu :
                SnmpScopedPduBulk bulkPdu = new SnmpScopedPduBulk() ;
                bulkPdu.requestId = bdec.fetchInteger() ;
                bulkPdu.setNonRepeaters(bdec.fetchInteger());
                bulkPdu.setMaxRepetitions(bdec.fetchInteger());
                pdu = bulkPdu ;
                break ;
            default:
                throw new SnmpStatusException(snmpRspWrongEncoding) ;
            }
            pdu.type = type;
            pdu.varBindList = decodeVarBindList(bdec);
            bdec.closeSequence() ;
        } catch(BerException e) {
            if (isDebugOn()) {
                debug("decodeSnmpPdu", e);
            }
            throw new SnmpStatusException(snmpRspWrongEncoding);
View Full Code Here

     */
    public void decodeMessage(byte[] inputBytes, int byteCount)
        throws SnmpStatusException {

        try {
            BerDecoder bdec = new BerDecoder(inputBytes);
            bdec.openSequence();
            version = bdec.fetchInteger();
            bdec.openSequence();
            msgId = bdec.fetchInteger();
            msgMaxSize = bdec.fetchInteger();
            msgFlags = bdec.fetchOctetString()[0];
            msgSecurityModel =bdec.fetchInteger();
            bdec.closeSequence();
            msgSecurityParameters = bdec.fetchOctetString();
            if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
                bdec.openSequence();
                contextEngineId = bdec.fetchOctetString();
                contextName = bdec.fetchOctetString();
                data = bdec.fetchAny();
                dataLength = data.length;
                bdec.closeSequence();
            }
            else {
                encryptedPdu = bdec.fetchOctetString();
            }
            bdec.closeSequence() ;
        }
        catch(BerException x) {
            x.printStackTrace();
            throw new SnmpStatusException("Invalid encoding") ;
        }
View Full Code Here

     * Returns the associated request Id.
     * @param data The flat message.
     * @return The request Id.
     */
    public int getRequestId(byte[] data) throws SnmpStatusException {
        BerDecoder bdec = null;
        int msgId = 0;
        try {
            bdec = new BerDecoder(data);
            bdec.openSequence();
            bdec.fetchInteger();
            bdec.openSequence();
            msgId = bdec.fetchInteger();
        }catch(BerException x) {
            throw new SnmpStatusException("Invalid encoding") ;
        }
        try {
            bdec.closeSequence();
        }
        catch(BerException x) {
        }

        return msgId;
View Full Code Here

    public SnmpPdu decodeSnmpPdu()
        throws SnmpStatusException {

        SnmpScopedPduPacket pdu = null;

        BerDecoder bdec = new BerDecoder(data) ;
        try {
            int type = bdec.getTag() ;
            bdec.openSequence(type) ;
            switch(type) {

            case pduGetRequestPdu :
            case pduGetNextRequestPdu :
            case pduInformRequestPdu :
            case pduGetResponsePdu :
            case pduSetRequestPdu :
            case pduV2TrapPdu :
            case pduReportPdu :
                SnmpScopedPduRequest reqPdu = new SnmpScopedPduRequest() ;
                reqPdu.requestId = bdec.fetchInteger() ;
                reqPdu.setErrorStatus(bdec.fetchInteger());
                reqPdu.setErrorIndex(bdec.fetchInteger());
                pdu = reqPdu ;
                break ;

            case pduGetBulkRequestPdu :
                SnmpScopedPduBulk bulkPdu = new SnmpScopedPduBulk() ;
                bulkPdu.requestId = bdec.fetchInteger() ;
                bulkPdu.setNonRepeaters(bdec.fetchInteger());
                bulkPdu.setMaxRepetitions(bdec.fetchInteger());
                pdu = bulkPdu ;
                break ;
            default:
                throw new SnmpStatusException(snmpRspWrongEncoding) ;
            }
            pdu.type = type;
            pdu.varBindList = decodeVarBindList(bdec);
            bdec.closeSequence() ;
        } catch(BerException e) {
            if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
                SNMP_LOGGER.logp(Level.FINEST, SnmpV3Message.class.getName(),
                        "decodeSnmpPdu", "BerException", e);
            }
View Full Code Here

TOP

Related Classes of com.sun.jmx.snmp.BerDecoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.