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);
}
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();
}
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();
}
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();
}
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();
}
Aggregations