@Test public void testProcessLSUpdateMessage() throws Exception { ospfInterface.setIpAddress(Ip4Address.valueOf("11.11.11.11")); ospfInterface.setInterfaceType(2); ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255")); ospfInterface.setHelloIntervalTime(10); ospfInterface.setRouterDeadIntervalTime(10); ospfArea.setAreaId(Ip4Address.valueOf("12.12.12.12")); channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); OspfMessage message; lsUpdate = new LsUpdate(); lsUpdate.setSourceIp(Ip4Address.valueOf("1.1.1.1")); lsUpdate.setOspfVer(2); lsUpdate.setAreaId(Ip4Address.valueOf("12.12.12.12")); lsUpdate.setRouterId(Ip4Address.valueOf("10.226.165.100")); RouterLsa routerLsa = new RouterLsa(); lsUpdate.addLsa(routerLsa); lsUpdate.setNumberOfLsa(1); message = lsUpdate; ospfNbrHashMap = new HashMap(); ospfNbr.setState(OspfNeighborState.FULL); ospfNbr = new OspfNbrImpl(ospfArea, createOspfInterface(), Ip4Address.valueOf("10.10.10.10"), Ip4Address.valueOf("10.226.165.100"), 2, topologyForDeviceAndLink); ospfNbr.setLastDdPacket(createDdPacket()); ospfNbr.setNeighborId(Ip4Address.valueOf("2.2.2.2")); ospfNbr.setState(OspfNeighborState.FULL); ospfNbr.setRouterPriority(0); ospfNbr.setNeighborDr(Ip4Address.valueOf("13.13.13.13")); ospfNbr.setDdSeqNum(123); ospfInterface.addNeighbouringRouter(ospfNbr); channelHandlerContext = null; channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); ospfInterface.processLsUpdateMessage(message, channelHandlerContext); assertThat(ospfInterfaceChannelHandler, is(notNullValue())); }
void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsUpdateMessage"); LsUpdate lsUpdate = (LsUpdate) ospfMessage; String neighbourId = lsUpdate.routerId().toString(); if (isNeighborInList(neighbourId)) { OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId); if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) { nbr.processLsUpdate(lsUpdate, ctx.getChannel()); } else if (nbr.getState() == OspfNeighborState.FULL) { if (lsUpdate.noLsa() != 0) { List<OspfLsa> list = lsUpdate.getLsaList(); Iterator itr = list.iterator(); while (itr.hasNext()) { LsaHeader lsa = (LsaHeader) itr.next(); nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp()); } } else { return; } } } }
OspfInterfaceImpl implements OspfInterface { void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsUpdateMessage"); LsUpdate lsUpdate = (LsUpdate) ospfMessage; String neighbourId = lsUpdate.routerId().toString(); if (isNeighborInList(neighbourId)) { OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId); if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) { nbr.processLsUpdate(lsUpdate, ctx.getChannel()); } else if (nbr.getState() == OspfNeighborState.FULL) { if (lsUpdate.noLsa() != 0) { List<OspfLsa> list = lsUpdate.getLsaList(); Iterator itr = list.iterator(); while (itr.hasNext()) { LsaHeader lsa = (LsaHeader) itr.next(); nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp()); } } else { return; } } } } }
OspfInterfaceImpl implements OspfInterface { void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsUpdateMessage"); LsUpdate lsUpdate = (LsUpdate) ospfMessage; String neighbourId = lsUpdate.routerId().toString(); if (isNeighborInList(neighbourId)) { OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId); if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) { nbr.processLsUpdate(lsUpdate, ctx.getChannel()); } else if (nbr.getState() == OspfNeighborState.FULL) { if (lsUpdate.noLsa() != 0) { List<OspfLsa> list = lsUpdate.getLsaList(); Iterator itr = list.iterator(); while (itr.hasNext()) { LsaHeader lsa = (LsaHeader) itr.next(); nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp()); } } else { return; } } } }  }
OspfInterfaceImpl implements OspfInterface { void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsUpdateMessage"); LsUpdate lsUpdate = (LsUpdate) ospfMessage; String neighbourId = lsUpdate.routerId().toString(); if (isNeighborInList(neighbourId)) { OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId); if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) { nbr.processLsUpdate(lsUpdate, ctx.getChannel()); } else if (nbr.getState() == OspfNeighborState.FULL) { if (lsUpdate.noLsa() != 0) { List<OspfLsa> list = lsUpdate.getLsaList(); Iterator itr = list.iterator(); while (itr.hasNext()) { LsaHeader lsa = (LsaHeader) itr.next(); nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp()); } } else { return; } } } }  OspfInterfaceState state(); void setState(OspfInterfaceState ospfInterfaceState); void setChannel(Channel channel); OspfArea ospfArea(); void setController(Controller controller); void setOspfArea(OspfArea ospfArea); String interfaceState(); List<LsaHeader> linkStateHeaders(); Ip4Address ipNetworkMask(); @Override void setIpNetworkMask(Ip4Address ipNetworkMask); void addNeighbouringRouter(OspfNbr ospfNbr); OspfNbr neighbouringRouter(String neighborId); void removeNeighbors(); void removeNeighbor(OspfNbr ospfNeighbor); void addLsaHeaderForDelayAck(LsaHeader lsaHeader); void removeLsaFromNeighborMap(String lsaKey); boolean isNeighborInList(String neighborId); Map<String, OspfNbr> listOfNeighbors(); void setListOfNeighbors(HashMap<String, OspfNbr> listOfNeighbors); int interfaceIndex(); void setInterfaceIndex(int interfaceIndex); Ip4Address ipAddress(); void setIpAddress(Ip4Address ipAddress); int routerPriority(); void setRouterPriority(int routerPriority); int helloIntervalTime(); void setHelloIntervalTime(int helloIntervalTime); int routerDeadIntervalTime(); void setRouterDeadIntervalTime(int routerDeadIntervalTime); int interfaceType(); void setInterfaceType(int interfaceType); int mtu(); void setMtu(int mtu); int reTransmitInterval(); void setReTransmitInterval(int reTransmitInterval); Ip4Address dr(); void setDr(Ip4Address dr); Ip4Address bdr(); void setBdr(Ip4Address bdr); void interfaceUp(); void backupSeen(Channel ch); void waitTimer(Channel ch); void callDrElection(Channel ch); void neighborChange(); void interfaceDown(); void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx); boolean compareDdPackets(DdPacket receivedDPacket, DdPacket lastDdPacket); void startHelloTimer(); void stopHelloTimer(); void startWaitTimer(); void stopWaitTimer(); void startDelayedAckTimer(); void stopDelayedAckTimer(); void electRouter(Channel ch); List<OspfEligibleRouter> calculateListOfEligibleRouters(OspfEligibleRouter electedDr); OspfEligibleRouter electBdr(List<OspfEligibleRouter> eligibleRouters); OspfEligibleRouter electDr(List<OspfEligibleRouter> eligibleRouters,
                                      OspfEligibleRouter electedBdr); OspfEligibleRouter selectRouterBasedOnPriority(List<OspfEligibleRouter> routersList); void addDeviceInformation(OspfRouter ospfRouter); void removeDeviceInformation(OspfRouter ospfRouter); void addLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); void removeLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
OspfInterfaceImpl implements OspfInterface { void processLsUpdateMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsUpdateMessage"); LsUpdate lsUpdate = (LsUpdate) ospfMessage; String neighbourId = lsUpdate.routerId().toString(); if (isNeighborInList(neighbourId)) { OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(neighbourId); if (nbr.getState() == OspfNeighborState.EXCHANGE || nbr.getState() == OspfNeighborState.LOADING) { nbr.processLsUpdate(lsUpdate, ctx.getChannel()); } else if (nbr.getState() == OspfNeighborState.FULL) { if (lsUpdate.noLsa() != 0) { List<OspfLsa> list = lsUpdate.getLsaList(); Iterator itr = list.iterator(); while (itr.hasNext()) { LsaHeader lsa = (LsaHeader) itr.next(); nbr.processReceivedLsa(lsa, true, ctx.getChannel(), lsUpdate.sourceIp()); } } else { return; } } } }  OspfInterfaceState state(); void setState(OspfInterfaceState ospfInterfaceState); void setChannel(Channel channel); OspfArea ospfArea(); void setController(Controller controller); void setOspfArea(OspfArea ospfArea); String interfaceState(); List<LsaHeader> linkStateHeaders(); Ip4Address ipNetworkMask(); @Override void setIpNetworkMask(Ip4Address ipNetworkMask); void addNeighbouringRouter(OspfNbr ospfNbr); OspfNbr neighbouringRouter(String neighborId); void removeNeighbors(); void removeNeighbor(OspfNbr ospfNeighbor); void addLsaHeaderForDelayAck(LsaHeader lsaHeader); void removeLsaFromNeighborMap(String lsaKey); boolean isNeighborInList(String neighborId); Map<String, OspfNbr> listOfNeighbors(); void setListOfNeighbors(HashMap<String, OspfNbr> listOfNeighbors); int interfaceIndex(); void setInterfaceIndex(int interfaceIndex); Ip4Address ipAddress(); void setIpAddress(Ip4Address ipAddress); int routerPriority(); void setRouterPriority(int routerPriority); int helloIntervalTime(); void setHelloIntervalTime(int helloIntervalTime); int routerDeadIntervalTime(); void setRouterDeadIntervalTime(int routerDeadIntervalTime); int interfaceType(); void setInterfaceType(int interfaceType); int mtu(); void setMtu(int mtu); int reTransmitInterval(); void setReTransmitInterval(int reTransmitInterval); Ip4Address dr(); void setDr(Ip4Address dr); Ip4Address bdr(); void setBdr(Ip4Address bdr); void interfaceUp(); void backupSeen(Channel ch); void waitTimer(Channel ch); void callDrElection(Channel ch); void neighborChange(); void interfaceDown(); void processOspfMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx); boolean compareDdPackets(DdPacket receivedDPacket, DdPacket lastDdPacket); void startHelloTimer(); void stopHelloTimer(); void startWaitTimer(); void stopWaitTimer(); void startDelayedAckTimer(); void stopDelayedAckTimer(); void electRouter(Channel ch); List<OspfEligibleRouter> calculateListOfEligibleRouters(OspfEligibleRouter electedDr); OspfEligibleRouter electBdr(List<OspfEligibleRouter> eligibleRouters); OspfEligibleRouter electDr(List<OspfEligibleRouter> eligibleRouters,
                                      OspfEligibleRouter electedBdr); OspfEligibleRouter selectRouterBasedOnPriority(List<OspfEligibleRouter> routersList); void addDeviceInformation(OspfRouter ospfRouter); void removeDeviceInformation(OspfRouter ospfRouter); void addLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); void removeLinkInformation(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }