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 java.util.List;
import org.opendaylight.protocol.pcep.spi.AbstractObjectWithTlvsParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.TlvRegistry;
import org.opendaylight.protocol.pcep.spi.UnknownObject;
+import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final int PCEP_VERSION = 1;
- public PCEPOpenObjectParser(final TlvRegistry tlvReg) {
- super(tlvReg);
+ public PCEPOpenObjectParser(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ super(tlvReg, viTlvReg);
}
@Override
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);
}
if (tlvs.getOfList() != null) {
serializeTlv(tlvs.getOfList(), body);
}
+ serializeVendorInformationTlvs(tlvs.getVendorInformationTlv(), body);
+ }
+
+ @Override
+ protected final void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
+ if (!tlvs.isEmpty()) {
+ builder.setVendorInformationTlv(tlvs);
+ }
}
}