use of org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException in project bgpcep by opendaylight.
the class XROIpv6PrefixSubobjectParser 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.");
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setMandatory(mandatory);
if (buffer.readableBytes() != CONTENT6_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
}
final int length = buffer.getUnsignedByte(PREFIX6_F_OFFSET);
final IpPrefixBuilder prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv6Util.IPV6_LENGTH), length)));
builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix.build()).build());
buffer.skipBytes(PREFIX_F_LENGTH);
builder.setAttribute(ExcludeRouteSubobjects.Attribute.forValue(buffer.readUnsignedByte()));
return builder.build();
}
use of org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException in project bgpcep by opendaylight.
the class EROUnnumberedInterfaceSubobjectParser 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() != CONTENT_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; Expected: " + CONTENT_LENGTH + ".");
}
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setLoose(loose);
buffer.skipBytes(RESERVED);
builder.setSubobjectType(parseUnnumeredInterface(buffer));
return builder.build();
}
use of org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException in project bgpcep by opendaylight.
the class RROIpv4PrefixSubobjectParser 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() != CONTENT4_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
}
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
final int length = buffer.getUnsignedByte(PREFIX4_F_OFFSET);
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefix prefix = new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv4Util.prefixForBytes(ByteArray.readBytes(buffer, Ipv4Util.IP4_LENGTH), length))).build();
buffer.skipBytes(PREFIX_F_LENGTH);
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
builder.setProtectionAvailable(flags.get(LPA_F_OFFSET));
builder.setProtectionInUse(flags.get(LPIU_F_OFFSET));
builder.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(prefix).build());
return builder.build();
}
use of org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException in project bgpcep by opendaylight.
the class XROPathKey128SubobjectParser 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() != CONTENT128_LENGTH) {
throw new RSVPParsingException("Wrong length of array of bytes. Passed: " + buffer.readableBytes() + "; " + "Expected: >" + CONTENT128_LENGTH + ".");
}
final SubobjectContainerBuilder builder = new SubobjectContainerBuilder();
builder.setMandatory(mandatory);
builder.setSubobjectType(new PathKeyCaseBuilder().setPathKey(parsePathKey(PCE128_ID_F_LENGTH, buffer)).build());
return builder.build();
}
use of org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException in project bgpcep by opendaylight.
the class TeLspAttributesParser method parseTeLspAttributes.
static LinkStateAttribute parseTeLspAttributes(final RSVPTeObjectRegistry registry, final ByteBuf attributes) throws BGPParsingException {
final TeLspAttributesBuilder builder = new TeLspAttributesBuilder();
LOG.trace("Initiated parsing TE LSP Objects.");
while (attributes.isReadable()) {
final int length = attributes.readUnsignedShort();
final int classNum = attributes.readUnsignedByte();
final int cType = attributes.readUnsignedByte();
final ByteBuf value = attributes.readSlice(length);
try {
addObject(builder, registry.parseRSPVTe(classNum, cType, value));
} catch (final RSVPParsingException e) {
LOG.debug("Parsering TE LSP Object error. class number: {} cType: {} value: {}", classNum, cType, value, e);
throw new BGPParsingException(e.getMessage());
}
}
LOG.trace("Finished parsing TE LSP Objects.");
return new TeLspAttributesCaseBuilder().setTeLspAttributes(builder.build()).build();
}
Aggregations