Search in sources :

Example 1 with ProtectionSubobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject in project bgpcep by opendaylight.

the class SEROBasicProtectionSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof BasicProtectionCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", subobject.getSubobjectType());
    final ProtectionSubobject protObj = ((BasicProtectionCase) subobject.getSubobjectType()).getBasicProtection().getProtectionSubobject();
    final ByteBuf body = Unpooled.buffer();
    serializeBody(CTYPE, protObj, body);
    EROSubobjectUtil.formatSubobject(TYPE, subobject.isLoose(), body, buffer);
}
Also used : BasicProtectionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.BasicProtectionCase) ByteBuf(io.netty.buffer.ByteBuf) ProtectionSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject)

Example 2 with ProtectionSubobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject in project bgpcep by opendaylight.

the class SEROBasicProtectionSubobjectParser 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.");
    final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
    builder.setLoose(loose);
    // skip reserved
    buffer.readByte();
    final short cType = buffer.readUnsignedByte();
    final ProtectionSubobject prot = parseCommonProtectionBody(cType, buffer);
    if (cType == CTYPE) {
        builder.setSubobjectType(new BasicProtectionCaseBuilder().setBasicProtection(new BasicProtectionBuilder().setProtectionSubobject(prot).build()).build());
    } else if (cType == SERODynamicProtectionSubobjectParser.CTYPE) {
        builder.setSubobjectType(new DynamicControlProtectionCaseBuilder().setDynamicControlProtection(new DynamicControlProtectionBuilder().setProtectionSubobject(prot).build()).build());
    }
    return builder.build();
}
Also used : BasicProtectionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.BasicProtectionCaseBuilder) DynamicControlProtectionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.dynamic.control.protection._case.DynamicControlProtectionBuilder) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder) DynamicControlProtectionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.DynamicControlProtectionCaseBuilder) ProtectionSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject) BasicProtectionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.basic.protection._case.BasicProtectionBuilder)

Example 3 with ProtectionSubobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject in project bgpcep by opendaylight.

the class ProtectionCommonParser method parseCommonProtectionBodyType1.

protected static ProtectionSubobject parseCommonProtectionBodyType1(final ByteBuf byteBuf) {
    final BitArray bitArray = BitArray.valueOf(byteBuf.readByte());
    final ProtectionSubobjectBuilder sub = new ProtectionSubobjectBuilder();
    sub.setSecondary(bitArray.get(SECONDARY));
    // Skip Reserved
    byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
    final int linkFlags = byteBuf.readByte();
    sub.setLinkFlags(LinkFlags.forValue(linkFlags));
    return sub.build();
}
Also used : ProtectionSubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobjectBuilder) BitArray(org.opendaylight.protocol.util.BitArray)

Example 4 with ProtectionSubobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject in project bgpcep by opendaylight.

the class ProtectionCommonParser method parseCommonProtectionBodyType2.

protected static ProtectionSubobject parseCommonProtectionBodyType2(final ByteBuf byteBuf) throws RSVPParsingException {
    if (byteBuf.readableBytes() != CONTENT_LENGTH_C2) {
        throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + byteBuf.readableBytes() + "; " + "Expected: " + CONTENT_LENGTH_C2 + ".");
    }
    final ProtectionSubobjectBuilder sub = new ProtectionSubobjectBuilder();
    final BitArray protectionFlag = BitArray.valueOf(byteBuf.readByte());
    sub.setSecondary(protectionFlag.get(SECONDARY));
    sub.setProtecting(protectionFlag.get(PROTECTING));
    sub.setNotification(protectionFlag.get(NOTIFICATION));
    sub.setOperational(protectionFlag.get(OPERATIONAL));
    final int lspFlags = byteBuf.readByte();
    sub.setLspFlag(LspFlag.forValue(lspFlags)).build();
    // Skip Reserved
    byteBuf.skipBytes(ByteBufWriteUtil.ONE_BYTE_LENGTH);
    final int linkFlags = byteBuf.readByte();
    sub.setLinkFlags(LinkFlags.forValue(linkFlags));
    final BitArray bitArray2 = BitArray.valueOf(byteBuf.readByte());
    sub.setInPlace(bitArray2.get(IN_PLACE));
    sub.setRequired(bitArray2.get(REQUIRED));
    final int segFlags = byteBuf.readByte();
    sub.setSegFlag(LspFlag.forValue(segFlags));
    byteBuf.skipBytes(ByteBufWriteUtil.SHORT_BYTES_LENGTH);
    return sub.build();
}
Also used : ProtectionSubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobjectBuilder) BitArray(org.opendaylight.protocol.util.BitArray) RSVPParsingException(org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)

Example 5 with ProtectionSubobject

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject in project bgpcep by opendaylight.

the class ProtectionObjectParser method localParseObject.

@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
    final BasicProtectionObjectBuilder builder = new BasicProtectionObjectBuilder();
    final ProtectionSubobject pSub = ProtectionCommonParser.parseCommonProtectionBodyType1(byteBuf);
    return builder.setProtectionSubobject(pSub).build();
}
Also used : BasicProtectionObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.BasicProtectionObjectBuilder) ProtectionSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject)

Aggregations

ProtectionSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject)8 ByteBuf (io.netty.buffer.ByteBuf)4 BitArray (org.opendaylight.protocol.util.BitArray)2 ProtectionSubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobjectBuilder)2 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)1 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder)1 BasicProtectionObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.BasicProtectionObjectBuilder)1 DynamicControlProtectionObjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.DynamicControlProtectionObjectBuilder)1 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.list.SubobjectContainerBuilder)1 BasicProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.BasicProtectionCase)1 BasicProtectionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.BasicProtectionCaseBuilder)1 DynamicControlProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.DynamicControlProtectionCase)1 DynamicControlProtectionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.DynamicControlProtectionCaseBuilder)1 BasicProtectionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.basic.protection._case.BasicProtectionBuilder)1 DynamicControlProtectionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.dynamic.control.protection._case.DynamicControlProtectionBuilder)1 BasicProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.secondary.record.route.object.subobject.container.subobject.type.BasicProtectionCase)1 BasicProtectionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.secondary.record.route.object.subobject.container.subobject.type.BasicProtectionCaseBuilder)1 DynamicControlProtectionCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.secondary.record.route.object.subobject.container.subobject.type.DynamicControlProtectionCase)1 DynamicControlProtectionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.secondary.record.route.object.subobject.container.subobject.type.DynamicControlProtectionCaseBuilder)1 BasicProtectionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.record.route.object.secondary.record.route.object.subobject.container.subobject.type.basic.protection._case.BasicProtectionBuilder)1