package net.onrc.onos.core.matchaction.match;

import net.onrc.onos.core.util.IPv4Net;

public class Ipv4Match implements Match {

    IPv4Net dstIp;

    public Ipv4Match(String ipAddressSlash) {
        this.dstIp = new IPv4Net(ipAddressSlash);
    }

    public IPv4Net getDestination() {
        return dstIp;
    }

}

@@ -40,16 +40,53 @@
 match;%0A%0A
+import net.onrc.onos.core.util.IPv4;%0A
 import n
@@ -276,16 +276,279 @@
 sSlash);
+%0A%0A        IPv4 ip = dstIp.address();%0A        short prefLen = dstIp.prefixLen();%0A        int mask = ~((1 %3C%3C (32 - prefLen)) - 1);;%0A        int newIpInt = ip.value() & mask;%0A        IPv4 newIp = new IPv4(newIpInt);%0A%0A        this.dstIp = new IPv4Net(newIp, prefLen);
 %0A    %7D%0A%0A

Change IP address mask according to the prefix when setting the IP forwarding rule.