Java InetAddress Create getIPv6InetAddresses(NetworkInterface networkInterface)

Here you can find the source of getIPv6InetAddresses(NetworkInterface networkInterface)

Description

Retrieves a list of all IPv6 addresses assigned to one interface.

License

Open Source License

Parameter

Parameter Description
networkInterface The requested interface

Return

A vector with all IP addresses associated with this interface

Declaration

public static Vector getIPv6InetAddresses(NetworkInterface networkInterface) 

Method Source Code

//package com.java2s;
/**//from   w ww  . java  2 s. c o  m
* 
* Copyright (C) 2004-2008 FhG Fokus
*
* This file is part of the FhG Fokus UPnP stack - an open source UPnP implementation
* with some additional features
*
* You can redistribute the FhG Fokus UPnP stack and/or modify it
* under the terms of the GNU General Public License Version 3 as published by
* the Free Software Foundation.
*
* For a license to use the FhG Fokus UPnP stack software under conditions
* other than those described here, or to purchase support for this
* software, please contact Fraunhofer FOKUS by e-mail at the following
* addresses:
*   upnpstack@fokus.fraunhofer.de
*
* The FhG Fokus UPnP stack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>
* or write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/

import java.net.Inet6Address;
import java.net.InetAddress;

import java.net.NetworkInterface;

import java.util.Enumeration;

import java.util.Vector;

public class Main {
    /**
     * Retrieves a list of all IPv6 addresses assigned to one interface.
     * 
     * @param networkInterface
     *          The requested interface
     * 
     * @return A vector with all IP addresses associated with this interface
     */
    public static Vector getIPv6InetAddresses(NetworkInterface networkInterface) {
        Enumeration e;
        Vector result = new Vector();

        e = networkInterface.getInetAddresses();

        while (e.hasMoreElements()) {
            InetAddress currentAddress = (InetAddress) e.nextElement();
            if (currentAddress instanceof Inet6Address) {
                result.add(currentAddress);
            }
        }
        return result;
    }
}

Related

  1. getIP(InetAddress ip)
  2. getIP(InetAddress ip)
  3. getIPAsLong(InetAddress address)
  4. getIPAsString(InetAddress addr)
  5. getIPv4LocalNetMask(InetAddress ip, int netPrefix)
  6. getLocalInetAddress()
  7. getLocalInetAddress()
  8. getLocalInetAddress()
  9. getLocalInetAddress(String host)