public void encodeBER(OutputStream outputStream) throws IOException { BER.encodeString(outputStream, BER.OPAQUE, getValue()); }
@Override public SnmpValue getOpaque(byte[] bs) { return new Snmp4JValue(new Opaque(bs)); }
private Object resolvOpaque(Opaque var) { // If not resolved, we will return the data as an array of bytes Object value = var.getValue(); try { byte[] bytesArray = var.getValue(); ByteBuffer bais = ByteBuffer.wrap(bytesArray); BERInputStream beris = new BERInputStream(bais); byte t1 = bais.get(); byte t2 = bais.get(); int l = BER.decodeLength(beris); if(t1 == TAG1) { if(t2 == TAG_FLOAT && l == 4) value = new Float(bais.getFloat()); else if(t2 == TAG_DOUBLE && l == 8) value = new Double(bais.getDouble()); } } catch (IOException e) { logger.error(var.toString()); } return value; }
public void decodeBER(BERInputStream inputStream) throws IOException { BER.MutableByte type = new BER.MutableByte(); byte[] v = BER.decodeString(inputStream, type); if (type.getValue() != (BER.ASN_APPLICATION | 0x04)) { throw new IOException("Wrong type encountered when decoding OctetString: "+ type.getValue()); } setValue(v); }
private Object resolvOpaque(Opaque var) { //If not resolved, we will return the data as an array of bytes Object value = var.getValue(); try { byte[] bytesArray = var.getValue(); ByteBuffer bais = ByteBuffer.wrap(bytesArray); BERInputStream beris = new BERInputStream(bais); byte t1 = bais.get(); byte t2 = bais.get(); int l = BER.decodeLength(beris); if(t1 == TAG1) { if(t2 == TAG_FLOAT && l == 4) value = new Float(bais.getFloat()); else if(t2 == TAG_DOUBLE && l == 8) value = new Double(bais.getDouble()); } } catch (IOException e) { logger.error(var.toString()); } return value; }
public void decodeBER(BERInputStream inputStream) throws IOException { BER.MutableByte type = new BER.MutableByte(); byte[] v = BER.decodeString(inputStream, type); if (type.getValue() != (BER.ASN_APPLICATION | 0x04)) { throw new IOException("Wrong type encountered when decoding OctetString: "+ type.getValue()); } setValue(v); }
@Override public SnmpValue getOpaque(byte[] bs) { return new Snmp4JValue(new Opaque(bs)); }
public void encodeBER(OutputStream outputStream) throws IOException { BER.encodeString(outputStream, BER.OPAQUE, getValue()); }
public void decodeBER(BERInputStream inputStream) throws IOException { BER.MutableByte type = new BER.MutableByte(); byte[] v = BER.decodeString(inputStream, type); if (type.getValue() != (BER.ASN_APPLICATION | 0x04)) { throw new IOException("Wrong type encountered when decoding OctetString: "+ type.getValue()); } setValue(v); }
public SnmpValue getOpaque(byte[] bs) { return new Snmp4JValue(new Opaque(bs)); }
public void encodeBER(OutputStream outputStream) throws IOException { BER.encodeString(outputStream, BER.OPAQUE, getValue()); }
public Object clone() { return new Opaque(super.getValue()); }
public byte[] getBytes() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_INTEGER: case SMIConstants.SYNTAX_COUNTER32: case SMIConstants.SYNTAX_COUNTER64: case SMIConstants.SYNTAX_TIMETICKS: case SMIConstants.SYNTAX_UNSIGNED_INTEGER32: return toBigInteger().toByteArray(); case SMIConstants.SYNTAX_IPADDRESS: return toInetAddress().getAddress(); case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: return toSnmpObjId().toString().getBytes(); case SMIConstants.SYNTAX_OCTET_STRING: return ((OctetString)m_value).getValue(); case SMIConstants.SYNTAX_OPAQUE: return((Opaque)m_value).getValue(); case SMIConstants.SYNTAX_NULL: return new byte[0]; default: throw new IllegalArgumentException("cannot convert "+m_value+" to a byte array"); } }
public Object clone() { return new Opaque(super.getValue()); }
@Override public byte[] getBytes() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_INTEGER: case SMIConstants.SYNTAX_COUNTER32: case SMIConstants.SYNTAX_COUNTER64: case SMIConstants.SYNTAX_TIMETICKS: case SMIConstants.SYNTAX_UNSIGNED_INTEGER32: return toBigInteger().toByteArray(); case SMIConstants.SYNTAX_IPADDRESS: return toInetAddress().getAddress(); case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: return toSnmpObjId().toString().getBytes(); case SMIConstants.SYNTAX_OCTET_STRING: return ((OctetString)m_value).getValue(); case SMIConstants.SYNTAX_OPAQUE: return((Opaque)m_value).getValue(); case SMIConstants.EXCEPTION_END_OF_MIB_VIEW: case SMIConstants.EXCEPTION_NO_SUCH_INSTANCE: case SMIConstants.EXCEPTION_NO_SUCH_OBJECT: case SMIConstants.SYNTAX_NULL: return new byte[0]; default: throw new IllegalArgumentException("cannot convert "+m_value+" to a byte array"); } }
public Object clone() { return new Opaque(super.getValue()); }
@Override public byte[] getBytes() { switch (m_value.getSyntax()) { case SMIConstants.SYNTAX_INTEGER: case SMIConstants.SYNTAX_COUNTER32: case SMIConstants.SYNTAX_COUNTER64: case SMIConstants.SYNTAX_TIMETICKS: case SMIConstants.SYNTAX_UNSIGNED_INTEGER32: return toBigInteger().toByteArray(); case SMIConstants.SYNTAX_IPADDRESS: return toInetAddress().getAddress(); case SMIConstants.SYNTAX_OBJECT_IDENTIFIER: return toSnmpObjId().toString().getBytes(); case SMIConstants.SYNTAX_OCTET_STRING: return ((OctetString)m_value).getValue(); case SMIConstants.SYNTAX_OPAQUE: return((Opaque)m_value).getValue(); case SMIConstants.EXCEPTION_END_OF_MIB_VIEW: case SMIConstants.EXCEPTION_NO_SUCH_INSTANCE: case SMIConstants.EXCEPTION_NO_SUCH_OBJECT: case SMIConstants.SYNTAX_NULL: return new byte[0]; default: throw new IllegalArgumentException("cannot convert "+m_value+" to a byte array"); } }