List of usage examples for io.netty.buffer ByteBuf readUnsignedInt
public abstract long readUnsignedInt();
From source file:org.opendaylight.protocol.bmp.impl.tlv.StatType006TlvHandler.java
License:Open Source License
@Override public Tlv parseTlv(final ByteBuf buffer) throws BmpDeserializationException { if (buffer == null) { return null; }// w ww . j a va2 s. c o m return new InvalidatedAsConfedLoopTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build(); }
From source file:org.opendaylight.protocol.bmp.impl.tlv.StatType011TlvHandler.java
License:Open Source License
@Override public Tlv parseTlv(final ByteBuf buffer) throws BmpDeserializationException { if (buffer == null) { return null; }// w w w . j a v a 2 s . c om return new UpdatesTreatedAsWithdrawTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build(); }
From source file:org.opendaylight.protocol.bmp.impl.tlv.StatType012TlvHandler.java
License:Open Source License
@Override public Tlv parseTlv(final ByteBuf buffer) throws BmpDeserializationException { if (buffer == null) { return null; }/*from w w w . j a v a 2 s . co m*/ return new PrefixesTreatedAsWithdrawTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build(); }
From source file:org.opendaylight.protocol.bmp.impl.tlv.StatType013TlvHandler.java
License:Open Source License
@Override public Tlv parseTlv(final ByteBuf buffer) throws BmpDeserializationException { if (buffer == null) { return null; }//w w w . j a v a 2s .co m return new DuplicateUpdatesTlvBuilder().setCount(new Counter32(buffer.readUnsignedInt())).build(); }
From source file:org.opendaylight.protocol.bmp.spi.parser.AbstractBmpPerPeerMessageParser.java
License:Open Source License
protected final PeerHeader parsePerPeerHeader(final ByteBuf bytes) { Preconditions.checkArgument(bytes.readableBytes() >= PER_PEER_HEADER_SIZE); final PeerHeaderBuilder phBuilder = new PeerHeaderBuilder(); final PeerType peerType = PeerType.forValue(bytes.readByte()); phBuilder.setType(peerType);//from w ww.ja v a2 s . c om final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE); phBuilder.setAdjRibInType(AdjRibInType.forValue(flags.get(L_FLAG_POS) ? 1 : 0)); phBuilder.setIpv4(!flags.get(V_FLAG_POS)); switch (peerType) { case L3vpn: phBuilder.setDistinguisher(PeerDistinguisherUtil.parsePeerDistingisher(bytes.slice())); phBuilder.setPeerDistinguisher( new PeerDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(bytes))); break; case Local: phBuilder.setPeerDistinguisher( new PeerDistinguisher(ByteArray.readBytes(bytes, PEER_DISTINGUISHER_SIZE))); break; case Global: default: bytes.skipBytes(PEER_DISTINGUISHER_SIZE); break; } if (phBuilder.isIpv4()) { bytes.skipBytes(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH); phBuilder.setAddress(new IpAddress(Ipv4Util.addressForByteBuf(bytes))); } else { phBuilder.setAddress(new IpAddress(Ipv6Util.addressForByteBuf(bytes))); } phBuilder.setAs(new AsNumber(bytes.readUnsignedInt())); phBuilder.setBgpId(Ipv4Util.addressForByteBuf(bytes)); phBuilder.setTimestampSec(new Timestamp(bytes.readUnsignedInt())); phBuilder.setTimestampMicro(new Timestamp(bytes.readUnsignedInt())); return phBuilder.build(); }
From source file:org.opendaylight.protocol.bmp.spi.parser.PeerDistinguisherUtil.java
License:Open Source License
public static Distinguisher parsePeerDistingisher(final ByteBuf buffer) { final DistinguisherBuilder distinguisherBuilder = new DistinguisherBuilder(); final DistinguisherType type = DistinguisherType.forValue(buffer.readUnsignedShort()); distinguisherBuilder.setDistinguisherType(type); switch (type) { case Type0: final int asNumber = buffer.readUnsignedShort(); distinguisherBuilder.setDistinguisher( PeerDistinguisher.toString(Integer.toString(asNumber), buffer.readUnsignedInt())); break;// ww w.j av a2 s .co m case Type1: final Ipv4Address ipv4Address = Ipv4Util.addressForByteBuf(buffer); distinguisherBuilder.setDistinguisher( PeerDistinguisher.toString(ipv4Address.getValue(), buffer.readUnsignedShort())); break; case Type2: final long asNumber4Bytes = buffer.readUnsignedInt(); distinguisherBuilder.setDistinguisher( PeerDistinguisher.toString(Long.toString(asNumber4Bytes), buffer.readUnsignedShort())); break; default: break; } return distinguisherBuilder.build(); }
From source file:org.opendaylight.protocol.bmp.spi.registry.SimpleBmpMessageRegistry.java
License:Open Source License
private int parseMessageHeader(final ByteBuf buffer) throws BmpDeserializationException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes cannot be null or empty."); Preconditions.checkArgument(buffer.readableBytes() >= COMMON_HEADER_LENGTH, "Too few bytes in passed array. Passed: %s. Expected: >= %s.", buffer.readableBytes(), COMMON_HEADER_LENGTH);/* w ww . ja va 2s .co m*/ final short messageVersion = buffer.readUnsignedByte(); if (messageVersion != BMP_VERSION) { throw new BmpDeserializationException( "Unsuppoted BMP version. Passed: " + messageVersion + "; Expected: " + BMP_VERSION + "."); } final long messageLength = buffer.readUnsignedInt(); final short msgType = buffer.readUnsignedByte(); if (messageLength - COMMON_HEADER_LENGTH != buffer.readableBytes()) { throw new BmpDeserializationException("Size doesn't match size specified in header. Passed: " + buffer.readableBytes() + COMMON_HEADER_LENGTH + "; Expected: " + messageLength + "."); } return msgType; }
From source file:org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07LspUpdateErrorTlvParser.java
License:Open Source License
@Override public LspErrorCode parseTlv(final ByteBuf buffer) throws PCEPDeserializerException { if (buffer == null) { return null; }// ww w .ja v a2s . co m return new LspErrorCodeBuilder().setErrorCode(buffer.readUnsignedInt()).build(); }
From source file:org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07RSVPErrorSpecTlvParser.java
License:Open Source License
private UserCase parseUserError(final ByteBuf buffer) { final UserErrorBuilder error = new UserErrorBuilder(); error.setEnterprise(new EnterpriseNumber(buffer.readUnsignedInt())); error.setSubOrg(buffer.readUnsignedByte()); final int errDescrLength = buffer.readUnsignedByte(); error.setValue(buffer.readUnsignedShort()); error.setDescription(ByteArray.bytesToHRString(ByteArray.readBytes(buffer, errDescrLength))); // if we have any subobjects, place the implementation here return new UserCaseBuilder().setUserError(error.build()).build(); }
From source file:org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07SrpObjectParser.java
License:Open Source License
@Override public Srp parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException { Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); if (bytes.readableBytes() < MIN_SIZE) { throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + "."); }/* www .j a v a 2 s .c om*/ final SrpBuilder builder = new SrpBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); parseFlags(builder, bytes); builder.setOperationId(new SrpIdNumber(bytes.readUnsignedInt())); final TlvsBuilder tlvsBuilder = new TlvsBuilder(); parseTlvs(tlvsBuilder, bytes.slice()); builder.setTlvs(tlvsBuilder.build()); return builder.build(); }