@Test(expected = Exception.class) public void testTwoWayReceived() throws Exception { ospfNbr.setNeighborDr(Ip4Address.valueOf("1.1.1.1")); ospfMessage = new HelloPacket(); ospfNbr.setState(OspfNeighborState.ATTEMPT); ospfNbr.setNeighborDr(Ip4Address.valueOf("2.2.2.2")); ospfInterface.setIpAddress(Ip4Address.valueOf("2.2.2.2")); channel = EasyMock.createMock(Channel.class); SocketAddress socketAddress = EasyMock.createMock(SocketAddress.class); channel.bind(socketAddress); ospfNbr.twoWayReceived(ospfMessage, channel); ospfInterface.setIpAddress(Ip4Address.valueOf("3.3.3.3")); channel1 = EasyMock.createMock(Channel.class); ospfNbr.twoWayReceived(ospfMessage, channel1); assertThat(ospfNbr, is(notNullValue())); }
public void twoWayReceived(OspfMessage ospfMessage, Channel channel) throws Exception { log.debug("OSPFNbr::twoWayReceived...!!!"); stopInactivityTimeCheck(); startInactivityTimeCheck(); startFloodingTimer(channel); OspfPacketHeader packet = (OspfPacketHeader) ospfMessage; if (state.getValue() <= OspfNeighborState.TWOWAY.getValue()) { if (formAdjacencyOrNot()) { state = OspfNeighborState.EXSTART; ddSeqNum++; DdPacket ddPacket = new DdPacket(); ddPacket.setOspfVer(OspfUtil.OSPF_VERSION); ddPacket.setOspftype(OspfPacketType.DD.value()); ddPacket.setRouterId(ospfArea.routerId()); ddPacket.setAreaId(ospfArea.areaId()); ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED); ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED); ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED); boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled(); if (isOpaqueEnabled) { ddPacket.setOptions(ospfArea.opaqueEnabledOptions()); } else { ddPacket.setOptions(ospfArea.options()); } ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET); ddPacket.setIsMore(OspfUtil.MORE_SET); ddPacket.setIsMaster(OspfUtil.IS_MASTER); ddPacket.setImtu(ospfInterface.mtu()); ddPacket.setSequenceNo(ddSeqNum); setLastSentDdPacket(ddPacket); rxmtDdPacketTask = new InternalRxmtDdPacket(channel); startRxMtDdTimer(channel); ddPacket.setDestinationIp(packet.sourceIp()); byte[] messageToWrite = getMessage(ddPacket); channel.write(messageToWrite); } else { state = OspfNeighborState.TWOWAY; } } }
OspfNbrImpl implements OspfNbr { public void twoWayReceived(OspfMessage ospfMessage, Channel channel) throws Exception { log.debug("OSPFNbr::twoWayReceived...!!!"); stopInactivityTimeCheck(); startInactivityTimeCheck(); startFloodingTimer(channel); OspfPacketHeader packet = (OspfPacketHeader) ospfMessage; if (state.getValue() <= OspfNeighborState.TWOWAY.getValue()) { if (formAdjacencyOrNot()) { state = OspfNeighborState.EXSTART; ddSeqNum++; DdPacket ddPacket = new DdPacket(); ddPacket.setOspfVer(OspfUtil.OSPF_VERSION); ddPacket.setOspftype(OspfPacketType.DD.value()); ddPacket.setRouterId(ospfArea.routerId()); ddPacket.setAreaId(ospfArea.areaId()); ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED); ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED); ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED); boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled(); if (isOpaqueEnabled) { ddPacket.setOptions(ospfArea.opaqueEnabledOptions()); } else { ddPacket.setOptions(ospfArea.options()); } ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET); ddPacket.setIsMore(OspfUtil.MORE_SET); ddPacket.setIsMaster(OspfUtil.IS_MASTER); ddPacket.setImtu(ospfInterface.mtu()); ddPacket.setSequenceNo(ddSeqNum); setLastSentDdPacket(ddPacket); rxmtDdPacketTask = new InternalRxmtDdPacket(channel); startRxMtDdTimer(channel); ddPacket.setDestinationIp(packet.sourceIp()); byte[] messageToWrite = getMessage(ddPacket); channel.write(messageToWrite); } else { state = OspfNeighborState.TWOWAY; } } } }
OspfNbrImpl implements OspfNbr { public void twoWayReceived(OspfMessage ospfMessage, Channel channel) throws Exception { log.debug("OSPFNbr::twoWayReceived...!!!"); stopInactivityTimeCheck(); startInactivityTimeCheck(); startFloodingTimer(channel); OspfPacketHeader packet = (OspfPacketHeader) ospfMessage; if (state.getValue() <= OspfNeighborState.TWOWAY.getValue()) { if (formAdjacencyOrNot()) { state = OspfNeighborState.EXSTART; ddSeqNum++; DdPacket ddPacket = new DdPacket(); ddPacket.setOspfVer(OspfUtil.OSPF_VERSION); ddPacket.setOspftype(OspfPacketType.DD.value()); ddPacket.setRouterId(ospfArea.routerId()); ddPacket.setAreaId(ospfArea.areaId()); ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED); ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED); ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED); boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled(); if (isOpaqueEnabled) { ddPacket.setOptions(ospfArea.opaqueEnabledOptions()); } else { ddPacket.setOptions(ospfArea.options()); } ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET); ddPacket.setIsMore(OspfUtil.MORE_SET); ddPacket.setIsMaster(OspfUtil.IS_MASTER); ddPacket.setImtu(ospfInterface.mtu()); ddPacket.setSequenceNo(ddSeqNum); setLastSentDdPacket(ddPacket); rxmtDdPacketTask = new InternalRxmtDdPacket(channel); startRxMtDdTimer(channel); ddPacket.setDestinationIp(packet.sourceIp()); byte[] messageToWrite = getMessage(ddPacket); channel.write(messageToWrite); } else { state = OspfNeighborState.TWOWAY; } } } OspfNbrImpl(OspfArea paramOspfArea, OspfInterface paramOspfInterface,
                       Ip4Address ipAddr, Ip4Address routerId, int options,
                       TopologyForDeviceAndLink topologyForDeviceAndLinkCommon); }
