List of usage examples for io.netty.buffer ByteBuf readUnsignedInt
public abstract long readUnsignedInt();
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser.java
License:Open Source License
@Override public Object 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 (!header.isProcessingRule()) { LOG.debug("Processed bit not set on CLASS TYPE OBJECT, ignoring it"); return null; }/* w w w . j a v a 2 s . c o m*/ if (bytes.readableBytes() != SIZE) { throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: " + bytes.readableBytes()); } final ClassTypeBuilder builder = new ClassTypeBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); final short ct = (short) bytes.readUnsignedInt(); builder.setClassType( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType( ct)); final Object obj = builder.build(); if (ct < 0 || ct > Byte.SIZE) { LOG.debug("Invalid class type {}", ct); return new UnknownObject(PCEPErrors.INVALID_CT, obj); } return obj; }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser.java
License:Open Source License
@Override public Lspa 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."); final LspaBuilder builder = new LspaBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setExcludeAny(new AttributeFilter(bytes.readUnsignedInt())); builder.setIncludeAll(new AttributeFilter(bytes.readUnsignedInt())); builder.setIncludeAny(new AttributeFilter(bytes.readUnsignedInt())); builder.setSetupPriority(bytes.readUnsignedByte()); builder.setHoldPriority(bytes.readUnsignedByte()); final BitArray flags = BitArray.valueOf(bytes.readByte()); builder.setLocalProtectionDesired(flags.get(L_FLAG_OFFSET)); final TlvsBuilder tbuilder = new TlvsBuilder(); bytes.skipBytes(RESERVED);/*from w w w. j a v a 2 s . c om*/ parseTlvs(tbuilder, bytes.slice()); builder.setTlvs(tbuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPMonitoringObjectParser.java
License:Open Source License
@Override public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final MonitoringBuilder builder = new MonitoringBuilder(); buffer.readBytes(RESERVED);// w w w. j a v a 2 s . co m final BitArray flagBits = BitArray.valueOf(buffer, FLAGS_SIZE); final Flags flags = new Flags(flagBits.get(G_FLAG_POS), flagBits.get(I_FLAG_POS), flagBits.get(L_FLAG_POS), flagBits.get(C_FLAG_POS), flagBits.get(P_FLAG_POS)); builder.setFlags(flags); builder.setMonitoringId(buffer.readUnsignedInt()); final TlvsBuilder tbuilder = new TlvsBuilder(); parseTlvs(tbuilder, buffer.slice()); builder.setTlvs(tbuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPProcTimeObjectParser.java
License:Open Source License
@Override public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); final ProcTimeBuilder builder = new ProcTimeBuilder(); buffer.skipBytes(RESERVED);/* w w w . j av a 2s .c o m*/ final BitArray flagBits = BitArray.valueOf(buffer, FLAGS); builder.setEstimated(flagBits.get(E_FLAG_POSITION)); builder.setCurrentProcTime(buffer.readUnsignedInt()); builder.setMinProcTime(buffer.readUnsignedInt()); builder.setMaxProcTime(buffer.readUnsignedInt()); builder.setAverageProcTime(buffer.readUnsignedInt()); builder.setVarianceProcTime(buffer.readUnsignedInt()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser.java
License:Open Source License
@Override public Object 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."); final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE); final RpBuilder builder = new RpBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); short priority = 0; priority |= flags.get(PRI_SF_OFFSET + 2) ? 1 : 0; priority |= (flags.get(PRI_SF_OFFSET + 1) ? 1 : 0) << 1; priority |= (flags.get(PRI_SF_OFFSET) ? 1 : 0) << 2; if (priority != 0) { builder.setPriority(priority);//from www .j av a 2s.c o m } builder.setFragmentation(flags.get(F_FLAG_OFFSET)); builder.setP2mp(flags.get(N_FLAG_OFFSET)); builder.setEroCompression(flags.get(E_FLAG_OFFSET)); builder.setMakeBeforeBreak(flags.get(M_FLAG_OFFSET)); builder.setOrder(flags.get(D_FLAG_OFFSET)); builder.setPathKey(flags.get(P_FLAG_OFFSET)); builder.setSupplyOf(flags.get(S_FLAG_OFFSET)); builder.setLoose(flags.get(O_FLAG_OFFSET)); builder.setBiDirectional(flags.get(B_FLAG_OFFSET)); builder.setReoptimization(flags.get(R_FLAG_OFFSET)); builder.setRequestId(new RequestId(bytes.readUnsignedInt())); final TlvsBuilder tlvsBuilder = new TlvsBuilder(); parseTlvs(tlvsBuilder, bytes.slice()); builder.setTlvs(tlvsBuilder.build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser.java
License:Open Source License
@Override public Svec 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 + "."); }/*from w w w. j ava 2 s . c o m*/ bytes.skipBytes(FLAGS_F_OFFSET); final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE); final List<RequestId> requestIDs = Lists.newArrayList(); while (bytes.isReadable()) { requestIDs.add(new RequestId(bytes.readUnsignedInt())); } if (requestIDs.isEmpty()) { throw new PCEPDeserializerException("Empty Svec Object - no request ids."); } final SvecBuilder builder = new SvecBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setLinkDiverse(flags.get(L_FLAG_OFFSET)); builder.setNodeDiverse(flags.get(N_FLAG_OFFSET)); builder.setSrlgDiverse(flags.get(S_FLAG_OFFSET)); builder.setRequestsIds(requestIDs); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.EROUnnumberedInterfaceSubobjectParser.java
License:Open Source License
@Override public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); if (buffer.readableBytes() != CONTENT_LENGTH) { throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + "."); }/*from ww w . ja va 2 s . com*/ final SubobjectBuilder builder = new SubobjectBuilder(); builder.setLoose(loose); final UnnumberedBuilder ubuilder = new UnnumberedBuilder(); buffer.skipBytes(RESERVED); ubuilder.setRouterId(buffer.readUnsignedInt()); ubuilder.setInterfaceId(buffer.readUnsignedInt()); builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.RROUnnumberedInterfaceSubobjectParser.java
License:Open Source License
@Override public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); if (buffer.readableBytes() != CONTENT_LENGTH) { throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + "."); }/* www.ja v a 2s. com*/ final SubobjectBuilder builder = new SubobjectBuilder(); final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE); builder.setProtectionAvailable(flags.get(LPA_F_OFFSET)); builder.setProtectionInUse(flags.get(LPIU_F_OFFSET)); final UnnumberedBuilder ubuilder = new UnnumberedBuilder(); buffer.skipBytes(RESERVED); ubuilder.setRouterId(buffer.readUnsignedInt()); ubuilder.setInterfaceId(buffer.readUnsignedInt()); builder.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.Type1LabelParser.java
License:Open Source License
@Override public LabelType parseLabel(final ByteBuf buffer) throws PCEPDeserializerException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); if (buffer.readableBytes() != LABEL_LENGTH) { throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + LABEL_LENGTH + "."); }//ww w. j av a 2s . c om return new Type1LabelCaseBuilder() .setType1Label(new Type1LabelBuilder().setType1Label(buffer.readUnsignedInt()).build()).build(); }
From source file:org.opendaylight.protocol.pcep.impl.subobject.WavebandSwitchingLabelParser.java
License:Open Source License
@Override public LabelType parseLabel(final ByteBuf buffer) throws PCEPDeserializerException { Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty."); if (buffer.readableBytes() != CONTENT_LENGTH) { throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + "."); }// w w w . j a v a 2 s .co m final WavebandSwitchingLabelBuilder builder = new WavebandSwitchingLabelBuilder(); builder.setWavebandId(buffer.readUnsignedInt()); builder.setStartLabel(buffer.readUnsignedInt()); builder.setEndLabel(buffer.readUnsignedInt()); return new WavebandSwitchingLabelCaseBuilder().setWavebandSwitchingLabel(builder.build()).build(); }