use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.
the class PCEPNoPathObjectParser method parseObject.
@Override
public NoPath parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
final Uint8 issue = ByteBufUtils.readUint8(bytes);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
bytes.skipBytes(RESERVED_F_LENGTH);
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
return new NoPathBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setNatureOfIssue(issue).setUnsatisfiedConstraints(flags.get(C_FLAG_OFFSET)).setTlvs(tlvsBuilder.build()).build();
}
use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.
the class SimpleAttributeRegistry method processUnrecognized.
private void processUnrecognized(final BitArray flags, final int type, final ByteBuf buffer, final int len) throws BGPDocumentedException {
if (!flags.get(OPTIONAL_BIT)) {
throw new BGPDocumentedException("Well known attribute not recognized.", BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED);
}
final Uint8 typeVal = Uint8.valueOf(type);
final UnrecognizedAttributes unrecognizedAttribute = new UnrecognizedAttributesBuilder().withKey(new UnrecognizedAttributesKey(typeVal)).setPartial(flags.get(PARTIAL_BIT)).setTransitive(flags.get(TRANSITIVE_BIT)).setType(typeVal).setValue(ByteArray.readBytes(buffer, len)).build();
this.unrecognizedAttributes.add(unrecognizedAttribute);
LOG.debug("Unrecognized attribute were parsed: {}", unrecognizedAttribute);
}
use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.
the class PCEPCloseObjectParser method parseObject.
@Override
public CClose parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Cannot be null or empty.");
bytes.skipBytes(FLAGS_F_LENGTH + RESERVED);
final Uint8 reason = ByteBufUtils.readUint8(bytes);
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parseTlvs(tlvsBuilder, bytes.slice());
return new CCloseBuilder().setIgnore(header.getIgnore()).setProcessingRule(header.getProcessingRule()).setReason(reason).setTlvs(tlvsBuilder.build()).build();
}
use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createTypes.
private static List<Types> createTypes(final UnkeyedListNode typesData) {
final List<Types> types = new ArrayList<>();
for (final UnkeyedListEntryNode node : typesData.body()) {
final TypesBuilder typesBuilder = new TypesBuilder();
node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> typesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> typesBuilder.setValue((Uint8) dataContainerChild.body()));
types.add(typesBuilder.build());
}
return types;
}
use of org.opendaylight.yangtools.yang.common.Uint8 in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createCodes.
private static List<Codes> createCodes(final UnkeyedListNode codesData) {
final List<Codes> codes = new ArrayList<>();
for (final UnkeyedListEntryNode node : codesData.body()) {
final CodesBuilder codesBuilder = new CodesBuilder();
node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> codesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> codesBuilder.setValue((Uint8) dataContainerChild.body()));
codes.add(codesBuilder.build());
}
return codes;
}
Aggregations