tom

Merge remote-tracking branch 'origin/master'

package org.onlab.onos.net.trivial.packet.impl;
import static org.slf4j.LoggerFactory.getLogger;
import org.onlab.onos.net.packet.PacketContext;
import org.onlab.onos.net.packet.PacketProcessor;
import org.slf4j.Logger;
public class ReactivePacketProcessor implements PacketProcessor {
private final Logger log = getLogger(getClass());
@Override
public void process(PacketContext context) {
log.info("Packet reveived {}", context.inPacket());
}
}
package org.onlab.onos.net.trivial.packet.impl;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.ArrayList;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.net.Device;
import org.onlab.onos.net.device.DeviceService;
import org.onlab.onos.net.packet.OutboundPacket;
import org.onlab.onos.net.packet.PacketContext;
import org.onlab.onos.net.packet.PacketProcessor;
import org.onlab.onos.net.packet.PacketProvider;
import org.onlab.onos.net.packet.PacketProviderRegistry;
import org.onlab.onos.net.packet.PacketProviderService;
import org.onlab.onos.net.packet.PacketService;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
import org.slf4j.Logger;
/**
* Provides a basic implementation of the packet SB & NB APIs.
*
*/
@Component(immediate = true)
@Service
public class SimplePacketManager
extends AbstractProviderRegistry<PacketProvider, PacketProviderService>
implements PacketService, PacketProviderRegistry {
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private DeviceService deviceService;
private final ArrayList<PacketProcessor> processors = new ArrayList<>();
private final PacketProcessor reactiveProcessor = new ReactivePacketProcessor();
@Activate
public void activate() {
addProcessor(reactiveProcessor, PacketProcessor.ADVISOR_MAX + 1);
log.info("Started");
}
@Deactivate
public void deactivate() {
removeProcessor(reactiveProcessor);
log.info("Stopped");
}
@Override
public void addProcessor(PacketProcessor processor, int priority) {
processors.add(priority, processor);
}
@Override
public void removeProcessor(PacketProcessor processor) {
processors.remove(processor);
}
@Override
public void emit(OutboundPacket packet) {
final Device device = deviceService.getDevice(packet.sendThrough());
final PacketProvider packetProvider = getProvider(device.providerId());
packetProvider.emit(packet);
}
@Override
protected PacketProviderService createProviderService(
PacketProvider provider) {
return new InternalPacketProviderService(provider);
}
// Personalized link provider service issued to the supplied provider.
private class InternalPacketProviderService
extends AbstractProviderService<PacketProvider>
implements PacketProviderService {
protected InternalPacketProviderService(PacketProvider provider) {
super(provider);
}
@Override
public void processPacket(PacketContext context) {
for (PacketProcessor processor : processors) {
processor.process(context);
}
}
}
}
......@@ -102,7 +102,7 @@ public class LinkDiscovery implements TimerTask {
this.sw = sw;
this.ofFactory = sw.factory();
this.ctrl = ctrl;
this.probeRate = 1000;
this.probeRate = 3000;
this.linkProvider = providerService;
this.slowPorts = Collections.synchronizedSet(new HashSet<Integer>());
this.fastPorts = Collections.synchronizedSet(new HashSet<Integer>());
......@@ -129,7 +129,7 @@ public class LinkDiscovery implements TimerTask {
addPort(port);
}
}
timeout = Timer.getTimer().newTimeout(this, this.probeRate,
timeout = Timer.getTimer().newTimeout(this, 0,
TimeUnit.MILLISECONDS);
this.log.debug("Started discovery manager for switch {}",
sw.getId());
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onlab.onos</groupId>
<artifactId>onos-of-providers</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-of-provider-packet</artifactId>
<packaging>bundle</packaging>
<description>ONOS OpenFlow protocol packet provider</description>
</project>
package org.onlab.onos.provider.of.packet.impl;
import static org.slf4j.LoggerFactory.getLogger;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.onos.net.packet.OutboundPacket;
import org.onlab.onos.net.packet.PacketProvider;
import org.onlab.onos.net.packet.PacketProviderRegistry;
import org.onlab.onos.net.packet.PacketProviderService;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.of.controller.OpenFlowController;
import org.onlab.onos.of.controller.OpenFlowPacketContext;
import org.onlab.onos.of.controller.PacketListener;
import org.slf4j.Logger;
/**
* Provider which uses an OpenFlow controller to detect network
* infrastructure links.
*/
@Component(immediate = true)
public class OpenFlowPacketProvider extends AbstractProvider implements PacketProvider {
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected PacketProviderRegistry providerRegistry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected OpenFlowController controller;
private PacketProviderService providerService;
private final boolean useBDDP = true;
private final InternalPacketProvider listener = new InternalPacketProvider();
/**
* Creates an OpenFlow link provider.
*/
public OpenFlowPacketProvider() {
super(new ProviderId("org.onlab.onos.provider.openflow"));
}
@Activate
public void activate() {
providerService = providerRegistry.register(this);
controller.addPacketListener(0, listener);
log.info("Started");
}
@Deactivate
public void deactivate() {
providerRegistry.unregister(this);
controller.removePacketListener(listener);
providerService = null;
log.info("Stopped");
}
@Override
public void emit(OutboundPacket packet) {
// TODO Auto-generated method stub
}
private class InternalPacketProvider implements PacketListener {
@Override
public void handlePacket(OpenFlowPacketContext pktCtx) {
}
}
}
......@@ -20,6 +20,7 @@
<module>device</module>
<module>link</module>
<module>host</module>
<module>packet</module>
</modules>
<dependencies>
......