blob: a6d1bff930d4d2cd4ad606fec8ed3000981d6bfc [file] [log] [blame]
Saurav Dasf710bd32014-09-25 16:56:00 -07001package net.onrc.onos.core.matchaction.match;
2
Sangho Shin47701ec2014-10-01 15:09:40 -07003import net.onrc.onos.core.util.IPv4;
Saurav Dasf710bd32014-09-25 16:56:00 -07004import net.onrc.onos.core.util.IPv4Net;
5
6public class Ipv4Match implements Match {
7
8 IPv4Net dstIp;
9
10 public Ipv4Match(String ipAddressSlash) {
11 this.dstIp = new IPv4Net(ipAddressSlash);
Sangho Shin47701ec2014-10-01 15:09:40 -070012
13 IPv4 ip = dstIp.address();
14 short prefLen = dstIp.prefixLen();
15 int mask = ~((1 << (32 - prefLen)) - 1);;
16 int newIpInt = ip.value() & mask;
17 IPv4 newIp = new IPv4(newIpInt);
18
19 this.dstIp = new IPv4Net(newIp, prefLen);
Saurav Dasf710bd32014-09-25 16:56:00 -070020 }
21
22 public IPv4Net getDestination() {
23 return dstIp;
24 }
25
26}