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;
    }

}

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

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

public class Ipv4Match implements Match {

    IPv4Net dstIp;

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

        IPv4 ip = dstIp.address();
        short prefLen = dstIp.prefixLen();
        int mask = ~((1 << (32 - prefLen)) - 1);;
        int newIpInt = ip.value() & mask;
        IPv4 newIp = new IPv4(newIpInt);

        this.dstIp = new IPv4Net(newIp, prefLen);
    }

    public IPv4Net getDestination() {
        return dstIp;
    }

}

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

Change-Id: Ic0f8fb43913473c622336de0dcf3e0751ba01d65
