Search in sources :

Example 1 with AttributeParser

use of org.opendaylight.protocol.bgp.parser.spi.AttributeParser in project bgpcep by opendaylight.

the class SimpleAttributeRegistry method addAttribute.

private void addAttribute(final ByteBuf buffer, final Map<Integer, RawAttribute> attributes) throws BGPDocumentedException {
    final BitArray flags = BitArray.valueOf(buffer.readByte());
    final int type = buffer.readUnsignedByte();
    final int len = (flags.get(EXTENDED_LENGTH_BIT)) ? buffer.readUnsignedShort() : buffer.readUnsignedByte();
    if (!attributes.containsKey(type)) {
        final AttributeParser parser = this.handlers.getParser(type);
        if (parser == null) {
            processUnrecognized(flags, type, buffer, len);
        } else {
            attributes.put(type, new RawAttribute(parser, buffer.readSlice(len)));
        }
    } else {
        LOG.debug("Ignoring duplicate attribute type {}", type);
    }
}
Also used : AttributeParser(org.opendaylight.protocol.bgp.parser.spi.AttributeParser) BitArray(org.opendaylight.protocol.util.BitArray) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)

Aggregations

AttributeParser (org.opendaylight.protocol.bgp.parser.spi.AttributeParser)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 BitArray (org.opendaylight.protocol.util.BitArray)1