clean packet context
diff --git a/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java b/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
index 8d3d91e..65434be 100644
--- a/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
+++ b/of/api/src/main/java/org/onlab/onos/of/controller/DefaultPacketContext.java
@@ -6,6 +6,7 @@
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut;
import org.projectfloodlight.openflow.protocol.action.OFAction;
+import org.projectfloodlight.openflow.protocol.action.OFActionOutput;
import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
@@ -36,21 +37,26 @@
}
@Override
- public void build(OFPort outPort) {
- isBuilt = true;
-
- }
-
- @Override
- public void build(Ethernet ethFrame, OFPort outPort) {
+ public synchronized void build(OFPort outPort) {
if (isBuilt) {
return;
}
OFPacketOut.Builder builder = sw.factory().buildPacketOut();
- OFAction act = sw.factory().actions()
- .buildOutput()
- .setPort(OFPort.of(outPort.getPortNumber()))
+ OFAction act = buildOutput(outPort.getPortNumber());
+ pktout = builder.setXid(pktin.getXid())
+ .setBufferId(pktin.getBufferId())
+ .setActions(Collections.singletonList(act))
.build();
+ isBuilt = true;
+ }
+
+ @Override
+ public synchronized void build(Ethernet ethFrame, OFPort outPort) {
+ if (isBuilt) {
+ return;
+ }
+ OFPacketOut.Builder builder = sw.factory().buildPacketOut();
+ OFAction act = buildOutput(outPort.getPortNumber());
pktout = builder.setXid(pktin.getXid())
.setBufferId(OFBufferId.NO_BUFFER)
.setActions(Collections.singletonList(act))
@@ -85,4 +91,12 @@
return pktin.getData().clone();
}
+ private OFActionOutput buildOutput(Integer port) {
+ OFActionOutput act = sw.factory().actions()
+ .buildOutput()
+ .setPort(OFPort.of(port))
+ .build();
+ return act;
+ }
+
}