public int valueHashCode(Object o) { if (o == null) { return 0; } switch (this) { case DL_SRC: case DL_DST: return NetUtils.byteArray4ToInt((byte[])o); default: return o.hashCode(); } }
data.get(dbytes); int address = NetUtils.byteArray4ToInt(dbytes); super.setNetworkDestination(address); byte[] mbytes = new byte[4]; byte[] dbytes = new byte[4]; data.get(dbytes); int address = NetUtils.byteArray4ToInt(dbytes); super.setNetworkDestination(address); this.nwDstState = MatchFieldState.MATCH_FIELD_ONLY;
public int hashCode(Object v, Object m) { final int prime = 31; int result = 1; result = prime * result + this.calculateConsistentHashCode(); switch (this) { case DL_SRC: case DL_DST: result = prime * result + ((v == null)? 0 : NetUtils.byteArray4ToInt((byte[])v)); result = prime * result + ((m == null)? 0 : NetUtils.byteArray4ToInt((byte[])m)); break; case NW_SRC: case NW_DST: // Hash code has to take into account only prefix address InetAddress ip = (InetAddress) v; int maskLen = (m == null) ? ((ip instanceof Inet4Address) ? 32 : 128) : NetUtils .getSubnetMaskLength((InetAddress) m); InetAddress prefix = NetUtils.getSubnetPrefix(ip, maskLen); result = prime * result + ((v == null)? 0 : prefix.hashCode()); break; default: result = prime * result + ((v == null)? 0 : v.hashCode()); result = prime * result + ((m == null)? 0 : m.hashCode()); } return result; } public boolean equalValues(Object a, Object b) {
data.get(sbytes); int address = NetUtils.byteArray4ToInt(sbytes); super.setNetworkSource(address); byte[] mbytes = new byte[4]; data.get(sbytes); int address = NetUtils.byteArray4ToInt(sbytes); super.setNetworkSource(address); this.nwSrcState = MatchFieldState.MATCH_FIELD_ONLY;
public void setNetworkDestination(InetAddress address, InetAddress mask) { if (address instanceof Inet6Address) { this.nwDst = (Inet6Address) address; if (mask == null) { this.nwDstState = MatchFieldState.MATCH_FIELD_ONLY; this.match_len += (address instanceof Inet6Address) ? 20 : 8; } else { this.dstIPv6SubnetMaskbits = (short)NetUtils.getSubnetMaskLength(mask); this.nwDstState = MatchFieldState.MATCH_FIELD_WITH_MASK; this.match_len += (address instanceof Inet6Address) ? 36 : 12; } } else { this.setNetworkDestination(NetUtils.byteArray4ToInt(address.getAddress())); this.wildcards ^= (((1 << 6) - 1) << 14); if (mask == null) { this.nwDstState = MatchFieldState.MATCH_FIELD_ONLY; this.match_len += 8; } else { this.nwDstState = MatchFieldState.MATCH_FIELD_WITH_MASK; this.match_len += 12; this.wildcards |= ((32 - NetUtils.getSubnetMaskLength(mask)) << 14); } } }
public void setNetworkSource(InetAddress address, InetAddress mask) { if (address instanceof Inet6Address) { this.nwSrc = (Inet6Address) address; if (mask == null) { this.nwSrcState = MatchFieldState.MATCH_FIELD_ONLY; this.match_len += (address instanceof Inet6Address) ? 20 : 8; } else { this.srcIPv6SubnetMaskbits = (short)NetUtils.getSubnetMaskLength(mask); this.nwSrcState = MatchFieldState.MATCH_FIELD_WITH_MASK; this.match_len += (address instanceof Inet6Address) ? 36 : 12; } } else { super.setNetworkSource(NetUtils.byteArray4ToInt(address.getAddress())); this.wildcards ^= (((1 << 6) - 1) << 8); if (mask == null) { this.nwSrcState = MatchFieldState.MATCH_FIELD_ONLY; this.match_len += 8; } else { this.nwSrcState = MatchFieldState.MATCH_FIELD_WITH_MASK; this.match_len += 12; this.wildcards |= ((32 - NetUtils.getSubnetMaskLength(mask)) << 8); } } }
SetNwSrc a = (SetNwSrc) action; OFActionNetworkLayerSource ofAction = new OFActionNetworkLayerSource(); ofAction.setNetworkAddress(NetUtils.byteArray4ToInt(a .getAddress().getAddress())); actionsList.add(ofAction); SetNwDst a = (SetNwDst) action; OFActionNetworkLayerDestination ofAction = new OFActionNetworkLayerDestination(); ofAction.setNetworkAddress(NetUtils.byteArray4ToInt(a .getAddress().getAddress())); actionsList.add(ofAction);
InetAddress mask = (InetAddress) match.getField(MatchType.NW_SRC).getMask(); if (!isIPv6) { ofMatch.setNetworkSource(NetUtils.byteArray4ToInt(address.getAddress())); int maskLength = (mask == null) ? 32 : NetUtils.getSubnetMaskLength(mask); wildcards = (wildcards & ~OFMatch.OFPFW_NW_SRC_MASK) | ((32 - maskLength) << OFMatch.OFPFW_NW_SRC_SHIFT); InetAddress mask = (InetAddress) match.getField(MatchType.NW_DST).getMask(); if (!isIPv6) { ofMatch.setNetworkDestination(NetUtils.byteArray4ToInt(address.getAddress())); int maskLength = (mask == null) ? 32 : NetUtils.getSubnetMaskLength(mask); wildcards = (wildcards & ~OFMatch.OFPFW_NW_DST_MASK) | ((32 - maskLength) << OFMatch.OFPFW_NW_DST_SHIFT);