@Test public void testProcessLsPduMessage() throws Exception { lsPdu = new LsPdu(isisHeader); lsPdu.setSourceMac(macAddress1); lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value()); lsPdu.setLspId(sysId); isisMessage = lsPdu; defaultIsisInterface.setNetworkType(IsisNetworkType.P2P); defaultIsisInterface.setSystemId(sysId); defaultIsisInterface.processIsisMessage(isisMessage, isisLsdb, channel); assertThat(defaultIsisInterface, is(notNullValue())); }
public void processLsPduMessage(IsisMessage isisMessage, Channel channel) { log.debug("Enters processLsPduMessage ...!!!"); IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac()); if (networkType == IsisNetworkType.BROADCAST && neighbor == null) { return; } LsPdu lsPdu = (LsPdu) isisMessage; LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId()); if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) { if (wrapper != null) { String lspKey = isisLsdb.lspKey(systemId); if (lsPdu.lspId().equals(lspKey)) { lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1); if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) { isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber()); } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) { isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber()); } isisLsdb.addLsp(lsPdu, true, this); sendLsp(lsPdu, channel); } else { isisLsdb.addLsp(lsPdu, false, this); } } else { isisLsdb.addLsp(lsPdu, false, this); } } if (networkType() == IsisNetworkType.P2P) { IsisPduType psnpType = null; if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L1LSPDU) { psnpType = IsisPduType.L1PSNP; } else if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L2LSPDU) { psnpType = IsisPduType.L2PSNP; } IsisHeader isisHeader = new LspGenerator().getHeader(psnpType); Psnp psnp = new Psnp(isisHeader); psnp.setSourceId(lspKeyP2P(this.systemId)); TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(TlvType.LSPENTRY.value()); tlvHeader.setTlvLength(0); LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); LspEntry lspEntry = new LspEntry(); lspEntry.setLspChecksum(lsPdu.checkSum()); lspEntry.setLspId(lsPdu.lspId()); lspEntry.setLspSequenceNumber(lsPdu.sequenceNumber()); lspEntry.setRemainingTime(lsPdu.remainingLifeTime()); lspEntriesTlv.addLspEntry(lspEntry); psnp.addTlv(lspEntriesTlv); byte[] psnpBytes = psnp.asBytes(); psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION, IsisConstants.LENGTHPOSITION + 1, IsisConstants.RESERVEDPOSITION); flagValue = false; if (channel != null && channel.isConnected() && channel.isOpen()) { channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex)); } } }
DefaultIsisInterface implements IsisInterface { public void processLsPduMessage(IsisMessage isisMessage, Channel channel) { log.debug("Enters processLsPduMessage ...!!!"); IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac()); if (networkType == IsisNetworkType.BROADCAST && neighbor == null) { return; } LsPdu lsPdu = (LsPdu) isisMessage; LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId()); if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) { if (wrapper != null) { String lspKey = isisLsdb.lspKey(systemId); if (lsPdu.lspId().equals(lspKey)) { lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1); if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) { isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber()); } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) { isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber()); } isisLsdb.addLsp(lsPdu, true, this); sendLsp(lsPdu, channel); } else { isisLsdb.addLsp(lsPdu, false, this); } } else { isisLsdb.addLsp(lsPdu, false, this); } } if (networkType() == IsisNetworkType.P2P) { IsisPduType psnpType = null; if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L1LSPDU) { psnpType = IsisPduType.L1PSNP; } else if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L2LSPDU) { psnpType = IsisPduType.L2PSNP; } IsisHeader isisHeader = new LspGenerator().getHeader(psnpType); Psnp psnp = new Psnp(isisHeader); psnp.setSourceId(lspKeyP2P(this.systemId)); TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(TlvType.LSPENTRY.value()); tlvHeader.setTlvLength(0); LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); LspEntry lspEntry = new LspEntry(); lspEntry.setLspChecksum(lsPdu.checkSum()); lspEntry.setLspId(lsPdu.lspId()); lspEntry.setLspSequenceNumber(lsPdu.sequenceNumber()); lspEntry.setRemainingTime(lsPdu.remainingLifeTime()); lspEntriesTlv.addLspEntry(lspEntry); psnp.addTlv(lspEntriesTlv); byte[] psnpBytes = psnp.asBytes(); psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION, IsisConstants.LENGTHPOSITION + 1, IsisConstants.RESERVEDPOSITION); flagValue = false; if (channel != null && channel.isConnected() && channel.isOpen()) { channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex)); } } } }
DefaultIsisInterface implements IsisInterface { public void processLsPduMessage(IsisMessage isisMessage, Channel channel) { log.debug("Enters processLsPduMessage ...!!!"); IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac()); if (networkType == IsisNetworkType.BROADCAST && neighbor == null) { return; } LsPdu lsPdu = (LsPdu) isisMessage; LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId()); if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) { if (wrapper != null) { String lspKey = isisLsdb.lspKey(systemId); if (lsPdu.lspId().equals(lspKey)) { lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1); if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) { isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber()); } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) { isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber()); } isisLsdb.addLsp(lsPdu, true, this); sendLsp(lsPdu, channel); } else { isisLsdb.addLsp(lsPdu, false, this); } } else { isisLsdb.addLsp(lsPdu, false, this); } } if (networkType() == IsisNetworkType.P2P) { IsisPduType psnpType = null; if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L1LSPDU) { psnpType = IsisPduType.L1PSNP; } else if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L2LSPDU) { psnpType = IsisPduType.L2PSNP; } IsisHeader isisHeader = new LspGenerator().getHeader(psnpType); Psnp psnp = new Psnp(isisHeader); psnp.setSourceId(lspKeyP2P(this.systemId)); TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(TlvType.LSPENTRY.value()); tlvHeader.setTlvLength(0); LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); LspEntry lspEntry = new LspEntry(); lspEntry.setLspChecksum(lsPdu.checkSum()); lspEntry.setLspId(lsPdu.lspId()); lspEntry.setLspSequenceNumber(lsPdu.sequenceNumber()); lspEntry.setRemainingTime(lsPdu.remainingLifeTime()); lspEntriesTlv.addLspEntry(lspEntry); psnp.addTlv(lspEntriesTlv); byte[] psnpBytes = psnp.asBytes(); psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION, IsisConstants.LENGTHPOSITION + 1, IsisConstants.RESERVEDPOSITION); flagValue = false; if (channel != null && channel.isConnected() && channel.isOpen()) { channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex)); } } }  }
DefaultIsisInterface implements IsisInterface { public void processLsPduMessage(IsisMessage isisMessage, Channel channel) { log.debug("Enters processLsPduMessage ...!!!"); IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac()); if (networkType == IsisNetworkType.BROADCAST && neighbor == null) { return; } LsPdu lsPdu = (LsPdu) isisMessage; LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId()); if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) { if (wrapper != null) { String lspKey = isisLsdb.lspKey(systemId); if (lsPdu.lspId().equals(lspKey)) { lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1); if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) { isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber()); } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) { isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber()); } isisLsdb.addLsp(lsPdu, true, this); sendLsp(lsPdu, channel); } else { isisLsdb.addLsp(lsPdu, false, this); } } else { isisLsdb.addLsp(lsPdu, false, this); } } if (networkType() == IsisNetworkType.P2P) { IsisPduType psnpType = null; if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L1LSPDU) { psnpType = IsisPduType.L1PSNP; } else if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L2LSPDU) { psnpType = IsisPduType.L2PSNP; } IsisHeader isisHeader = new LspGenerator().getHeader(psnpType); Psnp psnp = new Psnp(isisHeader); psnp.setSourceId(lspKeyP2P(this.systemId)); TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(TlvType.LSPENTRY.value()); tlvHeader.setTlvLength(0); LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); LspEntry lspEntry = new LspEntry(); lspEntry.setLspChecksum(lsPdu.checkSum()); lspEntry.setLspId(lsPdu.lspId()); lspEntry.setLspSequenceNumber(lsPdu.sequenceNumber()); lspEntry.setRemainingTime(lsPdu.remainingLifeTime()); lspEntriesTlv.addLspEntry(lspEntry); psnp.addTlv(lspEntriesTlv); byte[] psnpBytes = psnp.asBytes(); psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION, IsisConstants.LENGTHPOSITION + 1, IsisConstants.RESERVEDPOSITION); flagValue = false; if (channel != null && channel.isConnected() && channel.isOpen()) { channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex)); } } }  IsisLsdb isisLsdb(); void setAllConfiguredInterfaceIps(List<Ip4Address> allConfiguredInterfaces); void removeNeighbor(IsisNeighbor isisNeighbor); void removeNeighbors(); IsisNeighbor lookup(MacAddress isisNeighborMac); Set<MacAddress> neighbors(); Channel channel(); int interfaceIndex(); void setInterfaceIndex(int interfaceIndex); Ip4Address interfaceIpAddress(); void setInterfaceIpAddress(Ip4Address interfaceIpAddress); byte[] networkMask(); void setNetworkMask(byte[] networkMask); MacAddress getInterfaceMacAddress(); void setInterfaceMacAddress(MacAddress interfaceMacAddress); String intermediateSystemName(); void setIntermediateSystemName(String intermediateSystemName); String systemId(); void setSystemId(String systemId); String l1LanId(); void setL1LanId(String l1LanId); String l2LanId(); void setL2LanId(String l2LanId); int getIdLength(); void setIdLength(int idLength); int getMaxAreaAddresses(); void setMaxAreaAddresses(int maxAreaAddresses); int reservedPacketCircuitType(); void setReservedPacketCircuitType(int reservedPacketCircuitType); IsisNetworkType networkType(); void setNetworkType(IsisNetworkType networkType); String areaAddress(); void setAreaAddress(String areaAddress); int getAreaLength(); void setAreaLength(int areaLength); int holdingTime(); void setHoldingTime(int holdingTime); int priority(); void setPriority(int priority); int helloInterval(); void setHelloInterval(int helloInterval); IsisInterfaceState interfaceState(); void setInterfaceState(IsisInterfaceState interfaceState); String circuitId(); void setCircuitId(String circuitId); void processIsisMessage(IsisMessage isisMessage, IsisLsdb isisLsdb, Channel channel); boolean validateHelloMessage(HelloPdu helloPdu); void processL1L2HelloPduMessage(IsisMessage isisMessage, Channel channel); void processP2pHelloPduMessage(IsisMessage isisMessage, Channel channel); void processLsPduMessage(IsisMessage isisMessage, Channel channel); void processPsnPduMessage(IsisMessage isisMessage, Channel channel); void processCsnPduMessage(IsisMessage isisMessage, Channel channel); String lspKeyP2P(String systemId); void startHelloSender(Channel channel); void stopHelloSender(); }
DefaultIsisInterface implements IsisInterface { public void processLsPduMessage(IsisMessage isisMessage, Channel channel) { log.debug("Enters processLsPduMessage ...!!!"); IsisNeighbor neighbor = neighbouringRouter(isisMessage.sourceMac()); if (networkType == IsisNetworkType.BROADCAST && neighbor == null) { return; } LsPdu lsPdu = (LsPdu) isisMessage; LspWrapper wrapper = isisLsdb.findLsp(lsPdu.isisPduType(), lsPdu.lspId()); if (wrapper == null || isisLsdb.isNewerOrSameLsp(lsPdu, wrapper.lsPdu()).equalsIgnoreCase("latest")) { if (wrapper != null) { String lspKey = isisLsdb.lspKey(systemId); if (lsPdu.lspId().equals(lspKey)) { lsPdu.setSequenceNumber(lsPdu.sequenceNumber() + 1); if (lsPdu.pduType() == IsisPduType.L1LSPDU.value()) { isisLsdb.setL1LspSeqNo(lsPdu.sequenceNumber()); } else if (lsPdu.pduType() == IsisPduType.L2LSPDU.value()) { isisLsdb.setL2LspSeqNo(lsPdu.sequenceNumber()); } isisLsdb.addLsp(lsPdu, true, this); sendLsp(lsPdu, channel); } else { isisLsdb.addLsp(lsPdu, false, this); } } else { isisLsdb.addLsp(lsPdu, false, this); } } if (networkType() == IsisNetworkType.P2P) { IsisPduType psnpType = null; if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L1LSPDU) { psnpType = IsisPduType.L1PSNP; } else if (IsisPduType.get(lsPdu.pduType()) == IsisPduType.L2LSPDU) { psnpType = IsisPduType.L2PSNP; } IsisHeader isisHeader = new LspGenerator().getHeader(psnpType); Psnp psnp = new Psnp(isisHeader); psnp.setSourceId(lspKeyP2P(this.systemId)); TlvHeader tlvHeader = new TlvHeader(); tlvHeader.setTlvType(TlvType.LSPENTRY.value()); tlvHeader.setTlvLength(0); LspEntriesTlv lspEntriesTlv = new LspEntriesTlv(tlvHeader); LspEntry lspEntry = new LspEntry(); lspEntry.setLspChecksum(lsPdu.checkSum()); lspEntry.setLspId(lsPdu.lspId()); lspEntry.setLspSequenceNumber(lsPdu.sequenceNumber()); lspEntry.setRemainingTime(lsPdu.remainingLifeTime()); lspEntriesTlv.addLspEntry(lspEntry); psnp.addTlv(lspEntriesTlv); byte[] psnpBytes = psnp.asBytes(); psnpBytes = IsisUtil.addLengthAndMarkItInReserved(psnpBytes, IsisConstants.LENGTHPOSITION, IsisConstants.LENGTHPOSITION + 1, IsisConstants.RESERVEDPOSITION); flagValue = false; if (channel != null && channel.isConnected() && channel.isOpen()) { channel.write(IsisUtil.framePacket(psnpBytes, interfaceIndex)); } } }  IsisLsdb isisLsdb(); void setAllConfiguredInterfaceIps(List<Ip4Address> allConfiguredInterfaces); void removeNeighbor(IsisNeighbor isisNeighbor); void removeNeighbors(); IsisNeighbor lookup(MacAddress isisNeighborMac); Set<MacAddress> neighbors(); Channel channel(); int interfaceIndex(); void setInterfaceIndex(int interfaceIndex); Ip4Address interfaceIpAddress(); void setInterfaceIpAddress(Ip4Address interfaceIpAddress); byte[] networkMask(); void setNetworkMask(byte[] networkMask); MacAddress getInterfaceMacAddress(); void setInterfaceMacAddress(MacAddress interfaceMacAddress); String intermediateSystemName(); void setIntermediateSystemName(String intermediateSystemName); String systemId(); void setSystemId(String systemId); String l1LanId(); void setL1LanId(String l1LanId); String l2LanId(); void setL2LanId(String l2LanId); int getIdLength(); void setIdLength(int idLength); int getMaxAreaAddresses(); void setMaxAreaAddresses(int maxAreaAddresses); int reservedPacketCircuitType(); void setReservedPacketCircuitType(int reservedPacketCircuitType); IsisNetworkType networkType(); void setNetworkType(IsisNetworkType networkType); String areaAddress(); void setAreaAddress(String areaAddress); int getAreaLength(); void setAreaLength(int areaLength); int holdingTime(); void setHoldingTime(int holdingTime); int priority(); void setPriority(int priority); int helloInterval(); void setHelloInterval(int helloInterval); IsisInterfaceState interfaceState(); void setInterfaceState(IsisInterfaceState interfaceState); String circuitId(); void setCircuitId(String circuitId); void processIsisMessage(IsisMessage isisMessage, IsisLsdb isisLsdb, Channel channel); boolean validateHelloMessage(HelloPdu helloPdu); void processL1L2HelloPduMessage(IsisMessage isisMessage, Channel channel); void processP2pHelloPduMessage(IsisMessage isisMessage, Channel channel); void processLsPduMessage(IsisMessage isisMessage, Channel channel); void processPsnPduMessage(IsisMessage isisMessage, Channel channel); void processCsnPduMessage(IsisMessage isisMessage, Channel channel); String lspKeyP2P(String systemId); void startHelloSender(Channel channel); void stopHelloSender();  }