当前位置: 首页>>代码示例>>Java>>正文


Java BERInputStream类代码示例

本文整理汇总了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));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:IpAddressNetSnmp64bitBugAware.java

示例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);
  }
}
 
开发者ID:kaitoy,项目名称:sneo,代码行数:21,代码来源:LenientIpAddress.java

示例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);
 }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:38,代码来源:Integer32IgnoreTooManyBytes.java

示例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());
	}
	
}
 
开发者ID:Comcast,项目名称:Oscar,代码行数:47,代码来源:BEROIDConversion.java

示例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);
}
 
开发者ID:1and1,项目名称:snmpman,代码行数:6,代码来源:ModifiedVariable.java


注:本文中的org.snmp4j.asn1.BERInputStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。