3261N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. 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 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle 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. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * Windows implementation of the java.net.NetworkInterface native methods. 0N/A * This module provides the implementations of getAll, getByName, getByIndex, 0N/A * return an array of IP_ADAPTER_ADDRESSES containing one element 0N/A * for each apdapter on the system. Returned in *adapters. 0N/A * Buffer is malloc'd and must be freed (unless error returned) 0N/A "IP Helper Library GetAdaptersAddresses function failed");
0N/A * return an array of IP_ADAPTER_ADDRESSES containing one element 0N/A * for each apdapter on the system. Returned in *adapters. 0N/A * Buffer is malloc'd and must be freed (unless error returned) 0N/A "IP Helper Library GetAdaptersAddresses function failed");
0N/A * Get the IPv4 interfaces. This information is the same 0N/A * as what previous JDK versions would return. 0N/A /* locate the loopback (and the last) interface */ 2109N/A // Retrieve IPv4 addresses with the IP Helper API 0N/A /* Now get the IPv6 information. This includes: 0N/A * (a) IPv6 information associated with interfaces already found 0N/A * (b) IPv6 information for IPv6 only interfaces (probably tunnels) 0N/A * For compatibility with previous releases we use the naming 3877N/A * information gotten from enumInterfaces() for (a) entries 0N/A * However, the index numbers are taken from the new API. 0N/A * The procedure is to go through the list of adapters returned 0N/A * by the new API looking for entries that correspond to IPv4 interfaces 0N/A /* This entry is associated with an IPv4 interface */ 0N/A /* found the interface entry 0N/A * set the index to the IPv6 index and add the 0N/A /* This entry is IPv6 only */ 0N/A /* Windows allocates duplicate adapter entries 0N/A * for tunnel interfaces when there are multiple 0N/A * physical adapters. Need to check 0N/A * if this is a duplicate (ipv6Index is the same) 0N/A /* add the addresses from this adapter to the 0N/A * original (dup_nif) 0N/A/* If *netaddrPP is null, then the addresses are allocated and the beginning 0N/A * of the allocated chain is returned in *netaddrPP. 0N/A * If *netaddrPP is not null, then the addresses allocated here are appended 0N/A * to the existing chain. 0N/A * Returns count of addresses or -1 on error. 0N/A /* If chain passed in, find end */ 0N/A /* address is only usable if dad state is preferred or deprecated */ 2109N/A // IPv4 addresses already retrieved with enumAddresses_win 0N/A * Create a NetworkInterface object, populate the name and index, and 0N/A * populate the InetAddress array based on the IP addresses for this 0N/A * Create a NetworkInterface object and populate it 0N/A * Get the IP addresses for this interface if necessary 0N/A * Note that 0 is a valid number of addresses. 0N/A /* default ctor will set family to AF_INET */ 0N/A }
else /* AF_INET6 */ {
0N/A if (
scope != 0) {
/* zero is default value, no need to set */ 0N/A * Windows doesn't have virtual interfaces, so child array 0N/A /* return the NetworkInterface */ 0N/A /* get the name as a C string */ 0N/A /* Search by name */ 0N/A /* if found create a NetworkInterface */ 0N/A /* release the UTF string */ 0N/A /* release the interface list */ 0N/A * Class: NetworkInterface 509N/A * Method: getByIndex0_XP 0N/A * Signature: (I)LNetworkInterface; 0N/A /* search by index */ 0N/A /* if found create a NetworkInterface */ 0N/A /* release the interface list */ 0N/A * Class: java_net_NetworkInterface 0N/A * Method: getByInetAddress0 0N/A /* get the list of interfaces */ 0N/A * Enumerate the addresses on each interface until we find a 0N/A /* iterate through each address */ 0N/A * Address matched so create NetworkInterface for this interface 0N/A /* on next interface */ 0N/A /* release the interface list */ 0N/A * Class: java_net_NetworkInterface 0N/A * Get list of interfaces 0N/A /* allocate a NetworkInterface array */ 0N/A * Iterate through the interfaces, create a NetworkInterface instance 0N/A * for each array element and populate the object. 0N/A /* put the NetworkInterface into the array */ 0N/A /* release the interface list */ 0N/A * Class: java_net_NetworkInterface 0N/A * Method: supportsMulticast0 0N/A * Class: java_net_NetworkInterface 0N/A * Class: java_net_NetworkInterface 0N/A * Method: getMacAddr0 0N/A * Class: java_net_NetworkInterface 0N/A * Class: java_net_NetworkInterface 0N/A * Method: isLoopback0 0N/A * Class: java_net_NetworkInterface