use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class StatefulPCUpdateRequestMessageParser method validatePath.
private static boolean validatePath(final Queue<Object> objects, final List<Message> errors, final UpdatesBuilder builder) {
final PathBuilder pBuilder = new PathBuilder();
Object object = objects.remove();
if (object instanceof Ero) {
pBuilder.setEro((Ero) object);
} else {
errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.empty()));
return false;
}
parsePath(objects, pBuilder);
builder.setPath(pBuilder.build());
return true;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class TopologyProviderTest method createSrEroObject.
private static Ero createSrEroObject(final String nai) {
final SrEroTypeBuilder srEroBuilder = new SrEroTypeBuilder().setCFlag(false).setMFlag(false).setNaiType(NaiType.Ipv4NodeId).setSid(Uint32.valueOf(123456)).setNai(new IpNodeIdBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(nai))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(srEroBuilder.build()).setLoose(false);
final List<Subobject> subobjects = Lists.newArrayList(subobjBuilder.build());
return new EroBuilder().setProcessingRule(false).setIgnore(false).setSubobject(subobjects).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class MessagesUtil method getEro.
public static Ero getEro(final List<PathDescription> pathDescriptions) {
/* Prepare ERO */
final EroBuilder eroBuilder = new EroBuilder().setIgnore(false).setProcessingRule(true);
final List<Subobject> eroSubs = new ArrayList<>();
/* Fulfill ERO sublist */
for (PathDescription path : pathDescriptions) {
Subobject sb = null;
if (path.getSid() == null) {
IpPrefix ipPref = null;
/* Prepare SubObject for IPv4 or IPv6 address */
if (path.getIpv4() != null) {
final Ipv4Prefix ipv4Pref = new Ipv4Prefix(path.getIpv4().getValue() + "/32");
ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv4Pref)).build();
}
if (path.getIpv6() != null) {
final Ipv6Prefix ipv6Pref = new Ipv6Prefix(path.getIpv6().getValue() + "/128");
ipPref = new IpPrefixBuilder().setIpPrefix(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix(ipv6Pref)).build();
}
if (ipPref != null) {
final IpPrefixCase ipPrefCase = new IpPrefixCaseBuilder().setIpPrefix(ipPref).build();
sb = new SubobjectBuilder().setSubobjectType(ipPrefCase).setLoose(false).build();
}
} else {
/* Prepare SubObject for Segment Routing */
SrEroType srEro = null;
if (path.getLocalIpv4() != null && path.getRemoteIpv4() != null) {
srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv4Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getLocalIpv4().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(path.getRemoteIpv4().getValue()))).build()).build();
}
if (path.getLocalIpv6() != null && path.getRemoteIpv6() != null) {
srEro = new SrEroTypeBuilder().setNaiType(NaiType.Ipv6Adjacency).setSid(path.getSid()).setCFlag(false).setMFlag(true).setNai(new IpAdjacencyBuilder().setLocalIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getLocalIpv6().getValue()))).setRemoteIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone(path.getRemoteIpv6().getValue()))).build()).build();
}
if (srEro != null) {
sb = new SubobjectBuilder().setSubobjectType(srEro).setLoose(false).build();
}
}
/* Add corresponding SubObject to the ERO List */
if (sb != null) {
eroSubs.add(sb);
}
}
/* Set ERO sublist */
eroBuilder.setSubobject(eroSubs);
return eroBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class MessagesUtil method buildPath.
private static PathsBuilder buildPath(final ConstrainedPath cpath) {
final PathsBuilder pathBuilder = new PathsBuilder();
/* Get ERO from Path Description */
pathBuilder.setEro(getEro(cpath.getPathDescription()));
/* Fulfill Computed Metrics if available */
final ArrayList<Metrics> metrics = new ArrayList<>();
if (cpath.getMetric() != null) {
final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(IGP_METRIC)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getMetric().floatValue()).array()));
metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
}
if (cpath.getTeMetric() != null) {
final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(TE_METRIC)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getTeMetric().floatValue()).array()));
metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
}
if (cpath.getDelay() != null) {
final MetricBuilder metricBuilder = new MetricBuilder().setComputed(true).setMetricType(Uint8.valueOf(PATH_DELAY)).setValue(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getDelay().getValue().floatValue()).array()));
metrics.add(new MetricsBuilder().setMetric(metricBuilder.build()).build());
}
if (!metrics.isEmpty()) {
pathBuilder.setMetrics(metrics);
}
/* Fulfill Bandwidth and ClassType if set */
if (cpath.getBandwidth() != null) {
final BandwidthBuilder bwBuilder = new BandwidthBuilder();
bwBuilder.setBandwidth(new Bandwidth(new Float32(ByteBuffer.allocate(4).putFloat(cpath.getBandwidth().getValue().floatValue()).array())));
pathBuilder.setBandwidth(bwBuilder.build());
}
if (cpath.getClassType() != null && !cpath.getClassType().equals(Uint8.ZERO)) {
pathBuilder.setClassType(new ClassTypeBuilder().setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType(cpath.getClassType())).build());
}
return pathBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero in project bgpcep by opendaylight.
the class EROSubobjectListParser method parseList.
public List<SubobjectContainer> parseList(final ByteBuf buffer) throws RSVPParsingException {
// Explicit approval of empty ERO
Preconditions.checkArgument(buffer != null, "Array of bytes is mandatory. Can't be null.");
final List<SubobjectContainer> subs = new ArrayList<>();
while (buffer.isReadable()) {
final boolean loose = (buffer.getUnsignedByte(buffer.readerIndex()) & (1 << Values.FIRST_BIT_OFFSET)) != 0;
final int type = (buffer.readUnsignedByte() & Values.BYTE_MAX_VALUE_BYTES) & ~(1 << Values.FIRST_BIT_OFFSET);
final int length = buffer.readUnsignedByte() - HEADER_LENGTH;
if (length > buffer.readableBytes()) {
throw new RSVPParsingException("Wrong length specified. Passed: " + length + "; Expected: <= " + buffer.readableBytes());
}
LOG.debug("Attempt to parse subobject from bytes: {}", ByteBufUtil.hexDump(buffer));
final SubobjectContainer sub = this.subobjReg.parseSubobject(type, buffer.readSlice(length), loose);
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;
}
Aggregations