Java Code Examples for org.apache.commons.net.util.SubnetUtils.SubnetInfo#isInRange()
The following examples show how to use
org.apache.commons.net.util.SubnetUtils.SubnetInfo#isInRange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrivateDNS.java From PacketProxy with Apache License 2.0 | 5 votes |
String getSpoofAddr(String addr) { for (SubnetInfo info : subnets) { if (info.isInRange(addr)) { return info.getAddress(); } } return defaultAddr; }
Example 2
Source File: NetUtils.java From hadoop with Apache License 2.0 | 5 votes |
/** * Add all addresses associated with the given nif in the * given subnet to the given list. */ private static void addMatchingAddrs(NetworkInterface nif, SubnetInfo subnetInfo, List<InetAddress> addrs) { Enumeration<InetAddress> ifAddrs = nif.getInetAddresses(); while (ifAddrs.hasMoreElements()) { InetAddress ifAddr = ifAddrs.nextElement(); if (subnetInfo.isInRange(ifAddr.getHostAddress())) { addrs.add(ifAddr); } } }
Example 3
Source File: NetUtils.java From big-c with Apache License 2.0 | 5 votes |
/** * Add all addresses associated with the given nif in the * given subnet to the given list. */ private static void addMatchingAddrs(NetworkInterface nif, SubnetInfo subnetInfo, List<InetAddress> addrs) { Enumeration<InetAddress> ifAddrs = nif.getInetAddresses(); while (ifAddrs.hasMoreElements()) { InetAddress ifAddr = ifAddrs.nextElement(); if (subnetInfo.isInRange(ifAddr.getHostAddress())) { addrs.add(ifAddr); } } }