use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.
the class PCEPSecondaryRecordRouteObjectParser method parseObject.
@Override
public Srro parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), EMPTY_ARRAY_ERROR);
final SrroBuilder builder = new SrroBuilder();
builder.setIgnore(header.getIgnore());
builder.setProcessingRule(header.getProcessingRule());
final List<Subobject> subObjects = parseSubobjects(buffer);
builder.setSubobject(subObjects.stream().map(so -> new SubobjectBuilder().setSubobjectType(so.getSubobjectType()).setProtectionAvailable(so.getProtectionAvailable()).setProtectionInUse(so.getProtectionInUse()).build()).collect(Collectors.toList()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.
the class PCEPIncludeRouteObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof Iro, "Wrong instance of PCEPObject. Passed %s. Needed IroObject.", object.getClass());
final Iro iro = (Iro) object;
final ByteBuf body = Unpooled.buffer();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject> subs = new ArrayList<>();
for (final Subobject s : iro.nonnullSubobject()) {
subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setLoose(s.getLoose()).setSubobjectType(s.getSubobjectType()).build());
}
serializeSubobject(subs, body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.getProcessingRule(), object.getIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.
the class AbstractRROWithSubobjectsParser method parseSubobjects.
protected List<Subobject> parseSubobjects(final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final List<Subobject> subs = new ArrayList<>();
while (buffer.isReadable()) {
final int type = buffer.readUnsignedByte();
final int length = buffer.readUnsignedByte() - HEADER_LENGTH;
if (length > buffer.readableBytes()) {
throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= " + buffer.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
final Subobject sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length));
if (sub == null) {
LOG.warn("Parsing failed for subobject type: {}. Ignoring subobject.", type);
} else {
LOG.debug("Subobject was parsed. {}", sub);
subs.add(sub);
}
}
return subs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.
the class RROUnnumberedInterfaceSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer) throws PCEPDeserializerException {
checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
if (buffer.readableBytes() != CONTENT_LENGTH) {
throw new PCEPDeserializerException("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 SubobjectBuilder().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.pcep.types.rev181109.explicit.route.object.ero.Subobject in project bgpcep by opendaylight.
the class EROExplicitExclusionRouteSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject> xros = parseSubobject(buffer);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.Exrs> exrss = new ArrayList<>();
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject xro : xros) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder exrsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder().setAttribute(xro.getAttribute()).setMandatory(xro.getMandatory()).setSubobjectType(xro.getSubobjectType());
exrss.add(exrsBuilder.build());
}
final SubobjectBuilder builder = new SubobjectBuilder().setLoose(loose).setSubobjectType(new ExrsCaseBuilder().setExrs(new ExrsBuilder().setExrs(exrss).build()).build());
return builder.build();
}
Aggregations