use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType in project bgpcep by opendaylight.
the class EROLabelSubobjectParser method parseSubobject.
@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() < HEADER_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >" + HEADER_LENGTH + ".");
}
final BitArray reserved = BitArray.valueOf(buffer, FLAGS_SIZE);
final short cType = buffer.readUnsignedByte();
final LabelType labelType = this.registry.parseLabel(cType, buffer.slice());
if (labelType == null) {
throw new PCEPDeserializerException("Unknown C-TYPE for ero label subobject. Passed: " + cType);
}
final LabelBuilder builder = new LabelBuilder();
builder.setUniDirectional(reserved.get(U_FLAG_OFFSET));
builder.setLabelType(labelType);
return new SubobjectBuilder().setLoose(loose).setSubobjectType(new LabelCaseBuilder().setLabel(builder.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType in project bgpcep by opendaylight.
the class GeneralizedLabelParser method serializeLabel.
@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 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType in project bgpcep by opendaylight.
the class RROLabelSubobjectParser method parseSubobject.
@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() < HEADER_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: >" + HEADER_LENGTH + ".");
}
final BitArray reserved = BitArray.valueOf(buffer, FLAGS_SIZE);
final short cType = buffer.readUnsignedByte();
final LabelType labelType = this.registry.parseLabel(cType, buffer.slice());
if (labelType == null) {
throw new PCEPDeserializerException("Unknown C-TYPE for ero label subobject. Passed: " + cType);
}
final LabelBuilder builder = new LabelBuilder();
builder.setUniDirectional(reserved.get(U_FLAG_OFFSET));
builder.setGlobal(reserved.get(G_FLAG_OFFSET));
builder.setLabelType(labelType);
return new SubobjectBuilder().setSubobjectType(new LabelCaseBuilder().setLabel(builder.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType in project bgpcep by opendaylight.
the class Type1LabelParser method serializeLabel.
@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());
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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType in project bgpcep by opendaylight.
the class EROLabelSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean loose) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() < HEADER_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: >" + HEADER_LENGTH + ".");
}
final BitArray reserved = BitArray.valueOf(buffer, FLAGS_SIZE);
final short cType = buffer.readUnsignedByte();
final LabelType labelType = this.registry.parseLabel(cType, buffer.slice());
if (labelType == null) {
throw new RSVPParsingException("Unknown C-TYPE for ero label subobject. Passed: " + cType);
}
final LabelBuilder builder = new LabelBuilder();
builder.setUniDirectional(reserved.get(U_FLAG_OFFSET));
builder.setLabelType(labelType);
return new SubobjectContainerBuilder().setLoose(loose).setSubobjectType(new LabelCaseBuilder().setLabel(builder.build()).build()).build();
}
Aggregations