package org.opendaylight.protocol.rsvp.parser.impl.te;
import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint16;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObjectBuilder;
-import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
public abstract class AbstractAssociationParser extends AbstractRSVPObjectParser {
public static final short CLASS_NUM = 199;
protected final void localSerializeObject(final RsvpTeObject teLspObject, final ByteBuf output) {
checkArgument(teLspObject instanceof AssociationObject, "AssociationObject is mandatory.");
final AssociationObject assObject = (AssociationObject) teLspObject;
-
- if (assObject.getIpAddress().getIpv4AddressNoZone() != null) {
+ final IpAddressNoZone ipAddress = assObject.getIpAddress();
+ if (ipAddress.getIpv4AddressNoZone() != null) {
serializeAttributeHeader(BODY_SIZE_IPV4, CLASS_NUM, CTYPE_IPV4, output);
output.writeShort(assObject.getAssociationType().getIntValue());
- output.writeShort(assObject.getAssociationId().toJava());
- output.writeBytes(Ipv4Util.byteBufForAddress(assObject.getIpAddress().getIpv4AddressNoZone()));
+ writeUint16(output, assObject.getAssociationId());
+ output.writeBytes(Ipv4Util.byteBufForAddress(ipAddress.getIpv4AddressNoZone()));
} else {
serializeAttributeHeader(BODY_SIZE_IPV6, CLASS_NUM, CTYPE_IPV6, output);
output.writeShort(assObject.getAssociationType().getIntValue());
- output.writeShort(assObject.getAssociationId().toJava());
- output.writeBytes(Ipv6Util.byteBufForAddress(assObject.getIpAddress().getIpv6AddressNoZone()));
+ writeUint16(output, assObject.getAssociationId());
+ output.writeBytes(Ipv6Util.byteBufForAddress(ipAddress.getIpv6AddressNoZone()));
}
}
protected final RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
return new AssociationObjectBuilder()
.setAssociationType(AssociationType.forValue(byteBuf.readUnsignedShort()))
- .setAssociationId(ByteBufUtils.readUint16(byteBuf))
+ .setAssociationId(readUint16(byteBuf))
.setIpAddress(parseAssociationIpAddress(byteBuf))
.build();
}
*/
package org.opendaylight.protocol.rsvp.parser.impl.te;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint8;
+
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.basic.fast.reroute.object._case.BasicFastRerouteObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.basic.fast.reroute.object._case.BasicFastRerouteObjectBuilder;
-import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
public final class FastRerouteObjectParser extends AbstractRSVPObjectParser {
public static final short CLASS_NUM = 205;
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) {
final BasicFastRerouteObjectBuilder builder = new BasicFastRerouteObjectBuilder()
- .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
- .setHoldPriority(ByteBufUtils.readUint8(byteBuf))
- .setHopLimit(ByteBufUtils.readUint8(byteBuf))
+ .setSetupPriority(readUint8(byteBuf))
+ .setHoldPriority(readUint8(byteBuf))
+ .setHopLimit(readUint8(byteBuf))
.setFlags(FastRerouteFlags.forValue(byteBuf.readUnsignedByte()));
final ByteBuf v = byteBuf.readSlice(METRIC_VALUE_F_LENGTH);
return builder
.setBandwidth(new Bandwidth(ByteArray.readAllBytes(v)))
- .setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
- .setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
- .setIncludeAll(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
+ .setIncludeAny(new AttributeFilter(readUint32(byteBuf)))
+ .setExcludeAny(new AttributeFilter(readUint32(byteBuf)))
+ .setIncludeAll(new AttributeFilter(readUint32(byteBuf)))
.build();
}
final BasicFastRerouteObject fastRerouteObject = (BasicFastRerouteObject) teLspObject;
serializeAttributeHeader(BODY_SIZE_C1, CLASS_NUM, CTYPE, byteAggregator);
- byteAggregator.writeByte(fastRerouteObject.getSetupPriority().toJava());
- byteAggregator.writeByte(fastRerouteObject.getHoldPriority().toJava());
- byteAggregator.writeByte(fastRerouteObject.getHopLimit().toJava());
+ writeUint8(byteAggregator, fastRerouteObject.getSetupPriority());
+ writeUint8(byteAggregator, fastRerouteObject.getHoldPriority());
+ writeUint8(byteAggregator, fastRerouteObject.getHopLimit());
byteAggregator.writeByte(fastRerouteObject.getFlags().getIntValue());
byteAggregator.writeBytes(Unpooled.wrappedBuffer(fastRerouteObject.getBandwidth().getValue()));
writeAttributeFilter(fastRerouteObject.getIncludeAny(), byteAggregator);
package org.opendaylight.protocol.rsvp.parser.impl.te;
import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint8;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.legacy.fast.reroute.object._case.LegacyFastRerouteObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.legacy.fast.reroute.object._case.LegacyFastRerouteObjectBuilder;
-import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
public final class InformationalFastRerouteObjectParser extends AbstractRSVPObjectParser {
public static final short CLASS_NUM = 205;
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final LegacyFastRerouteObjectBuilder builder = new LegacyFastRerouteObjectBuilder()
- .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
- .setHoldPriority(ByteBufUtils.readUint8(byteBuf))
- .setHopLimit(ByteBufUtils.readUint8(byteBuf));
+ .setSetupPriority(readUint8(byteBuf))
+ .setHoldPriority(readUint8(byteBuf))
+ .setHopLimit(readUint8(byteBuf));
//skip reserved
byteBuf.skipBytes(Byte.BYTES);
final ByteBuf v = byteBuf.readSlice(METRIC_VALUE_F_LENGTH);
builder.setBandwidth(new Bandwidth(ByteArray.readAllBytes(v)));
- builder.setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
- builder.setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)));
+ builder.setIncludeAny(new AttributeFilter(readUint32(byteBuf)));
+ builder.setExcludeAny(new AttributeFilter(readUint32(byteBuf)));
return builder.build();
}
final LegacyFastRerouteObject fastRerouteObject = (LegacyFastRerouteObject) teLspObject;
serializeAttributeHeader(BODY_SIZE_C7, CLASS_NUM, CTYPE, byteAggregator);
- byteAggregator.writeByte(fastRerouteObject.getSetupPriority().toJava());
- byteAggregator.writeByte(fastRerouteObject.getHoldPriority().toJava());
- byteAggregator.writeByte(fastRerouteObject.getHopLimit().toJava());
+ writeUint8(byteAggregator, fastRerouteObject.getSetupPriority());
+ writeUint8(byteAggregator, fastRerouteObject.getHoldPriority());
+ writeUint8(byteAggregator, fastRerouteObject.getHopLimit());
byteAggregator.writeByte(0);
byteAggregator.writeBytes(Unpooled.wrappedBuffer(fastRerouteObject.getBandwidth().getValue()));
writeAttributeFilter(fastRerouteObject.getIncludeAny(), byteAggregator);
import static com.google.common.base.Preconditions.checkArgument;
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint8;
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.metric.object.MetricObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.metric.object.MetricObjectBuilder;
-import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
public final class MetricObjectParser extends AbstractRSVPObjectParser {
public static final short CLASS_NUM = 6;
return new MetricObjectBuilder()
.setBound(flags.get(BOUND))
.setComputed(flags.get(COMPUTED))
- .setMetricType(ByteBufUtils.readUint8(byteBuf))
+ .setMetricType(readUint8(byteBuf))
.setValue(new Float32(ByteArray.readBytes(byteBuf, METRIC_VALUE_F_LENGTH)))
.build();
}
reflect.set(BOUND, metric.getBound());
reflect.set(COMPUTED, metric.getComputed());
reflect.toByteBuf(output);
- output.writeByte(metric.getMetricType().toJava());
+ writeUint8(output, metric.getMetricType());
writeFloat32(metric.getValue(), output);
}
}
package org.opendaylight.protocol.rsvp.parser.impl.te;
import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint8;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.basic.session.attribute.object._case.BasicSessionAttributeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.basic.session.attribute.object._case.BasicSessionAttributeObjectBuilder;
-import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
public final class SessionAttributeLspObjectParser extends AbstractRSVPObjectParser {
public static final short CLASS_NUM = 207;
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final BasicSessionAttributeObjectBuilder builder = new BasicSessionAttributeObjectBuilder()
- .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
- .setHoldPriority(ByteBufUtils.readUint8(byteBuf));
+ .setSetupPriority(readUint8(byteBuf))
+ .setHoldPriority(readUint8(byteBuf));
final BitArray bs = BitArray.valueOf(byteBuf.readByte());
builder.setLocalProtectionDesired(bs.get(LOCAL_PROTECTION));
builder.setLabelRecordingDesired(bs.get(LABEL_RECORDING));
.getSessionName()));
final int pad = getPadding(sessionName.readableBytes());
serializeAttributeHeader(BODY_SIZE_C7 + pad + sessionName.readableBytes(), CLASS_NUM, CTYPE, output);
- output.writeByte(sessionObject.getSetupPriority().toJava());
- output.writeByte(sessionObject.getHoldPriority().toJava());
+ writeUint8(output, sessionObject.getSetupPriority());
+ writeUint8(output, sessionObject.getHoldPriority());
final BitArray bs = new BitArray(FLAGS_SIZE);
bs.set(LOCAL_PROTECTION, sessionObject.getLocalProtectionDesired());
bs.set(LABEL_RECORDING, sessionObject.getLabelRecordingDesired());
package org.opendaylight.protocol.rsvp.parser.impl.te;
import static com.google.common.base.Preconditions.checkArgument;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint8;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.RsvpTeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.session.attribute.object.with.resources.affinities._case.SessionAttributeObjectWithResourcesAffinities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.session.attribute.object.with.resources.affinities._case.SessionAttributeObjectWithResourcesAffinitiesBuilder;
-import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
public final class SessionAttributeLspRaObjectParser extends AbstractRSVPObjectParser {
public static final short CLASS_NUM = 207;
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final SessionAttributeObjectWithResourcesAffinitiesBuilder builder =
new SessionAttributeObjectWithResourcesAffinitiesBuilder()
- .setIncludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
- .setExcludeAny(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
- .setIncludeAll(new AttributeFilter(ByteBufUtils.readUint32(byteBuf)))
- .setSetupPriority(ByteBufUtils.readUint8(byteBuf))
- .setHoldPriority(ByteBufUtils.readUint8(byteBuf));
+ .setIncludeAny(new AttributeFilter(readUint32(byteBuf)))
+ .setExcludeAny(new AttributeFilter(readUint32(byteBuf)))
+ .setIncludeAll(new AttributeFilter(readUint32(byteBuf)))
+ .setSetupPriority(readUint8(byteBuf))
+ .setHoldPriority(readUint8(byteBuf));
final BitArray bs = BitArray.valueOf(byteBuf.readByte());
builder.setLocalProtectionDesired(bs.get(SessionAttributeLspObjectParser.LOCAL_PROTECTION));
writeAttributeFilter(sessionObject.getIncludeAny(), output);
writeAttributeFilter(sessionObject.getExcludeAny(), output);
writeAttributeFilter(sessionObject.getIncludeAll(), output);
- output.writeByte(sessionObject.getSetupPriority().toJava());
- output.writeByte(sessionObject.getHoldPriority().toJava());
+ writeUint8(output, sessionObject.getSetupPriority());
+ writeUint8(output, sessionObject.getHoldPriority());
final BitArray bs = new BitArray(FLAGS_SIZE);
bs.set(SessionAttributeLspObjectParser.LOCAL_PROTECTION, sessionObject.getLocalProtectionDesired());
bs.set(SessionAttributeLspObjectParser.LABEL_RECORDING, sessionObject.getLabelRecordingDesired());