Search in sources :

Example 1 with UnreachDestinationObj

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObj in project bgpcep by opendaylight.

the class PCEPIpv4UnreachDestinationParser method parseObject.

@Override
public UnreachDestinationObj 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 UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
    if (bytes.readableBytes() % Ipv4Util.IP4_LENGTH != 0) {
        throw new PCEPDeserializerException("Wrong length of array of bytes.");
    }
    builder.setIgnore(header.getIgnore());
    builder.setProcessingRule(header.getProcessingRule());
    List<Ipv4AddressNoZone> dest = new ArrayList<>();
    while (bytes.isReadable()) {
        dest.add(Ipv4Util.addressForByteBuf(bytes));
    }
    builder.setDestination(new Ipv4DestinationCaseBuilder().setDestinationIpv4Address(dest).build());
    return builder.build();
}
Also used : Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) ArrayList(java.util.ArrayList) UnreachDestinationObjBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObjBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) Ipv4DestinationCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCaseBuilder)

Example 2 with UnreachDestinationObj

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObj in project bgpcep by opendaylight.

the class PCEPUnreachDestinationSerializer method serializeObject.

@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
    Preconditions.checkArgument(object instanceof UnreachDestinationObj, "Wrong instance of PCEPObject. Passed %s. Needed UnreachDestinationObj.", object.getClass());
    final UnreachDestinationObj uPObj = (UnreachDestinationObj) object;
    final Destination destination = uPObj.getDestination();
    final Boolean processing = object.getProcessingRule();
    final Boolean ignore = object.getIgnore();
    if (destination instanceof Ipv6DestinationCase) {
        final Ipv6DestinationCase ipv6 = (Ipv6DestinationCase) destination;
        PCEPIpv6UnreachDestinationParser.serializeObject(processing, ignore, ipv6, buffer);
    } else if (destination instanceof Ipv4DestinationCase) {
        final Ipv4DestinationCase ipv4 = (Ipv4DestinationCase) destination;
        PCEPIpv4UnreachDestinationParser.serializeObject(processing, ignore, ipv4, buffer);
    }
}
Also used : Destination(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination) Ipv6DestinationCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCase) Ipv4DestinationCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCase) UnreachDestinationObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObj)

Example 3 with UnreachDestinationObj

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObj in project bgpcep by opendaylight.

the class PCEPIpv6UnreachDestinationParser method parseObject.

@Override
public UnreachDestinationObj 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 UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
    if (bytes.readableBytes() % Ipv6Util.IPV6_LENGTH != 0) {
        throw new PCEPDeserializerException("Wrong length of array of bytes.");
    }
    builder.setIgnore(header.getIgnore());
    builder.setProcessingRule(header.getProcessingRule());
    List<Ipv6AddressNoZone> dest = new ArrayList<>();
    while (bytes.isReadable()) {
        dest.add(Ipv6Util.addressForByteBuf(bytes));
    }
    return builder.setDestination(new Ipv6DestinationCaseBuilder().setDestinationIpv6Address(dest).build()).build();
}
Also used : ArrayList(java.util.ArrayList) Ipv6DestinationCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCaseBuilder) UnreachDestinationObjBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObjBuilder) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) Ipv6AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone)

Aggregations

ArrayList (java.util.ArrayList)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 UnreachDestinationObjBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObjBuilder)2 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)1 Ipv6AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone)1 UnreachDestinationObj (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObj)1 Destination (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination)1 Ipv4DestinationCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCase)1 Ipv4DestinationCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCaseBuilder)1 Ipv6DestinationCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCase)1 Ipv6DestinationCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCaseBuilder)1