use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPSvecObjectParser method parseObject.
@Override
public Svec 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.");
if (bytes.readableBytes() < MIN_SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.readableBytes() + "; Expected: >=" + MIN_SIZE + ".");
}
bytes.skipBytes(FLAGS_F_OFFSET);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
final List<RequestId> requestIDs = new ArrayList<>();
while (bytes.isReadable()) {
requestIDs.add(new RequestId(ByteBufUtils.readUint32(bytes)));
}
if (requestIDs.isEmpty()) {
throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
}
return new SvecBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setLinkDiverse(flags.get(L_FLAG_OFFSET)).setNodeDiverse(flags.get(N_FLAG_OFFSET)).setSrlgDiverse(flags.get(S_FLAG_OFFSET)).setLinkDirectionDiverse(flags.get(D_FLAG_OFFSET)).setPartialPathDiverse(flags.get(P_FLAG_OFFSET)).setRequestsIds(requestIDs).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPEndPointsIpv4ObjectParser method parseObject.
@Override
public Object 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 EndpointsObjBuilder builder = new EndpointsObjBuilder();
if (!header.getProcessingRule()) {
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.");
}
final Ipv4Builder ipv4bldr = new Ipv4Builder().setSourceIpv4Address(Ipv4Util.addressForByteBuf(bytes)).setDestinationIpv4Address(Ipv4Util.addressForByteBuf(bytes));
builder.setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setAddressFamily(new Ipv4CaseBuilder().setIpv4(ipv4bldr.build()).build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPP2MPEndPointsIpv6ObjectParser method parseObject.
@Override
public Object 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.");
if (!header.getProcessingRule()) {
LOG.debug("Processed bit not set on Endpoints OBJECT, ignoring it.");
return new UnknownObject(PCEPErrors.P_FLAG_NOT_SET, new EndpointsObjBuilder().build());
}
if (bytes.readableBytes() % Ipv6Util.IPV6_LENGTH != 4) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
final P2mpIpv6Builder p2mpIpv6Builder = new P2mpIpv6Builder().setP2mpLeaves(P2mpLeaves.forValue(bytes.readInt())).setSourceIpv6Address(Ipv6Util.addressForByteBuf(bytes));
List<Ipv6AddressNoZone> dest = new ArrayList<>();
while (bytes.isReadable()) {
dest.add(Ipv6Util.addressForByteBuf(bytes));
}
p2mpIpv6Builder.setDestinationIpv6Address(dest);
return new EndpointsObjBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setAddressFamily(new P2mpIpv6CaseBuilder().setP2mpIpv6(p2mpIpv6Builder.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader in project bgpcep by opendaylight.
the class PCEPNotificationObjectParser method parseObject.
@Override
public CNotification 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.");
bytes.skipBytes(NT_F_OFFSET);
final CNotificationBuilder builder = new CNotificationBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setType(ByteBufUtils.readUint8(bytes)).setValue(ByteBufUtils.readUint8(bytes));
parseTlvs(builder, bytes.slice());
return builder.build();
}
Aggregations