+
+ /**
+ * Handler to process response for start-exi message
+ */
+ private final class ExiConfirmationInboundHandler extends ChannelInboundHandlerAdapter {
+ private static final String EXI_CONFIRMED_HANDLER = "exiConfirmedHandler";
+
+ private final NetconfClientSession session;
+ private NetconfStartExiMessage startExiMessage;
+
+ ExiConfirmationInboundHandler(NetconfClientSession session, final NetconfStartExiMessage startExiMessage) {
+ this.session = session;
+ this.startExiMessage = startExiMessage;
+ }
+
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+ ctx.pipeline().remove(ExiConfirmationInboundHandler.EXI_CONFIRMED_HANDLER);
+
+ NetconfMessage netconfMessage = (NetconfMessage) msg;
+
+ // Ok response to start-exi, try to add exi handlers
+ if (NetconfMessageUtil.isOKMessage(netconfMessage)) {
+ logger.trace("Positive response on start-exi call received on session {}", session);
+ try {
+ session.startExiCommunication(startExiMessage);
+ } catch (RuntimeException e) {
+ // Unable to add exi, continue without exi
+ logger.warn("Unable to start exi communication, Communication will continue without exi on session {}", session, e);
+ }
+
+ // Error response
+ } else if(NetconfMessageUtil.isErrorMessage(netconfMessage)) {
+ logger.warn(
+ "Error response to start-exi message {}, Communication will continue without exi on session {}",
+ XmlUtil.toString(netconfMessage.getDocument()), session);
+
+ // Unexpected response to start-exi, throwing message away, continue without exi
+ } else {
+ logger.warn(
+ "Unexpected response to start-exi message, should be ok, was {}, " +
+ "Communication will continue without exi and response message will be thrown away on session {}",
+ XmlUtil.toString(netconfMessage.getDocument()), session);
+ }
+
+ negotiationSuccessful(session);
+ }
+ }
+