Search in sources :

Example 1 with UnrecognizedAttributesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesKey in project bgpcep by opendaylight.

the class UnrecognizedAttributesTest method testUnrecognizedAttributes.

@Test
public void testUnrecognizedAttributes() throws BGPDocumentedException, BGPParsingException {
    final byte[] attributeBytes = { (byte) 0xe0, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05 };
    final List<UnrecognizedAttributes> unrecogAttribs = simpleAttrReg.parseAttributes(Unpooled.wrappedBuffer(attributeBytes), null).getUnrecognizedAttributes();
    assertEquals(UNRECOGNIZED_ATTRIBUTE_COUNT, unrecogAttribs.size());
    final UnrecognizedAttributes unrecogAttrib = unrecogAttribs.get(FIRST_ATTRIBUTE);
    final UnrecognizedAttributesKey expectedAttribKey = new UnrecognizedAttributesKey(unrecogAttrib.getType());
    assertTrue(unrecogAttrib.isPartial());
    assertTrue(unrecogAttrib.isTransitive());
    assertArrayEquals(ByteArray.cutBytes(attributeBytes, NON_VALUE_BYTES), unrecogAttrib.getValue());
    assertEquals(NON_EXISTENT_TYPE, unrecogAttrib.getType().shortValue());
    assertEquals(expectedAttribKey, unrecogAttrib.getKey());
}
Also used : UnrecognizedAttributesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesKey) UnrecognizedAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributes) Test(org.junit.Test)

Example 2 with UnrecognizedAttributesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesKey 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);
}
Also used : BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) UnrecognizedAttributesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesKey) UnrecognizedAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesBuilder) UnrecognizedAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributes)

Aggregations

UnrecognizedAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributes)2 UnrecognizedAttributesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesKey)2 Test (org.junit.Test)1 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)1 UnrecognizedAttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.UnrecognizedAttributesBuilder)1