*/
package org.opendaylight.protocol.pcep.impl.object;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Bandwidth, "Wrong instance of PCEPObject. Passed %s. Needed BandwidthObject.", object.getClass());
final ByteBuf body = Unpooled.buffer();
- body.writeBytes(((Bandwidth) object).getBandwidth().getValue());
+ writeFloat32(((Bandwidth) object).getBandwidth(), body);
formatBandwidth(object.isProcessingRule(), object.isIgnore(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.object;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
Preconditions.checkArgument(object instanceof ClassType, "Wrong instance of PCEPObject. Passed %s. Needed ClassTypeObject.", object.getClass());
final ByteBuf body = Unpooled.buffer(SIZE);
body.writeZero(SIZE -1);
- body.writeByte(((ClassType) object).getClassType().getValue());
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType classType = ((ClassType) object).getClassType();
+ Preconditions.checkArgument(classType != null, "ClassType is mandatory.");
+ writeUnsignedByte(classType.getValue(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final CClose obj = (CClose) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(RESERVED + FLAGS_F_LENGTH);
- body.writeByte(obj.getReason());
- // FIXME: switch to ByteBuf
- final byte[] tlvs = serializeTlvs(obj.getTlvs());
- if (tlvs != null) {
- body.writeBytes(tlvs);
- }
+ Preconditions.checkArgument(obj.getReason() != null, "Reason is mandatory.");
+ writeUnsignedByte(obj.getReason(), body);
+ serializeTlvs(obj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
- public byte[] serializeTlvs(final Tlvs tlvs) {
- // No tlvs defined
- return new byte[0];
+ public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
+ return;
}
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Address;
+
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.pcep.types.rev131005.endpoints.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv4Case;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv4CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder;
final EndpointsObj ePObj = (EndpointsObj) object;
final AddressFamily afi = ePObj.getAddressFamily();
Preconditions.checkArgument(afi instanceof Ipv4Case, "Wrong instance of NetworkAddress. Passed %s. Needed IPv4", afi.getClass());
+ final Ipv4 ipv4 = ((Ipv4Case) afi).getIpv4();
final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH + Ipv4Util.IP4_LENGTH);
- body.writeBytes(Ipv4Util.bytesForAddress((((Ipv4Case) afi).getIpv4()).getSourceIpv4Address()));
- body.writeBytes(Ipv4Util.bytesForAddress((((Ipv4Case) afi).getIpv4()).getDestinationIpv4Address()));
+ Preconditions.checkArgument(ipv4.getSourceIpv4Address() != null, "SourceIpv4Address is mandatory.");
+ writeIpv4Address(ipv4.getSourceIpv4Address(), body);
+ Preconditions.checkArgument(ipv4.getDestinationIpv4Address() != null, "DestinationIpv4Address is mandatory.");
+ writeIpv4Address(ipv4.getDestinationIpv4Address(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Address;
+
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.pcep.types.rev131005.endpoints.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv6Case;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.Ipv6CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv6._case.Ipv6;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv6._case.Ipv6Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObjBuilder;
final AddressFamily afi = ePObj.getAddressFamily();
Preconditions.checkArgument(afi instanceof Ipv6Case, "Wrong instance of NetworkAddress. Passed %s. Needed IPv6", afi.getClass());
final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH + Ipv6Util.IPV6_LENGTH);
- body.writeBytes(Ipv6Util.bytesForAddress((((Ipv6Case) afi).getIpv6()).getSourceIpv6Address()));
- body.writeBytes(Ipv6Util.bytesForAddress((((Ipv6Case) afi).getIpv6()).getDestinationIpv6Address()));
+ final Ipv6 ipv6 = ((Ipv6Case) afi).getIpv6();
+ Preconditions.checkArgument(ipv6.getSourceIpv6Address() != null, "SourceIpv6Address is mandatory.");
+ writeIpv6Address(ipv6.getSourceIpv6Address(), body);
+ Preconditions.checkArgument(ipv6.getDestinationIpv6Address() != null, "DestinationIpv6Address is mandatory.");
+ writeIpv6Address(ipv6.getDestinationIpv6Address(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final ErrorObject errObj = (ErrorObject) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(FLAGS_F_LENGTH + RESERVED);
- body.writeByte(errObj.getType());
- body.writeByte(errObj.getValue());
+ Preconditions.checkArgument(errObj.getType() != null, "Type is mandatory.");
+ writeUnsignedByte(errObj.getType(), body);
+ Preconditions.checkArgument(errObj.getValue() != null, "Value is mandatory.");
+ writeUnsignedByte(errObj.getValue(), body);
serializeTlvs(errObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.object;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBoolean;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.XROSubobjectRegistry;
final Xro obj = (Xro) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(FLAGS_OFFSET);
- if (obj.getFlags().isFail() != null) {
- body.writeBoolean(obj.getFlags().isFail());
- }
+ writeBoolean(obj.getFlags() != null ? obj.getFlags().isFail() : null, body);
serializeSubobject(obj.getSubobject(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
Preconditions.checkArgument(object instanceof Gc, "Wrong instance of PCEPObject. Passed %s. Needed GcObject.", object.getClass());
final Gc specObj = (Gc) object;
final ByteBuf body = Unpooled.buffer();
- body.writeByte(specObj.getMaxHop());
- body.writeByte(specObj.getMaxUtilization());
- body.writeByte(specObj.getMinUtilization());
- body.writeByte(specObj.getOverBookingFactor());
+ writeUnsignedByte(specObj.getMaxHop(), body);
+ writeUnsignedByte(specObj.getMaxUtilization(), body);
+ writeUnsignedByte(specObj.getMinUtilization(), body);
+ writeUnsignedByte(specObj.getOverBookingFactor(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final LoadBalancing specObj = (LoadBalancing) object;
final ByteBuf body = Unpooled.buffer(SIZE);
body.writeZero(RESERVED + FLAGS_F_LENGTH);
- body.writeByte(specObj.getMaxLsp());
- body.writeBytes(specObj.getMinBandwidth().getValue());
+ writeUnsignedByte(specObj.getMaxLsp(), body);
+ writeFloat32(specObj.getMinBandwidth(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
Preconditions.checkArgument(object instanceof Lspa, "Wrong instance of PCEPObject. Passed %s. Needed LspaObject.", object.getClass());
final Lspa lspaObj = (Lspa) object;
final ByteBuf body = Unpooled.buffer();
- if (lspaObj.getExcludeAny() != null) {
- body.writeInt(lspaObj.getExcludeAny().getValue().intValue());
- } else {
- body.writeZero(Integer.SIZE / Byte.SIZE);
- }
- if (lspaObj.getIncludeAny() != null) {
- body.writeInt(lspaObj.getIncludeAny().getValue().intValue());
- } else {
- body.writeZero(Integer.SIZE / Byte.SIZE);
- }
- if (lspaObj.getIncludeAll() != null) {
- body.writeInt(lspaObj.getIncludeAll().getValue().intValue());
- } else {
- body.writeZero(Integer.SIZE / Byte.SIZE);
- }
- if (lspaObj.getSetupPriority() != null) {
- body.writeByte(lspaObj.getSetupPriority());
- } else {
- body.writeZero(1);
- }
- if (lspaObj.getHoldPriority() != null) {
- body.writeByte(lspaObj.getHoldPriority());
- } else {
- body.writeZero(1);
- }
+ writeAttributeFilter(lspaObj.getExcludeAny(), body);
+ writeAttributeFilter(lspaObj.getIncludeAny(), body);
+ writeAttributeFilter(lspaObj.getIncludeAll(), body);
+ writeUnsignedByte(lspaObj.getSetupPriority(), body);
+ writeUnsignedByte(lspaObj.getHoldPriority(), body);
final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
if (lspaObj.isLocalProtectionDesired() != null) {
flags.set(L_FLAG_OFFSET, lspaObj.isLocalProtectionDesired());
}
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
+ writeBitSet(flags, FLAGS_F_LENGTH, body);
body.writeZero(RESERVED);
serializeTlvs(lspaObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
return;
}
+
+ private void writeAttributeFilter(final AttributeFilter attributeFilter, final ByteBuf body) {
+ writeUnsignedInt(attributeFilter != null ? attributeFilter.getValue() : null, body);
+ }
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
if (mObj.isBound() != null) {
flags.set(B_FLAG_OFFSET, mObj.isBound());
}
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
- body.writeByte(mObj.getMetricType());
- body.writeBytes(mObj.getValue().getValue());
+ writeBitSet(flags, FLAGS_F_LENGTH, body);
+ Preconditions.checkArgument(mObj.getMetricType() != null, "MetricType is mandatory.");
+ writeUnsignedByte(mObj.getMetricType(), body);
+ writeFloat32(mObj.getValue(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
Preconditions.checkArgument(object instanceof NoPath, "Wrong instance of PCEPObject. Passed %s. Needed NoPathObject.", object.getClass());
final NoPath nPObj = (NoPath) object;
final ByteBuf body = Unpooled.buffer();
- body.writeByte(nPObj.getNatureOfIssue());
+ Preconditions.checkArgument(nPObj.getNatureOfIssue() != null, "NatureOfIssue is mandatory.");
+ writeUnsignedByte(nPObj.getNatureOfIssue(), body);
final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
if (nPObj.isUnsatisfiedConstraints() != null) {
flags.set(C_FLAG_OFFSET, nPObj.isUnsatisfiedConstraints());
}
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
+ writeBitSet(flags, FLAGS_F_LENGTH, body);
body.writeZero(RESERVED_F_LENGTH);
serializeTlvs(nPObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final CNotification notObj = (CNotification) object;
final ByteBuf body = Unpooled.buffer();
body.writeZero(NT_F_OFFSET);
- body.writeByte(notObj.getType());
- body.writeByte(notObj.getValue());
+ Preconditions.checkArgument(notObj.getType() != null, "Type is mandatory.");
+ writeUnsignedByte(notObj.getType(), body);
+ Preconditions.checkArgument(notObj.getValue() != null, "Value is mandatory.");
+ writeUnsignedByte(notObj.getValue(), body);
serializeTlvs(notObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.object;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
Preconditions.checkArgument(object instanceof Of, "Wrong instance of PCEPObject. Passed %s. Needed OfObject.", object.getClass());
final Of specObj = (Of) object;
final ByteBuf body = Unpooled.buffer();
- body.writeShort(specObj.getCode().getValue().shortValue());
+ Preconditions.checkArgument(specObj.getCode() != null, "Code is mandatory");
+ writeUnsignedShort(specObj.getCode().getValue(), body);
body.writeZero(RESERVED);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
Preconditions.checkArgument(object instanceof Open, "Wrong instance of PCEPObject. Passed %s. Needed OpenObject.", object.getClass());
final Open open = (Open) object;
final ByteBuf body = Unpooled.buffer();
- body.writeByte(PCEP_VERSION << (Byte.SIZE - VERSION_SF_LENGTH));
- body.writeByte(open.getKeepalive());
- body.writeByte(open.getDeadTimer());
- body.writeByte(open.getSessionId());
+ writeUnsignedByte((short) (PCEP_VERSION << (Byte.SIZE - VERSION_SF_LENGTH)), body);
+ writeUnsignedByte(open.getKeepalive(), body);
+ writeUnsignedByte(open.getDeadTimer(), body);
+ Preconditions.checkArgument(open.getSessionId() != null, "SessionId is mandatory.");
+ writeUnsignedByte(open.getSessionId(), body);
serializeTlvs(open.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final byte[] p = { 0, 0, 0, UnsignedBytes.checkedCast(rpObj.getPriority().shortValue())};
flags.or(ByteArray.bytesToBitSet(p));
}
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_PRI_MF_LENGTH));
- body.writeInt(rpObj.getRequestId().getValue().intValue());
+ writeBitSet(flags, FLAGS_PRI_MF_LENGTH, body);
+ Preconditions.checkArgument(rpObj.getRequestId() != null, "RequestId is mandatory");
+ writeUnsignedInt(rpObj.getRequestId().getValue(), body);
serializeTlvs(rpObj.getTlvs(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.object;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
import java.util.List;
-
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
if (svecObj.isSrlgDiverse() != null) {
flags.set(S_FLAG_OFFSET, svecObj.isSrlgDiverse());
}
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
+ writeBitSet(flags, FLAGS_F_LENGTH, body);
final List<RequestId> requestIDs = svecObj.getRequestsIds();
assert !(requestIDs.isEmpty()) : "Empty Svec Object - no request ids.";
- for (int i = 0; i < requestIDs.size(); i++) {
- body.writeInt(requestIDs.get(i).getValue().intValue());
+ for(final RequestId requestId : requestIDs) {
+ writeUnsignedInt(requestId.getValue(), body);
}
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof AsNumberCase, "Unknown subobject instance. Passed %s. Needed AsNumberCase.", subobject.getSubobjectType().getClass());
- final AsNumberSubobject s = ((AsNumberCase) subobject.getSubobjectType()).getAsNumber();
- EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), Unpooled.copyShort(s.getAsNumber().getValue().shortValue()), buffer);
+ final AsNumberSubobject asNumber = ((AsNumberCase) subobject.getSubobjectType()).getAsNumber();
+ final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
+ Preconditions.checkArgument(asNumber.getAsNumber() != null, "AsNumber is mandatory.");
+ writeShort(asNumber.getAsNumber().getValue().shortValue(), body);
+ EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Prefix;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
new EROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer);
} else {
final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
- body.writeBytes(Ipv4Util.bytesForPrefix(prefix.getIpv4Prefix()));
+ Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
+ writeIpv4Prefix(prefix.getIpv4Prefix(), body);
body.writeZero(RESERVED);
EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Prefix;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
final IpPrefix prefix = specObj.getIpPrefix();
final ByteBuf body = Unpooled.buffer();
- body.writeBytes(Ipv6Util.bytesForPrefix(prefix.getIpv6Prefix()));
+ Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory.");
+ writeIpv6Prefix(prefix.getIpv6Prefix(), body);
body.writeZero(RESERVED);
EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.subobject.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
final ByteBuf body = Unpooled.buffer();
- body.writeShort(pk.getPathKey().getValue().shortValue());
+ Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+ writeUnsignedShort(pk.getPathKey().getValue(), body);
+ Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
body.writeBytes(pk.getPceId().getBinary());
EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.subobject.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
final ByteBuf body = Unpooled.buffer();
- body.writeShort(pk.getPathKey().getValue().shortValue());
+ Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+ writeUnsignedShort(pk.getPathKey().getValue(), body);
+ Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
body.writeBytes(pk.getPceId().getBinary());
- EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);;
+ EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
import org.opendaylight.protocol.pcep.spi.EROSubobjectUtil;
final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writeZero(RESERVED);
- body.writeInt(specObj.getRouterId().intValue());
- body.writeInt(specObj.getInterfaceId().intValue());
+ Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
+ writeUnsignedInt(specObj.getRouterId(), body);
+ Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory");
+ writeUnsignedInt(specObj.getInterfaceId(), body);
EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
}
}
package org.opendaylight.protocol.pcep.impl.subobject;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.LabelParser;
import org.opendaylight.protocol.pcep.spi.LabelSerializer;
import org.opendaylight.protocol.pcep.spi.LabelUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.GeneralizedLabelCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.GeneralizedLabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.generalized.label._case.GeneralizedLabel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.generalized.label._case.GeneralizedLabelBuilder;
/**
@Override
public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject instanceof GeneralizedLabelCase, "Unknown Label Subobject instance. Passed {}. Needed GeneralizedLabelCase.", subobject.getClass());
- final ByteBuf body = Unpooled.wrappedBuffer(((GeneralizedLabelCase) subobject).getGeneralizedLabel().getGeneralizedLabel());
+ final GeneralizedLabel gl = ((GeneralizedLabelCase) subobject).getGeneralizedLabel();
+ Preconditions.checkArgument(gl != null, "GeneralizedLabel is mandatory.");
+ final ByteBuf body = Unpooled.wrappedBuffer(gl.getGeneralizedLabel());
LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Prefix;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
}
final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
- body.writeBytes(Ipv4Util.bytesForPrefix(prefix.getIpv4Prefix()));
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
+ Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
+ writeIpv4Prefix(prefix.getIpv4Prefix(), body);
+ writeBitSet(flags, FLAGS_F_LENGTH, body);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Prefix;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
}
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
- body.writeBytes(Ipv6Util.bytesForPrefix(prefix.getIpv6Prefix()));
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
+ Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory.");
+ writeIpv6Prefix(prefix.getIpv6Prefix(), body);
+ writeBitSet(flags, FLAGS_F_LENGTH, body);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.subobject.subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
final ByteBuf body = Unpooled.buffer();
- body.writeShort(pk.getPathKey().getValue().shortValue());
+ Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+ writeUnsignedShort(pk.getPathKey().getValue(), body);
+ Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
body.writeBytes(pk.getPceId().getBinary());
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.subobject.subobject.type.path.key._case.PathKey pk = pkcase.getPathKey();
final ByteBuf body = Unpooled.buffer();
- body.writeShort(pk.getPathKey().getValue().shortValue());
+ Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+ writeUnsignedShort(pk.getPathKey().getValue(), body);
+ Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
body.writeBytes(pk.getPceId().getBinary());
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeBitSet;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.RROSubobjectSerializer;
flags.set(LPIU_F_OFFSET, subobject.isProtectionInUse());
}
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
+ writeBitSet(flags, FLAGS_F_LENGTH, body);
body.writeZero(RESERVED);
- body.writeInt(specObj.getRouterId().intValue());
- body.writeInt(specObj.getInterfaceId().intValue());
+ Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
+ writeUnsignedInt(specObj.getRouterId(), body);
+ Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
+ writeUnsignedInt(specObj.getInterfaceId(), body);
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.LabelParser;
import org.opendaylight.protocol.pcep.spi.LabelSerializer;
import org.opendaylight.protocol.pcep.spi.LabelUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.Type1LabelCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.Type1LabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.type1.label._case.Type1Label;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.type1.label._case.Type1LabelBuilder;
/**
@Override
public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject instanceof Type1LabelCase, "Unknown Label Subobject instance. Passed {}. Needed Type1LabelCase.", subobject.getClass());
- LabelUtil.formatLabel(CTYPE, unidirectional, global, Unpooled.copyInt(
- ((Type1LabelCase) subobject).getType1Label().getType1Label().intValue()), buffer);
+ final ByteBuf body = Unpooled.buffer(LABEL_LENGTH);
+ final Type1Label type1Label = ((Type1LabelCase) subobject).getType1Label();
+ Preconditions.checkArgument(type1Label != null, "Type1Label is mandatory.");
+ writeUnsignedInt(type1Label.getType1Label(), body);
+ LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.LabelParser;
import org.opendaylight.protocol.pcep.spi.LabelSerializer;
import org.opendaylight.protocol.pcep.spi.LabelUtil;
Preconditions.checkArgument(subobject instanceof WavebandSwitchingLabelCase, "Unknown Label Subobject instance. Passed {}. Needed WavebandSwitchingLabelCase.", subobject.getClass());
final WavebandSwitchingLabel obj = ((WavebandSwitchingLabelCase) subobject).getWavebandSwitchingLabel();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
- body.writeInt(obj.getWavebandId().intValue());
- body.writeInt(obj.getStartLabel().intValue());
- body.writeInt(obj.getEndLabel().intValue());
+ Preconditions.checkArgument(obj.getWavebandId() != null, "WavebandId is mandatory.");
+ writeUnsignedInt(obj.getWavebandId(), body);
+ Preconditions.checkArgument(obj.getStartLabel() != null, "StartLabel is mandatory.");
+ writeUnsignedInt(obj.getStartLabel(), body);
+ Preconditions.checkArgument(obj.getEndLabel() != null, "EndLabel is mandatory.");
+ writeUnsignedInt(obj.getEndLabel(), body);
LabelUtil.formatLabel(CTYPE, unidirectional, global, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
Preconditions.checkArgument(subobject.getSubobjectType() instanceof AsNumberCase, "Unknown subobject instance. Passed %s. Needed AsNumberCase.", subobject.getSubobjectType().getClass());
- final AsNumberSubobject s = ((AsNumberCase) subobject.getSubobjectType()).getAsNumber();
- XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), Unpooled.copyShort(s.getAsNumber().getValue().shortValue()), buffer);
+ final AsNumberSubobject asNumber = ((AsNumberCase) subobject.getSubobjectType()).getAsNumber();
+ final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
+ Preconditions.checkArgument(asNumber.getAsNumber() != null, "AsNumber is mandatory.");
+ writeShort(asNumber.getAsNumber().getValue().shortValue(), body);
+ XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv4Prefix;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
new XROIpv6PrefixSubobjectParser().serializeSubobject(subobject, buffer);
} else {
final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
- body.writeBytes(Ipv4Util.bytesForPrefix(prefix.getIpv4Prefix()));
- body.writeByte(subobject.getAttribute().getIntValue());
+ Preconditions.checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
+ writeIpv4Prefix(prefix.getIpv4Prefix(), body);
+ Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
+ writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeIpv6Prefix;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
final IpPrefix prefix = specObj.getIpPrefix();
final ByteBuf body = Unpooled.buffer(CONTENT6_LENGTH);
- body.writeBytes(Ipv6Util.bytesForPrefix(prefix.getIpv6Prefix()));
- body.writeByte(subobject.getAttribute().getIntValue());
+ Preconditions.checkArgument(prefix.getIpv6Prefix() != null, "Ipv6Prefix is mandatory.");
+ writeIpv6Prefix(prefix.getIpv6Prefix(), body);
+ Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
+ writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.subobject.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
final ByteBuf body = Unpooled.buffer();
- body.writeShort(pk.getPathKey().getValue().shortValue());
+ Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+ writeUnsignedShort(pk.getPathKey().getValue(), body);
+ Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
body.writeBytes(pk.getPceId().getBinary());
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.subobject.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
final ByteBuf body = Unpooled.buffer();
- body.writeShort(pk.getPathKey().getValue().shortValue());
+ Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+ writeUnsignedShort(pk.getPathKey().getValue(), body);
+ Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
body.writeBytes(pk.getPceId().getBinary());
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
Preconditions.checkArgument(subobject.getSubobjectType() instanceof SrlgCase, "Unknown subobject instance. Passed %s. Needed SrlgCase.", subobject.getSubobjectType().getClass());
final SrlgSubobject specObj = ((SrlgCase) subobject.getSubobjectType()).getSrlg();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
- body.writeInt(specObj.getSrlgId().getValue().intValue());
- body.writeByte(subobject.getAttribute().getIntValue());
+ Preconditions.checkArgument(specObj.getSrlgId() != null, "SrlgId is mandatory.");
+ writeUnsignedInt(specObj.getSrlgId().getValue(), body);
+ Preconditions.checkArgument(subobject.getAttribute() != null, "Attribute is mandatory.");
+ writeUnsignedByte((short) subobject.getAttribute().getIntValue(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedByte;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
final UnnumberedSubobject specObj = ((UnnumberedCase) subobject.getSubobjectType()).getUnnumbered();
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
body.writeZero(RESERVED);
- body.writeByte(subobject.getAttribute().getIntValue());
- body.writeInt(specObj.getRouterId().intValue());
- body.writeInt(specObj.getInterfaceId().intValue());
+ writeUnsignedByte(subobject.getAttribute() != null ? (short) subobject.getAttribute().getIntValue() : null, body);
+ Preconditions.checkArgument(specObj.getRouterId() != null, "RouterId is mandatory.");
+ writeUnsignedInt(specObj.getRouterId(), body);
+ Preconditions.checkArgument(specObj.getInterfaceId() != null, "InterfaceId is mandatory.");
+ writeUnsignedInt(specObj.getInterfaceId(), body);
XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.tlv;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
final VsTlv vsTlv = (VsTlv) tlv;
final ByteBuf body = Unpooled.buffer();
if (vsTlv.getEnterpriseNumber().getValue() == getEnterpriseNumber()) {
- body.writeInt(vsTlv.getEnterpriseNumber().getValue().intValue());
+ Preconditions.checkArgument(vsTlv.getEnterpriseNumber() != null, "EnterpriseNumber is mandatory.");
+ writeUnsignedInt(vsTlv.getEnterpriseNumber().getValue(), body);
serializeVendorPayload(vsTlv.getVendorPayload(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
package org.opendaylight.protocol.pcep.impl.tlv;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.BitSet;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
import org.opendaylight.protocol.pcep.spi.TlvUtil;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVector;
if (f.isPceUnavailable() != null) {
flags.set(PCE_UNAVAILABLE, f.isPceUnavailable());
}
- body.writeBytes(ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH));
+ ByteBufWriteUtil.writeBitSet(flags, FLAGS_F_LENGTH, body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.tlv;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
-
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.util.List;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
final ByteBuf body = Unpooled.buffer();
final List<OfId> ofCodes = oft.getCodes();
for (OfId id : ofCodes) {
- body.writeShort(id.getValue().shortValue());
+ writeUnsignedShort(id.getValue(), body);
}
TlvUtil.formatTlv(TYPE, body, buffer);
}
*/
package org.opendaylight.protocol.pcep.impl.tlv;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
Preconditions.checkArgument(tlv != null, "OrderTlv is mandatory.");
final Order otlv = (Order) tlv;
final ByteBuf body = Unpooled.buffer();
- body.writeInt(otlv.getDelete().intValue());
- body.writeInt(otlv.getSetup().intValue());
+ writeUnsignedInt(otlv.getDelete(), body);
+ writeUnsignedInt(otlv.getSetup(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.tlv;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
Preconditions.checkArgument(tlv != null, "OverloadedTlv is mandatory.");
- TlvUtil.formatTlv(TYPE, Unpooled.copyInt(((OverloadDuration) tlv).getDuration().intValue()), buffer);
+ final ByteBuf body = Unpooled.buffer();
+ writeUnsignedInt(((OverloadDuration) tlv).getDuration(), body);
+ TlvUtil.formatTlv(TYPE, body, buffer);
}
}
*/
package org.opendaylight.protocol.pcep.impl.tlv;
-import com.google.common.base.Preconditions;
+import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedInt;
+import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
Preconditions.checkArgument(tlv != null, "ReqMissingTlv is mandatory.");
final ReqMissing req = (ReqMissing) tlv;
final ByteBuf body = Unpooled.buffer();
- body.writeInt(req.getRequestId().getValue().intValue());
+ Preconditions.checkArgument(req.getRequestId() != null, "RequestId is mandatory.");
+ writeUnsignedInt(req.getRequestId().getValue(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
}
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject2UpperBounds.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject2WithTLV.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
- assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
@Test
assertTrue(object instanceof UnknownObject);
assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_CLASS, ((UnknownObject) object).getError());
}
+
+ @Test
+ public void testLspaObjectSerializerDefence() throws IOException, PCEPDeserializerException {
+ final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry);
+ ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
+
+ final LspaBuilder builder = new LspaBuilder();
+ builder.setProcessingRule(true);
+ builder.setIgnore(true);
+ builder.setLocalProtectionDesired(false);
+
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeObject(builder.build(), buf);
+ assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
+ }
}