use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesBuilder in project bgpcep by opendaylight.
the class UnrecognizedAttributesSerializerTest method testUnrecognizedAttributesSerializer.
@Test
public void testUnrecognizedAttributesSerializer() {
final byte[] unrecognizedValue1 = { (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35 };
final byte[] unrecognizedValue2 = { (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd7, 0x5d, 0x75, (byte) 0xd7, 0x5d, 0x75 };
final byte[] unrecognizedBytes = { (byte) 0xe0, 0x65, 0x0c, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xe0, 0x66, 0x0c, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd3, 0x5d, 0x35, (byte) 0xd7, 0x5d, 0x75, (byte) 0xd7, 0x5d, 0x75 };
final List<UnrecognizedAttributes> unrecognizedAttrs = new ArrayList<>();
final UnrecognizedAttributes unrecognizedAttribute1 = new UnrecognizedAttributesBuilder().setPartial(true).setTransitive(true).setType((short) 101).setValue(unrecognizedValue1).build();
unrecognizedAttrs.add(unrecognizedAttribute1);
final UnrecognizedAttributes unrecognizedAttribute2 = new UnrecognizedAttributesBuilder().setPartial(true).setTransitive(true).setType((short) 102).setValue(unrecognizedValue2).build();
unrecognizedAttrs.add(unrecognizedAttribute2);
final Attributes attrs = new AttributesBuilder().setUnrecognizedAttributes(unrecognizedAttrs).build();
final ByteBuf buffer = Unpooled.buffer();
ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getAttributeRegistry().serializeAttribute(attrs, buffer);
assertArrayEquals(unrecognizedBytes, ByteArray.readAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesBuilder 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 UnrecognizedAttributes unrecognizedAttribute = new UnrecognizedAttributesBuilder().setKey(new UnrecognizedAttributesKey((short) type)).setPartial(flags.get(PARTIAL_BIT)).setTransitive(flags.get(TRANSITIVE_BIT)).setType((short) type).setValue(ByteArray.readBytes(buffer, len)).build();
this.unrecognizedAttributes.add(unrecognizedAttribute);
LOG.debug("Unrecognized attribute were parsed: {}", unrecognizedAttribute);
}
Aggregations