net.clackrouter.netutils
Class NetUtils

java.lang.Object
  extended by net.clackrouter.netutils.NetUtils

public class NetUtils
extends java.lang.Object

Simple utilities for operating on ByteBuffers and Internet Addresses.


Nested Class Summary
static class NetUtils.Net
           
 
Constructor Summary
NetUtils()
           
 
Method Summary
static java.net.InetAddress applyNetMask(java.net.InetAddress addr, java.net.InetAddress mask)
           
static java.net.InetAddress ByteBuffer2Inet(java.nio.ByteBuffer in)
           
static int getIntFromAddr(java.net.InetAddress in)
           
static long getLongFromAddr(java.net.InetAddress in)
           
static java.net.InetAddress getMaxAddressInSubnet(java.net.InetAddress network, java.net.InetAddress netmask)
           
static int getNumMaskBits(java.net.InetAddress mask)
           
static java.nio.ByteBuffer Inet2ByteBuffer(java.net.InetAddress in)
           
static java.nio.ByteBuffer Inet2ByteBuffer(java.lang.String in)
           
static java.net.InetAddress intToInetAddress(long addr)
           
static boolean isNetworkMatch(java.net.InetAddress testIp, java.net.InetAddress network, java.net.InetAddress netmask)
           
static NetUtils.Net NetworkAndMaskFromString(java.lang.String s)
           
static java.lang.String NetworkAndMaskToString(java.net.InetAddress net, java.net.InetAddress mask)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetUtils

public NetUtils()
Method Detail

Inet2ByteBuffer

public static java.nio.ByteBuffer Inet2ByteBuffer(java.lang.String in)

Inet2ByteBuffer

public static java.nio.ByteBuffer Inet2ByteBuffer(java.net.InetAddress in)

ByteBuffer2Inet

public static java.net.InetAddress ByteBuffer2Inet(java.nio.ByteBuffer in)

NetworkAndMaskToString

public static java.lang.String NetworkAndMaskToString(java.net.InetAddress net,
                                                      java.net.InetAddress mask)

getNumMaskBits

public static int getNumMaskBits(java.net.InetAddress mask)

NetworkAndMaskFromString

public static NetUtils.Net NetworkAndMaskFromString(java.lang.String s)
                                             throws java.lang.Exception
Throws:
java.lang.Exception

getIntFromAddr

public static int getIntFromAddr(java.net.InetAddress in)

getLongFromAddr

public static long getLongFromAddr(java.net.InetAddress in)

isNetworkMatch

public static boolean isNetworkMatch(java.net.InetAddress testIp,
                                     java.net.InetAddress network,
                                     java.net.InetAddress netmask)

intToInetAddress

public static java.net.InetAddress intToInetAddress(long addr)

applyNetMask

public static java.net.InetAddress applyNetMask(java.net.InetAddress addr,
                                                java.net.InetAddress mask)
                                         throws java.lang.Exception
Throws:
java.lang.Exception

getMaxAddressInSubnet

public static java.net.InetAddress getMaxAddressInSubnet(java.net.InetAddress network,
                                                         java.net.InetAddress netmask)