@Test(expected = Exception.class) public void testProcessLSAckMessage() 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; lsAck = new LsAcknowledge(); lsAck.setSourceIp(Ip4Address.valueOf("1.1.1.1")); lsAck.setOspfVer(2); lsAck.setAreaId(Ip4Address.valueOf("12.12.12.12")); LsaHeader lsaHeader = new LsaHeader(); lsAck.addLinkStateHeader(lsaHeader); message = lsAck; 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); channelHandlerContext = null; channelHandlerContext = EasyMock.createMock(ChannelHandlerContext.class); ospfInterface.processLsAckMessage(message, channelHandlerContext); assertThat(ospfInterfaceChannelHandler, is(notNullValue())); }
void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsAckMessage"); LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage; OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString()); if (nbr != null) { if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) { return; } else { Iterator itr = lsAckPacket.getLinkStateHeaders().iterator(); while (itr.hasNext()) { LsaHeader lsRequest = (LsaHeader) itr.next(); OspfLsa ospfLsa = (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); if (lsRequest != null && ospfLsa != null) { String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa( lsRequest, (LsaHeader) ospfLsa); if (isSame.equals("same")) { nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); } } } } } }
OspfInterfaceImpl implements OspfInterface { void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsAckMessage"); LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage; OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString()); if (nbr != null) { if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) { return; } else { Iterator itr = lsAckPacket.getLinkStateHeaders().iterator(); while (itr.hasNext()) { LsaHeader lsRequest = (LsaHeader) itr.next(); OspfLsa ospfLsa = (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); if (lsRequest != null && ospfLsa != null) { String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa( lsRequest, (LsaHeader) ospfLsa); if (isSame.equals("same")) { nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); } } } } } } }
OspfInterfaceImpl implements OspfInterface { void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsAckMessage"); LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage; OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString()); if (nbr != null) { if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) { return; } else { Iterator itr = lsAckPacket.getLinkStateHeaders().iterator(); while (itr.hasNext()) { LsaHeader lsRequest = (LsaHeader) itr.next(); OspfLsa ospfLsa = (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); if (lsRequest != null && ospfLsa != null) { String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa( lsRequest, (LsaHeader) ospfLsa); if (isSame.equals("same")) { nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); } } } } } }  }
OspfInterfaceImpl implements OspfInterface { void processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsAckMessage"); LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage; OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString()); if (nbr != null) { if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) { return; } else { Iterator itr = lsAckPacket.getLinkStateHeaders().iterator(); while (itr.hasNext()) { LsaHeader lsRequest = (LsaHeader) itr.next(); OspfLsa ospfLsa = (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); if (lsRequest != null && ospfLsa != null) { String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa( lsRequest, (LsaHeader) ospfLsa); if (isSame.equals("same")) { nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); } } } } } }  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 processLsAckMessage(OspfMessage ospfMessage, ChannelHandlerContext ctx) throws Exception { log.debug("OspfChannelHandler::processLsAckMessage"); LsAcknowledge lsAckPacket = (LsAcknowledge) ospfMessage; OspfNbrImpl nbr = (OspfNbrImpl) neighbouringRouter(lsAckPacket.routerId().toString()); if (nbr != null) { if (nbr.getState().getValue() < OspfNeighborState.EXCHANGE.getValue()) { return; } else { Iterator itr = lsAckPacket.getLinkStateHeaders().iterator(); while (itr.hasNext()) { LsaHeader lsRequest = (LsaHeader) itr.next(); OspfLsa ospfLsa = (OspfLsa) nbr.getPendingReTxList().get(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); if (lsRequest != null && ospfLsa != null) { String isSame = ((OspfLsdbImpl) ospfArea.database()).isNewerOrSameLsa( lsRequest, (LsaHeader) ospfLsa); if (isSame.equals("same")) { nbr.getPendingReTxList().remove(((OspfAreaImpl) ospfArea).getLsaKey(lsRequest)); } } } } } }  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();  }