Add JSON codec for ETH_DST_MASKED Criterion
- Enabling for a mcast flow rule to fetch its mask value from JSON dump
Change-Id: I8a69b0244dc332605d14e40998c329802a921286
(cherry picked from commit b62492324b4f913349ff7ed3e0ed3014b3f8f660)
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java b/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
index 83b25a7..067a99a 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/EncodeCriterionCodecHelper.java
@@ -89,6 +89,7 @@
formatMap.put(Criterion.Type.IN_PHY_PORT, new FormatInPort());
formatMap.put(Criterion.Type.METADATA, new FormatMetadata());
formatMap.put(Criterion.Type.ETH_DST, new FormatEth());
+ formatMap.put(Criterion.Type.ETH_DST_MASKED, new FormatEthMasked());
formatMap.put(Criterion.Type.ETH_SRC, new FormatEth());
formatMap.put(Criterion.Type.ETH_TYPE, new FormatEthType());
formatMap.put(Criterion.Type.VLAN_VID, new FormatVlanVid());
@@ -146,7 +147,6 @@
formatMap.put(Criterion.Type.ACTSET_OUTPUT, new FormatUnknown());
formatMap.put(Criterion.Type.PACKET_TYPE, new FormatUnknown());
formatMap.put(Criterion.Type.EXTENSION, new FormatUnknown());
- formatMap.put(Criterion.Type.ETH_DST_MASKED, new FormatUnknown());
formatMap.put(Criterion.Type.ETH_SRC_MASKED, new FormatUnknown());
formatMap.put(Criterion.Type.TCP_SRC_MASKED, new FormatUnknown());
formatMap.put(Criterion.Type.TCP_DST_MASKED, new FormatUnknown());
@@ -193,6 +193,17 @@
}
}
+ private static class FormatEthMasked implements CriterionTypeFormatter {
+ @Override
+ public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {
+ final EthCriterion ethCriterion = (EthCriterion) criterion;
+ root.put(CriterionCodec.MAC, ethCriterion.mac().toString());
+ root.put(CriterionCodec.MAC_MASK, ethCriterion.mask().toString());
+
+ return root;
+ }
+ }
+
private static class FormatEthType implements CriterionTypeFormatter {
@Override
public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) {