本文整理汇总了Java中org.snmp4j.asn1.BERInputStream类的典型用法代码示例。如果您正苦于以下问题:Java BERInputStream类的具体用法?Java BERInputStream怎么用?Java BERInputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BERInputStream类属于org.snmp4j.asn1包,在下文中一共展示了BERInputStream类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decodeBER
import org.snmp4j.asn1.BERInputStream; //导入依赖的package包/类
public void decodeBER(BERInputStream inputStream) throws java.io.IOException {
BER.MutableByte type = new BER.MutableByte();
byte[] value = BER.decodeString(inputStream, type);
if (type.getValue() != BER.IPADDRESS) {
throw new IOException("Wrong type encountered when decoding Counter: "+
type.getValue());
}
if (value.length != 4) {
if ( (value.length == 8) && Boolean.getBoolean("org.opennms.snmp.workarounds.allow64BitIpAddress") ) {
byte[] tempValue = { 0,0,0,0 };
for (int i = 0; i < 4; i++) {
tempValue[i] = value[i];
}
value = tempValue;
if (log().isDebugEnabled()) {
log().debug("Working around misencoded IpAddress (8 bytes, truncating to 4); likely dealing with a buggy Net-SNMP agent");
}
} else {
throw new IOException("IpAddress encoding error, wrong length: " +
value.length);
}
}
this.setInetAddress(InetAddress.getByAddress(value));
}
示例2: decodeBER
import org.snmp4j.asn1.BERInputStream; //导入依赖的package包/类
public void decodeBER(BERInputStream inputStream) throws IOException {
BER.MutableByte type = new BER.MutableByte();
byte[] value = BER.decodeString(inputStream, type);
if (type.getValue() != BER.IPADDRESS) {
throw new IOException(
"Wrong type encountered when decoding Counter: "
+ type.getValue()
);
}
if (value.length != 4) {
logger.warn(
"IpAddress encoding is invalid, wrong length: " + value.length
);
super.setInetAddress(null);
rawValue = value;
}
else {
setAddress(value);
}
}
示例3: decodeBER
import org.snmp4j.asn1.BERInputStream; //导入依赖的package包/类
public void decodeBER(BERInputStream inputStream) throws java.io.IOException {
BER.MutableByte type = new BER.MutableByte();
int length;
BigInteger value = BigInteger.ZERO;
type.setValue((byte)inputStream.read());
if ((type.getValue() != 0x02) && (type.getValue() != 0x43) &&
(type.getValue() != 0x41)) {
throw new IOException("Wrong ASN.1 type. Not an integer: "+type.getValue()+
(" at position "+inputStream.getPosition()));
}
length = BER.decodeLength(inputStream);
if (length > 4) {
if (log().isDebugEnabled()) {
log().debug("Working around invalid Integer32 likely dealing with a permissive Net-SNMP agent");
}
}
int b = inputStream.read() & 0xFF;
if ((b & 0x80) > 0) {
value = BigInteger.ONE.negate();
}
while (length-- > 0) {
value = value.shiftLeft(8).or(BigInteger.valueOf(b));
if (length > 0) {
b = inputStream.read();
}
}
int newValue = value.compareTo(BigInteger.valueOf(Integer.MAX_VALUE)) > 0 ? 0 : value.intValue();
if (type.getValue() != BER.INTEGER) {
throw new IOException("Wrong type encountered when decoding Counter: "+type.getValue());
}
setValue(newValue);
}
示例4: BEROIDConversion
import org.snmp4j.asn1.BERInputStream; //导入依赖的package包/类
/**
*
* @param bBER
*/
public BEROIDConversion (byte[] bBER) {
if (debug) {
HexString hs = new HexString(bBER);
logger.debug("BEROIDConversion() " + hs.toString());
}
//Save copy of BER
this.bBER = bBER;
//Convert to ByteBuffer
bbBER = ByteBuffer.allocate(this.bBER.length);
//Add byte Array
bbBER.put(this.bBER).rewind();
//Convert to BERInputStream
bisBER = new BERInputStream(bbBER);
//Create a VarBind
vbBER = new VariableBinding();
try {
vbBER.decodeBER(bisBER);
} catch (IOException e) {
if (debug) {
e.printStackTrace();
}
}
oOID = vbBER.getOid();
if (debug) {
logger.debug("BEROIDConversion() " + oOID.toString());
logger.debug("BEROIDConversion() " + vbBER.toString());
logger.debug("BEROIDConversion() " + vbBER.getSyntax());
}
}
示例5: decodeBER
import org.snmp4j.asn1.BERInputStream; //导入依赖的package包/类
@Override
public void decodeBER(final BERInputStream berInputStream) throws IOException {
log.trace("BER will be decoded for variable {}", variable);
variable.decodeBER(berInputStream);
}