use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class EROPathKey128SubobjectParser 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() != CONTENT128_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: >" + CONTENT128_LENGTH + ".");
}
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setLoose(loose);
builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(parsePathKey(PCE128_ID_F_LENGTH, buffer)).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class XROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer, final boolean mandatory) throws RSVPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: " + CONTENT_LENGTH + ".");
}
buffer.readerIndex(buffer.readerIndex() + RESERVED);
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setMandatory(mandatory);
builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
builder.setSubobjectType(parseUnnumeredInterface(buffer));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public SubobjectContainer parseSubobject(final ByteBuf buffer) throws RSVPParsingException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: " + CONTENT_LENGTH + ".");
}
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
buffer.skipBytes(RESERVED);
return new SubobjectContainerBuilder().setProtectionAvailable(flags.get(LPA_F_OFFSET)).setProtectionInUse(flags.get(LPIU_F_OFFSET)).setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(ByteBufUtils.readUint32(buffer)).setInterfaceId(ByteBufUtils.readUint32(buffer)).build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof UnnumberedCase, "Unknown subobject instance. Passed %s. Needed UnnumberedCase.", type.getClass());
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(LPA_F_OFFSET, subobject.getProtectionAvailable());
flags.set(LPIU_F_OFFSET, subobject.getProtectionInUse());
final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
flags.toByteBuf(body);
body.writeZero(RESERVED);
final UnnumberedSubobject specObj = ((UnnumberedCase) type).getUnnumbered();
ByteBufUtils.writeMandatory(body, specObj.getRouterId(), "RouterId");
ByteBufUtils.writeMandatory(body, specObj.getInterfaceId(), "InterfaceId");
RROSubobjectUtil.formatSubobject(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.
the class XROIpv4PrefixSubobjectParser method serializeSubobject.
@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
final SubobjectType type = subobject.getSubobjectType();
checkArgument(type instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", type.getClass());
final IpPrefixSubobject specObj = ((IpPrefixCase) type).getIpPrefix();
final IpPrefix prefix = specObj.getIpPrefix();
final Ipv6Prefix ipv6Prefix = prefix.getIpv6Prefix();
if (ipv6Prefix != null) {
XROIpv6PrefixSubobjectParser.serializeSubobject(buffer, subobject, ipv6Prefix);
return;
}
final ByteBuf body = Unpooled.buffer(CONTENT4_LENGTH);
checkArgument(prefix.getIpv4Prefix() != null, "Ipv4Prefix is mandatory.");
Ipv4Util.writeIpv4Prefix(prefix.getIpv4Prefix(), body);
final Attribute attribute = subobject.getAttribute();
checkArgument(attribute != null, "Attribute is mandatory.");
body.writeByte(attribute.getIntValue());
XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
Aggregations