import java.net.InetAddress;
import org.opendaylight.controller.sal.core.NodeConnector;
+import org.opendaylight.controller.sal.utils.HexEncode;
/**
* Represents the binding between the id, the value and mask type and the range values
*
*/
public enum MatchType {
- IN_PORT("inPort", 1 << 0, NodeConnector.class, 1, 0), DL_SRC("dlSrc",
- 1 << 1, Byte[].class, 0, 0xffffffffffffL), DL_DST("dlDst", 1 << 2,
- Byte[].class, 0, 0xffffffffffffL), DL_VLAN("dlVlan", 1 << 3,
- Short.class, 2, 0xfff), // 2 bytes
+ IN_PORT("inPort", 1 << 0, NodeConnector.class, 1, 0),
+ DL_SRC("dlSrc", 1 << 1, Byte[].class, 0, 0xffffffffffffL),
+ DL_DST("dlDst", 1 << 2, Byte[].class, 0, 0xffffffffffffL),
+ DL_VLAN("dlVlan", 1 << 3, Short.class, 1, 0xfff), // 2 bytes
DL_VLAN_PR("dlVlanPriority", 1 << 4, Byte.class, 0, 0x7), // 3 bits
- DL_OUTER_VLAN("dlOuterVlan", 1 << 5, Short.class, 2, 0xfff), DL_OUTER_VLAN_PR(
- "dlOuterVlanPriority", 1 << 6, Short.class, 0, 0x7), DL_TYPE(
- "dlType", 1 << 7, Short.class, 0, 0xffff), // 2 bytes
+ DL_OUTER_VLAN("dlOuterVlan", 1 << 5, Short.class, 1, 0xfff),
+ DL_OUTER_VLAN_PR("dlOuterVlanPriority", 1 << 6, Short.class, 0, 0x7),
+ DL_TYPE("dlType", 1 << 7, Short.class, 0, 0xffff), // 2 bytes
NW_TOS("nwTOS", 1 << 8, Byte.class, 0, 0xff), // 1 byte
NW_PROTO("nwProto", 1 << 9, Byte.class, 0, 0xff), // 1 byte
- NW_SRC("nwSrc", 1 << 10, InetAddress.class, 0, 0), NW_DST("nwDst", 1 << 11,
- InetAddress.class, 0, 0), TP_SRC("tpSrc", 1 << 12, Short.class, 1,
- 0xffff), // 2 bytes
+ NW_SRC("nwSrc", 1 << 10, InetAddress.class, 0, 0),
+ NW_DST("nwDst", 1 << 11, InetAddress.class, 0, 0),
+ TP_SRC("tpSrc", 1 << 12, Short.class, 1, 0xffff), // 2 bytes
TP_DST("tpDst", 1 << 13, Short.class, 1, 0xffff); // 2 bytes
private String id;
}
return 0L;
}
+
+ public String stringify(Object value) {
+ if (value == null) {
+ return null;
+ }
+
+ switch (this) {
+ case DL_DST:
+ case DL_SRC:
+ return HexEncode.bytesToHexStringFormat((byte[])value);
+ case DL_TYPE:
+ case DL_VLAN:
+ if ((Short)value < 0) {
+ return ((Integer) (((Short)value).intValue() & 0x7FFF | 0x8000)).toString();
+ }
+ break;
+ case NW_SRC:
+ case NW_DST:
+ return ((InetAddress)value).getHostAddress();
+ case TP_SRC:
+ case TP_DST:
+ if ((Short)value < 0) {
+ return ((Integer) (((Short)value).intValue() & 0x7FFF | 0x8000)).toString();
+ }
+ break;
+ default:
+ break;
+ }
+ return value.toString();
+ }
}