class OspfInterfaceChannelHandler extends IdleStateAwareChannelHandler {

    public void updateInterfaceMap(List<OspfProcess> ospfProcesses) throws Exception {
        for (OspfProcess ospfUpdatedProcess : ospfProcesses) {
            for (OspfArea updatedArea : ospfUpdatedProcess.areas()) {
                for (OspfInterface ospfUpdatedInterface : updatedArea.ospfInterfaceList()) {
                    OspfInterface ospfInterface = ospfInterfaceMap.get(ospfUpdatedInterface.interfaceIndex());
                    if (ospfInterface == null) {
                        ospfUpdatedInterface.setOspfArea(updatedArea);
                        ((OspfInterfaceImpl) ospfUpdatedInterface).setController(controller);
                        ((OspfInterfaceImpl) ospfUpdatedInterface).setState(OspfInterfaceState.DOWN);
                        ospfUpdatedInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
                        ospfUpdatedInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
                        ospfInterfaceMap.put(ospfUpdatedInterface.interfaceIndex(), ospfUpdatedInterface);
                        ((OspfInterfaceImpl) ospfUpdatedInterface).setChannel(channel);
                        ospfUpdatedInterface.interfaceUp();
                        ospfUpdatedInterface.startDelayedAckTimer();
                    } else {
                        ospfInterface.setOspfArea(updatedArea);

                        if (ospfInterface.routerDeadIntervalTime() != ospfUpdatedInterface.routerDeadIntervalTime()) {
                            ospfInterface.setRouterDeadIntervalTime(ospfUpdatedInterface.routerDeadIntervalTime());
                            Map<String, OspfNbr> neighbors = ospfInterface.listOfNeighbors();
                            for (String key : neighbors.keySet()) {
                                OspfNbr ospfNbr = ospfInterface.neighbouringRouter(key);
                                ospfNbr.setRouterDeadInterval(ospfInterface.routerDeadIntervalTime());
                                ospfNbr.stopInactivityTimeCheck();
                                ospfNbr.startInactivityTimeCheck();
                            }
                        }
                        if (ospfInterface.interfaceType() != ospfUpdatedInterface.interfaceType()) {
                            ospfInterface.setInterfaceType(ospfUpdatedInterface.interfaceType());
                            if (ospfInterface.interfaceType() == OspfInterfaceType.POINT_TO_POINT.value()) {
                                ospfInterface.setDr(Ip4Address.valueOf("0.0.0.0"));
                                ospfInterface.setBdr(Ip4Address.valueOf("0.0.0.0"));
                            }
                            ospfInterface.removeNeighbors();
                        }
                        if (ospfInterface.helloIntervalTime() != ospfUpdatedInterface.helloIntervalTime()) {
                            ospfInterface.setHelloIntervalTime(ospfUpdatedInterface.helloIntervalTime());
                            ospfInterface.stopHelloTimer();
                            ospfInterface.startHelloTimer();
                        }
                        ospfInterfaceMap.put(ospfInterface.interfaceIndex(), ospfInterface);
                    }
                }
            }
        }
    }

    public  OspfInterfaceChannelHandler(Controller controller, List<OspfProcess> processes);

}