use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getRequests.
protected List<Requests> getRequests(final List<Object> objects, final List<Message> errors) {
final List<Requests> requests = new ArrayList<>();
while (!objects.isEmpty()) {
final RequestsBuilder rBuilder = new RequestsBuilder();
Rp rpObj = null;
if (!(objects.get(0) instanceof Rp)) {
// if RP obj is missing return error only
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
return null;
}
rpObj = (Rp) objects.get(0);
objects.remove(0);
if (!rpObj.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
} else {
rBuilder.setRp(rpObj);
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
if (!vendorInfo.isEmpty()) {
rBuilder.setVendorInformationObject(vendorInfo);
}
// expansion
if (rpObj.isPathKey() && objects.get(0) instanceof PathKey) {
rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) objects.get(0)).build());
}
final P2pBuilder p2pBuilder = new P2pBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof EndpointsObj) {
final EndpointsObj ep = (EndpointsObj) objects.get(0);
objects.remove(0);
if (!ep.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
} else {
p2pBuilder.setEndpointsObj(ep);
}
} else {
errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
return null;
}
// p2p
if (!rpObj.isP2mp()) {
final SegmentComputation segm = getSegmentComputation(p2pBuilder, objects, errors, rpObj);
if (segm != null) {
rBuilder.setSegmentComputation(segm);
}
}
requests.add(rBuilder.build());
}
return requests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PCEPEndPointsIpv6ObjectParser method serializeObject.
public static void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof EndpointsObj, "Wrong instance of PCEPObject. Passed %s. Needed EndpointsObject.", object.getClass());
final EndpointsObj ePObj = (EndpointsObj) object;
final AddressFamily afi = ePObj.getAddressFamily();
Preconditions.checkArgument(afi instanceof Ipv6Case, "Wrong instance of NetworkAddress. Passed %s. Needed IPv6", afi.getClass());
final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH + Ipv6Util.IPV6_LENGTH);
final Ipv6 ipv6 = ((Ipv6Case) afi).getIpv6();
Preconditions.checkArgument(ipv6.getSourceIpv6Address() != null, "SourceIpv6Address is mandatory.");
writeIpv6Address(ipv6.getSourceIpv6Address(), body);
Preconditions.checkArgument(ipv6.getDestinationIpv6Address() != null, "DestinationIpv6Address is mandatory.");
writeIpv6Address(ipv6.getDestinationIpv6Address(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PCEPEndPointsIpv4ObjectParser method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof EndpointsObj, "Wrong instance of PCEPObject. Passed %s. Needed EndpointsObject.", object.getClass());
final EndpointsObj ePObj = (EndpointsObj) object;
final AddressFamily afi = ePObj.getAddressFamily();
if (afi instanceof Ipv6Case) {
PCEPEndPointsIpv6ObjectParser.serializeObject(object, buffer);
}
Preconditions.checkArgument(afi instanceof Ipv4Case, "Wrong instance of NetworkAddress. Passed %s. Needed IPv4", afi.getClass());
final Ipv4 ipv4 = ((Ipv4Case) afi).getIpv4();
final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH + Ipv4Util.IP4_LENGTH);
Preconditions.checkArgument(ipv4.getSourceIpv4Address() != null, "SourceIpv4Address is mandatory.");
writeIpv4Address(ipv4.getSourceIpv4Address(), body);
Preconditions.checkArgument(ipv4.getDestinationIpv4Address() != null, "DestinationIpv4Address is mandatory.");
writeIpv4Address(ipv4.getDestinationIpv4Address(), body);
ObjectUtil.formatSubobject(TYPE, CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PCEPEndPointsObjectSerializer method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof EndpointsObj, "Wrong instance of PCEPObject. Passed %s. Needed EndpointsObject.", object.getClass());
final EndpointsObj ePObj = (EndpointsObj) object;
final AddressFamily afi = ePObj.getAddressFamily();
final Boolean processing = object.getProcessingRule();
final Boolean ignore = object.getIgnore();
if (afi instanceof Ipv6Case) {
final Ipv6 ipv6 = ((Ipv6Case) afi).getIpv6();
PCEPEndPointsIpv6ObjectParser.serializeObject(processing, ignore, ipv6, buffer);
} else if (afi instanceof Ipv4Case) {
final Ipv4 ipv4 = ((Ipv4Case) afi).getIpv4();
PCEPEndPointsIpv4ObjectParser.serializeObject(processing, ignore, ipv4, buffer);
} else if (afi instanceof P2mpIpv4Case) {
final P2mpIpv4 ipv4 = ((P2mpIpv4Case) afi).getP2mpIpv4();
PCEPP2MPEndPointsIpv4ObjectParser.serializeObject(processing, ignore, ipv4, buffer);
} else if (afi instanceof P2mpIpv6Case) {
final P2mpIpv6 ipv6 = ((P2mpIpv6Case) afi).getP2mpIpv6();
PCEPP2MPEndPointsIpv6ObjectParser.serializeObject(processing, ignore, ipv6, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj in project bgpcep by opendaylight.
the class PathComputationImpl method getDestinationVertexKey.
private VertexKey getDestinationVertexKey(final EndpointsObj endPoints) {
IpAddress address = null;
if (endPoints.getAddressFamily() instanceof Ipv4Case) {
address = new IpAddress(((Ipv4Case) endPoints.getAddressFamily()).getIpv4().getDestinationIpv4Address());
}
if (endPoints.getAddressFamily() instanceof Ipv6Case) {
address = new IpAddress(((Ipv6Case) endPoints.getAddressFamily()).getIpv6().getDestinationIpv6Address());
}
if (address == null) {
return null;
}
ConnectedVertex vertex = tedGraph.getConnectedVertex(address);
LOG.debug("Compute path to Destination {}", vertex != null ? vertex : "Unknown");
return vertex != null ? vertex.getVertex().key() : null;
}
Aggregations