Manikandan K
Committed by Gerrit Code Review

ONOS-4107: ISIS Provider - Bug Fixes

Change-Id: I3c5cb3d1f45f7cf417267fe975256cba2dd066ab
...@@ -45,8 +45,6 @@ import java.util.concurrent.BlockingQueue; ...@@ -45,8 +45,6 @@ import java.util.concurrent.BlockingQueue;
45 public class LspEventConsumer implements Runnable { 45 public class LspEventConsumer implements Runnable {
46 private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class); 46 private static final Logger log = LoggerFactory.getLogger(LspEventConsumer.class);
47 public static List<LsPdu> lsPdus = new ArrayList<>(); 47 public static List<LsPdu> lsPdus = new ArrayList<>();
48 - private String lspAdded = "LSP_ADDED";
49 - private String lspRemoved = "LSP_REMOVED";
50 private BlockingQueue queue = null; 48 private BlockingQueue queue = null;
51 private Controller controller = null; 49 private Controller controller = null;
52 private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl(); 50 private TopologyForDeviceAndLinkImpl deviceAndLink = new TopologyForDeviceAndLinkImpl();
...@@ -64,28 +62,25 @@ public class LspEventConsumer implements Runnable { ...@@ -64,28 +62,25 @@ public class LspEventConsumer implements Runnable {
64 62
65 @Override 63 @Override
66 public void run() { 64 public void run() {
67 - log.debug("LspsForProvider:run...!!!");
68 try { 65 try {
69 while (true) { 66 while (true) {
70 if (!queue.isEmpty()) { 67 if (!queue.isEmpty()) {
71 LspWrapper wrapper = (LspWrapper) queue.take(); 68 LspWrapper wrapper = (LspWrapper) queue.take();
72 LsPdu lsPdu = (LsPdu) wrapper.lsPdu(); 69 LsPdu lsPdu = (LsPdu) wrapper.lsPdu();
70 + if (wrapper.lspProcessing().equals(IsisConstants.LSPREMOVED)) {
71 + callTopologyToRemoveInfo(lsPdu);
72 + } else if (wrapper.lspProcessing().equals(IsisConstants.LSPADDED)) {
73 for (IsisTlv isisTlv : lsPdu.tlvs()) { 73 for (IsisTlv isisTlv : lsPdu.tlvs()) {
74 if ((isisTlv instanceof IpExtendedReachabilityTlv) || 74 if ((isisTlv instanceof IpExtendedReachabilityTlv) ||
75 (isisTlv instanceof IsExtendedReachability)) { 75 (isisTlv instanceof IsExtendedReachability)) {
76 - lsPdus.add(lsPdu);
77 - if (wrapper.lspProcessing().equals(lspAdded)) {
78 callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(), 76 callTopologyToSendInfo(lsPdu, wrapper.isisInterface().networkType(),
79 wrapper.isisInterface().systemId() + ".00"); 77 wrapper.isisInterface().systemId() + ".00");
80 - }
81 - if (wrapper.lspProcessing().equals(lspRemoved)) {
82 - callTopologyToRemoveInfo(lsPdu);
83 - }
84 break; 78 break;
85 } 79 }
86 } 80 }
87 } 81 }
88 } 82 }
83 + }
89 } catch (Exception e) { 84 } catch (Exception e) {
90 log.debug("Error::LspsForProvider::{}", e.getMessage()); 85 log.debug("Error::LspsForProvider::{}", e.getMessage());
91 } 86 }
...@@ -99,6 +94,9 @@ public class LspEventConsumer implements Runnable { ...@@ -99,6 +94,9 @@ public class LspEventConsumer implements Runnable {
99 */ 94 */
100 private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType, 95 private void callTopologyToSendInfo(LsPdu lsPdu, IsisNetworkType isisNetworkType,
101 String ownSystemId) { 96 String ownSystemId) {
97 + if ((lsPdu.lspId().equals(ownSystemId + "-00"))) {
98 + return;
99 + }
102 if (isisNetworkType.equals(IsisNetworkType.BROADCAST)) { 100 if (isisNetworkType.equals(IsisNetworkType.BROADCAST)) {
103 sendDeviceInfo(lsPdu); 101 sendDeviceInfo(lsPdu);
104 boolean isDis = IsisUtil.checkIsDis(lsPdu.lspId()); 102 boolean isDis = IsisUtil.checkIsDis(lsPdu.lspId());
...@@ -106,9 +104,7 @@ public class LspEventConsumer implements Runnable { ...@@ -106,9 +104,7 @@ public class LspEventConsumer implements Runnable {
106 sendLinkInfo(lsPdu, ownSystemId); 104 sendLinkInfo(lsPdu, ownSystemId);
107 } 105 }
108 } else if (isisNetworkType.equals(IsisNetworkType.P2P)) { 106 } else if (isisNetworkType.equals(IsisNetworkType.P2P)) {
109 -
110 sendDeviceInfo(lsPdu); 107 sendDeviceInfo(lsPdu);
111 -
112 for (LsPdu wrapper : lsPdus) { 108 for (LsPdu wrapper : lsPdus) {
113 LsPdu lsPduStored = wrapper; 109 LsPdu lsPduStored = wrapper;
114 List<String> neStringList = neighborList(lsPduStored, ownSystemId); 110 List<String> neStringList = neighborList(lsPduStored, ownSystemId);
...@@ -117,7 +113,6 @@ public class LspEventConsumer implements Runnable { ...@@ -117,7 +113,6 @@ public class LspEventConsumer implements Runnable {
117 sendLinkInfo(lsPduStored, ownSystemId); 113 sendLinkInfo(lsPduStored, ownSystemId);
118 } 114 }
119 } 115 }
120 -
121 List<String> neStringList = neighborList(lsPdu, ownSystemId); 116 List<String> neStringList = neighborList(lsPdu, ownSystemId);
122 Map<String, IsisRouter> routerPresence = deviceAndLink.isisDeviceList(); 117 Map<String, IsisRouter> routerPresence = deviceAndLink.isisDeviceList();
123 for (String neighbor : neStringList) { 118 for (String neighbor : neStringList) {
...@@ -137,7 +132,8 @@ public class LspEventConsumer implements Runnable { ...@@ -137,7 +132,8 @@ public class LspEventConsumer implements Runnable {
137 * @param lsPdu ls pdu instance 132 * @param lsPdu ls pdu instance
138 */ 133 */
139 private void callTopologyToRemoveInfo(LsPdu lsPdu) { 134 private void callTopologyToRemoveInfo(LsPdu lsPdu) {
140 - removeDeviceInfo(lsPdu); 135 + IsisRouter isisRouter = deviceAndLink.isisRouter(lsPdu.lspId());
136 + removeDeviceInfo(isisRouter);
141 removeLinkInfo(lsPdu); 137 removeLinkInfo(lsPdu);
142 } 138 }
143 139
...@@ -195,13 +191,13 @@ public class LspEventConsumer implements Runnable { ...@@ -195,13 +191,13 @@ public class LspEventConsumer implements Runnable {
195 /** 191 /**
196 * Removes the device information from topology provider. 192 * Removes the device information from topology provider.
197 * 193 *
198 - * @param lsPdu ls pdu instance 194 + * @param isisRouter ISIS router instance
199 */ 195 */
200 - private void removeDeviceInfo(LsPdu lsPdu) { 196 + private void removeDeviceInfo(IsisRouter isisRouter) {
201 - IsisRouter isisRouter = deviceAndLink.removeDeviceAndLinkInfo(lsPdu);
202 if (isisRouter.systemId() != null) { 197 if (isisRouter.systemId() != null) {
203 controller.removeDeviceDetails(isisRouter); 198 controller.removeDeviceDetails(isisRouter);
204 } 199 }
200 + deviceAndLink.removeRouter(isisRouter.systemId());
205 } 201 }
206 202
207 /** 203 /**
...@@ -228,7 +224,7 @@ public class LspEventConsumer implements Runnable { ...@@ -228,7 +224,7 @@ public class LspEventConsumer implements Runnable {
228 * @param lsPdu ls pdu instance 224 * @param lsPdu ls pdu instance
229 */ 225 */
230 private void removeLinkInfo(LsPdu lsPdu) { 226 private void removeLinkInfo(LsPdu lsPdu) {
231 - Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu); 227 + Map<String, LinkInformation> linkInformationList = deviceAndLink.removeLinkInfo(lsPdu.lspId());
232 for (String key : linkInformationList.keySet()) { 228 for (String key : linkInformationList.keySet()) {
233 LinkInformation linkInformation = linkInformationList.get(key); 229 LinkInformation linkInformation = linkInformationList.get(key);
234 controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu)); 230 controller.removeLinkDetails(createIsisLink(linkInformation, lsPdu));
......
...@@ -22,21 +22,24 @@ import org.onosproject.isis.controller.topology.LinkInformation; ...@@ -22,21 +22,24 @@ import org.onosproject.isis.controller.topology.LinkInformation;
22 import org.onosproject.isis.controller.topology.TopologyForDeviceAndLink; 22 import org.onosproject.isis.controller.topology.TopologyForDeviceAndLink;
23 import org.onosproject.isis.controller.topology.IsisLinkTed; 23 import org.onosproject.isis.controller.topology.IsisLinkTed;
24 import org.onosproject.isis.io.isispacket.pdu.LsPdu; 24 import org.onosproject.isis.io.isispacket.pdu.LsPdu;
25 -import org.onosproject.isis.io.isispacket.tlv.IpExtendedReachabilityTlv;
26 import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability; 25 import org.onosproject.isis.io.isispacket.tlv.IsExtendedReachability;
27 import org.onosproject.isis.io.isispacket.tlv.IsisTlv; 26 import org.onosproject.isis.io.isispacket.tlv.IsisTlv;
28 import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs; 27 import org.onosproject.isis.io.isispacket.tlv.NeighborForExtendedIs;
29 -import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup; 28 +
30 import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv; 29 import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv;
31 import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress; 30 import org.onosproject.isis.io.isispacket.tlv.subtlv.InterfaceIpAddress;
32 import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress; 31 import org.onosproject.isis.io.isispacket.tlv.subtlv.NeighborIpAddress;
32 +import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup;
33 import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric; 33 import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringMetric;
34 +import org.onosproject.isis.io.isispacket.tlv.subtlv.UnreservedBandwidth;
34 import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth; 35 import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumReservableBandwidth;
36 +import org.onosproject.isis.io.isispacket.tlv.subtlv.MaximumBandwidth;
35 import org.onosproject.isis.io.util.IsisConstants; 37 import org.onosproject.isis.io.util.IsisConstants;
36 import org.onosproject.isis.io.util.IsisUtil; 38 import org.onosproject.isis.io.util.IsisUtil;
37 import org.slf4j.Logger; 39 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory; 40 import org.slf4j.LoggerFactory;
39 41
42 +import java.util.ArrayList;
40 import java.util.LinkedHashMap; 43 import java.util.LinkedHashMap;
41 import java.util.List; 44 import java.util.List;
42 import java.util.Map; 45 import java.util.Map;
...@@ -52,7 +55,6 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -52,7 +55,6 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
52 private Map<String, DeviceInformation> deviceInformationMapForPointToPoint = new LinkedHashMap<>(); 55 private Map<String, DeviceInformation> deviceInformationMapForPointToPoint = new LinkedHashMap<>();
53 private Map<String, DeviceInformation> deviceInformationMapToDelete = new LinkedHashMap<>(); 56 private Map<String, DeviceInformation> deviceInformationMapToDelete = new LinkedHashMap<>();
54 private Map<String, LinkInformation> addedLinkInformationMap = new LinkedHashMap<>(); 57 private Map<String, LinkInformation> addedLinkInformationMap = new LinkedHashMap<>();
55 - private Map<String, LinkInformation> removeLinkInformationMap = new LinkedHashMap<>();
56 58
57 /** 59 /**
58 * Gets device information. 60 * Gets device information.
...@@ -226,11 +228,33 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -226,11 +228,33 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
226 } 228 }
227 229
228 /** 230 /**
229 - * Creates Device and Link instance. 231 + * Returns the ISIS router instance.
230 * 232 *
231 - * @param lsPdu ISIS LSPDU instance 233 + * @param systemId system ID to get router details
234 + * @return ISIS router instance
235 + */
236 + public IsisRouter isisRouter(String systemId) {
237 + String routerId = IsisUtil.removeTailingZeros(systemId);
238 + IsisRouter isisRouter = isisRouterDetails.get(routerId);
239 + if (isisRouter != null) {
240 + return isisRouter;
241 + } else {
242 + log.debug("IsisRouter is not available");
243 + IsisRouter isisRouterCheck = new DefaultIsisRouter();
244 + isisRouterCheck.setSystemId(routerId);
245 + return isisRouterCheck;
246 + }
247 + }
248 +
249 + /**
250 + * Removes the ISIS router instance from map.
232 * 251 *
252 + * @param systemId system ID to remove router details
233 */ 253 */
254 + public void removeRouter(String systemId) {
255 + String routerId = IsisUtil.removeTailingZeros(systemId);
256 + isisRouterDetails.remove(systemId);
257 + }
234 258
235 /** 259 /**
236 * Creates Device instance. 260 * Creates Device instance.
...@@ -249,18 +273,18 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -249,18 +273,18 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
249 } 273 }
250 } 274 }
251 return isisRouter; 275 return isisRouter;
252 - } 276 + }/*
253 277
254 - /** 278 + *//**
255 * Removes Device and Link instance. 279 * Removes Device and Link instance.
256 * 280 *
257 * @param lsPdu ISIS LSPDU instance 281 * @param lsPdu ISIS LSPDU instance
258 * @return isisRouter isisRouter instance 282 * @return isisRouter isisRouter instance
259 - */ 283 + *//*
260 public IsisRouter removeDeviceAndLinkInfo(LsPdu lsPdu) { 284 public IsisRouter removeDeviceAndLinkInfo(LsPdu lsPdu) {
261 IsisRouter isisRouter = createIsisRouter(lsPdu); 285 IsisRouter isisRouter = createIsisRouter(lsPdu);
262 return isisRouter; 286 return isisRouter;
263 - } 287 + }*/
264 288
265 /** 289 /**
266 * Creates link information. 290 * Creates link information.
...@@ -302,13 +326,14 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -302,13 +326,14 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
302 /** 326 /**
303 * Removes link information. 327 * Removes link information.
304 * 328 *
305 - * @param lsPdu ls pdu instance 329 + * @param systemId system ID to remove link information
306 * @return updated link information 330 * @return updated link information
307 */ 331 */
308 - public Map<String, LinkInformation> removeLinkInfo(LsPdu lsPdu) { 332 + public Map<String, LinkInformation> removeLinkInfo(String systemId) {
309 - String lspId = lsPdu.lspId(); 333 + String routerId = IsisUtil.removeTailingZeros(systemId);
334 + Map<String, LinkInformation> removeLinkInformationMap = new LinkedHashMap<>();
310 for (String key : addedLinkInformationMap.keySet()) { 335 for (String key : addedLinkInformationMap.keySet()) {
311 - if (key.contains(lspId)) { 336 + if (key.contains(routerId)) {
312 removeLinkInformationMap.put(key, addedLinkInformationMap.get(key)); 337 removeLinkInformationMap.put(key, addedLinkInformationMap.get(key));
313 } 338 }
314 } 339 }
...@@ -328,22 +353,24 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -328,22 +353,24 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
328 LinkInformation linkInformation = new DefaultIsisLinkInformation(); 353 LinkInformation linkInformation = new DefaultIsisLinkInformation();
329 IsisRouter isisRouter = isisRouterDetails.get(neighborId); 354 IsisRouter isisRouter = isisRouterDetails.get(neighborId);
330 for (IsisTlv isisTlv : lsPdu.tlvs()) { 355 for (IsisTlv isisTlv : lsPdu.tlvs()) {
331 - if (isisTlv instanceof IpExtendedReachabilityTlv) { 356 + if (isisTlv instanceof IsExtendedReachability) {
332 - IpExtendedReachabilityTlv ipExtendedReachabilityTlv = (IpExtendedReachabilityTlv) isisTlv; 357 + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
333 - List<TrafficEngineeringSubTlv> trafEnginSubTlv = ipExtendedReachabilityTlv.teTlvs(); 358 + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
334 - for (TrafficEngineeringSubTlv teTlv : trafEnginSubTlv) { 359 + for (NeighborForExtendedIs teTlv : neighbours) {
335 - if (teTlv instanceof InterfaceIpAddress) { 360 + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
336 - InterfaceIpAddress localIpAddress = (InterfaceIpAddress) isisTlv; 361 + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
362 + if (teSubTlv instanceof InterfaceIpAddress) {
363 + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
337 linkInformation.setInterfaceIp(localIpAddress.localInterfaceIPAddress()); 364 linkInformation.setInterfaceIp(localIpAddress.localInterfaceIPAddress());
365 + } else if (teSubTlv instanceof NeighborIpAddress) {
366 + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
367 + linkInformation.setNeighborIp(neighborIpAddress.neighborIPAddress());
338 } 368 }
339 369
340 } 370 }
341 - } else {
342 - linkInformation.setInterfaceIp(IsisConstants.DEFAULTIP);
343 - linkInformation.setNeighborIp(IsisConstants.DEFAULTIP);
344 } 371 }
345 } 372 }
346 - linkInformation.setNeighborIp(IsisConstants.DEFAULTIP); 373 + }
347 linkInformation.setLinkId(linkId); 374 linkInformation.setLinkId(linkId);
348 linkInformation.setAlreadyCreated(false); 375 linkInformation.setAlreadyCreated(false);
349 linkInformation.setLinkDestinationId(neighborId); 376 linkInformation.setLinkDestinationId(neighborId);
...@@ -366,21 +393,22 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -366,21 +393,22 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
366 } 393 }
367 isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId())); 394 isisRouter.setSystemId(IsisUtil.removeTailingZeros(lsPdu.lspId()));
368 for (IsisTlv isisTlv : lsPdu.tlvs()) { 395 for (IsisTlv isisTlv : lsPdu.tlvs()) {
369 - if (isisTlv instanceof IpExtendedReachabilityTlv) { 396 + if (isisTlv instanceof IsExtendedReachability) {
370 - IpExtendedReachabilityTlv ipExtendedReachabilityTlv = (IpExtendedReachabilityTlv) isisTlv; 397 + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
371 - List<TrafficEngineeringSubTlv> trafEnginSubTlv = ipExtendedReachabilityTlv.teTlvs(); 398 + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
372 - for (TrafficEngineeringSubTlv teTlv : trafEnginSubTlv) { 399 + for (NeighborForExtendedIs teTlv : neighbours) {
373 - if (teTlv instanceof InterfaceIpAddress) { 400 + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
374 - InterfaceIpAddress localIpAddress = (InterfaceIpAddress) isisTlv; 401 + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
402 + if (teSubTlv instanceof InterfaceIpAddress) {
403 + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
375 isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress()); 404 isisRouter.setInterfaceId(localIpAddress.localInterfaceIPAddress());
376 - } 405 + } else if (teSubTlv instanceof NeighborIpAddress) {
377 - if (teTlv instanceof NeighborIpAddress) { 406 + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
378 - NeighborIpAddress neighborIpAddress = (NeighborIpAddress) isisTlv;
379 isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress()); 407 isisRouter.setNeighborRouterId(neighborIpAddress.neighborIPAddress());
380 } 408 }
409 +
410 + }
381 } 411 }
382 - } else {
383 - log.info("Invalid TLV");
384 } 412 }
385 } 413 }
386 return isisRouter; 414 return isisRouter;
...@@ -398,6 +426,7 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -398,6 +426,7 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
398 isisRouter.setDis(false); 426 isisRouter.setDis(false);
399 isisRouter.setInterfaceId(IsisConstants.DEFAULTIP); 427 isisRouter.setInterfaceId(IsisConstants.DEFAULTIP);
400 isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP); 428 isisRouter.setNeighborRouterId(IsisConstants.DEFAULTIP);
429 +
401 return isisRouter; 430 return isisRouter;
402 } 431 }
403 432
...@@ -410,26 +439,50 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink { ...@@ -410,26 +439,50 @@ public class TopologyForDeviceAndLinkImpl implements TopologyForDeviceAndLink {
410 public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) { 439 public IsisLinkTed createIsisLinkTedInfo(LsPdu lsPdu) {
411 IsisLinkTed isisLinkTed = new DefaultIsisLinkTed(); 440 IsisLinkTed isisLinkTed = new DefaultIsisLinkTed();
412 for (IsisTlv isisTlv : lsPdu.tlvs()) { 441 for (IsisTlv isisTlv : lsPdu.tlvs()) {
413 - if (isisTlv instanceof IpExtendedReachabilityTlv) { 442 + if (isisTlv instanceof IsExtendedReachability) {
414 - IpExtendedReachabilityTlv ipExtendedReachabilityTlv = (IpExtendedReachabilityTlv) isisTlv; 443 + IsExtendedReachability isExtendedReachability = (IsExtendedReachability) isisTlv;
415 - List<TrafficEngineeringSubTlv> trafficEngSubTlv = ipExtendedReachabilityTlv.teTlvs(); 444 + List<NeighborForExtendedIs> neighbours = isExtendedReachability.neighbours();
416 - for (TrafficEngineeringSubTlv teTlv : trafficEngSubTlv) { 445 + for (NeighborForExtendedIs teTlv : neighbours) {
417 - if (teTlv instanceof AdministrativeGroup) { 446 + List<TrafficEngineeringSubTlv> teSubTlvs = teTlv.teSubTlv();
418 - AdministrativeGroup ag = (AdministrativeGroup) isisTlv; 447 + for (TrafficEngineeringSubTlv teSubTlv : teSubTlvs) {
448 + if (teSubTlv instanceof AdministrativeGroup) {
449 + AdministrativeGroup ag = (AdministrativeGroup) teSubTlv;
419 isisLinkTed.setAdministrativeGroup(ag.administrativeGroup()); 450 isisLinkTed.setAdministrativeGroup(ag.administrativeGroup());
420 } 451 }
421 - if (teTlv instanceof TrafficEngineeringMetric) { 452 + if (teSubTlv instanceof InterfaceIpAddress) {
422 - TrafficEngineeringMetric teM = (TrafficEngineeringMetric) isisTlv; 453 + InterfaceIpAddress localIpAddress = (InterfaceIpAddress) teSubTlv;
454 + isisLinkTed.setIpv4InterfaceAddress(localIpAddress.localInterfaceIPAddress());
455 + }
456 + if (teSubTlv instanceof NeighborIpAddress) {
457 + NeighborIpAddress neighborIpAddress = (NeighborIpAddress) teSubTlv;
458 + isisLinkTed.setIpv4NeighborAddress(neighborIpAddress.neighborIPAddress());
459 + }
460 + if (teSubTlv instanceof TrafficEngineeringMetric) {
461 + TrafficEngineeringMetric teM = (TrafficEngineeringMetric) teSubTlv;
423 isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue()); 462 isisLinkTed.setTeDefaultMetric(teM.getTrafficEngineeringMetricValue());
424 } 463 }
425 - if (teTlv instanceof MaximumReservableBandwidth) { 464 + if (teSubTlv instanceof MaximumBandwidth) {
426 - MaximumReservableBandwidth reservableBw = (MaximumReservableBandwidth) isisTlv; 465 + MaximumBandwidth maxLinkBandwidth = (MaximumBandwidth) teSubTlv;
466 + isisLinkTed.setMaximumLinkBandwidth(
467 + Bandwidth.bps(maxLinkBandwidth.getMaximumBandwidthValue()));
468 + }
469 + if (teSubTlv instanceof MaximumReservableBandwidth) {
470 + MaximumReservableBandwidth maxReservableBw = (MaximumReservableBandwidth) teSubTlv;
427 isisLinkTed.setMaximumReservableLinkBandwidth( 471 isisLinkTed.setMaximumReservableLinkBandwidth(
428 - Bandwidth.bps(reservableBw.getMaximumBandwidthValue())); 472 + Bandwidth.bps(maxReservableBw.getMaximumBandwidthValue()));
473 + }
474 + if (teSubTlv instanceof UnreservedBandwidth) {
475 + UnreservedBandwidth unReservedBandwidth = (UnreservedBandwidth) teSubTlv;
476 + List<Bandwidth> bandwidthList = new ArrayList<>();
477 + List<Float> unReservedBandwidthList = unReservedBandwidth.unReservedBandwidthValue();
478 + for (Float unReservedBandwidthFloatValue : unReservedBandwidthList) {
479 + Bandwidth bandwidth = Bandwidth.bps(unReservedBandwidthFloatValue);
480 + bandwidthList.add(bandwidth);
481 + }
482 + isisLinkTed.setUnreservedBandwidth(bandwidthList);
483 + }
429 } 484 }
430 } 485 }
431 - } else {
432 - log.debug("TLV type not supported");
433 } 486 }
434 } 487 }
435 return isisLinkTed; 488 return isisLinkTed;
......
...@@ -46,6 +46,15 @@ public class NeighborForExtendedIs { ...@@ -46,6 +46,15 @@ public class NeighborForExtendedIs {
46 } 46 }
47 47
48 /** 48 /**
49 + * Returns list of sub tlvs.
50 + *
51 + * @return teSubTlv list of sub tlvs
52 + */
53 + public List<TrafficEngineeringSubTlv> teSubTlv() {
54 + return teSubTlv;
55 + }
56 +
57 + /**
49 * Sets neighbor ID. 58 * Sets neighbor ID.
50 * 59 *
51 * @param neighborId neighbor ID 60 * @param neighborId neighbor ID
......
...@@ -67,10 +67,15 @@ public final class SubTlvFinder { ...@@ -67,10 +67,15 @@ public final class SubTlvFinder {
67 subTlv = unreservedBandwidth; 67 subTlv = unreservedBandwidth;
68 break; 68 break;
69 case INTERFACEADDRESS: 69 case INTERFACEADDRESS:
70 - NeighborIpAddress ipInterfaceAddressTlv = new NeighborIpAddress(tlvHeader); 70 + InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader);
71 ipInterfaceAddressTlv.readFrom(channelBuffer); 71 ipInterfaceAddressTlv.readFrom(channelBuffer);
72 subTlv = ipInterfaceAddressTlv; 72 subTlv = ipInterfaceAddressTlv;
73 break; 73 break;
74 + case NEIGHBORADDRESS:
75 + NeighborIpAddress ipNeighborAddressTlv = new NeighborIpAddress(tlvHeader);
76 + ipNeighborAddressTlv.readFrom(channelBuffer);
77 + subTlv = ipNeighborAddressTlv;
78 + break;
74 default: 79 default:
75 //TODO 80 //TODO
76 break; 81 break;
......
...@@ -54,7 +54,7 @@ public class UnreservedBandwidth extends TlvHeader implements TrafficEngineering ...@@ -54,7 +54,7 @@ public class UnreservedBandwidth extends TlvHeader implements TrafficEngineering
54 * 54 *
55 * @return List of un reserved bandwidth 55 * @return List of un reserved bandwidth
56 */ 56 */
57 - public List<Float> getUnReservedBandwidthValue() { 57 + public List<Float> unReservedBandwidthValue() {
58 return this.unReservedBandwidth; 58 return this.unReservedBandwidth;
59 } 59 }
60 60
......
...@@ -59,6 +59,7 @@ import org.slf4j.Logger; ...@@ -59,6 +59,7 @@ import org.slf4j.Logger;
59 import java.util.ArrayList; 59 import java.util.ArrayList;
60 import java.util.HashMap; 60 import java.util.HashMap;
61 import java.util.List; 61 import java.util.List;
62 +import java.util.StringTokenizer;
62 63
63 import static org.slf4j.LoggerFactory.getLogger; 64 import static org.slf4j.LoggerFactory.getLogger;
64 65
...@@ -132,7 +133,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -132,7 +133,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
132 @Override 133 @Override
133 public boolean isReachable(DeviceId deviceId) { 134 public boolean isReachable(DeviceId deviceId) {
134 log.debug("IsisDeviceProvider::isReachable...!!!!"); 135 log.debug("IsisDeviceProvider::isReachable...!!!!");
135 - return false; 136 + return true;
136 } 137 }
137 138
138 @Override 139 @Override
...@@ -149,6 +150,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -149,6 +150,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
149 private LinkDescription buildLinkDes(IsisLink isisLink) { 150 private LinkDescription buildLinkDes(IsisLink isisLink) {
150 long srcAddress = 0; 151 long srcAddress = 0;
151 long dstAddress = 0; 152 long dstAddress = 0;
153 + boolean localPseduo = false;
154 + boolean remotePseduo = false;
152 String localSystemId = isisLink.localSystemId(); 155 String localSystemId = isisLink.localSystemId();
153 String remoteSystemId = isisLink.remoteSystemId(); 156 String remoteSystemId = isisLink.remoteSystemId();
154 //Changing of port numbers 157 //Changing of port numbers
...@@ -156,9 +159,17 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -156,9 +159,17 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
156 dstAddress = isisLink.neighborIp().toInt(); 159 dstAddress = isisLink.neighborIp().toInt();
157 DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId)); 160 DeviceId srcId = DeviceId.deviceId(IsisRouterId.uri(localSystemId));
158 DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId)); 161 DeviceId dstId = DeviceId.deviceId(IsisRouterId.uri(remoteSystemId));
159 - if (srcAddress == 0) { 162 + if (checkIsDis(isisLink.localSystemId())) {
163 + localPseduo = true;
164 + } else if (checkIsDis(isisLink.remoteSystemId())) {
165 + remotePseduo = true;
166 + } else {
167 + log.debug("IsisDeviceProvider::buildLinkDes : unknown type.!");
168 + }
169 +
170 + if (localPseduo && srcAddress == 0) {
160 srcAddress = PSEUDO_PORT; 171 srcAddress = PSEUDO_PORT;
161 - } else if (dstAddress == 0) { 172 + } else if (remotePseduo && dstAddress == 0) {
162 dstAddress = PSEUDO_PORT; 173 dstAddress = PSEUDO_PORT;
163 } 174 }
164 175
...@@ -173,6 +184,28 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -173,6 +184,28 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
173 } 184 }
174 185
175 /** 186 /**
187 + * Return the DIS value from the systemId.
188 + *
189 + * @param systemId system Id.
190 + * @return return true if DIS else false
191 + */
192 + public static boolean checkIsDis(String systemId) {
193 + StringTokenizer stringTokenizer = new StringTokenizer(systemId, "." + "-");
194 + int count = 0;
195 + while (stringTokenizer.hasMoreTokens()) {
196 + String str = stringTokenizer.nextToken();
197 + if (count == 3) {
198 + int x = Integer.parseInt(str);
199 + if (x > 0) {
200 + return true;
201 + }
202 + }
203 + count++;
204 + }
205 + return false;
206 + }
207 +
208 + /**
176 * Builds port description. 209 * Builds port description.
177 * 210 *
178 * @param deviceId device ID for the port 211 * @param deviceId device ID for the port
...@@ -181,9 +214,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -181,9 +214,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
181 */ 214 */
182 private List<PortDescription> buildPortDescriptions(DeviceId deviceId, 215 private List<PortDescription> buildPortDescriptions(DeviceId deviceId,
183 PortNumber portNumber) { 216 PortNumber portNumber) {
184 -
185 List<PortDescription> portList; 217 List<PortDescription> portList;
186 -
187 if (portMap.containsKey(deviceId)) { 218 if (portMap.containsKey(deviceId)) {
188 portList = portMap.get(deviceId); 219 portList = portMap.get(deviceId);
189 } else { 220 } else {
...@@ -193,8 +224,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -193,8 +224,8 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
193 PortDescription portDescriptions = new DefaultPortDescription(portNumber, true); 224 PortDescription portDescriptions = new DefaultPortDescription(portNumber, true);
194 portList.add(portDescriptions); 225 portList.add(portDescriptions);
195 } 226 }
196 -
197 portMap.put(deviceId, portList); 227 portMap.put(deviceId, portList);
228 +
198 return portList; 229 return portList;
199 } 230 }
200 231
...@@ -215,6 +246,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv ...@@ -215,6 +246,7 @@ public class IsisTopologyProvider extends AbstractProvider implements DeviceProv
215 246
216 //TE Info 247 //TE Info
217 IsisLinkTed isisLinkTed = isisLink.linkTed(); 248 IsisLinkTed isisLinkTed = isisLink.linkTed();
249 + log.info("Ted Information: {}", isisLinkTed.toString());
218 administrativeGroup = isisLinkTed.administrativeGroup(); 250 administrativeGroup = isisLinkTed.administrativeGroup();
219 teMetric = isisLinkTed.teDefaultMetric(); 251 teMetric = isisLinkTed.teDefaultMetric();
220 maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth(); 252 maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth();
......