ONOS-2581 Add codec for tunnel id
Change-Id: I6ff456b0419b427945cc53fb74fd0a91cdfa758e
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
index 9c778fb..f2786b6 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/FlowRuleCodecTest.java
@@ -58,6 +58,7 @@
import org.onosproject.net.flow.criteria.PortCriterion;
import org.onosproject.net.flow.criteria.SctpPortCriterion;
import org.onosproject.net.flow.criteria.TcpPortCriterion;
+import org.onosproject.net.flow.criteria.TunnelIdCriterion;
import org.onosproject.net.flow.criteria.UdpPortCriterion;
import org.onosproject.net.flow.criteria.VlanIdCriterion;
import org.onosproject.net.flow.criteria.VlanPcpCriterion;
@@ -205,7 +206,7 @@
instruction.type().name() + "/" + subType, instruction);
});
- assertThat(rule.treatment().allInstructions().size(), is(19));
+ assertThat(rule.treatment().allInstructions().size(), is(20));
Instruction instruction;
@@ -273,6 +274,12 @@
assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
assertThat(instruction, instanceOf(L2ModificationInstruction.PushHeaderInstructions.class));
+ instruction = getInstruction(Instruction.Type.L2MODIFICATION,
+ L2ModificationInstruction.L2SubType.TUNNEL_ID.name());
+ assertThat(instruction.type(), is(Instruction.Type.L2MODIFICATION));
+ assertThat(((L2ModificationInstruction.ModTunnelIdInstruction) instruction)
+ .tunnelId(), is(100L));
+
instruction = getInstruction(Instruction.Type.L3MODIFICATION,
L3ModificationInstruction.L3SubType.IPV4_SRC.name());
assertThat(instruction.type(), is(Instruction.Type.L3MODIFICATION));
@@ -347,7 +354,7 @@
checkCommonData(rule);
- assertThat(rule.selector().criteria().size(), is(32));
+ assertThat(rule.selector().criteria().size(), is(33));
rule.selector().criteria()
.stream()
@@ -479,6 +486,10 @@
criterion = getCriterion(Criterion.Type.OCH_SIGID);
assertThat(((IndexedLambdaCriterion) criterion).lambda(),
is(Lambda.indexedLambda(122)));
+
+ criterion = getCriterion(Criterion.Type.TUNNEL_ID);
+ assertThat(((TunnelIdCriterion) criterion).tunnelId(),
+ is(100L));
}
/**
diff --git a/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json b/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
index 7061820..1a96e92 100644
--- a/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
+++ b/core/common/src/test/resources/org/onosproject/codec/impl/criteria-flow.json
@@ -37,7 +37,8 @@
{"type":"IPV6_ND_TLL", "mac":"00:11:22:33:44:57"},
{"type":"MPLS_LABEL", "label":123},
{"type":"IPV6_EXTHDR", "exthdrFlags":99},
- {"type":"OCH_SIGID", "lambda":122}
+ {"type":"OCH_SIGID", "lambda":122},
+ {"type":"TUNNEL_ID", "tunnelId":100}
]
}
}
diff --git a/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json b/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
index a57731b..b3e4e4c 100644
--- a/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
+++ b/core/common/src/test/resources/org/onosproject/codec/impl/instructions-flow.json
@@ -19,6 +19,7 @@
{"type":"L2MODIFICATION","subtype":"DEC_MPLS_TTL"},
{"type":"L2MODIFICATION","subtype":"VLAN_POP"},
{"type":"L2MODIFICATION","subtype":"VLAN_PUSH"},
+ {"type":"L2MODIFICATION","subtype":"TUNNEL_ID", "tunnelId":100},
{"type":"L3MODIFICATION","subtype":"IPV4_SRC", "ip":"1.2.3.4"},
{"type":"L3MODIFICATION","subtype":"IPV4_DST", "ip":"1.2.3.3"},
{"type":"L3MODIFICATION","subtype":"IPV6_SRC", "ip":"1.2.3.2"},