]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
android: Remove unused methods on NetworkManager/network_manager_t
authorTobias Brunner <tobias@strongswan.org>
Tue, 16 Apr 2013 13:01:47 +0000 (15:01 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 3 May 2013 13:11:20 +0000 (15:11 +0200)
src/frontends/android/jni/libandroidbridge/kernel/network_manager.c
src/frontends/android/jni/libandroidbridge/kernel/network_manager.h
src/frontends/android/src/org/strongswan/android/logic/NetworkManager.java

index c8950cbd17c9f067f8c3ac738ee9cf49feb09802..f8e560b56159dfd4828be6d117fe623c8dcfd2b6 100644 (file)
@@ -52,79 +52,6 @@ struct private_network_manager_t {
        mutex_t *mutex;
 };
 
-METHOD(network_manager_t, get_local_address, host_t*,
-       private_network_manager_t *this, bool ipv4)
-{
-       JNIEnv *env;
-       jmethodID method_id;
-       jstring jaddr;
-       char *addr;
-       host_t *host;
-
-       androidjni_attach_thread(&env);
-       method_id = (*env)->GetMethodID(env, this->cls, "getLocalAddress",
-                                                                       "(Z)Ljava/lang/String;");
-       if (!method_id)
-       {
-               goto failed;
-       }
-       jaddr = (*env)->CallObjectMethod(env, this->obj, method_id, ipv4);
-       if (!jaddr || androidjni_exception_occurred(env))
-       {
-               goto failed;
-       }
-       addr = androidjni_convert_jstring(env, jaddr);
-       androidjni_detach_thread();
-       host = host_create_from_string(addr, 0);
-       free(addr);
-       return host;
-
-failed:
-       androidjni_exception_occurred(env);
-       androidjni_detach_thread();
-       return NULL;
-}
-
-METHOD(network_manager_t, get_interface, bool,
-       private_network_manager_t *this, host_t *ip, char **name)
-{
-       JNIEnv *env;
-       jmethodID method_id;
-       jbyteArray jaddr;
-       jstring jinterface;
-
-       if (ip->is_anyaddr(ip))
-       {
-               return FALSE;
-       }
-
-       androidjni_attach_thread(&env);
-
-       method_id = (*env)->GetMethodID(env, this->cls, "getInterface",
-                                                                       "([B)Ljava/lang/String;");
-       if (!method_id)
-       {
-               goto failed;
-       }
-       jaddr = byte_array_from_chunk(env, ip->get_address(ip));
-       jinterface = (*env)->CallObjectMethod(env, this->obj, method_id, jaddr);
-       if (!jinterface || androidjni_exception_occurred(env))
-       {
-               goto failed;
-       }
-       if (name)
-       {
-               *name = androidjni_convert_jstring(env, jinterface);
-       }
-       androidjni_detach_thread();
-       return TRUE;
-
-failed:
-       androidjni_exception_occurred(env);
-       androidjni_detach_thread();
-       return FALSE;
-}
-
 JNI_METHOD(NetworkManager, networkChanged, void,
        bool disconnected)
 {
@@ -245,8 +172,6 @@ network_manager_t *network_manager_create(jobject context)
 
        INIT(this,
                .public = {
-                       .get_local_address = _get_local_address,
-                       .get_interface = _get_interface,
                        .add_connectivity_cb = _add_connectivity_cb,
                        .remove_connectivity_cb = _remove_connectivity_cb,
                        .destroy = _destroy,
index da0106829f6a23e96591e79429597207ec66745e..abca239ea58d324d35e4ecde74bc4a061f9d5c12 100644 (file)
@@ -40,30 +40,12 @@ typedef struct network_manager_t network_manager_t;
 typedef void (*connectivity_cb_t)(void *data, bool disconnected);
 
 /**
- * NetworkManager, used to listen for network changes and retrieve local IP
- * addresses.
+ * NetworkManager, used to listen for network changes.
  *
  * Communicates with NetworkManager via JNI
  */
 struct network_manager_t {
 
-       /**
-        * Get a local address
-        *
-        * @param ipv4                          TRUE to get an IPv4 address
-        * @return                                      the address or NULL if none available
-        */
-       host_t *(*get_local_address)(network_manager_t *this, bool ipv4);
-
-       /**
-        * Get the name of the interface on which the given IP address is installed
-        *
-        * @param ip                            the IP address to look for
-        * @param name                          returns the name of the interface (optional)
-        * @return                                      TRUE if found
-        */
-       bool (*get_interface)(network_manager_t *this, host_t *ip, char **name);
-
        /**
         * Register a callback that is called if connectivity changes
         *
index 168341a6896525810f79a85ef7602e84392bec95..8ea07f4c08d728558264fbc49ca0932167f6e179 100644 (file)
 
 package org.strongswan.android.logic;
 
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -64,79 +56,4 @@ public class NetworkManager extends BroadcastReceiver
         * @param disconnected true if no connection is available at the moment
         */
        public native void networkChanged(boolean disconnected);
-
-       /**
-        * Function that retrieves a local address of the given family.
-        *
-        * @param ipv4 true to return an IPv4 address, false for IPv6
-        * @return string representation of an IPv4 address, or null if none found
-        */
-       public String getLocalAddress(boolean ipv4)
-       {
-               try
-               {
-                       Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
-                       if (en == null)
-                       {       /* no interfaces at all */
-                               return null;
-                       }
-                       while (en.hasMoreElements())
-                       {
-                               NetworkInterface intf = en.nextElement();
-                               if (intf.isLoopback() || !intf.isUp() ||
-                                       intf.getName().startsWith("tun"))
-                               {
-                                       continue;
-                               }
-                               Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses();
-                               while (enumIpAddr.hasMoreElements())
-                               {
-                                       InetAddress inetAddress = enumIpAddr.nextElement();
-                                       if (inetAddress.isLoopbackAddress())
-                                       {
-                                               continue;
-                                       }
-                                       if ((ipv4 && inetAddress instanceof Inet4Address) ||
-                                               (!ipv4 && inetAddress instanceof Inet6Address))
-                                       {
-                                               return inetAddress.getHostAddress();
-                                       }
-                               }
-                       }
-               }
-               catch (SocketException ex)
-               {
-                       ex.printStackTrace();
-                       return null;
-               }
-               return null;
-       }
-
-       /**
-        * Search for an interface that has the given address installed.
-        *
-        * @param addr network-order byte encoding of the address to look for
-        * @return name of the interface, or null if not found
-        */
-       public String getInterface(byte[] addr)
-       {
-               try
-               {
-                       InetAddress inetAddress = InetAddress.getByAddress(addr);
-                       NetworkInterface intf = NetworkInterface.getByInetAddress(inetAddress);
-                       if (intf != null)
-                       {
-                               return intf.getName();
-                       }
-               }
-               catch (UnknownHostException e)
-               {
-                       e.printStackTrace();
-               }
-               catch (SocketException e)
-               {
-                       e.printStackTrace();
-               }
-               return null;
-       }
 }