public NetUtils.SupersetOrSubset checkIfSubsetOrSuperset(String vlanGateway, String vlanNetmask, String newVlanGateway, String newVlanNetmask, final String newStartIP, final String newEndIP) { if (newVlanGateway == null && newVlanNetmask == null) { newVlanGateway = vlanGateway; newVlanNetmask = vlanNetmask; // this means he is trying to add to the existing subnet. if (NetUtils.sameSubnet(newStartIP, newVlanGateway, newVlanNetmask)) { if (NetUtils.sameSubnet(newEndIP, newVlanGateway, newVlanNetmask)) { return NetUtils.SupersetOrSubset.sameSubnet; } } return NetUtils.SupersetOrSubset.neitherSubetNorSuperset; } else if (newVlanGateway == null || newVlanNetmask == null) { throw new InvalidParameterValueException( "either both netmask and gateway should be passed or both should me omited."); } else { if (!NetUtils.sameSubnet(newStartIP, newVlanGateway, newVlanNetmask)) { throw new InvalidParameterValueException("The start ip and gateway do not belong to the same subnet"); } if (!NetUtils.sameSubnet(newEndIP, newVlanGateway, newVlanNetmask)) { throw new InvalidParameterValueException("The end ip and gateway do not belong to the same subnet"); } } final String cidrnew = NetUtils.getCidrFromGatewayAndNetmask(newVlanGateway, newVlanNetmask); final String existing_cidr = NetUtils.getCidrFromGatewayAndNetmask(vlanGateway, vlanNetmask); return NetUtils.isNetowrkASubsetOrSupersetOfNetworkB(cidrnew, existing_cidr); }
if (NetUtils.isValidIp4(destIpOrCidr)) { if (eth1ip != null && eth1mask != null) { inSameSubnet = NetUtils.sameSubnet(eth1ip, destIpOrCidr, eth1mask); } else { s_logger.warn("addRouteToInternalIp: unable to determine same subnet: _eth1ip=" + eth1ip + ", dest ip=" + destIpOrCidr + ", _eth1mask=" + eth1mask);
if (NetUtils.isValidIp4(destIpOrCidr)) { if (eth1ip != null && eth1mask != null) { inSameSubnet = NetUtils.sameSubnet(eth1ip, destIpOrCidr, eth1mask); } else { s_logger.warn("addRouteToInternalIp: unable to determine same subnet: _eth1ip=" + eth1ip + ", dest ip=" + destIpOrCidr + ", _eth1mask=" + eth1mask);
if (endIP != null && !NetUtils.sameSubnet(startIP, endIP, vlanNetmask)) { throw new InvalidParameterValueException("Please ensure that your start IP and end IP are in the same subnet, as per the IP range's netmask."); if (!NetUtils.sameSubnet(startIP, vlanGateway, vlanNetmask)) { throw new InvalidParameterValueException("Please ensure that your start IP is in the same subnet as your IP range's gateway, as per the IP range's netmask."); if (endIP != null && !NetUtils.sameSubnet(endIP, vlanGateway, vlanNetmask)) { throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as your IP range's gateway, as per the IP range's netmask.");
if (NetUtils.sameSubnet(vlanSelfIp, server.get_ipaddress(), vlanNetmask)) {
if (!NetUtils.sameSubnet(startIP, gateway, netmask)) { throw new InvalidParameterValueException("Please ensure that your start IP is in the same subnet as " + "your portable IP range's gateway and as per the IP range's netmask."); if (!NetUtils.sameSubnet(endIP, gateway, netmask)) { throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as " + "your portable IP range's gateway and as per the IP range's netmask.");
if (!NetUtils.sameSubnet(domrGuestNic.getIPv4Address(), _nic.getIPv4Address(), _nic.getIPv4Netmask())) { final NicIpAliasDao nicIpAliasDao = visitor.getVirtualNetworkApplianceFactory().getNicIpAliasDao(); final List<NicIpAliasVO> aliasIps = nicIpAliasDao.listByNetworkIdAndState(domrGuestNic.getNetworkId(), NicIpAlias.State.active); for (final NicIpAliasVO alias : aliasIps) { if (NetUtils.sameSubnet(alias.getIp4Address(), _nic.getIPv4Address(), _nic.getIPv4Netmask())) { ipInVmsubnet = true; break;