import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+
import io.netty.channel.Channel;
import io.netty.handler.ssl.SslHandler;
import io.netty.util.Timeout;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.concurrent.Promise;
+
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.NetconfSessionPreferences;
+import org.opendaylight.controller.netconf.util.handler.FramingMechanismHandlerFactory;
+import org.opendaylight.controller.netconf.util.handler.NetconfMessageAggregator;
+import org.opendaylight.controller.netconf.util.handler.NetconfMessageChunkDecoder;
+import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
import org.opendaylight.controller.netconf.util.xml.XmlElement;
import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
import org.opendaylight.controller.netconf.util.xml.XmlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
import java.util.concurrent.TimeUnit;
final Document doc = netconfMessage.getDocument();
if (isHelloMessage(doc)) {
+ if (containsBase11Capability(doc)
+ && containsBase11Capability(sessionPreferences.getHelloMessage().getDocument())) {
+ channel.pipeline().replace("frameEncoder", "frameEncoder",
+ FramingMechanismHandlerFactory.createHandler(FramingMechanism.CHUNK));
+ channel.pipeline().replace("aggregator", "aggregator",
+ new NetconfMessageAggregator(FramingMechanism.CHUNK));
+ channel.pipeline().addAfter("aggregator", "chunkDecoder", new NetconfMessageChunkDecoder());
+ }
changeState(State.ESTABLISHED);
S session = getSession(sessionListener, channel, doc);
negotiationSuccessful(session);
this.state = newState;
}
+ private boolean containsBase11Capability(final Document doc) {
+ final NodeList nList = doc.getElementsByTagName("capability");
+ for (int i = 0; i < nList.getLength(); i++) {
+ if (nList.item(i).getTextContent().contains("base:1.1")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private static boolean isStateChangePermitted(State state, State newState) {
if (state == State.IDLE && newState == State.OPEN_WAIT)
return true;