Search in sources :

Example 1 with ParameterLengthOverflowException

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

the class BGPOpenMessageParser method normalSerializeParameters.

private ByteBuf normalSerializeParameters(final List<BgpParameters> params) {
    final ByteBuf buffer = Unpooled.buffer();
    for (final BgpParameters param : params) {
        final Optional<ParameterSerializer> optSer = reg.findSerializer(param);
        if (optSer.isPresent()) {
            try {
                optSer.get().serializeParameter(param, buffer);
            } catch (ParameterLengthOverflowException e) {
                LOG.debug("Forcing extended parameter serialization", e);
                return null;
            }
        } else {
            LOG.debug("Ingnoring unregistered parameter {}", param);
        }
    }
    final int length = buffer.writerIndex();
    if (length > Values.UNSIGNED_BYTE_MAX_VALUE) {
        LOG.debug("Final parameter size is {}, forcing extended serialization", length);
        return null;
    }
    return buffer;
}
Also used : ParameterLengthOverflowException(org.opendaylight.protocol.bgp.parser.spi.ParameterLengthOverflowException) ByteBuf(io.netty.buffer.ByteBuf) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) ParameterSerializer(org.opendaylight.protocol.bgp.parser.spi.ParameterSerializer) PeerSpecificParserConstraint(org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ParameterLengthOverflowException (org.opendaylight.protocol.bgp.parser.spi.ParameterLengthOverflowException)1 ParameterSerializer (org.opendaylight.protocol.bgp.parser.spi.ParameterSerializer)1 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)1 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters)1