NetworkInterface.java revision 0
0N/A * Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * This class represents a Network Interface made up of a name, 0N/A * and a list of IP addresses assigned to this interface. 0N/A * It is used to identify the local interface on which a multicast group 0N/A * Interfaces are normally known by names such as "le0". 0N/A * Returns an NetworkInterface object with index set to 0 and name to null. 0N/A * Setting such an interface on a MulticastSocket will cause the 0N/A * kernel to choose one interface for sending multicast packets. 0N/A * Get the name of this network interface. 0N/A * @return the name of this network interface 0N/A * Convenience method to return an Enumeration with all or a 0N/A * subset of the InetAddresses bound to this network interface. 0N/A * If there is a security manager, its <code>checkConnect</code> 0N/A * method is called for each InetAddress. Only InetAddresses where 0N/A * the <code>checkConnect</code> doesn't throw a SecurityException 0N/A * will be returned in the Enumeration. 0N/A * @return an Enumeration object with all or a subset of the InetAddresses 0N/A * bound to this network interface 0N/A * Get a List of all or a subset of the <code>InterfaceAddresses</code> 0N/A * of this network interface. 0N/A * If there is a security manager, its <code>checkConnect</code> 0N/A * method is called with the InetAddress for each InterfaceAddress. 0N/A * Only InterfaceAddresses where the <code>checkConnect</code> doesn't throw 0N/A * a SecurityException will be returned in the List. 0N/A * @return a <code>List</code> object with all or a subset of the 0N/A * InterfaceAddresss of this network interface 0N/A * Get an Enumeration with all the subinterfaces (also known as virtual 0N/A * interfaces) attached to this network interface. 0N/A * For instance eth0:1 will be a subinterface to eth0. 0N/A * @return an Enumeration object with all of the subinterfaces 0N/A * of this network interface 0N/A * Returns the parent NetworkInterface of this interface if this is 0N/A * a subinterface, or <code>null</code> if it is a physical 0N/A * (non virtual) interface or has no parent. 0N/A * @return The <code>NetworkInterface</code> this interface is attached to. 0N/A * Get the index of this network interface. 0N/A * @return the index of this network interface 0N/A * Get the display name of this network interface. 0N/A * A display name is a human readable String describing the network 0N/A * @return the display name of this network interface, 0N/A * or null if no display name is available. 0N/A * Searches for the network interface with the specified name. 0N/A * The name of the network interface. 0N/A * @return A <tt>NetworkInterface</tt> with the specified name, 0N/A * or <tt>null</tt> if there is no network interface 0N/A * with the specified name. 0N/A * @throws SocketException 0N/A * If an I/O error occurs. 0N/A * @throws NullPointerException 0N/A * If the specified name is <tt>null</tt>. 0N/A * Get a network interface given its index. 0N/A * @param index an integer, the index of the interface 0N/A * @return the NetworkInterface obtained from its index 0N/A * @exception SocketException if an I/O error occurs. 0N/A * Convenience method to search for a network interface that 0N/A * has the specified Internet Protocol (IP) address bound to 0N/A * If the specified IP address is bound to multiple network 0N/A * interfaces it is not defined which network interface is 0N/A * The <tt>InetAddress</tt> to search with. 0N/A * @return A <tt>NetworkInterface</tt> 0N/A * or <tt>null</tt> if there is no network interface 0N/A * with the specified IP address. 0N/A * @throws SocketException 0N/A * If an I/O error occurs. 0N/A * @throws NullPointerException 0N/A * If the specified address is <tt>null</tt>. 0N/A * Returns all the interfaces on this machine. Returns null if no 0N/A * network interfaces could be found on this machine. 0N/A * NOTE: can use getNetworkInterfaces()+getInetAddresses() 0N/A * to obtain all IP addresses for this node 0N/A * @return an Enumeration of NetworkInterfaces found on this machine 0N/A * @exception SocketException if an I/O error occurs. 0N/A // specified to return null if no network interfaces 0N/A * Returns whether a network interface is up and running. 0N/A * @return <code>true</code> if the interface is up and running. 0N/A * @exception SocketException if an I/O error occurs. 0N/A * Returns whether a network interface is a loopback interface. 0N/A * @return <code>true</code> if the interface is a loopback interface. 0N/A * @exception SocketException if an I/O error occurs. 0N/A * Returns whether a network interface is a point to point interface. 0N/A * A typical point to point interface would be a PPP connection through 0N/A * @return <code>true</code> if the interface is a point to point 0N/A * @exception SocketException if an I/O error occurs. 0N/A * Returns whether a network interface supports multicasting or not. 0N/A * @return <code>true</code> if the interface supports Multicasting. 0N/A * @exception SocketException if an I/O error occurs. 0N/A * Returns the hardware address (usually MAC) of the interface if it 0N/A * has one and if it can be accessed given the current privileges. 0N/A * @return a byte array containing the address or <code>null</code> if 0N/A * the address doesn't exist or is not accessible. 0N/A * @exception SocketException if an I/O error occurs. 0N/A * Returns the Maximum Transmission Unit (MTU) of this interface. 0N/A * @return the value of the MTU for that interface. 0N/A * @exception SocketException if an I/O error occurs. 0N/A * Returns whether this interface is a virtual interface (also called 0N/A * Virtual interfaces are, on some systems, interfaces created as a child 0N/A * of a physical interface and given different settings (like address or 0N/A * MTU). Usually the name of the interface will the name of the parent 0N/A * followed by a colon (:) and a number identifying the child since there 0N/A * can be several virtual interfaces attached to a single physical 0N/A * @return <code>true</code> if this interface is a virtual interface. 0N/A * Compares this object against the specified object. 0N/A * The result is <code>true</code> if and only if the argument is 0N/A * not <code>null</code> and it represents the same NetworkInterface 0N/A * Two instances of <code>NetworkInterface</code> represent the same 0N/A * NetworkInterface if both name and addrs are the same for both. 0N/A * @param obj the object to compare against. 0N/A * @return <code>true</code> if the objects are the same; 0N/A * <code>false</code> otherwise. 0N/A * @see java.net.InetAddress#getAddress() 0N/A * Compare number of addresses (in the checked subset)