added treatment support and conversion to an instruction
moved to meter api to onos-api
Change-Id: I0504f06fdc503953fa7696224d97edda43596d6e
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 06c49ba..2dad08b 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -28,6 +28,7 @@
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.instructions.Instruction;
import org.onosproject.net.flow.instructions.Instructions;
+import org.onosproject.net.meter.MeterId;
import java.util.Collections;
import java.util.List;
@@ -50,6 +51,7 @@
private static final DefaultTrafficTreatment EMPTY
= new DefaultTrafficTreatment(Collections.emptyList());
+ private final Instructions.MeterInstruction meter;
/**
* Creates a new traffic treatment from the specified list of instructions.
@@ -63,6 +65,7 @@
this.hasClear = false;
this.table = null;
this.meta = null;
+ this.meter = null;
}
/**
@@ -77,7 +80,8 @@
List<Instruction> immediate,
Instructions.TableTypeTransition table,
boolean clear,
- Instructions.MetadataInstruction meta) {
+ Instructions.MetadataInstruction meta,
+ Instructions.MeterInstruction meter) {
this.immediate = ImmutableList.copyOf(checkNotNull(immediate));
this.deferred = ImmutableList.copyOf(checkNotNull(deferred));
this.all = new ImmutableList.Builder<Instruction>()
@@ -87,6 +91,7 @@
this.table = table;
this.meta = meta;
this.hasClear = clear;
+ this.meter = meter;
}
@Override
@@ -119,6 +124,11 @@
return meta;
}
+ @Override
+ public Instructions.MeterInstruction metered() {
+ return meter;
+ }
+
/**
* Returns a new traffic treatment builder.
*
@@ -193,12 +203,16 @@
Instructions.MetadataInstruction meta;
+ Instructions.MeterInstruction meter;
+
List<Instruction> deferred = Lists.newLinkedList();
List<Instruction> immediate = Lists.newLinkedList();
List<Instruction> current = immediate;
+
+
// Creates a new builder
private Builder() {
}
@@ -233,6 +247,8 @@
case METADATA:
meta = (Instructions.MetadataInstruction) instruction;
break;
+ case METER:
+ meter = (Instructions.MeterInstruction) instruction;
default:
throw new IllegalArgumentException("Unknown instruction type: " +
instruction.type());
@@ -343,6 +359,11 @@
}
@Override
+ public TrafficTreatment.Builder meter(MeterId meterId) {
+ return add(Instructions.meterTraffic(meterId));
+ }
+
+ @Override
public Builder popVlan() {
return add(Instructions.popVlan());
}
@@ -420,7 +441,7 @@
// && table == null && !clear) {
// drop();
//}
- return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta);
+ return new DefaultTrafficTreatment(deferred, immediate, table, clear, meta, meter);
}
}