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();
}
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);
}
}
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();
}
Aggregations