import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
+import org.opendaylight.protocol.bgp.parser.spi.PeerConstraint;
+import org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraintProvider;
+import org.opendaylight.protocol.bgp.parser.spi.pojo.PeerSpecificParserConstraintImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final class BGPByteToMessageDecoder extends ByteToMessageDecoder {
private static final Logger LOG = LoggerFactory.getLogger(BGPByteToMessageDecoder.class);
private final MessageRegistry registry;
+ private final PeerSpecificParserConstraintProvider constraints;
public BGPByteToMessageDecoder(final MessageRegistry registry) {
+ this.constraints = new PeerSpecificParserConstraintImpl();
this.registry = Preconditions.checkNotNull(registry);
}
+ public <T extends PeerConstraint> boolean addDecoderConstraint(final Class<T> classType, final T peerConstraint) {
+ return this.constraints.addPeerConstraint(classType, peerConstraint);
+ }
+
@Override
protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws BGPDocumentedException,
BGPParsingException {
if (LOG.isTraceEnabled()) {
LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
}
- out.add(this.registry.parseMessage(in));
+ out.add(this.registry.parseMessage(in, this.constraints));
} else {
LOG.trace("No more content in incoming buffer.");
}
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPipeline;
import io.netty.channel.SimpleChannelInboundHandler;
import java.io.IOException;
import java.util.Date;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BgpExtendedMessageUtil;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
+import org.opendaylight.protocol.bgp.parser.spi.MultiPathSupport;
+import org.opendaylight.protocol.bgp.parser.spi.pojo.MultiPathSupportImpl;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionStatistics;
this.tableTypes = tats;
this.addPathTypes = addPathCapabilitiesList;
+ if (! this.addPathTypes.isEmpty()) {
+ final ChannelPipeline pipeline = this.channel.pipeline();
+ final BGPByteToMessageDecoder decoder = pipeline.get(BGPByteToMessageDecoder.class);
+ decoder.addDecoderConstraint(MultiPathSupport.class,
+ MultiPathSupportImpl.createParserMultiPathSupport(this.addPathTypes));
+ }
+
if (this.holdTimerValue != 0) {
channel.eventLoop().schedule(new Runnable() {
@Override