Search in sources :

Example 6 with LabelType

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);
}
Also used : GeneralizedLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase) GeneralizedLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.generalized.label._case.GeneralizedLabel) ByteBuf(io.netty.buffer.ByteBuf)

Example 7 with LabelType

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();
}
Also used : LabelType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType) LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.label._case.LabelBuilder) BitArray(org.opendaylight.protocol.util.BitArray) LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.LabelCaseBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)

Example 8 with LabelType

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);
}
Also used : Type1Label(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.type1.label._case.Type1Label) Type1LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase) ByteBuf(io.netty.buffer.ByteBuf)

Example 9 with LabelType

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 SimpleLabelRegistryTest method testParseLabel.

@Test
public void testParseLabel() throws RSVPParsingException {
    final LabelType output = this.simpleLabelRegistry.parseLabel(this.ctype, this.input);
    assertNotNull(output);
    assertTrue(output instanceof MockLabel);
    final ByteBuf aggregator = Unpooled.EMPTY_BUFFER;
    this.simpleLabelRegistry.serializeLabel(false, false, output, aggregator);
    Mockito.verify(this.labelSerializer).serializeLabel(false, false, output, aggregator);
}
Also used : LabelType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 10 with LabelType

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 SubobjectContainer parseSubobject(final ByteBuf buffer) 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.setGlobal(reserved.get(G_FLAG_OFFSET));
    builder.setLabelType(labelType);
    return new SubobjectContainerBuilder().setSubobjectType(new LabelCaseBuilder().setLabel(builder.build()).build()).build();
}
Also used : SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder) LabelType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType) LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.label._case.LabelBuilder) BitArray(org.opendaylight.protocol.util.BitArray) LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.LabelCaseBuilder) RSVPParsingException(org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)7 LabelType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType)5 BitArray (org.opendaylight.protocol.util.BitArray)4 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)3 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)3 LabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCaseBuilder)2 LabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.label._case.LabelBuilder)2 GeneralizedLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase)2 Type1LabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase)2 WavebandSwitchingLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCase)2 WavebandSwitchingLabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCaseBuilder)2 GeneralizedLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.generalized.label._case.GeneralizedLabel)2 Type1Label (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.type1.label._case.Type1Label)2 WavebandSwitchingLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.waveband.switching.label._case.WavebandSwitchingLabel)2 WavebandSwitchingLabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.waveband.switching.label._case.WavebandSwitchingLabelBuilder)2 LabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.LabelCaseBuilder)2 LabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.label._case.LabelBuilder)2 Test (org.junit.Test)1 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)1 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder)1