OspfNbrImpl implements OspfNbr { public void twoWayReceived(OspfMessage ospfMessage, Channel channel) throws Exception { log.debug("OSPFNbr::twoWayReceived...!!!"); stopInactivityTimeCheck(); startInactivityTimeCheck(); startFloodingTimer(channel); OspfPacketHeader packet = (OspfPacketHeader) ospfMessage; if (state.getValue() <= OspfNeighborState.TWOWAY.getValue()) { if (formAdjacencyOrNot()) { state = OspfNeighborState.EXSTART; ddSeqNum++; DdPacket ddPacket = new DdPacket(); ddPacket.setOspfVer(OspfUtil.OSPF_VERSION); ddPacket.setOspftype(OspfPacketType.DD.value()); ddPacket.setRouterId(ospfArea.routerId()); ddPacket.setAreaId(ospfArea.areaId()); ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED); ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED); ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED); boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled(); if (isOpaqueEnabled) { ddPacket.setOptions(ospfArea.opaqueEnabledOptions()); } else { ddPacket.setOptions(ospfArea.options()); } ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET); ddPacket.setIsMore(OspfUtil.MORE_SET); ddPacket.setIsMaster(OspfUtil.IS_MASTER); ddPacket.setImtu(ospfInterface.mtu()); ddPacket.setSequenceNo(ddSeqNum); setLastSentDdPacket(ddPacket); rxmtDdPacketTask = new InternalRxmtDdPacket(channel); startRxMtDdTimer(channel); ddPacket.setDestinationIp(packet.sourceIp()); byte[] messageToWrite = getMessage(ddPacket); channel.write(messageToWrite); } else { state = OspfNeighborState.TWOWAY; } } } OspfNbrImpl(OspfArea paramOspfArea, OspfInterface paramOspfInterface,
                       Ip4Address ipAddr, Ip4Address routerId, int options,
                       TopologyForDeviceAndLink topologyForDeviceAndLinkCommon); Ip4Address neighborIpAddr(); boolean isOpaqueCapable(); void setIsOpaqueCapable(boolean isOpaqueCapable); void setRouterDeadInterval(int routerDeadInterval); void oneWayReceived(OspfMessage ospfHello, Channel channel); void twoWayReceived(OspfMessage ospfMessage, Channel channel); void negotiationDone(OspfMessage ospfMessage,
                                boolean neighborIsMaster, List payload, Channel ch); void processLsas(List ddPayload); OspfMessage seqNumMismatch(String reason); void badLSReq(Channel ch); void processDdPacket(boolean neighborIsMaster, DdPacket dataDescPkt,
                                Channel ch); void exchangeDone(OspfMessage message, Channel ch); void adjOk(Channel ch); void processLsUpdate(LsUpdate lsUpdPkt, Channel ch); void loadingDone(); boolean processReceivedLsa(LsaHeader recLsa,
                                      boolean receivedViaFlooding, Channel ch, Ip4Address sourceIp); String isNullorLatest(LsaWrapper lsWrapper, LsaHeader recLsa); void processSelfOriginatedLsa(); void sendLsa(LsaHeader lsa, Ip4Address destination, Channel ch); void directAcknowledge(LsaHeader ackLsa, Channel ch, Ip4Address sourceIp); void neighborDown(); void startInactivityTimeCheck(); void stopInactivityTimeCheck(); void startFloodingTimer(Channel channel); void stopFloodingTimer(); void stopRxMtDdTimer(); void stopRxMtLsrTimer(); DdPacket lastDdPacket(); void setLastDdPacket(DdPacket lastDdPacket); Ip4Address neighborId(); void setNeighborId(Ip4Address neighborId); Ip4Address neighborDr(); void setNeighborDr(Ip4Address neighborDr); Ip4Address neighborBdr(); void setNeighborBdr(Ip4Address neighborBdr); int routerPriority(); void setRouterPriority(int routerPriority); int options(); void setOptions(int options); long ddSeqNum(); void setDdSeqNum(long ddSeqNum); int isMaster(); DdPacket lastSentDdPacket(); void setLastSentDdPacket(DdPacket lastSentDdPacket); LsRequest getLastSentLsrPacket(); void setLastSentLsrPacket(LsRequest lastSentLsrPacket); OspfNeighborState getState(); void setState(OspfNeighborState state); void setIsMaster(int isMaster); Hashtable getLsReqList(); Map getReTxList(); Map<String, OspfLsa> getPendingReTxList(); }
