Fixes to the OF 1.0 match support
- fixed bug with matching on VLAN
- added support for matching on ARP fields
diff --git a/java_gen/templates/custom/OFMatchV1Ver10.Builder.java b/java_gen/templates/custom/OFMatchV1Ver10.Builder.java
index 38cc127..a29e8a0 100644
--- a/java_gen/templates/custom/OFMatchV1Ver10.Builder.java
+++ b/java_gen/templates/custom/OFMatchV1Ver10.Builder.java
@@ -25,6 +25,15 @@
case VLAN_PCP:
result = vlanPcp;
break;
+ case ARP_OP:
+ result = ArpOpcode.of(ipProto.getIpProtocolNumber());
+ break;
+ case ARP_SPA:
+ result = ipv4Src;
+ break;
+ case ARP_TPA:
+ result = ipv4Dst;
+ break;
case IP_DSCP:
result = ipDscp;
break;
@@ -32,13 +41,13 @@
result = ipProto;
break;
case IPV4_SRC:
- result = ipv4Dst;
+ result = ipv4Src;
break;
case IPV4_DST:
result = ipv4Dst;
break;
case TCP_SRC:
- result = ipv4Src;
+ result = tcpSrc;
break;
case TCP_DST:
result = tcpDst;
@@ -77,10 +86,12 @@
Object result;
switch (field.id) {
case IPV4_SRC:
+ case ARP_SPA:
int srcBitMask = (-1) << (32 - getIpv4SrcCidrMaskLen());
result = IPv4AddressWithMask.of(ipv4Src, IPv4Address.of(srcBitMask));
break;
case IPV4_DST:
+ case ARP_TPA:
int dstMaskedBits = Math.min(32, (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT);
int dstBitMask = (-1) << (32 - getIpv4DstCidrMaskLen());
@@ -101,6 +112,9 @@
case ETH_TYPE:
case VLAN_VID:
case VLAN_PCP:
+ case ARP_OP:
+ case ARP_SPA:
+ case ARP_TPA:
case IP_DSCP:
case IP_PROTO:
case IPV4_SRC:
@@ -122,6 +136,8 @@
@Override
public boolean supportsMasked(MatchField<?> field) {
switch (field.id) {
+ case ARP_SPA:
+ case ARP_TPA:
case IPV4_SRC:
case IPV4_DST:
return true;
@@ -145,6 +161,12 @@
return (this.wildcards & OFPFW_DL_VLAN) == 0;
case VLAN_PCP:
return (this.wildcards & OFPFW_DL_VLAN_PCP) == 0;
+ case ARP_OP:
+ return (this.wildcards & OFPFW_NW_PROTO) == 0;
+ case ARP_SPA:
+ return this.getIpv4SrcCidrMaskLen() >= 32;
+ case ARP_TPA:
+ return this.getIpv4DstCidrMaskLen() >= 32;
case IP_DSCP:
return (this.wildcards & OFPFW_NW_TOS) == 0;
case IP_PROTO:
@@ -216,6 +238,12 @@
return (this.wildcards & OFPFW_DL_VLAN) != 0;
case VLAN_PCP:
return (this.wildcards & OFPFW_DL_VLAN_PCP) != 0;
+ case ARP_OP:
+ return (this.wildcards & OFPFW_NW_PROTO) != 0;
+ case ARP_SPA:
+ return this.getIpv4SrcCidrMaskLen() <= 0;
+ case ARP_TPA:
+ return this.getIpv4DstCidrMaskLen() <= 0;
case IP_DSCP:
return (this.wildcards & OFPFW_NW_TOS) != 0;
case IP_PROTO:
@@ -248,9 +276,11 @@
@Override
public boolean isPartiallyMasked(MatchField<?> field) {
switch (field.id) {
+ case ARP_SPA:
case IPV4_SRC:
int srcCidrLen = getIpv4SrcCidrMaskLen();
return srcCidrLen > 0 && srcCidrLen < 32;
+ case ARP_TPA:
case IPV4_DST:
int dstCidrLen = getIpv4SrcCidrMaskLen();
return dstCidrLen > 0 && dstCidrLen < 32;
@@ -300,10 +330,16 @@
setInPort((OFPort) value);
wildcards &= ~OFPFW_IN_PORT;
break;
+ case ARP_OP:
+ setIpProto(IpProtocol.of((short)((ArpOpcode)value).getOpcode()));
+ wildcards &= ~OFPFW_NW_PROTO;
+ break;
+ case ARP_TPA:
case IPV4_DST:
setIpv4Dst((IPv4Address) value);
wildcards &= ~OFPFW_NW_DST_MASK;
break;
+ case ARP_SPA:
case IPV4_SRC:
setIpv4Src((IPv4Address) value);
wildcards &= ~OFPFW_NW_SRC_MASK;
@@ -347,6 +383,7 @@
case VLAN_VID:
setVlanVid((VlanVid) value);
wildcards &= ~OFPFW_DL_VLAN;
+ break;
default:
throw new UnsupportedOperationException(
"OFMatch does not support matching on field " + field.getName());
@@ -359,6 +396,8 @@
F value, F mask) {
initWildcards();
switch (field.id) {
+ case ARP_SPA:
+ case ARP_TPA:
case IPV4_DST:
case IPV4_SRC:
Object valObj = value;
@@ -369,10 +408,12 @@
throw new UnsupportedOperationException("OFMatch only supports CIDR masks for IPv4");
int maskLen = 32 - Integer.bitCount(maskval);
switch(field.id) {
+ case ARP_TPA:
case IPV4_DST:
setIpv4Dst(ip);
wildcards = (wildcards &~OFPFW_NW_DST_MASK) | (maskLen << OFPFW_NW_DST_SHIFT);
break;
+ case ARP_SPA:
case IPV4_SRC:
setIpv4Src(ip);
wildcards = (wildcards &~OFPFW_NW_SRC_MASK) | (maskLen << OFPFW_NW_SRC_SHIFT);
@@ -428,10 +469,12 @@
setInPort(OFPort.of(0)); // NOTE: not 'NONE' -- that is 0xFF for ports
wildcards |= OFPFW_IN_PORT;
break;
+ case ARP_TPA:
case IPV4_DST:
setIpv4Dst(IPv4Address.NONE);
wildcards |= OFPFW_NW_DST_MASK;
break;
+ case ARP_SPA:
case IPV4_SRC:
setIpv4Src(IPv4Address.NONE);
wildcards |= OFPFW_NW_SRC_MASK;