use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class PCEPClassTypeObjectParser method parseObject.
@Override
public Object 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.");
if (!header.isProcessingRule()) {
LOG.debug("Processed bit not set on CLASS TYPE OBJECT, ignoring it");
return null;
}
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: " + bytes.readableBytes());
}
final ClassTypeBuilder builder = new ClassTypeBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
final short ct = (short) bytes.readUnsignedInt();
builder.setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType(ct));
final Object obj = builder.build();
if (ct < 0 || ct > Byte.SIZE) {
LOG.debug("Invalid class type {}", ct);
return new UnknownObject(PCEPErrors.INVALID_CT, obj);
}
return obj;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object 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.rev131005.Object in project bgpcep by opendaylight.
the class PCEPEndPointsIpv4ObjectParser method parseObject.
@Override
public Object 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 EndpointsObjBuilder builder = new EndpointsObjBuilder();
if (!header.isProcessingRule()) {
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 * 2) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
final Ipv4Builder b = new Ipv4Builder();
b.setSourceIpv4Address(Ipv4Util.addressForByteBuf(bytes));
b.setDestinationIpv4Address((Ipv4Util.addressForByteBuf(bytes)));
builder.setAddressFamily(new Ipv4CaseBuilder().setIpv4(b.build()).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class BandwidthUsageObjectCodec method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof BandwidthUsage, "Wrong instance of PCEPObject. Passed %s. Needed BandwidthUsage.", object.getClass());
final List<Bandwidth> bwSample = ((BandwidthUsage) object).getBwSample();
final ByteBuf body = Unpooled.buffer(bwSample.size() * BW_LENGTH);
for (final Bandwidth bw : bwSample) {
writeFloat32(bw, body);
}
ObjectUtil.formatSubobject(getType(), CLASS, object.isProcessingRule(), object.isIgnore(), body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object in project bgpcep by opendaylight.
the class FlowspecL3vpnIpv6NlriParser method createWithdrawnDestinationType.
@Override
public DestinationType createWithdrawnDestinationType(@Nonnull final Object[] nlriFields, @Nullable final PathId pathId) {
final RouteDistinguisher rd = (RouteDistinguisher) nlriFields[0];
final List<Flowspec> flowspecList = (List<Flowspec>) nlriFields[1];
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationFlowspecL3vpnIpv6CaseBuilder().setDestinationFlowspecL3vpnIpv6(new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(rd).setFlowspec(flowspecList).setPathId(pathId).build()).build();
}
Aggregations