List of usage examples for io.netty.buffer ByteBuf isReadable
public abstract boolean isReadable();
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);//ww 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.PCEPMetricObjectParser.java
License:Open Source License
@Override public Metric 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() != SIZE) { throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: " + SIZE + "."); }/*from w w w .j av a 2 s. co m*/ bytes.skipBytes(RESERVED); final BitArray flags = BitArray.valueOf(bytes.readByte()); final MetricBuilder builder = new MetricBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setBound(flags.get(B_FLAG_OFFSET)); builder.setComputed(flags.get(C_FLAG_OFFSET)); builder.setMetricType(bytes.readUnsignedByte()); builder.setValue(new Float32(ByteArray.readBytes(bytes, METRIC_VALUE_F_LENGTH))); 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);//from www. 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.PCEPNoPathObjectParser.java
License:Open Source License
@Override public NoPath 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 NoPathBuilder builder = new NoPathBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setNatureOfIssue(bytes.readUnsignedByte()); final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE); builder.setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET)); bytes.skipBytes(RESERVED_F_LENGTH);/*from w w w . j a va 2s. com*/ 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.PCEPNotificationObjectParser.java
License:Open Source License
@Override public CNotification 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 CNotificationBuilder builder = new CNotificationBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); bytes.skipBytes(NT_F_OFFSET);/*from ww w .j av a 2 s . c o m*/ builder.setType(bytes.readUnsignedByte()); builder.setValue(bytes.readUnsignedByte()); parseTlvs(builder, bytes.slice()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser.java
License:Open Source License
@Override public Of 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 OfBuilder builder = new OfBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); builder.setCode(new OfId(bytes.readUnsignedShort())); bytes.readBytes(RESERVED);/*from ww w .j a va 2s. com*/ 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.PCEPOpenObjectParser.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 int versionValue = ByteArray.copyBitsRange(bytes.readByte(), VERSION_SF_OFFSET, VERSION_SF_LENGTH); final OpenBuilder builder = new OpenBuilder(); builder.setVersion(new ProtocolVersion((short) versionValue)); builder.setProcessingRule(header.isProcessingRule()); builder.setIgnore(header.isIgnore()); final short keepalive = bytes.readUnsignedByte(); builder.setKeepalive(keepalive);/*from ww w. j a va 2 s . co m*/ final short deadTimer = bytes.readUnsignedByte(); if (keepalive == 0) { builder.setDeadTimer((short) 0); } else { builder.setDeadTimer(deadTimer); } builder.setSessionId(bytes.readUnsignedByte()); final TlvsBuilder tbuilder = new TlvsBuilder(); parseTlvs(tbuilder, bytes.slice()); builder.setTlvs(tbuilder.build()); final Open obj = builder.build(); if (versionValue != PCEP_VERSION) { // TODO: Should we move this check into the negotiator LOG.debug("Unsupported PCEP version {}", versionValue); return new UnknownObject(PCEPErrors.PCEP_VERSION_NOT_SUPPORTED, obj); } return obj; }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPOverloadObjectParser.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 OverloadBuilder builder = new OverloadBuilder(); buffer.readBytes(RESERVED + FLAGS);//ww w . ja va 2 s.c o m builder.setDuration(buffer.readUnsignedShort()); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPPathKeyObjectParser.java
License:Open Source License
@Override public PathKey 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 PathKeyBuilder builder = new PathKeyBuilder(); builder.setIgnore(header.isIgnore()); builder.setProcessingRule(header.isProcessingRule()); final List<PathKeys> pk = new ArrayList<>(); final List<Subobject> subs = parseSubobjects(bytes); for (final Subobject s : subs) { final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase k = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase) s .getSubobjectType();//from w ww. j av a 2s. co m pk.add(new PathKeysBuilder().setLoose(s.isLoose()).setPceId(k.getPathKey().getPceId()) .setPathKey(k.getPathKey().getPathKey()).build()); } builder.setPathKeys(pk); return builder.build(); }
From source file:org.opendaylight.protocol.pcep.impl.object.PCEPPccIdReqIPv4ObjectParser.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 PccIdReqBuilder builder = new PccIdReqBuilder(); builder.setIpAddress(new IpAddress(Ipv4Util.addressForByteBuf(buffer))); return builder.build(); }