Committed by
Gerrit Code Review
ONOS-4505: Bug Fixes
Change-Id: Ia030aa3aff9e2ad34a5e27fbe4ba088dda65bfa7
Showing
34 changed files
with
576 additions
and
47 deletions
... | @@ -195,13 +195,6 @@ public interface IsisInterface { | ... | @@ -195,13 +195,6 @@ public interface IsisInterface { |
195 | void setAreaLength(int areaLength); | 195 | void setAreaLength(int areaLength); |
196 | 196 | ||
197 | /** | 197 | /** |
198 | - * Sets link state packet ID. | ||
199 | - * | ||
200 | - * @param lspId link state packet ID | ||
201 | - */ | ||
202 | - void setLspId(String lspId); | ||
203 | - | ||
204 | - /** | ||
205 | * Returns holding time. | 198 | * Returns holding time. |
206 | * | 199 | * |
207 | * @return holding time | 200 | * @return holding time |
... | @@ -251,6 +244,11 @@ public interface IsisInterface { | ... | @@ -251,6 +244,11 @@ public interface IsisInterface { |
251 | void startHelloSender(Channel channel); | 244 | void startHelloSender(Channel channel); |
252 | 245 | ||
253 | /** | 246 | /** |
247 | + * Stops the hello timer which sends hello packet every configured seconds. | ||
248 | + */ | ||
249 | + void stopHelloSender(); | ||
250 | + | ||
251 | + /** | ||
254 | * Processes an ISIS message which is received on this interface. | 252 | * Processes an ISIS message which is received on this interface. |
255 | * | 253 | * |
256 | * @param isisMessage ISIS message instance | 254 | * @param isisMessage ISIS message instance |
... | @@ -315,4 +313,9 @@ public interface IsisInterface { | ... | @@ -315,4 +313,9 @@ public interface IsisInterface { |
315 | * @param isisNeighbor ISIS neighbor instance | 313 | * @param isisNeighbor ISIS neighbor instance |
316 | */ | 314 | */ |
317 | void removeNeighbor(IsisNeighbor isisNeighbor); | 315 | void removeNeighbor(IsisNeighbor isisNeighbor); |
316 | + | ||
317 | + /** | ||
318 | + * Removes all the neighbors. | ||
319 | + */ | ||
320 | + void removeNeighbors(); | ||
318 | } | 321 | } | ... | ... |
... | @@ -108,4 +108,18 @@ public interface IsisLsdb { | ... | @@ -108,4 +108,18 @@ public interface IsisLsdb { |
108 | * @return neighbor database information | 108 | * @return neighbor database information |
109 | */ | 109 | */ |
110 | Map<String, LspWrapper> getL2Db(); | 110 | Map<String, LspWrapper> getL2Db(); |
111 | + | ||
112 | + /** | ||
113 | + * Sets the level 1 link state sequence number. | ||
114 | + * | ||
115 | + * @param l1LspSeqNo link state sequence number | ||
116 | + */ | ||
117 | + void setL1LspSeqNo(int l1LspSeqNo); | ||
118 | + | ||
119 | + /** | ||
120 | + * Sets the level 2 link state sequence number. | ||
121 | + * | ||
122 | + * @param l2LspSeqNo link state sequence number | ||
123 | + */ | ||
124 | + void setL2LspSeqNo(int l2LspSeqNo); | ||
111 | } | 125 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -108,4 +108,16 @@ public interface IsisNeighbor { | ... | @@ -108,4 +108,16 @@ public interface IsisNeighbor { |
108 | * Stops the inactivity timer. | 108 | * Stops the inactivity timer. |
109 | */ | 109 | */ |
110 | void stopInactivityTimeCheck(); | 110 | void stopInactivityTimeCheck(); |
111 | + | ||
112 | + /** | ||
113 | + * Stops the holding time check timer. | ||
114 | + */ | ||
115 | + void stopHoldingTimeCheck(); | ||
116 | + | ||
117 | + /** | ||
118 | + * Returns router type. | ||
119 | + * | ||
120 | + * @return router type | ||
121 | + */ | ||
122 | + IsisRouterType routerType(); | ||
111 | } | 123 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
100755 → 100644
This diff is collapsed. Click to expand it.
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisController.java
100755 → 100644
File mode changed
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisInterface.java
100755 → 100644
This diff is collapsed. Click to expand it.
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisNeighbor.java
100755 → 100644
... | @@ -88,6 +88,7 @@ public class DefaultIsisNeighbor implements IsisNeighbor { | ... | @@ -88,6 +88,7 @@ public class DefaultIsisNeighbor implements IsisNeighbor { |
88 | } | 88 | } |
89 | this.isisInterface = isisInterface; | 89 | this.isisInterface = isisInterface; |
90 | startHoldingTimeCheck(); | 90 | startHoldingTimeCheck(); |
91 | + log.debug("Neighbor added - {}", neighborMacAddress); | ||
91 | } | 92 | } |
92 | 93 | ||
93 | /** | 94 | /** |
... | @@ -387,6 +388,10 @@ public class DefaultIsisNeighbor implements IsisNeighbor { | ... | @@ -387,6 +388,10 @@ public class DefaultIsisNeighbor implements IsisNeighbor { |
387 | @Override | 388 | @Override |
388 | public void run() { | 389 | public void run() { |
389 | holdingTime--; | 390 | holdingTime--; |
391 | + if (holdingTime <= 0) { | ||
392 | + log.debug("Calling neighbor down. Holding time is 0."); | ||
393 | + neighborDown(); | ||
394 | + } | ||
390 | } | 395 | } |
391 | } | 396 | } |
392 | } | 397 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/DefaultIsisProcess.java
100755 → 100644
File mode changed
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisChannelHandler.java
100755 → 100644
... | @@ -94,13 +94,35 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -94,13 +94,35 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { |
94 | for (IsisInterface isisUpdatedInterface : isisUpdatedProcess.isisInterfaceList()) { | 94 | for (IsisInterface isisUpdatedInterface : isisUpdatedProcess.isisInterfaceList()) { |
95 | IsisInterface isisInterface = isisInterfaceMap.get(isisUpdatedInterface.interfaceIndex()); | 95 | IsisInterface isisInterface = isisInterfaceMap.get(isisUpdatedInterface.interfaceIndex()); |
96 | if (isisInterface == null) { | 96 | if (isisInterface == null) { |
97 | - isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface); | 97 | + isisInterfaceMap.put(isisUpdatedInterface.interfaceIndex(), isisUpdatedInterface); |
98 | - interfaceIps.add(isisInterface.interfaceIpAddress()); | 98 | + interfaceIps.add(isisUpdatedInterface.interfaceIpAddress()); |
99 | } else { | 99 | } else { |
100 | + if (isisInterface.intermediateSystemName() != isisUpdatedInterface.intermediateSystemName()) { | ||
101 | + isisInterface.setIntermediateSystemName(isisUpdatedInterface.intermediateSystemName()); | ||
102 | + } | ||
103 | + if (isisInterface.reservedPacketCircuitType() != isisUpdatedInterface.reservedPacketCircuitType()) { | ||
100 | isisInterface.setReservedPacketCircuitType(isisUpdatedInterface.reservedPacketCircuitType()); | 104 | isisInterface.setReservedPacketCircuitType(isisUpdatedInterface.reservedPacketCircuitType()); |
105 | + isisInterface.removeNeighbors(); | ||
106 | + } | ||
107 | + if (isisInterface.circuitId() != isisUpdatedInterface.circuitId()) { | ||
108 | + isisInterface.setCircuitId(isisUpdatedInterface.circuitId()); | ||
109 | + } | ||
110 | + if (isisInterface.networkType() != isisUpdatedInterface.networkType()) { | ||
101 | isisInterface.setNetworkType(isisUpdatedInterface.networkType()); | 111 | isisInterface.setNetworkType(isisUpdatedInterface.networkType()); |
112 | + isisInterface.removeNeighbors(); | ||
113 | + } | ||
114 | + if (isisInterface.areaAddress() != isisUpdatedInterface.areaAddress()) { | ||
115 | + isisInterface.setAreaAddress(isisUpdatedInterface.areaAddress()); | ||
116 | + } | ||
117 | + if (isisInterface.holdingTime() != isisUpdatedInterface.holdingTime()) { | ||
102 | isisInterface.setHoldingTime(isisUpdatedInterface.holdingTime()); | 118 | isisInterface.setHoldingTime(isisUpdatedInterface.holdingTime()); |
119 | + } | ||
120 | + if (isisInterface.helloInterval() != isisUpdatedInterface.helloInterval()) { | ||
103 | isisInterface.setHelloInterval(isisUpdatedInterface.helloInterval()); | 121 | isisInterface.setHelloInterval(isisUpdatedInterface.helloInterval()); |
122 | + isisInterface.stopHelloSender(); | ||
123 | + isisInterface.startHelloSender(channel); | ||
124 | + } | ||
125 | + | ||
104 | isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface); | 126 | isisInterfaceMap.put(isisInterface.interfaceIndex(), isisInterface); |
105 | } | 127 | } |
106 | } | 128 | } |
... | @@ -144,6 +166,9 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -144,6 +166,9 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { |
144 | @Override | 166 | @Override |
145 | public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) { | 167 | public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent evt) { |
146 | log.debug("IsisChannelHandler::channelDisconnected...!!!"); | 168 | log.debug("IsisChannelHandler::channelDisconnected...!!!"); |
169 | + if (controller != null) { | ||
170 | + controller.connectPeer(); | ||
171 | + } | ||
147 | } | 172 | } |
148 | 173 | ||
149 | @Override | 174 | @Override |
... | @@ -169,8 +194,9 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -169,8 +194,9 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler { |
169 | } else if (e.getCause() instanceof RejectedExecutionException) { | 194 | } else if (e.getCause() instanceof RejectedExecutionException) { |
170 | log.warn("Could not process message: queue full"); | 195 | log.warn("Could not process message: queue full"); |
171 | } else { | 196 | } else { |
172 | - log.error("Error while processing message from ISIS {}", | 197 | + log.error("Error while processing message from ISIS {}, {}", |
173 | - e.getChannel().getRemoteAddress()); | 198 | + e.getChannel().getRemoteAddress(), e.getCause().getMessage()); |
199 | + e.getCause().printStackTrace(); | ||
174 | } | 200 | } |
175 | } | 201 | } |
176 | 202 | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisHelloPduSender.java
100755 → 100644
... | @@ -45,7 +45,7 @@ public class IsisHelloPduSender implements Runnable { | ... | @@ -45,7 +45,7 @@ public class IsisHelloPduSender implements Runnable { |
45 | 45 | ||
46 | @Override | 46 | @Override |
47 | public void run() { | 47 | public void run() { |
48 | - if (channel != null) { | 48 | + if (channel != null && channel.isConnected() && channel.isOpen()) { |
49 | try { | 49 | try { |
50 | byte[] helloPdu = null; | 50 | byte[] helloPdu = null; |
51 | byte[] interfaceIndex = {(byte) isisInterface.interfaceIndex()}; | 51 | byte[] interfaceIndex = {(byte) isisInterface.interfaceIndex()}; | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageDecoder.java
100755 → 100644
... | @@ -44,7 +44,6 @@ public class IsisMessageDecoder extends FrameDecoder { | ... | @@ -44,7 +44,6 @@ public class IsisMessageDecoder extends FrameDecoder { |
44 | log.info("Channel is not connected."); | 44 | log.info("Channel is not connected."); |
45 | return null; | 45 | return null; |
46 | } | 46 | } |
47 | - | ||
48 | IsisMessageReader messageReader = new IsisMessageReader(); | 47 | IsisMessageReader messageReader = new IsisMessageReader(); |
49 | List<IsisMessage> isisMessageList = new LinkedList<>(); | 48 | List<IsisMessage> isisMessageList = new LinkedList<>(); |
50 | int dataLength = buffer.readableBytes(); | 49 | int dataLength = buffer.readableBytes(); |
... | @@ -74,8 +73,7 @@ public class IsisMessageDecoder extends FrameDecoder { | ... | @@ -74,8 +73,7 @@ public class IsisMessageDecoder extends FrameDecoder { |
74 | isisMessageList.add(message); | 73 | isisMessageList.add(message); |
75 | } | 74 | } |
76 | } | 75 | } |
77 | - | 76 | + return (isisMessageList.size() > 0) ? isisMessageList : null; |
78 | - return isisMessageList; | ||
79 | } | 77 | } |
80 | 78 | ||
81 | /** | 79 | /** | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisMessageEncoder.java
100755 → 100644
File mode changed
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/IsisPipelineFactory.java
100755 → 100644
File mode changed
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdb.java
100755 → 100644
... | @@ -45,7 +45,6 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -45,7 +45,6 @@ public class DefaultIsisLsdb implements IsisLsdb { |
45 | private IsisLsdbAge lsdbAge = null; | 45 | private IsisLsdbAge lsdbAge = null; |
46 | 46 | ||
47 | 47 | ||
48 | - | ||
49 | private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; | 48 | private int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; |
50 | private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; | 49 | private int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; |
51 | 50 | ||
... | @@ -80,6 +79,7 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -80,6 +79,7 @@ public class DefaultIsisLsdb implements IsisLsdb { |
80 | public void setL2LspSeqNo(int l2LspSeqNo) { | 79 | public void setL2LspSeqNo(int l2LspSeqNo) { |
81 | this.l2LspSeqNo = l2LspSeqNo; | 80 | this.l2LspSeqNo = l2LspSeqNo; |
82 | } | 81 | } |
82 | + | ||
83 | /** | 83 | /** |
84 | * Returns the LSDB LSP key. | 84 | * Returns the LSDB LSP key. |
85 | * | 85 | * |
... | @@ -96,6 +96,7 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -96,6 +96,7 @@ public class DefaultIsisLsdb implements IsisLsdb { |
96 | return lspKey.toString(); | 96 | return lspKey.toString(); |
97 | } | 97 | } |
98 | 98 | ||
99 | + | ||
99 | /** | 100 | /** |
100 | * Returns the neighbor L1 database information. | 101 | * Returns the neighbor L1 database information. |
101 | * | 102 | * |
... | @@ -218,7 +219,12 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -218,7 +219,12 @@ public class DefaultIsisLsdb implements IsisLsdb { |
218 | byte[] checkSum = {lspBytes[IsisConstants.CHECKSUMPOSITION], lspBytes[IsisConstants.CHECKSUMPOSITION + 1]}; | 219 | byte[] checkSum = {lspBytes[IsisConstants.CHECKSUMPOSITION], lspBytes[IsisConstants.CHECKSUMPOSITION + 1]}; |
219 | lspdu.setCheckSum(ChannelBuffers.copiedBuffer(checkSum).readUnsignedShort()); | 220 | lspdu.setCheckSum(ChannelBuffers.copiedBuffer(checkSum).readUnsignedShort()); |
220 | } | 221 | } |
221 | - DefaultLspWrapper lspWrapper = new DefaultLspWrapper(); | 222 | + |
223 | + DefaultLspWrapper lspWrapper = (DefaultLspWrapper) findLsp(lspdu.isisPduType(), lspdu.lspId()); | ||
224 | + if (lspWrapper == null) { | ||
225 | + lspWrapper = new DefaultLspWrapper(); | ||
226 | + } | ||
227 | + | ||
222 | lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime()); | 228 | lspWrapper.setLspAgeReceived(IsisConstants.LSPMAXAGE - lspdu.remainingLifeTime()); |
223 | lspWrapper.setLspType(IsisPduType.get(lspdu.pduType())); | 229 | lspWrapper.setLspType(IsisPduType.get(lspdu.pduType())); |
224 | lspWrapper.setLsPdu(lspdu); | 230 | lspWrapper.setLsPdu(lspdu); |
... | @@ -228,8 +234,8 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -228,8 +234,8 @@ public class DefaultIsisLsdb implements IsisLsdb { |
228 | lspWrapper.setIsisInterface(isisInterface); | 234 | lspWrapper.setIsisInterface(isisInterface); |
229 | lspWrapper.setLsdbAge(lsdbAge); | 235 | lspWrapper.setLsdbAge(lsdbAge); |
230 | addLsp(lspWrapper, lspdu.lspId()); | 236 | addLsp(lspWrapper, lspdu.lspId()); |
231 | - log.debug("Added LSp In LSDB: {}", lspWrapper); | ||
232 | 237 | ||
238 | + log.debug("Added LSp In LSDB: {}", lspWrapper); | ||
233 | return true; | 239 | return true; |
234 | } | 240 | } |
235 | 241 | ||
... | @@ -270,7 +276,6 @@ public class DefaultIsisLsdb implements IsisLsdb { | ... | @@ -270,7 +276,6 @@ public class DefaultIsisLsdb implements IsisLsdb { |
270 | lspWrapper.lsPdu().isisPduType(), | 276 | lspWrapper.lsPdu().isisPduType(), |
271 | binNumber, lspWrapper.remainingLifetime()); | 277 | binNumber, lspWrapper.remainingLifetime()); |
272 | } | 278 | } |
273 | - | ||
274 | return false; | 279 | return false; |
275 | } | 280 | } |
276 | 281 | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLsdbAge.java
100755 → 100644
... | @@ -36,10 +36,10 @@ import java.util.concurrent.TimeUnit; | ... | @@ -36,10 +36,10 @@ import java.util.concurrent.TimeUnit; |
36 | */ | 36 | */ |
37 | public class DefaultIsisLsdbAge implements IsisLsdbAge { | 37 | public class DefaultIsisLsdbAge implements IsisLsdbAge { |
38 | private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdbAge.class); | 38 | private static final Logger log = LoggerFactory.getLogger(DefaultIsisLsdbAge.class); |
39 | - protected static int ageCounter = 0; | 39 | + protected int ageCounter = 0; |
40 | private InternalAgeTimer dbAgeTimer; | 40 | private InternalAgeTimer dbAgeTimer; |
41 | private ScheduledExecutorService exServiceage; | 41 | private ScheduledExecutorService exServiceage; |
42 | - private Integer maxBins = 1200; | 42 | + private Integer maxBins = IsisConstants.LSPMAXAGE; |
43 | private Map<Integer, IsisLspBin> ageBins = new ConcurrentHashMap<>(maxBins); | 43 | private Map<Integer, IsisLspBin> ageBins = new ConcurrentHashMap<>(maxBins); |
44 | private int ageCounterRollOver = 0; | 44 | private int ageCounterRollOver = 0; |
45 | private IsisLspQueueConsumer queueConsumer = null; | 45 | private IsisLspQueueConsumer queueConsumer = null; |
... | @@ -202,7 +202,7 @@ public class DefaultIsisLsdbAge implements IsisLsdbAge { | ... | @@ -202,7 +202,7 @@ public class DefaultIsisLsdbAge implements IsisLsdbAge { |
202 | } else { | 202 | } else { |
203 | binNumber = ageCounter - IsisConstants.LSPREFRESH; | 203 | binNumber = ageCounter - IsisConstants.LSPREFRESH; |
204 | } | 204 | } |
205 | - if (binNumber > IsisConstants.LSPMAXAGE) { | 205 | + if (binNumber >= IsisConstants.LSPMAXAGE) { |
206 | binNumber = binNumber - IsisConstants.LSPMAXAGE; | 206 | binNumber = binNumber - IsisConstants.LSPMAXAGE; |
207 | } | 207 | } |
208 | IsisLspBin lspBin = ageBins.get(binNumber); | 208 | IsisLspBin lspBin = ageBins.get(binNumber); | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultIsisLspBin.java
100755 → 100644
File mode changed
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/DefaultLspWrapper.java
100755 → 100644
... | @@ -21,11 +21,14 @@ import org.onosproject.isis.controller.IsisPduType; | ... | @@ -21,11 +21,14 @@ import org.onosproject.isis.controller.IsisPduType; |
21 | import org.onosproject.isis.controller.LspWrapper; | 21 | import org.onosproject.isis.controller.LspWrapper; |
22 | import org.onosproject.isis.io.isispacket.pdu.LsPdu; | 22 | import org.onosproject.isis.io.isispacket.pdu.LsPdu; |
23 | import org.onosproject.isis.io.util.IsisConstants; | 23 | import org.onosproject.isis.io.util.IsisConstants; |
24 | +import org.slf4j.Logger; | ||
25 | +import org.slf4j.LoggerFactory; | ||
24 | 26 | ||
25 | /** | 27 | /** |
26 | * Representation of LSP wrapper where the LSPs are stored with metadata. | 28 | * Representation of LSP wrapper where the LSPs are stored with metadata. |
27 | */ | 29 | */ |
28 | public class DefaultLspWrapper implements LspWrapper { | 30 | public class DefaultLspWrapper implements LspWrapper { |
31 | + private static final Logger log = LoggerFactory.getLogger(DefaultLspWrapper.class); | ||
29 | private int binNumber = -1; | 32 | private int binNumber = -1; |
30 | private boolean selfOriginated = false; | 33 | private boolean selfOriginated = false; |
31 | private IsisPduType lspType; | 34 | private IsisPduType lspType; |
... | @@ -229,8 +232,16 @@ public class DefaultLspWrapper implements LspWrapper { | ... | @@ -229,8 +232,16 @@ public class DefaultLspWrapper implements LspWrapper { |
229 | int currentAge = 0; | 232 | int currentAge = 0; |
230 | //ls age received | 233 | //ls age received |
231 | if (lsdbAge.ageCounter() >= ageCounterWhenReceived) { | 234 | if (lsdbAge.ageCounter() >= ageCounterWhenReceived) { |
235 | + if (!selfOriginated) { | ||
236 | + if (ageCounterRollOverWhenAdded == lsdbAge.ageCounterRollOver()) { | ||
232 | currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived); | 237 | currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived); |
233 | } else { | 238 | } else { |
239 | + return IsisConstants.LSPMAXAGE; | ||
240 | + } | ||
241 | + } else { | ||
242 | + currentAge = lspAgeReceived + (lsdbAge.ageCounter() - ageCounterWhenReceived); | ||
243 | + } | ||
244 | + } else { | ||
234 | currentAge = lspAgeReceived + ((IsisConstants.LSPMAXAGE + lsdbAge.ageCounter()) | 245 | currentAge = lspAgeReceived + ((IsisConstants.LSPMAXAGE + lsdbAge.ageCounter()) |
235 | - ageCounterWhenReceived); | 246 | - ageCounterWhenReceived); |
236 | } | 247 | } |
... | @@ -245,6 +256,8 @@ public class DefaultLspWrapper implements LspWrapper { | ... | @@ -245,6 +256,8 @@ public class DefaultLspWrapper implements LspWrapper { |
245 | return currentAge; | 256 | return currentAge; |
246 | } | 257 | } |
247 | 258 | ||
259 | + | ||
260 | + | ||
248 | /** | 261 | /** |
249 | * Returns remaining time. | 262 | * Returns remaining time. |
250 | * | 263 | * |
... | @@ -252,7 +265,7 @@ public class DefaultLspWrapper implements LspWrapper { | ... | @@ -252,7 +265,7 @@ public class DefaultLspWrapper implements LspWrapper { |
252 | */ | 265 | */ |
253 | public int remainingLifetime() { | 266 | public int remainingLifetime() { |
254 | //Calculate the remaining lifetime | 267 | //Calculate the remaining lifetime |
255 | - remainingLifetime = IsisConstants.LSPMAXAGE - lsdbAge.ageCounter(); | 268 | + remainingLifetime = IsisConstants.LSPMAXAGE - currentAge(); |
256 | return remainingLifetime; | 269 | return remainingLifetime; |
257 | } | 270 | } |
258 | 271 | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
100755 → 100644
... | @@ -100,7 +100,9 @@ public class IsisLspQueueConsumer implements Runnable { | ... | @@ -100,7 +100,9 @@ public class IsisLspQueueConsumer implements Runnable { |
100 | IsisConstants.CHECKSUMPOSITION + 1); | 100 | IsisConstants.CHECKSUMPOSITION + 1); |
101 | //write to the channel | 101 | //write to the channel |
102 | channel.write(IsisUtil.framePacket(lspBytes, isisInterface.interfaceIndex())); | 102 | channel.write(IsisUtil.framePacket(lspBytes, isisInterface.interfaceIndex())); |
103 | - | 103 | + // Updating the database with resetting remaining life time to default. |
104 | + IsisLsdb isisDb = isisInterface.isisLsdb(); | ||
105 | + isisDb.addLsp(lsPdu, true, isisInterface); | ||
104 | log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}", | 106 | log.debug("LSPQueueConsumer: processRefreshLsp - Flooded SelfOriginated LSP {}", |
105 | wrapper.lsPdu()); | 107 | wrapper.lsPdu()); |
106 | } | 108 | } | ... | ... |
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/package-info.java
100755 → 100644
File mode changed
protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/package-info.java
100755 → 100644
File mode changed
... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
16 | 16 | ||
17 | package org.onosproject.isis.controller.impl; | 17 | package org.onosproject.isis.controller.impl; |
18 | 18 | ||
19 | +import com.fasterxml.jackson.databind.JsonNode; | ||
20 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
19 | import org.junit.After; | 21 | import org.junit.After; |
20 | import org.junit.Before; | 22 | import org.junit.Before; |
21 | import org.junit.Test; | 23 | import org.junit.Test; |
... | @@ -30,10 +32,65 @@ import static org.junit.Assert.assertThat; | ... | @@ -30,10 +32,65 @@ import static org.junit.Assert.assertThat; |
30 | public class ControllerTest { | 32 | public class ControllerTest { |
31 | 33 | ||
32 | private Controller controller; | 34 | private Controller controller; |
35 | + private ObjectMapper mapper; | ||
36 | + private JsonNode jsonNode; | ||
37 | + private JsonNode jsonNode1; | ||
38 | + private String jsonString = "{" + | ||
39 | + " \"processes\": [{" + | ||
40 | + " \"processId\": \"4.4.4.4\"," + | ||
41 | + " \"interface\": [{" + | ||
42 | + " \"interfaceIndex\": \"2\"," + | ||
43 | + " \"macAddress\": \"08:00:27:b7:ab:bf\"," + | ||
44 | + " \"interfaceIp\": \"192.168.56.101\"," + | ||
45 | + " \"networkMask\": \"255.255.255.224\"," + | ||
46 | + " \"intermediateSystemName\": \"ROUTERONE\"," + | ||
47 | + " \"systemId\": \"2929.2929.2929\"," + | ||
48 | + " \"lanId\": \"0000.0000.0000.00\"," + | ||
49 | + " \"idLength\": \"0\"," + | ||
50 | + " \"maxAreaAddresses\": \"3\"," + | ||
51 | + " \"reservedPacketCircuitType\": \"1\"," + | ||
52 | + " \"circuitId\": \"10\"," + | ||
53 | + " \"networkType\": \"2\"," + | ||
54 | + " \"areaAddress\": \"490000\"," + | ||
55 | + " \"areaLength\": \"3\"," + | ||
56 | + " \"lspId\": \"1313131313130000\"," + | ||
57 | + " \"holdingTime\": \"50\"," + | ||
58 | + " \"helloInterval\": \"10\"," + | ||
59 | + " \"priority\": \"0\"" + | ||
60 | + " }]" + | ||
61 | + " }]" + | ||
62 | + "}"; | ||
63 | + private String jsonString1 = "{" + | ||
64 | + " \"processes\": {" + | ||
65 | + " \"interface\": [{" + | ||
66 | + " \"interfaceIndex\": \"2\"," + | ||
67 | + " \"interfaceIp\": \"100.100.100.100\"," + | ||
68 | + " \"macAddress\": \"08:00:27:b7:ab:bf\"," + | ||
69 | + " \"networkMask\": \"255.255.255.224\"," + | ||
70 | + " \"intermediateSystemName\": \"ROUTERONE\"," + | ||
71 | + " \"systemId\": \"2929.2929.2929\"," + | ||
72 | + " \"lanId\": \"0000.0000.0000.00\"," + | ||
73 | + " \"idLength\": \"0\"," + | ||
74 | + " \"maxAreaAddresses\": \"3\"," + | ||
75 | + " \"reservedPacketCircuitType\": \"1\"," + | ||
76 | + " \"circuitId\": \"10\"," + | ||
77 | + " \"networkType\": \"2\"," + | ||
78 | + " \"areaAddress\": \"490000\"," + | ||
79 | + " \"areaLength\": \"3\"," + | ||
80 | + " \"lspId\": \"1313131313130000\"," + | ||
81 | + " \"holdingTime\": \"50\"," + | ||
82 | + " \"helloInterval\": \"10\"," + | ||
83 | + " \"priority\": \"0\"" + | ||
84 | + " }]" + | ||
85 | + " }" + | ||
86 | + "}"; | ||
33 | 87 | ||
34 | @Before | 88 | @Before |
35 | public void setUp() throws Exception { | 89 | public void setUp() throws Exception { |
36 | controller = new Controller(); | 90 | controller = new Controller(); |
91 | + mapper = new ObjectMapper(); | ||
92 | + jsonNode = mapper.readTree(jsonString); | ||
93 | + jsonNode1 = mapper.readTree(jsonString1); | ||
37 | } | 94 | } |
38 | 95 | ||
39 | @After | 96 | @After |
... | @@ -58,4 +115,18 @@ public class ControllerTest { | ... | @@ -58,4 +115,18 @@ public class ControllerTest { |
58 | controller.getAllConfiguredProcesses(); | 115 | controller.getAllConfiguredProcesses(); |
59 | assertThat(controller, is(notNullValue())); | 116 | assertThat(controller, is(notNullValue())); |
60 | } | 117 | } |
118 | + | ||
119 | + /** | ||
120 | + * Tests updateConfig() method. | ||
121 | + */ | ||
122 | + @Test | ||
123 | + public void testUpdateConfig() throws Exception { | ||
124 | + jsonNode.path("interface"); | ||
125 | + controller.updateConfig(jsonNode); | ||
126 | + assertThat(controller, is(notNullValue())); | ||
127 | + | ||
128 | + controller.updateConfig(jsonNode1); | ||
129 | + assertThat(controller, is(notNullValue())); | ||
130 | + } | ||
131 | + | ||
61 | } | 132 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
protocols/isis/ctl/src/test/java/org/onosproject/isis/controller/impl/DefaultIsisControllerTest.java
... | @@ -15,9 +15,13 @@ | ... | @@ -15,9 +15,13 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.isis.controller.impl; | 16 | package org.onosproject.isis.controller.impl; |
17 | 17 | ||
18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
19 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
20 | +import org.easymock.EasyMock; | ||
18 | import org.junit.After; | 21 | import org.junit.After; |
19 | import org.junit.Before; | 22 | import org.junit.Before; |
20 | import org.junit.Test; | 23 | import org.junit.Test; |
24 | +import org.onosproject.isis.controller.topology.IsisRouterListener; | ||
21 | 25 | ||
22 | import static org.hamcrest.CoreMatchers.is; | 26 | import static org.hamcrest.CoreMatchers.is; |
23 | import static org.hamcrest.CoreMatchers.notNullValue; | 27 | import static org.hamcrest.CoreMatchers.notNullValue; |
... | @@ -27,11 +31,43 @@ import static org.junit.Assert.assertThat; | ... | @@ -27,11 +31,43 @@ import static org.junit.Assert.assertThat; |
27 | * Unit test case for DefaultIsisController. | 31 | * Unit test case for DefaultIsisController. |
28 | */ | 32 | */ |
29 | public class DefaultIsisControllerTest { | 33 | public class DefaultIsisControllerTest { |
34 | + private ObjectMapper mapper; | ||
35 | + private JsonNode jsonNode; | ||
30 | private DefaultIsisController defaultIsisController; | 36 | private DefaultIsisController defaultIsisController; |
37 | + private String jsonString = "{" + | ||
38 | + " \"processes\": [{" + | ||
39 | + " \"processId\": \"4.4.4.4\"," + | ||
40 | + " \"interface\": [{" + | ||
41 | + " \"interfaceIndex\": \"2\"," + | ||
42 | + " \"macAddress\": \"08:00:27:b7:ab:bf\"," + | ||
43 | + " \"interfaceIp\": \"192.168.56.101\"," + | ||
44 | + " \"networkMask\": \"255.255.255.224\"," + | ||
45 | + " \"intermediateSystemName\": \"ROUTERONE\"," + | ||
46 | + " \"systemId\": \"2929.2929.2929\"," + | ||
47 | + " \"lanId\": \"0000.0000.0000.00\"," + | ||
48 | + " \"idLength\": \"0\"," + | ||
49 | + " \"maxAreaAddresses\": \"3\"," + | ||
50 | + " \"reservedPacketCircuitType\": \"1\"," + | ||
51 | + " \"circuitId\": \"10\"," + | ||
52 | + " \"networkType\": \"2\"," + | ||
53 | + " \"areaAddress\": \"490000\"," + | ||
54 | + " \"areaLength\": \"3\"," + | ||
55 | + " \"lspId\": \"1313131313130000\"," + | ||
56 | + " \"holdingTime\": \"50\"," + | ||
57 | + " \"helloInterval\": \"10\"," + | ||
58 | + " \"priority\": \"0\"" + | ||
59 | + " }]" + | ||
60 | + " }]" + | ||
61 | + "}"; | ||
62 | + | ||
63 | + private IsisRouterListener isisRouterListener; | ||
31 | 64 | ||
32 | @Before | 65 | @Before |
33 | public void setUp() throws Exception { | 66 | public void setUp() throws Exception { |
34 | defaultIsisController = new DefaultIsisController(); | 67 | defaultIsisController = new DefaultIsisController(); |
68 | + mapper = new ObjectMapper(); | ||
69 | + jsonNode = mapper.readTree(jsonString); | ||
70 | + isisRouterListener = EasyMock.createNiceMock(IsisRouterListener.class); | ||
35 | } | 71 | } |
36 | 72 | ||
37 | @After | 73 | @After |
... | @@ -66,4 +102,31 @@ public class DefaultIsisControllerTest { | ... | @@ -66,4 +102,31 @@ public class DefaultIsisControllerTest { |
66 | defaultIsisController.allConfiguredProcesses(); | 102 | defaultIsisController.allConfiguredProcesses(); |
67 | assertThat(defaultIsisController, is(notNullValue())); | 103 | assertThat(defaultIsisController, is(notNullValue())); |
68 | } | 104 | } |
105 | + | ||
106 | + /** | ||
107 | + * Tests updateConfig() method. | ||
108 | + */ | ||
109 | + @Test | ||
110 | + public void testUpdateConfig() throws Exception { | ||
111 | + defaultIsisController.updateConfig(jsonNode); | ||
112 | + assertThat(defaultIsisController, is(notNullValue())); | ||
113 | + } | ||
114 | + | ||
115 | + /** | ||
116 | + * Tests addRouterListener() method. | ||
117 | + */ | ||
118 | + @Test | ||
119 | + public void testaddRouterListener() throws Exception { | ||
120 | + defaultIsisController.addRouterListener(isisRouterListener); | ||
121 | + assertThat(defaultIsisController, is(notNullValue())); | ||
122 | + } | ||
123 | + | ||
124 | + /** | ||
125 | + * Tests removeRouterListener() method. | ||
126 | + */ | ||
127 | + @Test | ||
128 | + public void testremoveRouterListener() throws Exception { | ||
129 | + defaultIsisController.removeRouterListener(isisRouterListener); | ||
130 | + assertThat(defaultIsisController, is(notNullValue())); | ||
131 | + } | ||
69 | } | 132 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -36,6 +36,7 @@ public class DefaultIsisProcessTest { | ... | @@ -36,6 +36,7 @@ public class DefaultIsisProcessTest { |
36 | private final String processId = "1"; | 36 | private final String processId = "1"; |
37 | private IsisProcess isisProcess; | 37 | private IsisProcess isisProcess; |
38 | private String result; | 38 | private String result; |
39 | + private IsisProcess defaultIsisProcess; | ||
39 | private IsisInterface isisInterface; | 40 | private IsisInterface isisInterface; |
40 | private List<IsisInterface> isisInterfaceList; | 41 | private List<IsisInterface> isisInterfaceList; |
41 | private List<IsisInterface> result1; | 42 | private List<IsisInterface> result1; |
... | @@ -44,6 +45,7 @@ public class DefaultIsisProcessTest { | ... | @@ -44,6 +45,7 @@ public class DefaultIsisProcessTest { |
44 | public void setUp() throws Exception { | 45 | public void setUp() throws Exception { |
45 | isisProcess = new DefaultIsisProcess(); | 46 | isisProcess = new DefaultIsisProcess(); |
46 | isisInterface = EasyMock.createNiceMock(DefaultIsisInterface.class); | 47 | isisInterface = EasyMock.createNiceMock(DefaultIsisInterface.class); |
48 | + defaultIsisProcess = new DefaultIsisProcess(); | ||
47 | } | 49 | } |
48 | 50 | ||
49 | @After | 51 | @After | ... | ... |
... | @@ -23,10 +23,14 @@ import org.jboss.netty.channel.MessageEvent; | ... | @@ -23,10 +23,14 @@ import org.jboss.netty.channel.MessageEvent; |
23 | import org.junit.After; | 23 | import org.junit.After; |
24 | import org.junit.Before; | 24 | import org.junit.Before; |
25 | import org.junit.Test; | 25 | import org.junit.Test; |
26 | +import org.onlab.packet.Ip4Address; | ||
27 | +import org.onosproject.isis.controller.IsisInterface; | ||
26 | import org.onosproject.isis.controller.IsisMessage; | 28 | import org.onosproject.isis.controller.IsisMessage; |
29 | +import org.onosproject.isis.controller.IsisNetworkType; | ||
27 | import org.onosproject.isis.controller.IsisProcess; | 30 | import org.onosproject.isis.controller.IsisProcess; |
28 | import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu; | 31 | import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu; |
29 | 32 | ||
33 | +import java.util.ArrayList; | ||
30 | import java.util.List; | 34 | import java.util.List; |
31 | 35 | ||
32 | import static org.hamcrest.CoreMatchers.is; | 36 | import static org.hamcrest.CoreMatchers.is; |
... | @@ -43,12 +47,14 @@ public class IsisChannelHandlerTest { | ... | @@ -43,12 +47,14 @@ public class IsisChannelHandlerTest { |
43 | private IsisChannelHandler isisChannelHandler; | 47 | private IsisChannelHandler isisChannelHandler; |
44 | private Controller controller; | 48 | private Controller controller; |
45 | private IsisProcess isisProcess; | 49 | private IsisProcess isisProcess; |
46 | - private List<IsisProcess> isisProcessList; | 50 | + private List<IsisProcess> isisProcessList = new ArrayList(); |
47 | private ChannelHandlerContext channelHandlerContext; | 51 | private ChannelHandlerContext channelHandlerContext; |
48 | private ChannelStateEvent channelStateEvent; | 52 | private ChannelStateEvent channelStateEvent; |
49 | private ExceptionEvent exceptionEvent; | 53 | private ExceptionEvent exceptionEvent; |
50 | private MessageEvent messageEvent; | 54 | private MessageEvent messageEvent; |
51 | private IsisMessage isisMessage; | 55 | private IsisMessage isisMessage; |
56 | + private List<IsisInterface> isisInterfaceList = new ArrayList<>(); | ||
57 | + private Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10"); | ||
52 | 58 | ||
53 | @Before | 59 | @Before |
54 | public void setUp() throws Exception { | 60 | public void setUp() throws Exception { |
... | @@ -71,7 +77,7 @@ public class IsisChannelHandlerTest { | ... | @@ -71,7 +77,7 @@ public class IsisChannelHandlerTest { |
71 | /** | 77 | /** |
72 | * Tests initializeInterfaceMap() method. | 78 | * Tests initializeInterfaceMap() method. |
73 | */ | 79 | */ |
74 | - @Test(expected = Exception.class) | 80 | + @Test |
75 | public void testInitializeInterfaceMap() throws Exception { | 81 | public void testInitializeInterfaceMap() throws Exception { |
76 | isisChannelHandler.initializeInterfaceMap(); | 82 | isisChannelHandler.initializeInterfaceMap(); |
77 | assertThat(isisChannelHandler, is(notNullValue())); | 83 | assertThat(isisChannelHandler, is(notNullValue())); |
... | @@ -82,6 +88,32 @@ public class IsisChannelHandlerTest { | ... | @@ -82,6 +88,32 @@ public class IsisChannelHandlerTest { |
82 | */ | 88 | */ |
83 | @Test(expected = Exception.class) | 89 | @Test(expected = Exception.class) |
84 | public void testUpdateInterfaceMap() throws Exception { | 90 | public void testUpdateInterfaceMap() throws Exception { |
91 | + IsisInterface isisInterface = new DefaultIsisInterface(); | ||
92 | + IsisInterface isisInterface1 = new DefaultIsisInterface(); | ||
93 | + isisInterface.setInterfaceIpAddress(ip4Address); | ||
94 | + isisInterface.setInterfaceIndex(1); | ||
95 | + isisInterfaceList.add(isisInterface); | ||
96 | + IsisProcess isisProcess = new DefaultIsisProcess(); | ||
97 | + isisProcess.setIsisInterfaceList(isisInterfaceList); | ||
98 | + isisProcessList.add(isisProcess); | ||
99 | + isisChannelHandler.updateInterfaceMap(isisProcessList); | ||
100 | + assertThat(isisChannelHandler, is(notNullValue())); | ||
101 | + isisProcessList = new ArrayList<>(); | ||
102 | + isisInterface1.setInterfaceIpAddress(ip4Address); | ||
103 | + isisInterface1.setInterfaceIndex(1); | ||
104 | + isisInterface1.setInterfaceIpAddress(ip4Address); | ||
105 | + isisInterface1.setInterfaceIndex(1); | ||
106 | + isisInterface1.setSystemId("9999.9999.9999"); | ||
107 | + isisInterface1.setIntermediateSystemName("router"); | ||
108 | + isisInterface1.setReservedPacketCircuitType(3); | ||
109 | + isisInterface1.setCircuitId("10"); | ||
110 | + isisInterface1.setNetworkType(IsisNetworkType.BROADCAST); | ||
111 | + isisInterface1.setAreaAddress("490001"); | ||
112 | + isisInterface1.setHoldingTime(50); | ||
113 | + isisInterface1.setHelloInterval(10); | ||
114 | + isisInterfaceList.add(isisInterface1); | ||
115 | + isisProcess.setIsisInterfaceList(isisInterfaceList); | ||
116 | + isisProcessList.add(isisProcess); | ||
85 | isisChannelHandler.updateInterfaceMap(isisProcessList); | 117 | isisChannelHandler.updateInterfaceMap(isisProcessList); |
86 | assertThat(isisChannelHandler, is(notNullValue())); | 118 | assertThat(isisChannelHandler, is(notNullValue())); |
87 | } | 119 | } |
... | @@ -89,7 +121,7 @@ public class IsisChannelHandlerTest { | ... | @@ -89,7 +121,7 @@ public class IsisChannelHandlerTest { |
89 | /** | 121 | /** |
90 | * Tests initializeInterfaceIpList() method. | 122 | * Tests initializeInterfaceIpList() method. |
91 | */ | 123 | */ |
92 | - @Test(expected = Exception.class) | 124 | + @Test |
93 | public void testInitializeInterfaceIpList() throws Exception { | 125 | public void testInitializeInterfaceIpList() throws Exception { |
94 | isisChannelHandler.initializeInterfaceIpList(); | 126 | isisChannelHandler.initializeInterfaceIpList(); |
95 | assertThat(isisChannelHandler, is(notNullValue())); | 127 | assertThat(isisChannelHandler, is(notNullValue())); | ... | ... |
... | @@ -58,7 +58,7 @@ public class IsisHelloPduSenderTest { | ... | @@ -58,7 +58,7 @@ public class IsisHelloPduSenderTest { |
58 | /** | 58 | /** |
59 | * Tests run() method. | 59 | * Tests run() method. |
60 | */ | 60 | */ |
61 | - @Test | 61 | + @Test(expected = Exception.class) |
62 | public void testRun() throws Exception { | 62 | public void testRun() throws Exception { |
63 | isisInterface.setNetworkType(IsisNetworkType.P2P); | 63 | isisInterface.setNetworkType(IsisNetworkType.P2P); |
64 | isisInterface.setCircuitId(circuitId); | 64 | isisInterface.setCircuitId(circuitId); | ... | ... |
... | @@ -24,11 +24,14 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -24,11 +24,14 @@ import static org.hamcrest.MatcherAssert.assertThat; |
24 | public class IsisMessageDecoderTest { | 24 | public class IsisMessageDecoderTest { |
25 | 25 | ||
26 | private final byte[] hello = { | 26 | private final byte[] hello = { |
27 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
27 | -125, 20, 1, 0, 17, 1, 0, 0, | 28 | -125, 20, 1, 0, 17, 1, 0, 0, |
28 | 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3, | 29 | 2, 51, 51, 51, 51, 51, 51, 0, 100, 5, -39, -126, 1, 4, 3, |
29 | 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102 | 30 | 73, 0, 0, -127, 1, -52, -124, 4, -64, -88, 56, 102 |
30 | }; | 31 | }; |
32 | + private final byte[] array2 = {0, 0, 0, 0, 0, 0, 0}; | ||
31 | private final String id = "127.0.0.1"; | 33 | private final String id = "127.0.0.1"; |
34 | + private byte[] array1; | ||
32 | private IsisMessageDecoder isisMessageDecoder; | 35 | private IsisMessageDecoder isisMessageDecoder; |
33 | private ChannelHandlerContext ctx; | 36 | private ChannelHandlerContext ctx; |
34 | private Channel channel; | 37 | private Channel channel; |
... | @@ -49,7 +52,8 @@ public class IsisMessageDecoderTest { | ... | @@ -49,7 +52,8 @@ public class IsisMessageDecoderTest { |
49 | public void testDecode() throws Exception { | 52 | public void testDecode() throws Exception { |
50 | channel = EasyMock.createMock(Channel.class); | 53 | channel = EasyMock.createMock(Channel.class); |
51 | socketAddress = InetSocketAddress.createUnresolved(id, 7000); | 54 | socketAddress = InetSocketAddress.createUnresolved(id, 7000); |
52 | - byte[] array = IsisUtil.getPaddingTlvs(hello.length); | 55 | + byte[] array = IsisUtil.getPaddingTlvs(hello.length - 17); |
56 | + array1 = Bytes.concat(hello, array); | ||
53 | channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array)); | 57 | channelBuffer = ChannelBuffers.copiedBuffer(Bytes.concat(hello, array)); |
54 | assertThat(isisMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue())); | 58 | assertThat(isisMessageDecoder.decode(ctx, channel, channelBuffer), is(nullValue())); |
55 | } | 59 | } | ... | ... |
... | @@ -22,8 +22,13 @@ import org.onosproject.isis.controller.IsisLsdb; | ... | @@ -22,8 +22,13 @@ import org.onosproject.isis.controller.IsisLsdb; |
22 | import org.onosproject.isis.controller.IsisLsdbAge; | 22 | import org.onosproject.isis.controller.IsisLsdbAge; |
23 | import org.onosproject.isis.controller.IsisPduType; | 23 | import org.onosproject.isis.controller.IsisPduType; |
24 | import org.onosproject.isis.controller.LspWrapper; | 24 | import org.onosproject.isis.controller.LspWrapper; |
25 | +import org.onosproject.isis.controller.impl.DefaultIsisInterface; | ||
26 | +import org.onosproject.isis.io.isispacket.IsisHeader; | ||
27 | +import org.onosproject.isis.io.isispacket.pdu.AttachedToOtherAreas; | ||
28 | +import org.onosproject.isis.io.isispacket.pdu.LsPdu; | ||
25 | import org.onosproject.isis.io.util.IsisConstants; | 29 | import org.onosproject.isis.io.util.IsisConstants; |
26 | 30 | ||
31 | +import java.util.List; | ||
27 | import java.util.Map; | 32 | import java.util.Map; |
28 | import java.util.concurrent.ConcurrentHashMap; | 33 | import java.util.concurrent.ConcurrentHashMap; |
29 | 34 | ||
... | @@ -37,19 +42,27 @@ public class DefaultIsisLsdbTest { | ... | @@ -37,19 +42,27 @@ public class DefaultIsisLsdbTest { |
37 | private final int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; | 42 | private final int l1LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; |
38 | private final int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; | 43 | private final int l2LspSeqNo = IsisConstants.STARTLSSEQUENCENUM; |
39 | private final String srcId = "1111.1111.1111"; | 44 | private final String srcId = "1111.1111.1111"; |
40 | - | ||
41 | private DefaultIsisLsdb defaultIsisLsdb; | 45 | private DefaultIsisLsdb defaultIsisLsdb; |
42 | private IsisLsdbAge lsdbAge = null; | 46 | private IsisLsdbAge lsdbAge = null; |
43 | - | ||
44 | - | ||
45 | private int resultInt; | 47 | private int resultInt; |
46 | private Map<String, LspWrapper> resultMap = new ConcurrentHashMap<>(); | 48 | private Map<String, LspWrapper> resultMap = new ConcurrentHashMap<>(); |
47 | private IsisLsdb resultLsdb; | 49 | private IsisLsdb resultLsdb; |
48 | private LspWrapper resultLspWrapper; | 50 | private LspWrapper resultLspWrapper; |
49 | - | 51 | + private List<LspWrapper> lspWrapperList; |
52 | + private LsPdu lsPdu; | ||
53 | + private IsisHeader isisHeader; | ||
54 | + private DefaultIsisInterface defaultIsisInterface; | ||
55 | + private String lspId = "1234.1234.1234.00-00"; | ||
56 | + private String result; | ||
50 | 57 | ||
51 | @Before | 58 | @Before |
52 | public void setUp() throws Exception { | 59 | public void setUp() throws Exception { |
60 | + defaultIsisInterface = new DefaultIsisInterface(); | ||
61 | + isisHeader = new IsisHeader(); | ||
62 | + lsPdu = new LsPdu(isisHeader); | ||
63 | + lsPdu.setLspId(lspId); | ||
64 | + lsPdu.setAttachedToOtherAreas(AttachedToOtherAreas.DEFAULTMETRIC); | ||
65 | + lsPdu.setIsisPduType(IsisPduType.L1LSPDU.value()); | ||
53 | defaultIsisLsdb = new DefaultIsisLsdb(); | 66 | defaultIsisLsdb = new DefaultIsisLsdb(); |
54 | } | 67 | } |
55 | 68 | ||
... | @@ -129,5 +142,60 @@ public class DefaultIsisLsdbTest { | ... | @@ -129,5 +142,60 @@ public class DefaultIsisLsdbTest { |
129 | resultLspWrapper = defaultIsisLsdb.findLsp(IsisPduType.L1HELLOPDU, srcId); | 142 | resultLspWrapper = defaultIsisLsdb.findLsp(IsisPduType.L1HELLOPDU, srcId); |
130 | assertThat(resultLspWrapper, is(nullValue())); | 143 | assertThat(resultLspWrapper, is(nullValue())); |
131 | } | 144 | } |
145 | + | ||
146 | + /** | ||
147 | + * Tests allLspHeaders() method. | ||
148 | + */ | ||
149 | + @Test | ||
150 | + public void testAllLspHeaders() throws Exception { | ||
151 | + defaultIsisLsdb.addLsp(lsPdu, false, defaultIsisInterface); | ||
152 | + lspWrapperList = defaultIsisLsdb.allLspHeaders(true); | ||
153 | + assertThat(lspWrapperList, is(notNullValue())); | ||
154 | + | ||
155 | + defaultIsisLsdb.addLsp(lsPdu, true, defaultIsisInterface); | ||
156 | + lspWrapperList = defaultIsisLsdb.allLspHeaders(true); | ||
157 | + assertThat(lspWrapperList, is(notNullValue())); | ||
158 | + } | ||
159 | + | ||
160 | + /** | ||
161 | + * Tests isNewerOrSameLsp() method. | ||
162 | + */ | ||
163 | + @Test | ||
164 | + public void testIsNewerOrSameLsp() throws Exception { | ||
165 | + result = defaultIsisLsdb.isNewerOrSameLsp(lsPdu, lsPdu); | ||
166 | + assertThat(result, is("same")); | ||
167 | + } | ||
168 | + | ||
169 | + /** | ||
170 | + * Tests lsSequenceNumber() method. | ||
171 | + */ | ||
172 | + @Test | ||
173 | + public void testLsSequenceNumber() throws Exception { | ||
174 | + resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1LSPDU); | ||
175 | + assertThat(resultInt, is(1)); | ||
176 | + | ||
177 | + resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L2LSPDU); | ||
178 | + assertThat(resultInt, is(1)); | ||
179 | + | ||
180 | + resultInt = defaultIsisLsdb.lsSequenceNumber(IsisPduType.L1CSNP); | ||
181 | + assertThat(resultInt, is(1)); | ||
182 | + } | ||
183 | + | ||
184 | + /** | ||
185 | + * Tests deleteLsp() method. | ||
186 | + */ | ||
187 | + @Test | ||
188 | + public void testdeleteLsp() throws Exception { | ||
189 | + defaultIsisLsdb.deleteLsp(lsPdu); | ||
190 | + assertThat(defaultIsisLsdb, is(notNullValue())); | ||
191 | + | ||
192 | + lsPdu.setIsisPduType(IsisPduType.L2LSPDU.value()); | ||
193 | + defaultIsisLsdb.deleteLsp(lsPdu); | ||
194 | + assertThat(defaultIsisLsdb, is(notNullValue())); | ||
195 | + | ||
196 | + lsPdu.setIsisPduType(IsisPduType.L1CSNP.value()); | ||
197 | + defaultIsisLsdb.deleteLsp(lsPdu); | ||
198 | + assertThat(defaultIsisLsdb, is(notNullValue())); | ||
199 | + } | ||
132 | } | 200 | } |
133 | 201 | ... | ... |
... | @@ -19,7 +19,11 @@ import org.junit.After; | ... | @@ -19,7 +19,11 @@ import org.junit.After; |
19 | import org.junit.Before; | 19 | import org.junit.Before; |
20 | import org.junit.Test; | 20 | import org.junit.Test; |
21 | import org.onosproject.isis.controller.IsisInterface; | 21 | import org.onosproject.isis.controller.IsisInterface; |
22 | +import org.onosproject.isis.controller.IsisLsdbAge; | ||
23 | +import org.onosproject.isis.controller.IsisPduType; | ||
22 | import org.onosproject.isis.controller.impl.DefaultIsisInterface; | 24 | import org.onosproject.isis.controller.impl.DefaultIsisInterface; |
25 | +import org.onosproject.isis.io.isispacket.IsisHeader; | ||
26 | +import org.onosproject.isis.io.isispacket.pdu.LsPdu; | ||
23 | 27 | ||
24 | import static org.hamcrest.CoreMatchers.is; | 28 | import static org.hamcrest.CoreMatchers.is; |
25 | import static org.hamcrest.CoreMatchers.notNullValue; | 29 | import static org.hamcrest.CoreMatchers.notNullValue; |
... | @@ -36,11 +40,20 @@ public class DefaultLspWrapperTest { | ... | @@ -36,11 +40,20 @@ public class DefaultLspWrapperTest { |
36 | private int result1; | 40 | private int result1; |
37 | private IsisInterface isisInterface; | 41 | private IsisInterface isisInterface; |
38 | private IsisInterface result2; | 42 | private IsisInterface result2; |
43 | + private IsisPduType isisPduType; | ||
44 | + private boolean result3; | ||
45 | + private LsPdu lsPdu; | ||
46 | + private LsPdu pdu; | ||
47 | + private DefaultIsisLsdbAge defaultIsisLsdbAge; | ||
48 | + private IsisLsdbAge lsdbAge; | ||
39 | 49 | ||
40 | @Before | 50 | @Before |
41 | public void setUp() throws Exception { | 51 | public void setUp() throws Exception { |
42 | defaultLspWrapper = new DefaultLspWrapper(); | 52 | defaultLspWrapper = new DefaultLspWrapper(); |
43 | isisInterface = new DefaultIsisInterface(); | 53 | isisInterface = new DefaultIsisInterface(); |
54 | + pdu = new LsPdu(new IsisHeader()); | ||
55 | + defaultIsisLsdbAge = new DefaultIsisLsdbAge(); | ||
56 | + defaultIsisLsdbAge.startDbAging(); | ||
44 | } | 57 | } |
45 | 58 | ||
46 | @After | 59 | @After |
... | @@ -108,4 +121,169 @@ public class DefaultLspWrapperTest { | ... | @@ -108,4 +121,169 @@ public class DefaultLspWrapperTest { |
108 | assertThat(result2, is(notNullValue())); | 121 | assertThat(result2, is(notNullValue())); |
109 | } | 122 | } |
110 | 123 | ||
124 | + /** | ||
125 | + * Tests ageCounterWhenReceived() getter method. | ||
126 | + */ | ||
127 | + @Test | ||
128 | + public void testAgeCounterWhenReceived() throws Exception { | ||
129 | + defaultLspWrapper.setAgeCounterWhenReceived(1); | ||
130 | + result1 = defaultLspWrapper.ageCounterWhenReceived(); | ||
131 | + assertThat(result1, is(notNullValue())); | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * Tests ageCounterWhenReceived() setter method. | ||
136 | + */ | ||
137 | + @Test | ||
138 | + public void testSetAgeCounterWhenReceived() throws Exception { | ||
139 | + defaultLspWrapper.setAgeCounterWhenReceived(1); | ||
140 | + result1 = defaultLspWrapper.ageCounterWhenReceived(); | ||
141 | + assertThat(result1, is(notNullValue())); | ||
142 | + } | ||
143 | + | ||
144 | + /** | ||
145 | + * Tests ageCounterRollOverWhenAdded() getter method. | ||
146 | + */ | ||
147 | + @Test | ||
148 | + public void testAgeCounterRollOverWhenAdded() throws Exception { | ||
149 | + defaultLspWrapper.setAgeCounterRollOverWhenAdded(1); | ||
150 | + result1 = defaultLspWrapper.ageCounterRollOverWhenAdded(); | ||
151 | + assertThat(result1, is(notNullValue())); | ||
152 | + } | ||
153 | + | ||
154 | + /** | ||
155 | + * Tests ageCounterRollOverWhenAdded() setter method. | ||
156 | + */ | ||
157 | + @Test | ||
158 | + public void testSetAgeCounterRollOverWhenAdded() throws Exception { | ||
159 | + defaultLspWrapper.setAgeCounterRollOverWhenAdded(1); | ||
160 | + result1 = defaultLspWrapper.ageCounterRollOverWhenAdded(); | ||
161 | + assertThat(result1, is(notNullValue())); | ||
162 | + } | ||
163 | + | ||
164 | + /** | ||
165 | + * Tests lspType() getter method. | ||
166 | + */ | ||
167 | + @Test | ||
168 | + public void testLspType() throws Exception { | ||
169 | + defaultLspWrapper.setLspType(IsisPduType.L1LSPDU); | ||
170 | + isisPduType = defaultLspWrapper.lspType(); | ||
171 | + assertThat(isisPduType, is(IsisPduType.L1LSPDU)); | ||
172 | + } | ||
173 | + | ||
174 | + /** | ||
175 | + * Tests lspType() setter method. | ||
176 | + */ | ||
177 | + @Test | ||
178 | + public void testSetLspType() throws Exception { | ||
179 | + defaultLspWrapper.setLspType(IsisPduType.L1LSPDU); | ||
180 | + isisPduType = defaultLspWrapper.lspType(); | ||
181 | + assertThat(isisPduType, is(IsisPduType.L1LSPDU)); | ||
182 | + } | ||
183 | + | ||
184 | + /** | ||
185 | + * Tests isSelfOriginated() getter method. | ||
186 | + */ | ||
187 | + @Test | ||
188 | + public void testIsSelfOriginated() throws Exception { | ||
189 | + defaultLspWrapper.setSelfOriginated(true); | ||
190 | + result3 = defaultLspWrapper.isSelfOriginated(); | ||
191 | + assertThat(result3, is(true)); | ||
192 | + } | ||
193 | + | ||
194 | + /** | ||
195 | + * Tests isSelfOriginated() setter method. | ||
196 | + */ | ||
197 | + @Test | ||
198 | + public void testSetSelfOriginated() throws Exception { | ||
199 | + defaultLspWrapper.setSelfOriginated(true); | ||
200 | + result3 = defaultLspWrapper.isSelfOriginated(); | ||
201 | + assertThat(result3, is(true)); | ||
202 | + } | ||
203 | + | ||
204 | + /** | ||
205 | + * Tests binNumber() getter method. | ||
206 | + */ | ||
207 | + @Test | ||
208 | + public void testBinNumber() throws Exception { | ||
209 | + defaultLspWrapper.setBinNumber(1); | ||
210 | + result1 = defaultLspWrapper.binNumber(); | ||
211 | + assertThat(result1, is(1)); | ||
212 | + } | ||
213 | + | ||
214 | + /** | ||
215 | + * Tests binNumber() setter method. | ||
216 | + */ | ||
217 | + @Test | ||
218 | + public void testSetBinNumber() throws Exception { | ||
219 | + defaultLspWrapper.setBinNumber(1); | ||
220 | + result1 = defaultLspWrapper.binNumber(); | ||
221 | + assertThat(result1, is(1)); | ||
222 | + } | ||
223 | + | ||
224 | + /** | ||
225 | + * Tests lsPdu() getter method. | ||
226 | + */ | ||
227 | + @Test | ||
228 | + public void testLsPdu() throws Exception { | ||
229 | + defaultLspWrapper.setLsPdu(pdu); | ||
230 | + lsPdu = defaultLspWrapper.lsPdu(); | ||
231 | + assertThat(lsPdu, is(pdu)); | ||
232 | + } | ||
233 | + | ||
234 | + /** | ||
235 | + * Tests lsPdu() setter method. | ||
236 | + */ | ||
237 | + @Test | ||
238 | + public void testSetLsPdu() throws Exception { | ||
239 | + defaultLspWrapper.setLsPdu(pdu); | ||
240 | + lsPdu = defaultLspWrapper.lsPdu(); | ||
241 | + assertThat(lsPdu, is(pdu)); | ||
242 | + } | ||
243 | + | ||
244 | + /** | ||
245 | + * Tests lsdbAge() getter method. | ||
246 | + */ | ||
247 | + @Test | ||
248 | + public void testlsdbAge() throws Exception { | ||
249 | + defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge); | ||
250 | + lsdbAge = defaultLspWrapper.lsdbAge(); | ||
251 | + assertThat(lsdbAge, is(defaultIsisLsdbAge)); | ||
252 | + } | ||
253 | + | ||
254 | + /** | ||
255 | + * Tests lsdbAge() setter method. | ||
256 | + */ | ||
257 | + @Test | ||
258 | + public void testSetLsdbAge() throws Exception { | ||
259 | + defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge); | ||
260 | + lsdbAge = defaultLspWrapper.lsdbAge(); | ||
261 | + assertThat(lsdbAge, is(defaultIsisLsdbAge)); | ||
262 | + } | ||
263 | + | ||
264 | + /** | ||
265 | + * Tests remainingLifetime() getter method. | ||
266 | + */ | ||
267 | + @Test | ||
268 | + public void testRemainingLifetime() throws Exception { | ||
269 | + defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge); | ||
270 | + defaultLspWrapper.setAgeCounterWhenReceived(1); | ||
271 | + defaultLspWrapper.currentAge(); | ||
272 | + defaultLspWrapper.setRemainingLifetime(1); | ||
273 | + result1 = defaultLspWrapper.remainingLifetime(); | ||
274 | + assertThat(result1, is(1)); | ||
275 | + } | ||
276 | + | ||
277 | + /** | ||
278 | + * Tests remainingLifetime() setter method. | ||
279 | + */ | ||
280 | + @Test | ||
281 | + public void testSetRemainingLifetime() throws Exception { | ||
282 | + defaultLspWrapper.setLsdbAge(defaultIsisLsdbAge); | ||
283 | + defaultLspWrapper.setAgeCounterWhenReceived(1); | ||
284 | + defaultLspWrapper.currentAge(); | ||
285 | + defaultLspWrapper.setRemainingLifetime(1); | ||
286 | + result1 = defaultLspWrapper.remainingLifetime(); | ||
287 | + assertThat(result1, is(1)); | ||
288 | + } | ||
111 | } | 289 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -18,7 +18,11 @@ package org.onosproject.isis.controller.impl.lsdb; | ... | @@ -18,7 +18,11 @@ package org.onosproject.isis.controller.impl.lsdb; |
18 | import org.junit.After; | 18 | import org.junit.After; |
19 | import org.junit.Before; | 19 | import org.junit.Before; |
20 | import org.junit.Test; | 20 | import org.junit.Test; |
21 | +import org.onosproject.isis.controller.impl.DefaultIsisInterface; | ||
21 | 22 | ||
23 | +import java.net.InetSocketAddress; | ||
24 | +import java.net.SocketAddress; | ||
25 | +import java.util.concurrent.ArrayBlockingQueue; | ||
22 | import java.util.concurrent.BlockingQueue; | 26 | import java.util.concurrent.BlockingQueue; |
23 | 27 | ||
24 | import static org.hamcrest.CoreMatchers.is; | 28 | import static org.hamcrest.CoreMatchers.is; |
... | @@ -31,10 +35,22 @@ import static org.junit.Assert.assertThat; | ... | @@ -31,10 +35,22 @@ import static org.junit.Assert.assertThat; |
31 | public class IsisLspQueueConsumerTest { | 35 | public class IsisLspQueueConsumerTest { |
32 | 36 | ||
33 | private IsisLspQueueConsumer isisLspQueueConsumer; | 37 | private IsisLspQueueConsumer isisLspQueueConsumer; |
34 | - private BlockingQueue blockingQueue; | 38 | + private BlockingQueue blockingQueue = new ArrayBlockingQueue(1024); |
39 | + private DefaultLspWrapper lspWrapper; | ||
40 | + private DefaultLspWrapper lspWrapper1; | ||
41 | + private SocketAddress socketAddress = InetSocketAddress.createUnresolved("127.0.0.1", 7000); | ||
35 | 42 | ||
36 | @Before | 43 | @Before |
37 | public void setUp() throws Exception { | 44 | public void setUp() throws Exception { |
45 | + lspWrapper = new DefaultLspWrapper(); | ||
46 | + lspWrapper.setLspProcessing("refreshLsp"); | ||
47 | + lspWrapper.setSelfOriginated(true); | ||
48 | + lspWrapper.setIsisInterface(new DefaultIsisInterface()); | ||
49 | + lspWrapper1 = new DefaultLspWrapper(); | ||
50 | + lspWrapper1.setLspProcessing("maxAgeLsp"); | ||
51 | + lspWrapper1.setIsisInterface(new DefaultIsisInterface()); | ||
52 | + blockingQueue.add(lspWrapper); | ||
53 | + blockingQueue.add(lspWrapper1); | ||
38 | isisLspQueueConsumer = new IsisLspQueueConsumer(blockingQueue); | 54 | isisLspQueueConsumer = new IsisLspQueueConsumer(blockingQueue); |
39 | } | 55 | } |
40 | 56 | ... | ... |
protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/pdu/Psnp.java
100755 → 100644
File mode changed
... | @@ -33,6 +33,7 @@ public final class IsisConstants { | ... | @@ -33,6 +33,7 @@ public final class IsisConstants { |
33 | public static final int IRPDISCRIMINATOR = 131; | 33 | public static final int IRPDISCRIMINATOR = 131; |
34 | public static final int ISISVERSION = 1; | 34 | public static final int ISISVERSION = 1; |
35 | public static final int RESERVED = 0; | 35 | public static final int RESERVED = 0; |
36 | + public static final int PRIORITY = 0; | ||
36 | public static final int MAXAREAADDRESS = 0; | 37 | public static final int MAXAREAADDRESS = 0; |
37 | public static final int SYSTEMIDLENGTH = 0; | 38 | public static final int SYSTEMIDLENGTH = 0; |
38 | public static final int PROTOCOLSUPPORTED = 204; | 39 | public static final int PROTOCOLSUPPORTED = 204; |
... | @@ -55,24 +56,15 @@ public final class IsisConstants { | ... | @@ -55,24 +56,15 @@ public final class IsisConstants { |
55 | public static final String DEFAULTLANID = "0000.0000.0000.00"; | 56 | public static final String DEFAULTLANID = "0000.0000.0000.00"; |
56 | public static final String PROCESSESID = "processId"; | 57 | public static final String PROCESSESID = "processId"; |
57 | public static final String INTERFACE = "interface"; | 58 | public static final String INTERFACE = "interface"; |
58 | - public static final String INTERFACEIP = "interfaceIp"; | ||
59 | - public static final String NETWORKMASK = "networkMask"; | ||
60 | public static final String INTERFACEINDEX = "interfaceIndex"; | 59 | public static final String INTERFACEINDEX = "interfaceIndex"; |
61 | public static final String INTERMEDIATESYSTEMNAME = "intermediateSystemName"; | 60 | public static final String INTERMEDIATESYSTEMNAME = "intermediateSystemName"; |
62 | public static final String SYSTEMID = "systemId"; | 61 | public static final String SYSTEMID = "systemId"; |
63 | - public static final String LANID = "lanId"; | ||
64 | - public static final String IDLENGTH = "idLength"; | ||
65 | - public static final String MAXAREAADDRESSES = "maxAreaAddresses"; | ||
66 | public static final String RESERVEDPACKETCIRCUITTYPE = "reservedPacketCircuitType"; | 62 | public static final String RESERVEDPACKETCIRCUITTYPE = "reservedPacketCircuitType"; |
67 | public static final String CIRCUITID = "circuitId"; | 63 | public static final String CIRCUITID = "circuitId"; |
68 | public static final String NETWORKTYPE = "networkType"; | 64 | public static final String NETWORKTYPE = "networkType"; |
69 | public static final String AREAADDRESS = "areaAddress"; | 65 | public static final String AREAADDRESS = "areaAddress"; |
70 | - public static final String AREALENGTH = "areaLength"; | ||
71 | - public static final String LSPID = "lspId"; | ||
72 | public static final String HOLDINGTIME = "holdingTime"; | 66 | public static final String HOLDINGTIME = "holdingTime"; |
73 | public static final String HELLOINTERVAL = "helloInterval"; | 67 | public static final String HELLOINTERVAL = "helloInterval"; |
74 | - public static final String PRIORITY = "priority"; | ||
75 | - public static final String MACADDRESS = "macAddress"; | ||
76 | 68 | ||
77 | /** | 69 | /** |
78 | * Non parameterized constructor. | 70 | * Non parameterized constructor. | ... | ... |
... | @@ -22,6 +22,7 @@ import org.onosproject.isis.controller.IsisInterface; | ... | @@ -22,6 +22,7 @@ import org.onosproject.isis.controller.IsisInterface; |
22 | import org.onosproject.isis.controller.IsisInterfaceState; | 22 | import org.onosproject.isis.controller.IsisInterfaceState; |
23 | import org.onosproject.isis.controller.IsisNeighbor; | 23 | import org.onosproject.isis.controller.IsisNeighbor; |
24 | import org.onosproject.isis.controller.IsisPduType; | 24 | import org.onosproject.isis.controller.IsisPduType; |
25 | +import org.onosproject.isis.controller.IsisRouterType; | ||
25 | import org.onosproject.isis.io.isispacket.IsisHeader; | 26 | import org.onosproject.isis.io.isispacket.IsisHeader; |
26 | import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu; | 27 | import org.onosproject.isis.io.isispacket.pdu.L1L2HelloPdu; |
27 | import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu; | 28 | import org.onosproject.isis.io.isispacket.pdu.P2PHelloPdu; |
... | @@ -394,7 +395,6 @@ public final class IsisUtil { | ... | @@ -394,7 +395,6 @@ public final class IsisUtil { |
394 | isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH); | 395 | isisHeader.setIdLength((byte) IsisConstants.SYSTEMIDLENGTH); |
395 | isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value()); | 396 | isisHeader.setIsisPduType(IsisPduType.P2PHELLOPDU.value()); |
396 | isisHeader.setVersion2((byte) IsisConstants.ISISVERSION); | 397 | isisHeader.setVersion2((byte) IsisConstants.ISISVERSION); |
397 | - //isisHeader.setReserved((byte) IsisConstants.RESERVED); | ||
398 | isisHeader.setReserved((byte) IsisConstants.PDULENGTHPOSITION); | 398 | isisHeader.setReserved((byte) IsisConstants.PDULENGTHPOSITION); |
399 | isisHeader.setMaximumAreaAddresses((byte) IsisConstants.MAXAREAADDRESS); | 399 | isisHeader.setMaximumAreaAddresses((byte) IsisConstants.MAXAREAADDRESS); |
400 | P2PHelloPdu p2pHelloPdu = new P2PHelloPdu(isisHeader); | 400 | P2PHelloPdu p2pHelloPdu = new P2PHelloPdu(isisHeader); |
... | @@ -510,14 +510,32 @@ public final class IsisUtil { | ... | @@ -510,14 +510,32 @@ public final class IsisUtil { |
510 | l1L2HelloPdu.addTlv(areaAddressTlv); | 510 | l1L2HelloPdu.addTlv(areaAddressTlv); |
511 | Set<MacAddress> neighbors = isisInterface.neighbors(); | 511 | Set<MacAddress> neighbors = isisInterface.neighbors(); |
512 | if (neighbors.size() > 0) { | 512 | if (neighbors.size() > 0) { |
513 | + List<MacAddress> neighborMacs = new ArrayList<>(); | ||
514 | + for (MacAddress neighbor : neighbors) { | ||
515 | + IsisNeighbor isisNeighbor = isisInterface.lookup(neighbor); | ||
516 | + if (isisPduType == IsisPduType.L1HELLOPDU) { | ||
517 | + if (isisNeighbor.routerType() == IsisRouterType.L1 || | ||
518 | + isisNeighbor.routerType() == IsisRouterType.L1L2) { | ||
519 | + neighborMacs.add(neighbor); | ||
520 | + } | ||
521 | + } else if (isisPduType == IsisPduType.L2HELLOPDU) { | ||
522 | + if (isisNeighbor.routerType() == IsisRouterType.L2 || | ||
523 | + isisNeighbor.routerType() == IsisRouterType.L1L2) { | ||
524 | + neighborMacs.add(neighbor); | ||
525 | + } | ||
526 | + } | ||
527 | + } | ||
528 | + | ||
513 | tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value()); | 529 | tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value()); |
514 | tlvHeader.setTlvLength(0); | 530 | tlvHeader.setTlvLength(0); |
531 | + | ||
515 | IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader); | 532 | IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader); |
516 | - for (MacAddress neighbor : neighbors) { | 533 | + for (MacAddress neighbor : neighborMacs) { |
517 | isisNeighborTlv.addNeighbor(neighbor); | 534 | isisNeighborTlv.addNeighbor(neighbor); |
518 | } | 535 | } |
519 | l1L2HelloPdu.addTlv(isisNeighborTlv); | 536 | l1L2HelloPdu.addTlv(isisNeighborTlv); |
520 | } | 537 | } |
538 | + | ||
521 | tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value()); | 539 | tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value()); |
522 | tlvHeader.setTlvLength(0); | 540 | tlvHeader.setTlvLength(0); |
523 | ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader); | 541 | ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader); | ... | ... |
... | @@ -140,8 +140,15 @@ public class LspGenerator { | ... | @@ -140,8 +140,15 @@ public class LspGenerator { |
140 | metricOfIntRea.setExpenseIsInternal(true); | 140 | metricOfIntRea.setExpenseIsInternal(true); |
141 | Ip4Address ip4Address = isisInterface.interfaceIpAddress(); | 141 | Ip4Address ip4Address = isisInterface.interfaceIpAddress(); |
142 | byte[] ipAddress = ip4Address.toOctets(); | 142 | byte[] ipAddress = ip4Address.toOctets(); |
143 | - ipAddress[ipAddress.length - 1] = 0; | 143 | + // ipAddress[ipAddress.length - 1] = 0; |
144 | - metricOfIntRea.setIpAddress(Ip4Address.valueOf(ipAddress)); | 144 | + byte[] networkmass = isisInterface.networkMask(); |
145 | + // metric calculation part | ||
146 | + byte[] result = new byte[ipAddress.length]; | ||
147 | + result[0] = (byte) (ipAddress[0] & networkmass[0]); | ||
148 | + result[1] = (byte) (ipAddress[1] & networkmass[1]); | ||
149 | + result[2] = (byte) (ipAddress[2] & networkmass[2]); | ||
150 | + result[3] = (byte) (ipAddress[3] & networkmass[3]); | ||
151 | + metricOfIntRea.setIpAddress(Ip4Address.valueOf(result)); | ||
145 | metricOfIntRea.setSubnetAddres(Ip4Address.valueOf(isisInterface.networkMask())); | 152 | metricOfIntRea.setSubnetAddres(Ip4Address.valueOf(isisInterface.networkMask())); |
146 | ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea); | 153 | ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea); |
147 | lsp.addTlv(ipInterReacTlv); | 154 | lsp.addTlv(ipInterReacTlv); | ... | ... |
-
Please register or login to post a comment