X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FDiscoveryService.java;h=3be6f22742432795a55f17540fa03b8792b1bac9;hb=refs%2Fchanges%2F17%2F417%2F1;hp=8c41624570b5239dfb0e4a84e72d95a250780522;hpb=39339b8d596baaf6505fec657d66bcfc7ae0df31;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java index 8c41624570..3be6f22742 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * @@ -27,6 +26,8 @@ import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketListen; import org.opendaylight.controller.protocol_plugin.openflow.IDataPacketMux; +import org.opendaylight.controller.protocol_plugin.openflow.IDiscoveryListener; +import org.opendaylight.controller.protocol_plugin.openflow.IInventoryProvider; import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener; import org.opendaylight.controller.protocol_plugin.openflow.core.IController; import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch; @@ -46,8 +47,6 @@ import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.core.Property; import org.opendaylight.controller.sal.core.State; import org.opendaylight.controller.sal.core.UpdateType; -import org.opendaylight.controller.sal.discovery.IDiscoveryService; -import org.opendaylight.controller.sal.inventory.IPluginInInventoryService; import org.opendaylight.controller.sal.packet.Ethernet; import org.opendaylight.controller.sal.packet.LLDP; import org.opendaylight.controller.sal.packet.LLDPTLV; @@ -68,37 +67,66 @@ public class DiscoveryService implements IInventoryShimExternalListener, private static Logger logger = LoggerFactory .getLogger(DiscoveryService.class); private IController controller = null; - private IDiscoveryService discoveryService = null; - private IPluginInInventoryService pluginInInventoryService = null; + private IDiscoveryListener discoveryListener = null; + private IInventoryProvider inventoryProvider = null; private IDataPacketMux iDataPacketMux = null; - private List readyListHi = null; // newly added ports go into this list and will be served first - private List readyListLo = null; // come here after served at least once - private List waitingList = null; // staging area during quiet period - private ConcurrentMap pendingMap = null;// wait for response back - private ConcurrentMap edgeMap = null; // openflow edges keyed by head connector - private ConcurrentMap agingMap = null; // aging entries keyed by edge port - private ConcurrentMap prodMap = null; // production edges keyed by edge port + private List readyListHi = null; // newly added ports go into + // this list and will be + // served first + private List readyListLo = null; // come here after served at + // least once + private List waitingList = null; // staging area during quiet + // period + private ConcurrentMap pendingMap = null;// wait for + // response + // back + private ConcurrentMap edgeMap = null; // openflow edges + // keyed by head + // connector + private ConcurrentMap agingMap = null; // aging + // entries + // keyed by + // edge port + private ConcurrentMap prodMap = null; // production + // edges keyed by + // edge port private Timer discoveryTimer; // discovery timer private DiscoveryTimerTask discoveryTimerTask; // timer task private long discoveryTimerTick = 1L * 1000; // per tick in msec private int discoveryTimerTickCount = 0; // main tick counter - private int discoveryBatchMaxPorts = 500; // max # of ports handled in one batch - private int discoveryBatchRestartTicks = getDiscoveryInterval(); // periodically restart batching process + private int discoveryBatchMaxPorts = 500; // max # of ports handled in one + // batch + private int discoveryBatchRestartTicks = getDiscoveryInterval(); // periodically + // restart + // batching + // process private int discoveryBatchPausePeriod = 5; // pause for few secs - private int discoveryBatchPauseTicks = discoveryBatchRestartTicks - discoveryBatchPausePeriod; // pause after this point - private int discoveryRetry = getDiscoveryRetry(); // number of retries after initial timeout + private int discoveryBatchPauseTicks = discoveryBatchRestartTicks + - discoveryBatchPausePeriod; // pause after this point + private int discoveryRetry = getDiscoveryRetry(); // number of retries after + // initial timeout private int discoveryTimeoutTicks = getDiscoveryTimeout(); // timeout in sec private int discoveryAgeoutTicks = 120; // age out 2 min - private int discoveryConsistencyCheckMultiple = 2; // multiple of discoveryBatchRestartTicks - private int discoveryConsistencyCheckTickCount = discoveryBatchPauseTicks; // CC tick counter - private int discoveryConsistencyCheckCallingTimes = 0; // # of times CC gets called - private int discoveryConsistencyCheckCorrected = 0; // # of cases CC corrected - private boolean discoveryConsistencyCheckEnabled = true;// enable or disable CC + private int discoveryConsistencyCheckMultiple = 2; // multiple of + // discoveryBatchRestartTicks + private int discoveryConsistencyCheckTickCount = discoveryBatchPauseTicks; // CC + // tick + // counter + private int discoveryConsistencyCheckCallingTimes = 0; // # of times CC gets + // called + private int discoveryConsistencyCheckCorrected = 0; // # of cases CC + // corrected + private boolean discoveryConsistencyCheckEnabled = true;// enable or disable + // CC private boolean discoveryAgingEnabled = true; // enable or disable aging - private boolean discoverySnoopingEnabled = true; // global flag to enable or disable LLDP snooping - private List discoverySnoopingDisableList; // the list of ports that will not do LLDP snooping + private boolean discoverySnoopingEnabled = true; // global flag to enable or + // disable LLDP snooping + private List discoverySnoopingDisableList; // the list of + // ports that will + // not do LLDP + // snooping private BlockingQueue transmitQ; private Thread transmitThread; private Boolean throttling = false; // if true, no more batching. @@ -121,13 +149,11 @@ public class DiscoveryService implements IInventoryShimExternalListener, sendDiscoveryPacket(nodeConnector, outPkt); nodeConnector = null; } catch (InterruptedException e1) { - logger - .warn("DiscoveryTransmit interupted", e1 - .getMessage()); + logger.warn("DiscoveryTransmit interupted", e1.getMessage()); if (shuttingDown) return; } catch (Exception e2) { - logger.error("",e2); + logger.error("", e2); } } } @@ -158,7 +184,8 @@ public class DiscoveryService implements IInventoryShimExternalListener, .setLength((short) pidValue.length).setValue(pidValue); // Create LLDP Custom TLV - byte[] customValue = LLDPTLV.createCustomTLVValue(nodeConnector.toString()); + byte[] customValue = LLDPTLV.createCustomTLVValue(nodeConnector + .toString()); customTlv.setType((byte) LLDPTLV.TLVType.Custom.getValue()) .setLength((short) customValue.length).setValue(customValue); @@ -168,24 +195,25 @@ public class DiscoveryService implements IInventoryShimExternalListener, // Create discovery pkt LLDP discoveryPkt = new LLDP(); - discoveryPkt.setChassisId(chassisIdTlv).setPortId(portIdTlv).setTtl( - ttlTlv).setOptionalTLVList(customList); + discoveryPkt.setChassisId(chassisIdTlv).setPortId(portIdTlv) + .setTtl(ttlTlv).setOptionalTLVList(customList); RawPacket rawPkt = null; try { // Create ethernet pkt - byte[] sourceMac = getSouceMACFromNodeID(nodeId); + byte[] sourceMac = getSouceMACFromNodeID(nodeId); Ethernet ethPkt = new Ethernet(); - ethPkt.setSourceMACAddress(sourceMac).setDestinationMACAddress( - LLDP.LLDPMulticastMac).setEtherType( - EtherTypes.LLDP.shortValue()).setPayload(discoveryPkt); + ethPkt.setSourceMACAddress(sourceMac) + .setDestinationMACAddress(LLDP.LLDPMulticastMac) + .setEtherType(EtherTypes.LLDP.shortValue()) + .setPayload(discoveryPkt); byte[] data = ethPkt.serialize(); rawPkt = new RawPacket(data); rawPkt.setOutgoingNodeConnector(nodeConnector); } catch (ConstructionException cex) { - logger.warn("RawPacket creation caught exception {}", cex - .getMessage()); + logger.warn("RawPacket creation caught exception {}", + cex.getMessage()); } catch (Exception e) { logger.error("Failed to serialize the LLDP packet: " + e); } @@ -209,12 +237,16 @@ public class DiscoveryService implements IInventoryShimExternalListener, ISwitch sw = controller.getSwitches().get(sid); if (sw == null) { - logger.debug("Can not send discovery packet out since switch {} is null", sid); + logger.debug( + "Can not send discovery packet out since switch {} is null", + sid); return; } if (!sw.isOperational()) { - logger.debug("Can not send discovery packet out since switch {} is not operational", sw); + logger.debug( + "Can not send discovery packet out since switch {} is not operational", + sw); return; } @@ -260,19 +292,23 @@ public class DiscoveryService implements IInventoryShimExternalListener, inPkt.getIncomingNodeConnector(), e); return PacketResult.IGNORED; } + if (ethPkt.getPayload() instanceof LLDP) { NodeConnector dst = inPkt.getIncomingNodeConnector(); - if (!processDiscoveryPacket(dst, ethPkt)) { - /* Snoop the discovery pkt if not generated from us */ - snoopDiscoveryPacket(dst, ethPkt); + if (isEnabled(dst)) { + if (!processDiscoveryPacket(dst, ethPkt)) { + /* Snoop the discovery pkt if not generated from us */ + snoopDiscoveryPacket(dst, ethPkt); + } + return PacketResult.CONSUME; } - return PacketResult.CONSUME; } return PacketResult.IGNORED; } /* - * Snoop incoming discovery frames generated by the production network neighbor switch + * Snoop incoming discovery frames generated by the production network + * neighbor switch */ private void snoopDiscoveryPacket(NodeConnector dstNodeConnector, Ethernet ethPkt) { @@ -292,21 +328,25 @@ public class DiscoveryService implements IInventoryShimExternalListener, LLDP lldp = (LLDP) ethPkt.getPayload(); try { - String nodeId = LLDPTLV.getHexStringValue(lldp.getChassisId().getValue(), lldp.getChassisId().getLength()); - String portId = LLDPTLV.getStringValue(lldp.getPortId().getValue(), lldp.getPortId().getLength()); - byte[] systemNameBytes = null; - // get system name if present in the LLDP pkt - for (LLDPTLV lldptlv : lldp.getOptionalTLVList()) { - if (lldptlv.getType() == LLDPTLV.TLVType.SystemName.getValue()) { - systemNameBytes = lldptlv.getValue(); - break; - } - } - String nodeName = (systemNameBytes == null) ? nodeId : new String(systemNameBytes); - Node srcNode = new Node(Node.NodeIDType.PRODUCTION, nodeName); - NodeConnector srcNodeConnector = NodeConnectorCreator - .createNodeConnector(NodeConnector.NodeConnectorIDType.PRODUCTION, - portId, srcNode); + String nodeId = LLDPTLV.getHexStringValue(lldp.getChassisId() + .getValue(), lldp.getChassisId().getLength()); + String portId = LLDPTLV.getStringValue(lldp.getPortId().getValue(), + lldp.getPortId().getLength()); + byte[] systemNameBytes = null; + // get system name if present in the LLDP pkt + for (LLDPTLV lldptlv : lldp.getOptionalTLVList()) { + if (lldptlv.getType() == LLDPTLV.TLVType.SystemName.getValue()) { + systemNameBytes = lldptlv.getValue(); + break; + } + } + String nodeName = (systemNameBytes == null) ? nodeId : new String( + systemNameBytes); + Node srcNode = new Node(Node.NodeIDType.PRODUCTION, nodeName); + NodeConnector srcNodeConnector = NodeConnectorCreator + .createNodeConnector( + NodeConnector.NodeConnectorIDType.PRODUCTION, + portId, srcNode); Edge edge = null; Set props = null; @@ -321,13 +361,13 @@ public class DiscoveryService implements IInventoryShimExternalListener, /* * Handle discovery frames generated by our controller + * * @return true if it's a success */ private boolean processDiscoveryPacket(NodeConnector dstNodeConnector, Ethernet ethPkt) { if ((dstNodeConnector == null) || (ethPkt == null)) { - logger - .trace("Ignoring processing of discovery packet: Null node connector or packet"); + logger.trace("Ignoring processing of discovery packet: Null node connector or packet"); return false; } @@ -347,26 +387,26 @@ public class DiscoveryService implements IInventoryShimExternalListener, NodeConnector srcNodeConnector = null; for (LLDPTLV lldptlv : lldp.getOptionalTLVList()) { if (lldptlv.getType() == LLDPTLV.TLVType.Custom.getValue()) { - String ncString = LLDPTLV.getCustomString(lldptlv.getValue(), lldptlv.getLength()); - srcNodeConnector = NodeConnector.fromString(ncString); - if (srcNodeConnector != null) { - srcNode = srcNodeConnector.getNode(); - /* Check if it's expected */ - if (isTracked(srcNodeConnector)) { - break; + String ncString = LLDPTLV.getCustomString(lldptlv.getValue(), + lldptlv.getLength()); + srcNodeConnector = NodeConnector.fromString(ncString); + if (srcNodeConnector != null) { + srcNode = srcNodeConnector.getNode(); + /* Check if it's expected */ + if (isTracked(srcNodeConnector)) { + break; } else { - srcNode = null; - srcNodeConnector = null; + srcNode = null; + srcNodeConnector = null; } } } } if ((srcNode == null) || (srcNodeConnector == null)) { - logger - .trace( - "Received non-controller generated discovery packet from {}", - dstNodeConnector); + logger.trace( + "Received non-controller generated discovery packet from {}", + dstNodeConnector); return false; } @@ -391,11 +431,11 @@ public class DiscoveryService implements IInventoryShimExternalListener, return null; } - if (pluginInInventoryService == null) { + if (inventoryProvider == null) { return null; } - Map> props = pluginInInventoryService + Map> props = inventoryProvider .getNodeConnectorProps(false); if (props == null) { return null; @@ -719,8 +759,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, } NodeConnector src = edge.getTailNodeConnector(); - if (!src.getType().equals( - NodeConnector.NodeConnectorIDType.PRODUCTION)) { + if (!src.getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) { pendingMap.remove(src); if (!waitingList.contains(src)) { waitingList.add(src); @@ -735,44 +774,47 @@ public class DiscoveryService implements IInventoryShimExternalListener, logger.trace("Add edge {}", edge); } - /** * Update Production Edge - * - * @param edge The Production Edge - * @param props Properties associated with the edge + * + * @param edge + * The Production Edge + * @param props + * Properties associated with the edge */ private void updateProdEdge(Edge edge, Set props) { - NodeConnector edgePort = edge.getHeadNodeConnector(); - - /* Do not update in case there is an existing OpenFlow link */ - if (edgeMap.get(edgePort) != null) { - logger.trace("Discarded edge {} since there is an existing OF link {}", - edge, edgeMap.get(edgePort)); - return; - } - - /* Look for any existing Production Edge */ - Edge oldEdge = prodMap.get(edgePort); - if (oldEdge == null) { - /* Let's add a new one */ - addEdge(edge, props); - } else if (!edge.equals(oldEdge)) { - /* Remove the old one first */ - removeProdEdge(oldEdge.getHeadNodeConnector()); - /* Then add the new one */ - addEdge(edge, props); - } else { - /* o/w, just reset the aging timer */ + NodeConnector edgePort = edge.getHeadNodeConnector(); + + /* Do not update in case there is an existing OpenFlow link */ + if (edgeMap.get(edgePort) != null) { + logger.trace( + "Discarded edge {} since there is an existing OF link {}", + edge, edgeMap.get(edgePort)); + return; + } + + /* Look for any existing Production Edge */ + Edge oldEdge = prodMap.get(edgePort); + if (oldEdge == null) { + /* Let's add a new one */ + addEdge(edge, props); + } else if (!edge.equals(oldEdge)) { + /* Remove the old one first */ + removeProdEdge(oldEdge.getHeadNodeConnector()); + /* Then add the new one */ + addEdge(edge, props); + } else { + /* o/w, just reset the aging timer */ NodeConnector dst = edge.getHeadNodeConnector(); - agingMap.put(dst, 0); - } + agingMap.put(dst, 0); + } } /** * Remove Production Edge for a given edge port - * - * @param edgePort The OF edge port + * + * @param edgePort + * The OF edge port */ private void removeProdEdge(NodeConnector edgePort) { agingMap.remove(edgePort); @@ -785,8 +827,8 @@ public class DiscoveryService implements IInventoryShimExternalListener, } // notify Topology - if (this.discoveryService != null) { - this.discoveryService.notifyEdge(edge, UpdateType.REMOVED, null); + if (this.discoveryListener != null) { + this.discoveryListener.notifyEdge(edge, UpdateType.REMOVED, null); } logger.trace("Remove edge {}", edge); } @@ -817,8 +859,8 @@ public class DiscoveryService implements IInventoryShimExternalListener, } // notify Topology - if (this.discoveryService != null) { - this.discoveryService.notifyEdge(edge, UpdateType.REMOVED, null); + if (this.discoveryListener != null) { + this.discoveryListener.notifyEdge(edge, UpdateType.REMOVED, null); } logger.trace("Remove {}", nodeConnector); } @@ -828,20 +870,19 @@ public class DiscoveryService implements IInventoryShimExternalListener, } private void updateEdge(Edge edge, UpdateType type, Set props) { - if (discoveryService == null) { + if (discoveryListener == null) { return; } - this.discoveryService.notifyEdge(edge, type, props); + this.discoveryListener.notifyEdge(edge, type, props); NodeConnector src = edge.getTailNodeConnector(), dst = edge .getHeadNodeConnector(); - if (!src.getType().equals( - NodeConnector.NodeConnectorIDType.PRODUCTION)) { + if (!src.getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) { if (type == UpdateType.ADDED) { - edgeMap.put(src, edge); + edgeMap.put(dst, edge); } else { - edgeMap.remove(src); + edgeMap.remove(dst); } } else { /* @@ -1081,7 +1122,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, } else { ci.println("Discovery snooping is globally disabled"); } - + ci.println("\nDiscovery snooping is locally disabled on these ports"); for (NodeConnector nodeConnector : discoverySnoopingDisableList) { ci.println(nodeConnector); @@ -1091,20 +1132,20 @@ public class DiscoveryService implements IInventoryShimExternalListener, public void _esnp(CommandInterpreter ci) { String val = ci.nextArgument(); - + if (val == null) { - ci.println("Usage: esnp "); + ci.println("Usage: esnp "); } else if (val.equalsIgnoreCase("all")) { this.discoverySnoopingEnabled = true; ci.println("Discovery snooping is globally enabled"); } else { NodeConnector nodeConnector = NodeConnector.fromString(val); if (nodeConnector != null) { - discoverySnoopingDisableList.remove(nodeConnector); + discoverySnoopingDisableList.remove(nodeConnector); ci.println("Discovery snooping is locally enabled on port " + nodeConnector); } else { - ci.println("Entered invalid NodeConnector " + val); + ci.println("Entered invalid NodeConnector " + val); } } return; @@ -1112,9 +1153,9 @@ public class DiscoveryService implements IInventoryShimExternalListener, public void _dsnp(CommandInterpreter ci) { String val = ci.nextArgument(); - + if (val == null) { - ci.println("Usage: dsnp "); + ci.println("Usage: dsnp "); } else if (val.equalsIgnoreCase("all")) { this.discoverySnoopingEnabled = false; ci.println("Discovery snooping is globally disabled"); @@ -1125,7 +1166,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, ci.println("Discovery snooping is locally disabled on port " + nodeConnector); } else { - ci.println("Entered invalid NodeConnector " + val); + ci.println("Entered invalid NodeConnector " + val); } } return; @@ -1134,16 +1175,17 @@ public class DiscoveryService implements IInventoryShimExternalListener, public void _spause(CommandInterpreter ci) { String val = ci.nextArgument(); String out = "Please enter pause period less than " - + discoveryBatchRestartTicks + ". Current pause period is " - + discoveryBatchPausePeriod + " pause tick is " - + discoveryBatchPauseTicks + "."; + + discoveryBatchRestartTicks + ". Current pause period is " + + discoveryBatchPausePeriod + " pause tick is " + + discoveryBatchPauseTicks + "."; if (val != null) { try { int pause = Integer.parseInt(val); if (pause < discoveryBatchRestartTicks) { - discoveryBatchPausePeriod = pause; - discoveryBatchPauseTicks = discoveryBatchRestartTicks - discoveryBatchPausePeriod; + discoveryBatchPausePeriod = pause; + discoveryBatchPauseTicks = discoveryBatchRestartTicks + - discoveryBatchPausePeriod; return; } } catch (Exception e) { @@ -1156,19 +1198,20 @@ public class DiscoveryService implements IInventoryShimExternalListener, public void _sdi(CommandInterpreter ci) { String val = ci.nextArgument(); String out = "Please enter discovery interval greater than " - + discoveryBatchPausePeriod + ". Current value is " - + discoveryBatchRestartTicks + "."; + + discoveryBatchPausePeriod + ". Current value is " + + discoveryBatchRestartTicks + "."; if (val != null) { - try { - int restart = Integer.parseInt(val); - if (restart > discoveryBatchPausePeriod) { - discoveryBatchRestartTicks = restart; - discoveryBatchPauseTicks = discoveryBatchRestartTicks - discoveryBatchPausePeriod; - return; - } - } catch (Exception e) { - } + try { + int restart = Integer.parseInt(val); + if (restart > discoveryBatchPausePeriod) { + discoveryBatchRestartTicks = restart; + discoveryBatchPauseTicks = discoveryBatchRestartTicks + - discoveryBatchPausePeriod; + return; + } + } catch (Exception e) { + } } ci.println(out); } @@ -1340,9 +1383,6 @@ public class DiscoveryService implements IInventoryShimExternalListener, removeDiscovery(node); } - public void updateNode(Node node, Set props) { - } - void setController(IController s) { this.controller = s; } @@ -1353,12 +1393,12 @@ public class DiscoveryService implements IInventoryShimExternalListener, } } - public void setPluginInInventoryService(IPluginInInventoryService service) { - this.pluginInInventoryService = service; + public void setInventoryProvider(IInventoryProvider service) { + this.inventoryProvider = service; } - public void unsetPluginInInventoryService(IPluginInInventoryService service) { - this.pluginInInventoryService = null; + public void unsetInventoryProvider(IInventoryProvider service) { + this.inventoryProvider = null; } public void setIDataPacketMux(IDataPacketMux service) { @@ -1371,13 +1411,13 @@ public class DiscoveryService implements IInventoryShimExternalListener, } } - void setDiscoveryService(IDiscoveryService s) { - this.discoveryService = s; + void setDiscoveryListener(IDiscoveryListener s) { + this.discoveryListener = s; } - void unsetDiscoveryService(IDiscoveryService s) { - if (this.discoveryService == s) { - this.discoveryService = null; + void unsetDiscoveryListener(IDiscoveryListener s) { + if (this.discoveryListener == s) { + this.discoveryListener = null; } } @@ -1391,10 +1431,10 @@ public class DiscoveryService implements IInventoryShimExternalListener, portIdTlv.setType((byte) LLDPTLV.TLVType.PortID.getValue()); // Create LLDP TTL TLV - byte[] ttl = new byte[] {(byte) 0, (byte) 120 }; + byte[] ttl = new byte[] { (byte) 0, (byte) 120 }; ttlTlv = new LLDPTLV(); - ttlTlv.setType((byte) LLDPTLV.TLVType.TTL.getValue()).setLength( - (short) ttl.length).setValue(ttl); + ttlTlv.setType((byte) LLDPTLV.TLVType.TTL.getValue()) + .setLength((short) ttl.length).setValue(ttl); customTlv = new LLDPTLV(); } @@ -1460,8 +1500,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, } /** - * Function called after registering the - * service in OSGi service registry. + * Function called after registering the service in OSGi service registry. */ void started() { /* get a snapshot of all the existing switches */ @@ -1506,23 +1545,23 @@ public class DiscoveryService implements IInventoryShimExternalListener, public void containerModeUpdated(UpdateType t) { // do nothing } - - private byte[] getSouceMACFromNodeID(String nodeId) { + + private byte[] getSouceMACFromNodeID(String nodeId) { byte[] cid = HexEncode.bytesFromHexString(nodeId); byte[] sourceMac = new byte[6]; int pos = cid.length - sourceMac.length; if (pos >= 0) { - System.arraycopy(cid, pos, sourceMac, 0, sourceMac.length); + System.arraycopy(cid, pos, sourceMac, 0, sourceMac.length); } - + return sourceMac; } - + /** * This method returns the interval which determines how often the discovery * packets will be sent. Default is 300 seconds. - * + * * @return The discovery interval in second */ private int getDiscoveryInterval() { @@ -1542,7 +1581,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, /** * This method returns the timeout value in waiting for response of a * discovery query. Default is 60 seconds. - * + * * @return The discovery timeout in second */ private int getDiscoveryTimeout() { @@ -1562,7 +1601,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, /** * This method returns the number of retries after the initial discovery * packet is not received within the timeout period. Default is 2 times. - * + * * @return The number of discovery retries */ private int getDiscoveryRetry() {