OspfNbrImpl implements OspfNbr { public void twoWayReceived(OspfMessage ospfMessage, Channel channel) throws Exception { log.debug("OSPFNbr::twoWayReceived...!!!"); stopInactivityTimeCheck(); startInactivityTimeCheck(); startFloodingTimer(channel); OspfPacketHeader packet = (OspfPacketHeader) ospfMessage; if (state.getValue() <= OspfNeighborState.TWOWAY.getValue()) { if (formAdjacencyOrNot()) { state = OspfNeighborState.EXSTART; ddSeqNum++; DdPacket ddPacket = new DdPacket(); ddPacket.setOspfVer(OspfUtil.OSPF_VERSION); ddPacket.setOspftype(OspfPacketType.DD.value()); ddPacket.setRouterId(ospfArea.routerId()); ddPacket.setAreaId(ospfArea.areaId()); ddPacket.setAuthType(OspfUtil.NOT_ASSIGNED); ddPacket.setAuthentication(OspfUtil.NOT_ASSIGNED); ddPacket.setOspfPacLength(OspfUtil.NOT_ASSIGNED); ddPacket.setChecksum(OspfUtil.NOT_ASSIGNED); boolean isOpaqueEnabled = ospfArea.isOpaqueEnabled(); if (isOpaqueEnabled) { ddPacket.setOptions(ospfArea.opaqueEnabledOptions()); } else { ddPacket.setOptions(ospfArea.options()); } ddPacket.setIsInitialize(OspfUtil.INITIALIZE_SET); ddPacket.setIsMore(OspfUtil.MORE_SET); ddPacket.setIsMaster(OspfUtil.IS_MASTER); ddPacket.setImtu(ospfInterface.mtu()); ddPacket.setSequenceNo(ddSeqNum); setLastSentDdPacket(ddPacket); rxmtDdPacketTask = new InternalRxmtDdPacket(channel); startRxMtDdTimer(channel); ddPacket.setDestinationIp(packet.sourceIp()); byte[] messageToWrite = getMessage(ddPacket); channel.write(messageToWrite); } else { state = OspfNeighborState.TWOWAY; } } } OspfNbrImpl(OspfArea paramOspfArea, OspfInterface paramOspfInterface,
                       Ip4Address ipAddr, Ip4Address routerId, int options,
                       TopologyForDeviceAndLink topologyForDeviceAndLinkCommon); Ip4Address neighborIpAddr(); boolean isOpaqueCapable(); void setIsOpaqueCapable(boolean isOpaqueCapable); void setRouterDeadInterval(int routerDeadInterval); void oneWayReceived(OspfMessage ospfHello, Channel channel); void twoWayReceived(OspfMessage ospfMessage, Channel channel); void negotiationDone(OspfMessage ospfMessage,
                                boolean neighborIsMaster, List payload, Channel ch); void processLsas(List ddPayload); OspfMessage seqNumMismatch(String reason); void badLSReq(Channel ch); void processDdPacket(boolean neighborIsMaster, DdPacket dataDescPkt,
                                Channel ch); void exchangeDone(OspfMessage message, Channel ch); void adjOk(Channel ch); void processLsUpdate(LsUpdate lsUpdPkt, Channel ch); void loadingDone(); boolean processReceivedLsa(LsaHeader recLsa,
                                      boolean receivedViaFlooding, Channel ch, Ip4Address sourceIp); String isNullorLatest(LsaWrapper lsWrapper, LsaHeader recLsa); void processSelfOriginatedLsa(); void sendLsa(LsaHeader lsa, Ip4Address destination, Channel ch); void directAcknowledge(LsaHeader ackLsa, Channel ch, Ip4Address sourceIp); void neighborDown(); void startInactivityTimeCheck(); void stopInactivityTimeCheck(); void startFloodingTimer(Channel channel); void stopFloodingTimer(); void stopRxMtDdTimer(); void stopRxMtLsrTimer(); DdPacket lastDdPacket(); void setLastDdPacket(DdPacket lastDdPacket); Ip4Address neighborId(); void setNeighborId(Ip4Address neighborId); Ip4Address neighborDr(); void setNeighborDr(Ip4Address neighborDr); Ip4Address neighborBdr(); void setNeighborBdr(Ip4Address neighborBdr); int routerPriority(); void setRouterPriority(int routerPriority); int options(); void setOptions(int options); long ddSeqNum(); void setDdSeqNum(long ddSeqNum); int isMaster(); DdPacket lastSentDdPacket(); void setLastSentDdPacket(DdPacket lastSentDdPacket); LsRequest getLastSentLsrPacket(); void setLastSentLsrPacket(LsRequest lastSentLsrPacket); OspfNeighborState getState(); void setState(OspfNeighborState state); void setIsMaster(int isMaster); Hashtable getLsReqList(); Map getReTxList(); Map<String, OspfLsa> getPendingReTxList();  }