use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPPathKeyObjectParser method parseObject.
@Override
public PathKey parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final List<PathKeys> pk = new ArrayList<>();
final List<Subobject> subs = parseSubobjects(bytes);
for (final Subobject sub : subs) {
final PathKeyCase pkc = (PathKeyCase) sub.getSubobjectType();
pk.add(new PathKeysBuilder().setLoose(sub.getLoose()).setPceId(pkc.getPathKey().getPceId()).setPathKey(pkc.getPathKey().getPathKey()).build());
}
return new PathKeyBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setPathKeys(pk).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPSecondaryExplicitRouteObjecParser method parseObject.
@Override
public Sero parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), EMPTY_ARRAY_ERROR);
final SeroBuilder builder = new SeroBuilder();
builder.setIgnore(header.getIgnore());
builder.setProcessingRule(header.getProcessingRule());
final List<Subobject> subObjects = parseSubobjects(buffer);
builder.setSubobject(subObjects.stream().map(so -> new SubobjectBuilder().setLoose(so.getLoose()).setSubobjectType(so.getSubobjectType()).build()).collect(Collectors.toList()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPEndPointsIpv6ObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final EndpointsObjBuilder builder = new EndpointsObjBuilder();
if (!header.getProcessingRule()) {
LOG.debug("Processed bit not set on Endpoints OBJECT, ignoring it.");
return new UnknownObject(PCEPErrors.P_FLAG_NOT_SET, builder.build());
}
if (bytes.readableBytes() != Ipv6Util.IPV6_LENGTH * 2) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
final Ipv6Builder ipv6bldr = new Ipv6Builder().setSourceIpv6Address(Ipv6Util.addressForByteBuf(bytes)).setDestinationIpv6Address(Ipv6Util.addressForByteBuf(bytes));
return builder.setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setAddressFamily(new Ipv6CaseBuilder().setIpv6(ipv6bldr.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPP2MPEndPointsIpv4ObjectParser method parseObject.
@Override
public Object parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final EndpointsObjBuilder builder = new EndpointsObjBuilder();
if (!header.getProcessingRule()) {
LOG.debug("Processed bit not set on Endpoints OBJECT, ignoring it.");
return new UnknownObject(PCEPErrors.P_FLAG_NOT_SET, builder.build());
}
if (bytes.readableBytes() % Ipv4Util.IP4_LENGTH != 0) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
builder.setIgnore(header.getIgnore());
builder.setProcessingRule(header.getProcessingRule());
final P2mpIpv4Builder p2mpIpv4Builder = new P2mpIpv4Builder();
p2mpIpv4Builder.setP2mpLeaves(P2mpLeaves.forValue(bytes.readInt()));
p2mpIpv4Builder.setSourceIpv4Address(Ipv4Util.addressForByteBuf(bytes));
List<Ipv4AddressNoZone> dest = new ArrayList<>();
while (bytes.isReadable()) {
dest.add(Ipv4Util.addressForByteBuf(bytes));
}
p2mpIpv4Builder.setDestinationIpv4Address(dest);
builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(p2mpIpv4Builder.build()).build());
return builder.build();
}
Aggregations