From d551a6b4ecf6a507807181c560aba1a87a0731ba Mon Sep 17 00:00:00 2001 From: mkoch Date: Fri, 29 Apr 2005 22:10:09 +0000 Subject: 2005-04-29 Michael Koch * java/net/NetworkInterface.java (static): Removed. (NetworkInterface(String,InetAddress)): Made package-private. (NetworkInterface(String,InetAddress[])): New constructor. (getRealNetworkInterfaces): Removed. (getByName): Use VMNetworkInterface.getInterfaces(). (getByInetAddress): Likewise. (getNetworkInterfaces): Likewise. * java/net/VMNetworkInterface.java, java/net/natVMNetworkInterfaceNoNet.cc, java/net/natVMNetworkInterfacePosix.c,c java/net/natVMNetworkInterfaceWin32.cc: New files. * java/net/natNetworkInterfaceNoNet.cc, java/net/natNetworkInterfacePosix.cc, java/net/natNetworkInterfaceWin32.cc: Removed. * configure.ac * Makefile.am * configure, Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@99021 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/java/net/NetworkInterface.java | 26 +++-- libjava/java/net/VMNetworkInterface.java | 66 ++++++++++++ libjava/java/net/natNetworkInterfaceNoNet.cc | 21 ---- libjava/java/net/natNetworkInterfacePosix.cc | 115 -------------------- libjava/java/net/natNetworkInterfaceWin32.cc | 143 ------------------------- libjava/java/net/natVMNetworkInterfaceNoNet.cc | 21 ++++ libjava/java/net/natVMNetworkInterfacePosix.cc | 116 ++++++++++++++++++++ libjava/java/net/natVMNetworkInterfaceWin32.cc | 143 +++++++++++++++++++++++++ 8 files changed, 358 insertions(+), 293 deletions(-) create mode 100644 libjava/java/net/VMNetworkInterface.java delete mode 100644 libjava/java/net/natNetworkInterfaceNoNet.cc delete mode 100644 libjava/java/net/natNetworkInterfacePosix.cc delete mode 100644 libjava/java/net/natNetworkInterfaceWin32.cc create mode 100644 libjava/java/net/natVMNetworkInterfaceNoNet.cc create mode 100644 libjava/java/net/natVMNetworkInterfacePosix.cc create mode 100644 libjava/java/net/natVMNetworkInterfaceWin32.cc (limited to 'libjava/java') diff --git a/libjava/java/net/NetworkInterface.java b/libjava/java/net/NetworkInterface.java index 2b4da7392e6..cd59e4e459b 100644 --- a/libjava/java/net/NetworkInterface.java +++ b/libjava/java/net/NetworkInterface.java @@ -38,8 +38,6 @@ exception statement from your version. */ package java.net; -import gnu.classpath.Configuration; - import java.util.Enumeration; import java.util.Vector; @@ -55,24 +53,24 @@ import java.util.Vector; */ public final class NetworkInterface { - static - { - if (Configuration.INIT_LOAD_LIBRARY) - System.loadLibrary("javanet"); - } - private String name; private Vector inetAddresses; - private NetworkInterface(String name, InetAddress address) + NetworkInterface(String name, InetAddress address) { this.name = name; this.inetAddresses = new Vector(1, 1); this.inetAddresses.add(address); } - private static native Vector getRealNetworkInterfaces() - throws SocketException; + NetworkInterface(String name, InetAddress[] addresses) + { + this.name = name; + this.inetAddresses = new Vector(addresses.length, 1); + + for (int i = 0; i < addresses.length; i++) + this.inetAddresses.add(addresses[i]); + } /** * Returns the name of the network interface @@ -145,7 +143,7 @@ public final class NetworkInterface public static NetworkInterface getByName(String name) throws SocketException { - Vector networkInterfaces = getRealNetworkInterfaces(); + Vector networkInterfaces = VMNetworkInterface.getInterfaces(); for (Enumeration e = networkInterfaces.elements(); e.hasMoreElements();) { @@ -172,7 +170,7 @@ public final class NetworkInterface public static NetworkInterface getByInetAddress(InetAddress addr) throws SocketException { - Vector networkInterfaces = getRealNetworkInterfaces(); + Vector networkInterfaces = VMNetworkInterface.getInterfaces(); for (Enumeration interfaces = networkInterfaces.elements(); interfaces.hasMoreElements();) @@ -199,7 +197,7 @@ public final class NetworkInterface */ public static Enumeration getNetworkInterfaces() throws SocketException { - Vector networkInterfaces = getRealNetworkInterfaces(); + Vector networkInterfaces = VMNetworkInterface.getInterfaces(); if (networkInterfaces.isEmpty()) return null; diff --git a/libjava/java/net/VMNetworkInterface.java b/libjava/java/net/VMNetworkInterface.java new file mode 100644 index 00000000000..3aaca387254 --- /dev/null +++ b/libjava/java/net/VMNetworkInterface.java @@ -0,0 +1,66 @@ +/* VMNetworkInterface.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package java.net; + +import gnu.classpath.Configuration; + +import java.util.Enumeration; +import java.util.Vector; + +/** + * This class models a network interface on the host computer. A network + * interface contains a name (typically associated with a specific + * hardware adapter) and a list of addresses that are bound to it. + * For example, an ethernet interface may be named "eth0" and have the + * address 192.168.1.101 assigned to it. + * + * @author Michael Koch (konqueror@gmx.de) + * @since 1.4 + */ +final class VMNetworkInterface +{ + static + { + if (Configuration.INIT_LOAD_LIBRARY) + System.loadLibrary("javanet"); + } + + public static native Vector getInterfaces() + throws SocketException; +} diff --git a/libjava/java/net/natNetworkInterfaceNoNet.cc b/libjava/java/net/natNetworkInterfaceNoNet.cc deleted file mode 100644 index 5f3c5089221..00000000000 --- a/libjava/java/net/natNetworkInterfaceNoNet.cc +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (C) 2003 Free Software Foundation - - This file is part of libgcj. - -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - -#include -#include - -#include -#include -#include - -::java::util::Vector* -java::net::NetworkInterface::getRealNetworkInterfaces () -{ - throw new SocketException ( - JvNewStringLatin1 ("NetworkInterface.getrealNetworkInterfaces: unimplemented")); -} diff --git a/libjava/java/net/natNetworkInterfacePosix.cc b/libjava/java/net/natNetworkInterfacePosix.cc deleted file mode 100644 index f4c5d6b4840..00000000000 --- a/libjava/java/net/natNetworkInterfacePosix.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 2003 Free Software Foundation - - This file is part of libgcj. - -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#include - -#include -#include -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_ARPA_INET_H -#include -#endif -#ifdef HAVE_NETDB_H -#include -#endif -#ifdef HAVE_SYS_IOCTL_H -#define BSD_COMP /* Get FIONREAD on Solaris2. */ -#include -#endif -#ifdef HAVE_NET_IF_H -#include -#endif - -#include -#include -#include -#include -#include -#include - -::java::util::Vector* -java::net::NetworkInterface::getRealNetworkInterfaces () -{ - int fd; - int num_interfaces = 0; - struct ifconf if_data; - struct ifreq* if_record; - ::java::util::Vector* ht = new ::java::util::Vector (); - - if_data.ifc_len = 0; - if_data.ifc_buf = NULL; - - // Open a (random) socket to have a file descriptor for the ioctl calls. - fd = _Jv_socket (PF_INET, SOCK_DGRAM, htons (IPPROTO_IP)); - - if (fd < 0) - throw new ::java::net::SocketException; - - // Get all interfaces. If not enough buffers are available try it - // with a bigger buffer size. - do - { - num_interfaces += 16; - - if_data.ifc_len = sizeof (struct ifreq) * num_interfaces; - if_data.ifc_buf = - (char*) _Jv_Realloc (if_data.ifc_buf, if_data.ifc_len); - - // Try to get all local interfaces. - if (::ioctl (fd, SIOCGIFCONF, &if_data) < 0) - throw new java::net::SocketException; - } - while (if_data.ifc_len >= (sizeof (struct ifreq) * num_interfaces)); - - // Get addresses of all interfaces. - if_record = if_data.ifc_req; - - for (int n = 0; n < if_data.ifc_len; n += sizeof (struct ifreq)) - { - struct ifreq ifr; - - memset (&ifr, 0, sizeof (ifr)); - strcpy (ifr.ifr_name, if_record->ifr_name); - - // Try to get the IPv4-address of the local interface - if (::ioctl (fd, SIOCGIFADDR, &ifr) < 0) - throw new java::net::SocketException; - - int len = 4; - struct sockaddr_in sa = *((sockaddr_in*) &(ifr.ifr_addr)); - - jbyteArray baddr = JvNewByteArray (len); - memcpy (elements (baddr), &(sa.sin_addr), len); - jstring if_name = JvNewStringLatin1 (if_record->ifr_name); - Inet4Address* address = - new java::net::Inet4Address (baddr, JvNewStringLatin1 ("")); - ht->add (new NetworkInterface (if_name, address)); - if_record++; - } - -#ifdef HAVE_INET6 - // FIXME: read /proc/net/if_inet6 (on Linux 2.4) -#endif - - _Jv_Free (if_data.ifc_buf); - - if (fd >= 0) - _Jv_close (fd); - - return ht; -} diff --git a/libjava/java/net/natNetworkInterfaceWin32.cc b/libjava/java/net/natNetworkInterfaceWin32.cc deleted file mode 100644 index 429066e1bfb..00000000000 --- a/libjava/java/net/natNetworkInterfaceWin32.cc +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (C) 2003 Free Software Foundation - - This file is part of libgcj. - -This software is copyrighted work licensed under the terms of the -Libgcj License. Please consult the file "LIBGCJ_LICENSE" for -details. */ - -#include -#include - -#undef STRICT - -#include -#include -#include -#include - -/* As of this writing, NetworkInterface.java has - getName() == getDisplayName() and only one IP address - per interface. If this changes, we'll need to use - iphlpapi (not supported on Win95) to retrieve richer - adapter information via GetAdaptersInfo(). In this - module, we provide the necessary hooks to detect the - presence of iphlpapi and use it if necessary, but - comment things out for now to avoid compiler warnings. */ - -enum {MAX_INTERFACES = 50}; - -typedef int -(*PfnGetRealNetworkInterfaces) (jstring* pjstrName, - java::net::InetAddress** ppAddress); - -static int -winsock2GetRealNetworkInterfaces (jstring* pjstrName, - java::net::InetAddress** ppAddress) -{ - // FIXME: Add IPv6 support. - - INTERFACE_INFO arInterfaceInfo[MAX_INTERFACES]; - - // Open a (random) socket to have a file descriptor for the WSAIoctl call. - SOCKET skt = ::socket (AF_INET, SOCK_DGRAM, 0); - if (skt == INVALID_SOCKET) - _Jv_ThrowSocketException (); - - DWORD dwOutBufSize; - int nRetCode = ::WSAIoctl (skt, SIO_GET_INTERFACE_LIST, - NULL, 0, &arInterfaceInfo, sizeof(arInterfaceInfo), - &dwOutBufSize, NULL, NULL); - - if (nRetCode == SOCKET_ERROR) - { - DWORD dwLastErrorCode = WSAGetLastError (); - ::closesocket (skt); - _Jv_ThrowSocketException (dwLastErrorCode); - } - - // Get addresses of all interfaces. - int nNbInterfaces = dwOutBufSize / sizeof(INTERFACE_INFO); - int nCurETHInterface = 0; - for (int i=0; i < nNbInterfaces; ++i) - { - int len = 4; - jbyteArray baddr = JvNewByteArray (len); - SOCKADDR_IN* pAddr = (SOCKADDR_IN*) &arInterfaceInfo[i].iiAddress; - memcpy (elements (baddr), &(pAddr->sin_addr), len); - - // Concoct a name for this interface. Since we don't - // have access to the real name under Winsock 2, we use - // "lo" for the loopback interface and ethX for the - // real ones. - TCHAR szName[30]; - u_long lFlags = arInterfaceInfo[i].iiFlags; - - if (lFlags & IFF_LOOPBACK) - _tcscpy (szName, _T("lo")); - else - { - _tcscpy (szName, _T("eth")); - wsprintf(szName+3, _T("%d"), nCurETHInterface++); - } - - jstring if_name = _Jv_Win32NewString (szName); - java::net::Inet4Address* address = - new java::net::Inet4Address (baddr, JvNewStringLatin1 ("")); - pjstrName[i] = if_name; - ppAddress[i] = address; - } - - ::closesocket (skt); - - return nNbInterfaces; -} - -/* -static int -iphlpapiGetRealNetworkInterfaces (jstring* pjstrName, - java::net::InetAddress** ppAddress) -{ - return 0; -} -*/ - -static PfnGetRealNetworkInterfaces -determineGetRealNetworkInterfacesFN () -{ - /* FIXME: Try to dynamically load iphlpapi.dll and - detect the presence of GetAdaptersInfo() using - GetProcAddress(). If successful, return - iphlpapiGetRealNetworkInterfaces; if not, - return winsock2GetRealNetworkInterfaces */ - return &winsock2GetRealNetworkInterfaces; -} - -::java::util::Vector* -java::net::NetworkInterface::getRealNetworkInterfaces () -{ - // This next declaration used to be a static local, - // but this introduced a dependency on libsupc++ due - // to _cxa_guard_acquire and _cxa_guard_release. - // When Win95 is gone and we eventually get rid of - // winsock2GetRealNetworkInterfaces, we can rework - // all of this. Alternatively, we could move this all - // to win32.cc and initialize this at startup time, - // but that seems more trouble than it's worth at - // the moment. - PfnGetRealNetworkInterfaces pfn = - determineGetRealNetworkInterfacesFN (); - - jstring arIFName[MAX_INTERFACES]; - InetAddress* arpInetAddress[MAX_INTERFACES]; - ::java::util::Vector* ht = new ::java::util::Vector (); - - int nNbInterfaces = (*pfn) (arIFName, arpInetAddress); - for (int i=0; i < nNbInterfaces; ++i) - { - ht->add (new java::net::NetworkInterface (arIFName[i], - arpInetAddress[i])); - } - - return ht; -} diff --git a/libjava/java/net/natVMNetworkInterfaceNoNet.cc b/libjava/java/net/natVMNetworkInterfaceNoNet.cc new file mode 100644 index 00000000000..eda7f99f0f4 --- /dev/null +++ b/libjava/java/net/natVMNetworkInterfaceNoNet.cc @@ -0,0 +1,21 @@ +/* Copyright (C) 2003, 2005 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#include +#include + +#include +#include +#include + +::java::util::Vector* +java::net::VMNetworkInterface::getInterfaces () +{ + throw new SocketException ( + JvNewStringLatin1 ("VMNetworkInterface.getInterfaces: unimplemented")); +} diff --git a/libjava/java/net/natVMNetworkInterfacePosix.cc b/libjava/java/net/natVMNetworkInterfacePosix.cc new file mode 100644 index 00000000000..c3a222aed6b --- /dev/null +++ b/libjava/java/net/natVMNetworkInterfacePosix.cc @@ -0,0 +1,116 @@ +/* Copyright (C) 2003, 2005 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#include +#include + +#ifdef HAVE_UNISTD_H +#include +#endif +#include +#include +#include + +#include +#include +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_SYS_IOCTL_H +#define BSD_COMP /* Get FIONREAD on Solaris2. */ +#include +#endif +#ifdef HAVE_NET_IF_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include + +::java::util::Vector* +java::net::VMNetworkInterface::getInterfaces () +{ + int fd; + int num_interfaces = 0; + struct ifconf if_data; + struct ifreq* if_record; + ::java::util::Vector* ht = new ::java::util::Vector (); + + if_data.ifc_len = 0; + if_data.ifc_buf = NULL; + + // Open a (random) socket to have a file descriptor for the ioctl calls. + fd = _Jv_socket (PF_INET, SOCK_DGRAM, htons (IPPROTO_IP)); + + if (fd < 0) + throw new ::java::net::SocketException; + + // Get all interfaces. If not enough buffers are available try it + // with a bigger buffer size. + do + { + num_interfaces += 16; + + if_data.ifc_len = sizeof (struct ifreq) * num_interfaces; + if_data.ifc_buf = + (char*) _Jv_Realloc (if_data.ifc_buf, if_data.ifc_len); + + // Try to get all local interfaces. + if (::ioctl (fd, SIOCGIFCONF, &if_data) < 0) + throw new java::net::SocketException; + } + while (if_data.ifc_len >= (sizeof (struct ifreq) * num_interfaces)); + + // Get addresses of all interfaces. + if_record = if_data.ifc_req; + + for (int n = 0; n < if_data.ifc_len; n += sizeof (struct ifreq)) + { + struct ifreq ifr; + + memset (&ifr, 0, sizeof (ifr)); + strcpy (ifr.ifr_name, if_record->ifr_name); + + // Try to get the IPv4-address of the local interface + if (::ioctl (fd, SIOCGIFADDR, &ifr) < 0) + throw new java::net::SocketException; + + int len = 4; + struct sockaddr_in sa = *((sockaddr_in*) &(ifr.ifr_addr)); + + jbyteArray baddr = JvNewByteArray (len); + memcpy (elements (baddr), &(sa.sin_addr), len); + jstring if_name = JvNewStringLatin1 (if_record->ifr_name); + Inet4Address* address = + new java::net::Inet4Address (baddr, JvNewStringLatin1 ("")); + ht->add (new NetworkInterface (if_name, address)); + if_record++; + } + +#ifdef HAVE_INET6 + // FIXME: read /proc/net/if_inet6 (on Linux 2.4) +#endif + + _Jv_Free (if_data.ifc_buf); + + if (fd >= 0) + _Jv_close (fd); + + return ht; +} diff --git a/libjava/java/net/natVMNetworkInterfaceWin32.cc b/libjava/java/net/natVMNetworkInterfaceWin32.cc new file mode 100644 index 00000000000..257e06d1778 --- /dev/null +++ b/libjava/java/net/natVMNetworkInterfaceWin32.cc @@ -0,0 +1,143 @@ +/* Copyright (C) 2003, 2005 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +#include +#include + +#undef STRICT + +#include +#include +#include +#include + +/* As of this writing, NetworkInterface.java has + getName() == getDisplayName() and only one IP address + per interface. If this changes, we'll need to use + iphlpapi (not supported on Win95) to retrieve richer + adapter information via GetAdaptersInfo(). In this + module, we provide the necessary hooks to detect the + presence of iphlpapi and use it if necessary, but + comment things out for now to avoid compiler warnings. */ + +enum {MAX_INTERFACES = 50}; + +typedef int +(*PfnGetRealNetworkInterfaces) (jstring* pjstrName, + java::net::InetAddress** ppAddress); + +static int +winsock2GetRealNetworkInterfaces (jstring* pjstrName, + java::net::InetAddress** ppAddress) +{ + // FIXME: Add IPv6 support. + + INTERFACE_INFO arInterfaceInfo[MAX_INTERFACES]; + + // Open a (random) socket to have a file descriptor for the WSAIoctl call. + SOCKET skt = ::socket (AF_INET, SOCK_DGRAM, 0); + if (skt == INVALID_SOCKET) + _Jv_ThrowSocketException (); + + DWORD dwOutBufSize; + int nRetCode = ::WSAIoctl (skt, SIO_GET_INTERFACE_LIST, + NULL, 0, &arInterfaceInfo, sizeof(arInterfaceInfo), + &dwOutBufSize, NULL, NULL); + + if (nRetCode == SOCKET_ERROR) + { + DWORD dwLastErrorCode = WSAGetLastError (); + ::closesocket (skt); + _Jv_ThrowSocketException (dwLastErrorCode); + } + + // Get addresses of all interfaces. + int nNbInterfaces = dwOutBufSize / sizeof(INTERFACE_INFO); + int nCurETHInterface = 0; + for (int i=0; i < nNbInterfaces; ++i) + { + int len = 4; + jbyteArray baddr = JvNewByteArray (len); + SOCKADDR_IN* pAddr = (SOCKADDR_IN*) &arInterfaceInfo[i].iiAddress; + memcpy (elements (baddr), &(pAddr->sin_addr), len); + + // Concoct a name for this interface. Since we don't + // have access to the real name under Winsock 2, we use + // "lo" for the loopback interface and ethX for the + // real ones. + TCHAR szName[30]; + u_long lFlags = arInterfaceInfo[i].iiFlags; + + if (lFlags & IFF_LOOPBACK) + _tcscpy (szName, _T("lo")); + else + { + _tcscpy (szName, _T("eth")); + wsprintf(szName+3, _T("%d"), nCurETHInterface++); + } + + jstring if_name = _Jv_Win32NewString (szName); + java::net::Inet4Address* address = + new java::net::Inet4Address (baddr, JvNewStringLatin1 ("")); + pjstrName[i] = if_name; + ppAddress[i] = address; + } + + ::closesocket (skt); + + return nNbInterfaces; +} + +/* +static int +iphlpapiGetRealNetworkInterfaces (jstring* pjstrName, + java::net::InetAddress** ppAddress) +{ + return 0; +} +*/ + +static PfnGetRealNetworkInterfaces +determineGetRealNetworkInterfacesFN () +{ + /* FIXME: Try to dynamically load iphlpapi.dll and + detect the presence of GetAdaptersInfo() using + GetProcAddress(). If successful, return + iphlpapiGetRealNetworkInterfaces; if not, + return winsock2GetRealNetworkInterfaces */ + return &winsock2GetRealNetworkInterfaces; +} + +::java::util::Vector* +java::net::VMNetworkInterface::getInterfaces () +{ + // This next declaration used to be a static local, + // but this introduced a dependency on libsupc++ due + // to _cxa_guard_acquire and _cxa_guard_release. + // When Win95 is gone and we eventually get rid of + // winsock2GetRealNetworkInterfaces, we can rework + // all of this. Alternatively, we could move this all + // to win32.cc and initialize this at startup time, + // but that seems more trouble than it's worth at + // the moment. + PfnGetRealNetworkInterfaces pfn = + determineGetRealNetworkInterfacesFN (); + + jstring arIFName[MAX_INTERFACES]; + InetAddress* arpInetAddress[MAX_INTERFACES]; + ::java::util::Vector* ht = new ::java::util::Vector (); + + int nNbInterfaces = (*pfn) (arIFName, arpInetAddress); + for (int i=0; i < nNbInterfaces; ++i) + { + ht->add (new java::net::NetworkInterface (arIFName[i], + arpInetAddress[i])); + } + + return ht; +} -- cgit v1.2.3