Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 16 | package org.onosproject.provider.lldpcommon; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 17 | |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 18 | import com.google.common.collect.Sets; |
Ayaka Koshibe | 12c8c08 | 2015-12-08 12:48:46 -0800 | [diff] [blame] | 19 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 20 | import org.jboss.netty.util.Timeout; |
| 21 | import org.jboss.netty.util.TimerTask; |
Jonathan Hart | e8600eb | 2015-01-12 10:30:45 -0800 | [diff] [blame] | 22 | import org.onlab.packet.Ethernet; |
| 23 | import org.onlab.packet.ONOSLLDP; |
| 24 | import org.onlab.util.Timer; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 25 | import org.onosproject.net.ConnectPoint; |
| 26 | import org.onosproject.net.Device; |
| 27 | import org.onosproject.net.DeviceId; |
| 28 | import org.onosproject.net.Link.Type; |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 29 | import org.onosproject.net.LinkKey; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 30 | import org.onosproject.net.Port; |
| 31 | import org.onosproject.net.PortNumber; |
| 32 | import org.onosproject.net.link.DefaultLinkDescription; |
| 33 | import org.onosproject.net.link.LinkDescription; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 34 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 35 | import org.onosproject.net.packet.OutboundPacket; |
| 36 | import org.onosproject.net.packet.PacketContext; |
Ayaka Koshibe | 4822922 | 2016-05-16 18:04:26 -0700 | [diff] [blame] | 37 | import org.onosproject.net.link.ProbedLinkProvider; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 38 | import org.slf4j.Logger; |
| 39 | |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 40 | import java.nio.ByteBuffer; |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 41 | import java.util.Set; |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 42 | |
Thomas Vachuska | 586bc4f | 2016-08-19 12:44:26 -0700 | [diff] [blame] | 43 | import static com.google.common.base.Strings.isNullOrEmpty; |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 44 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
| 45 | import static org.onosproject.net.PortNumber.portNumber; |
| 46 | import static org.onosproject.net.flow.DefaultTrafficTreatment.builder; |
| 47 | import static org.slf4j.LoggerFactory.getLogger; |
| 48 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 49 | /** |
| 50 | * Run discovery process from a physical switch. Ports are initially labeled as |
| 51 | * slow ports. When an LLDP is successfully received, label the remote port as |
| 52 | * fast. Every probeRate milliseconds, loop over all fast ports and send an |
| 53 | * LLDP, send an LLDP for a single slow port. Based on FlowVisor topology |
| 54 | * discovery implementation. |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 55 | */ |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 56 | public class LinkDiscovery implements TimerTask { |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 57 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 58 | private final Logger log = getLogger(getClass()); |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 59 | |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 60 | private final Device device; |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 61 | private final LinkDiscoveryContext context; |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 62 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 63 | private final Ethernet ethPacket; |
HIGUCHI Yuta | 9a9edf8 | 2015-10-21 11:23:20 -0700 | [diff] [blame] | 64 | private final Ethernet bddpEth; |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 65 | |
| 66 | private Timeout timeout; |
| 67 | private volatile boolean isStopped; |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 68 | // Set of ports to be probed |
| 69 | private final Set<Long> ports = Sets.newConcurrentHashSet(); |
| 70 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 71 | /** |
| 72 | * Instantiates discovery manager for the given physical switch. Creates a |
| 73 | * generic LLDP packet that will be customized for the port it is sent out on. |
| 74 | * Starts the the timer for the discovery process. |
Thomas Vachuska | e1bcb0b | 2014-10-27 17:45:10 -0700 | [diff] [blame] | 75 | * |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 76 | * @param device the physical switch |
| 77 | * @param context discovery context |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 78 | */ |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 79 | public LinkDiscovery(Device device, LinkDiscoveryContext context) { |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 80 | this.device = device; |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 81 | this.context = context; |
alshabib | 3d643ec | 2014-10-22 18:33:00 -0700 | [diff] [blame] | 82 | |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 83 | ethPacket = new Ethernet(); |
| 84 | ethPacket.setEtherType(Ethernet.TYPE_LLDP); |
Jonathan Hart | 7838c51 | 2016-06-07 15:18:22 -0700 | [diff] [blame] | 85 | ethPacket.setDestinationMACAddress(ONOSLLDP.LLDP_ONLAB); |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 86 | ethPacket.setPad(true); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 87 | |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 88 | bddpEth = new Ethernet(); |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 89 | bddpEth.setEtherType(Ethernet.TYPE_BSN); |
| 90 | bddpEth.setDestinationMACAddress(ONOSLLDP.BDDP_MULTICAST); |
| 91 | bddpEth.setPad(true); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 92 | |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 93 | isStopped = true; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 94 | start(); |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 95 | log.debug("Started discovery manager for switch {}", device.id()); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 96 | |
| 97 | } |
| 98 | |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 99 | public synchronized void stop() { |
Jon Hall | 3edc08a | 2015-09-14 16:59:07 -0700 | [diff] [blame] | 100 | if (!isStopped) { |
| 101 | isStopped = true; |
| 102 | timeout.cancel(); |
| 103 | } else { |
| 104 | log.warn("LinkDiscovery stopped multiple times?"); |
| 105 | } |
Thomas Vachuska | e4ebac9 | 2015-09-10 11:39:05 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 108 | public synchronized void start() { |
Thomas Vachuska | e4ebac9 | 2015-09-10 11:39:05 -0700 | [diff] [blame] | 109 | if (isStopped) { |
| 110 | isStopped = false; |
| 111 | timeout = Timer.getTimer().newTimeout(this, 0, MILLISECONDS); |
| 112 | } else { |
| 113 | log.warn("LinkDiscovery started multiple times?"); |
| 114 | } |
| 115 | } |
| 116 | |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 117 | public synchronized boolean isStopped() { |
Thomas Vachuska | e4ebac9 | 2015-09-10 11:39:05 -0700 | [diff] [blame] | 118 | return isStopped || timeout.isCancelled(); |
| 119 | } |
| 120 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 121 | /** |
HIGUCHI Yuta | 9a9edf8 | 2015-10-21 11:23:20 -0700 | [diff] [blame] | 122 | * Add physical port to discovery process. |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 123 | * Send out initial LLDP and label it as slow port. |
| 124 | * |
| 125 | * @param port the port |
| 126 | */ |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 127 | public void addPort(Port port) { |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 128 | boolean newPort = ports.add(port.number().toLong()); |
| 129 | boolean isMaster = context.mastershipService().isLocalMaster(device.id()); |
Jonathan Hart | 45066bc | 2015-07-28 11:18:34 -0700 | [diff] [blame] | 130 | if (newPort && isMaster) { |
Thomas Vachuska | e4ebac9 | 2015-09-10 11:39:05 -0700 | [diff] [blame] | 131 | log.debug("Sending initial probe to port {}@{}", port.number().toLong(), device.id()); |
Jonathan Hart | 45066bc | 2015-07-28 11:18:34 -0700 | [diff] [blame] | 132 | sendProbes(port.number().toLong()); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 133 | } |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | /** |
HIGUCHI Yuta | 9a9edf8 | 2015-10-21 11:23:20 -0700 | [diff] [blame] | 137 | * removed physical port from discovery process. |
| 138 | * @param port the port number |
| 139 | */ |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 140 | public void removePort(PortNumber port) { |
HIGUCHI Yuta | 9a9edf8 | 2015-10-21 11:23:20 -0700 | [diff] [blame] | 141 | ports.remove(port.toLong()); |
| 142 | } |
| 143 | |
| 144 | /** |
Thomas Vachuska | e4ebac9 | 2015-09-10 11:39:05 -0700 | [diff] [blame] | 145 | * Handles an incoming LLDP packet. Creates link in topology and adds the |
| 146 | * link for staleness tracking. |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 147 | * |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 148 | * @param packetContext packet context |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 149 | * @return true if handled |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 150 | */ |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 151 | public boolean handleLldp(PacketContext packetContext) { |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 152 | Ethernet eth = packetContext.inPacket().parsed(); |
Jonathan Hart | e8600eb | 2015-01-12 10:30:45 -0800 | [diff] [blame] | 153 | if (eth == null) { |
| 154 | return false; |
| 155 | } |
| 156 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 157 | ONOSLLDP onoslldp = ONOSLLDP.parseONOSLLDP(eth); |
| 158 | if (onoslldp != null) { |
Ayaka Koshibe | 4822922 | 2016-05-16 18:04:26 -0700 | [diff] [blame] | 159 | Type lt; |
| 160 | if (notMy(eth.getSourceMAC().toString())) { |
| 161 | lt = Type.EDGE; |
| 162 | } else { |
| 163 | lt = eth.getEtherType() == Ethernet.TYPE_LLDP ? |
| 164 | Type.DIRECT : Type.INDIRECT; |
Ayaka Koshibe | 3ddb7b2 | 2015-12-10 17:32:59 -0800 | [diff] [blame] | 165 | } |
| 166 | |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 167 | PortNumber srcPort = portNumber(onoslldp.getPort()); |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 168 | PortNumber dstPort = packetContext.inPacket().receivedFrom().port(); |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 169 | |
Thomas Vachuska | 586bc4f | 2016-08-19 12:44:26 -0700 | [diff] [blame] | 170 | String idString = onoslldp.getDeviceString(); |
| 171 | if (!isNullOrEmpty(idString)) { |
| 172 | DeviceId srcDeviceId = DeviceId.deviceId(idString); |
| 173 | DeviceId dstDeviceId = packetContext.inPacket().receivedFrom().deviceId(); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 174 | |
Thomas Vachuska | 586bc4f | 2016-08-19 12:44:26 -0700 | [diff] [blame] | 175 | ConnectPoint src = new ConnectPoint(srcDeviceId, srcPort); |
| 176 | ConnectPoint dst = new ConnectPoint(dstDeviceId, dstPort); |
| 177 | |
| 178 | LinkDescription ld = new DefaultLinkDescription(src, dst, lt); |
| 179 | try { |
| 180 | context.providerService().linkDetected(ld); |
| 181 | context.touchLink(LinkKey.linkKey(src, dst)); |
| 182 | } catch (IllegalStateException e) { |
| 183 | return true; |
| 184 | } |
Sahil Lele | 3a0cdd5 | 2015-07-21 14:16:31 -0700 | [diff] [blame] | 185 | return true; |
| 186 | } |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 187 | } |
| 188 | return false; |
| 189 | } |
| 190 | |
Ayaka Koshibe | 3ddb7b2 | 2015-12-10 17:32:59 -0800 | [diff] [blame] | 191 | // true if *NOT* this cluster's own probe. |
Ayaka Koshibe | 4822922 | 2016-05-16 18:04:26 -0700 | [diff] [blame] | 192 | private boolean notMy(String mac) { |
| 193 | // if we are using DEFAULT_MAC, clustering hadn't initialized, so conservative 'yes' |
| 194 | String ourMac = context.fingerprint(); |
| 195 | if (ProbedLinkProvider.defaultMac().equalsIgnoreCase(ourMac)) { |
Ayaka Koshibe | 3ddb7b2 | 2015-12-10 17:32:59 -0800 | [diff] [blame] | 196 | return true; |
Ayaka Koshibe | 3ddb7b2 | 2015-12-10 17:32:59 -0800 | [diff] [blame] | 197 | } |
Ayaka Koshibe | 4822922 | 2016-05-16 18:04:26 -0700 | [diff] [blame] | 198 | return !mac.equalsIgnoreCase(ourMac); |
Ayaka Koshibe | 3ddb7b2 | 2015-12-10 17:32:59 -0800 | [diff] [blame] | 199 | } |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 200 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 201 | /** |
| 202 | * Execute this method every t milliseconds. Loops over all ports |
| 203 | * labeled as fast and sends out an LLDP. Send out an LLDP on a single slow |
| 204 | * port. |
| 205 | * |
| 206 | * @param t timeout |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 207 | */ |
| 208 | @Override |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 209 | public void run(Timeout t) { |
Yuta HIGUCHI | 3419858 | 2014-11-10 16:24:58 -0800 | [diff] [blame] | 210 | if (isStopped()) { |
| 211 | return; |
| 212 | } |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 213 | |
Thomas Vachuska | e4ebac9 | 2015-09-10 11:39:05 -0700 | [diff] [blame] | 214 | if (context.mastershipService().isLocalMaster(device.id())) { |
| 215 | log.trace("Sending probes from {}", device.id()); |
| 216 | ports.forEach(this::sendProbes); |
Yuta HIGUCHI | f672588 | 2014-10-29 15:25:51 -0700 | [diff] [blame] | 217 | } |
| 218 | |
Yuta HIGUCHI | 3225578 | 2014-11-04 22:32:14 -0800 | [diff] [blame] | 219 | if (!isStopped()) { |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 220 | timeout = Timer.getTimer().newTimeout(this, context.probeRate(), MILLISECONDS); |
Yuta HIGUCHI | 3225578 | 2014-11-04 22:32:14 -0800 | [diff] [blame] | 221 | } |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 222 | } |
| 223 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 224 | /** |
| 225 | * Creates packet_out LLDP for specified output port. |
| 226 | * |
| 227 | * @param port the port |
| 228 | * @return Packet_out message with LLDP data |
| 229 | */ |
Jonathan Hart | b35540a | 2015-11-17 09:30:56 -0800 | [diff] [blame] | 230 | private OutboundPacket createOutBoundLldp(Long port) { |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 231 | if (port == null) { |
| 232 | return null; |
| 233 | } |
Ayaka Koshibe | 12c8c08 | 2015-12-08 12:48:46 -0800 | [diff] [blame] | 234 | ONOSLLDP lldp = getLinkProbe(port); |
Ayaka Koshibe | 4822922 | 2016-05-16 18:04:26 -0700 | [diff] [blame] | 235 | ethPacket.setSourceMACAddress(context.fingerprint()).setPayload(lldp); |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 236 | return new DefaultOutboundPacket(device.id(), |
Thomas Vachuska | e1bcb0b | 2014-10-27 17:45:10 -0700 | [diff] [blame] | 237 | builder().setOutput(portNumber(port)).build(), |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 238 | ByteBuffer.wrap(ethPacket.serialize())); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /** |
| 242 | * Creates packet_out BDDP for specified output port. |
| 243 | * |
| 244 | * @param port the port |
| 245 | * @return Packet_out message with LLDP data |
| 246 | */ |
Jonathan Hart | b35540a | 2015-11-17 09:30:56 -0800 | [diff] [blame] | 247 | private OutboundPacket createOutBoundBddp(Long port) { |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 248 | if (port == null) { |
| 249 | return null; |
| 250 | } |
Ayaka Koshibe | 12c8c08 | 2015-12-08 12:48:46 -0800 | [diff] [blame] | 251 | ONOSLLDP lldp = getLinkProbe(port); |
Ayaka Koshibe | 4822922 | 2016-05-16 18:04:26 -0700 | [diff] [blame] | 252 | bddpEth.setSourceMACAddress(context.fingerprint()).setPayload(lldp); |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 253 | return new DefaultOutboundPacket(device.id(), |
Thomas Vachuska | e1bcb0b | 2014-10-27 17:45:10 -0700 | [diff] [blame] | 254 | builder().setOutput(portNumber(port)).build(), |
Thomas Vachuska | 96f3ea7 | 2015-09-08 13:50:12 -0700 | [diff] [blame] | 255 | ByteBuffer.wrap(bddpEth.serialize())); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Ayaka Koshibe | 12c8c08 | 2015-12-08 12:48:46 -0800 | [diff] [blame] | 258 | private ONOSLLDP getLinkProbe(Long port) { |
Ayaka Koshibe | 4822922 | 2016-05-16 18:04:26 -0700 | [diff] [blame] | 259 | return ONOSLLDP.onosLLDP(device.id().toString(), device.chassisId(), port.intValue()); |
Ayaka Koshibe | 12c8c08 | 2015-12-08 12:48:46 -0800 | [diff] [blame] | 260 | } |
| 261 | |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 262 | private void sendProbes(Long portNumber) { |
Ray Milkey | d9bbde8 | 2016-06-09 11:35:00 -0700 | [diff] [blame] | 263 | if (context.packetService() == null) { |
| 264 | return; |
| 265 | } |
Yuta HIGUCHI | 4128938 | 2014-12-19 17:47:12 -0800 | [diff] [blame] | 266 | log.trace("Sending probes out to {}@{}", portNumber, device.id()); |
Jonathan Hart | b35540a | 2015-11-17 09:30:56 -0800 | [diff] [blame] | 267 | OutboundPacket pkt = createOutBoundLldp(portNumber); |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 268 | context.packetService().emit(pkt); |
Jonathan Hart | b35540a | 2015-11-17 09:30:56 -0800 | [diff] [blame] | 269 | if (context.useBddp()) { |
| 270 | OutboundPacket bpkt = createOutBoundBddp(portNumber); |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 271 | context.packetService().emit(bpkt); |
Thomas Vachuska | e1bcb0b | 2014-10-27 17:45:10 -0700 | [diff] [blame] | 272 | } |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Ray Milkey | 957390e | 2016-02-09 10:02:46 -0800 | [diff] [blame] | 275 | public boolean containsPort(long portNumber) { |
Thomas Vachuska | 05453c9 | 2015-09-09 14:40:49 -0700 | [diff] [blame] | 276 | return ports.contains(portNumber); |
| 277 | } |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 278 | } |