receiving packet ins
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/packet/impl/SimplePacketManager.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/packet/impl/SimplePacketManager.java
index 2233c32..95d3664 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/packet/impl/SimplePacketManager.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/packet/impl/SimplePacketManager.java
@@ -2,7 +2,8 @@
import static org.slf4j.LoggerFactory.getLogger;
-import java.util.ArrayList;
+import java.util.Map;
+import java.util.TreeMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@@ -39,7 +40,7 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
private DeviceService deviceService;
- private final ArrayList<PacketProcessor> processors = new ArrayList<>();
+ private final Map<Integer, PacketProcessor> processors = new TreeMap<>();
private final PacketProcessor reactiveProcessor = new ReactivePacketProcessor();
@@ -57,12 +58,12 @@
@Override
public void addProcessor(PacketProcessor processor, int priority) {
- processors.add(priority, processor);
+ processors.put(priority, processor);
}
@Override
public void removeProcessor(PacketProcessor processor) {
- processors.remove(processor);
+ processors.values().remove(processor);
}
@Override
@@ -89,7 +90,7 @@
@Override
public void processPacket(PacketContext context) {
- for (PacketProcessor processor : processors) {
+ for (PacketProcessor processor : processors.values()) {
processor.process(context);
}
}
diff --git a/features/features.xml b/features/features.xml
index 620b3cc..72493c0 100644
--- a/features/features.xml
+++ b/features/features.xml
@@ -68,6 +68,8 @@
<bundle>mvn:org.onlab.onos/onos-of-provider-device/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.onlab.onos/onos-of-provider-link/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.onlab.onos/onos-of-provider-host/1.0.0-SNAPSHOT</bundle>
+ <bundle>mvn:org.onlab.onos/onos-of-provider-packet/1.0.0-SNAPSHOT</bundle>
+
</feature>
<feature name="onos-app-tvue" version="1.0.0"
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/DefaultOpenFlowPacketContext.java b/of/api/src/main/java/org/onlab/onos/of/controller/DefaultOpenFlowPacketContext.java
index f05a7ff..d0b1f13 100644
--- a/of/api/src/main/java/org/onlab/onos/of/controller/DefaultOpenFlowPacketContext.java
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/DefaultOpenFlowPacketContext.java
@@ -33,8 +33,8 @@
public void send() {
if (free && isBuilt) {
sw.sendMsg(pktout);
+ block();
}
-
}
@Override
diff --git a/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java b/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
index f1ff6cc..eceeb6c 100644
--- a/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
+++ b/of/ctl/src/main/java/org/onlab/onos/of/controller/impl/OpenFlowControllerImpl.java
@@ -1,9 +1,9 @@
package org.onlab.onos.of.controller.impl;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
+import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -43,7 +43,7 @@
protected OpenFlowSwitchAgent agent = new OpenFlowSwitchAgent();
protected Set<OpenFlowSwitchListener> ofEventListener = new HashSet<>();
- protected List<PacketListener> ofPacketListener = new ArrayList<>();
+ protected Map<Integer, PacketListener> ofPacketListener = new TreeMap<>();
private final Controller ctrl = new Controller();
@@ -101,7 +101,7 @@
@Override
public void addPacketListener(int priority, PacketListener listener) {
- ofPacketListener.add(priority, listener);
+ ofPacketListener.put(priority, listener);
}
@Override
@@ -123,7 +123,7 @@
}
break;
case PACKET_IN:
- for (PacketListener p : ofPacketListener) {
+ for (PacketListener p : ofPacketListener.values()) {
p.handlePacket(DefaultOpenFlowPacketContext
.packetContextFromPacketIn(this.getSwitch(dpid),
(OFPacketIn) msg));
diff --git a/providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java b/providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
index c854daa..44a3a58 100644
--- a/providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
+++ b/providers/of/packet/src/main/java/org/onlab/onos/provider/of/packet/impl/OpenFlowPacketProvider.java
@@ -2,17 +2,24 @@
import static org.slf4j.LoggerFactory.getLogger;
+import java.nio.ByteBuffer;
+
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.ConnectPoint;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.PortNumber;
+import org.onlab.onos.net.packet.DefaultInboundPacket;
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.Dpid;
import org.onlab.onos.of.controller.OpenFlowController;
import org.onlab.onos.of.controller.OpenFlowPacketContext;
import org.onlab.onos.of.controller.PacketListener;
@@ -35,12 +42,8 @@
private PacketProviderService providerService;
- private final boolean useBDDP = true;
-
private final InternalPacketProvider listener = new InternalPacketProvider();
-
-
/**
* Creates an OpenFlow link provider.
*/
@@ -51,7 +54,7 @@
@Activate
public void activate() {
providerService = providerRegistry.register(this);
- controller.addPacketListener(0, listener);
+ controller.addPacketListener(1, listener);
log.info("Started");
}
@@ -65,18 +68,29 @@
@Override
public void emit(OutboundPacket packet) {
- // TODO Auto-generated method stub
}
+ /**
+ * Internal Packet Provider implementation.
+ *
+ */
private class InternalPacketProvider implements PacketListener {
@Override
public void handlePacket(OpenFlowPacketContext pktCtx) {
+ DeviceId id = DeviceId.deviceId(Dpid.uri(pktCtx.dpid().value()));
+ DefaultInboundPacket inPkt = new DefaultInboundPacket(
+ new ConnectPoint(id, PortNumber.portNumber(pktCtx.inPort())),
+ pktCtx.parsed(), ByteBuffer.wrap(pktCtx.unparsed()));
+ OpenFlowCorePacketContext corePktCtx =
+ new OpenFlowCorePacketContext(0, inPkt, null, false, pktCtx,
+ controller.getSwitch(pktCtx.dpid()));
+ providerService.processPacket(corePktCtx);
}
}