Merge branch 'pt-tls'
[strongswan.git] / src / frontends / android / jni / libandroidbridge / kernel / network_manager.h
index cb0da7f..da01068 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012-2013 Tobias Brunner
  * Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
  * Hochschule fuer Technik Rapperswil
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -15,7 +15,7 @@
 
 /**
  * @defgroup network_manager network_manager
 
 /**
  * @defgroup network_manager network_manager
- * @{ @ingroup kernel_android
+ * @{ @ingroup android_kernel
  */
 
 #ifndef NETWORK_MANAGER_H_
  */
 
 #ifndef NETWORK_MANAGER_H_
 #include <jni.h>
 
 #include <library.h>
 #include <jni.h>
 
 #include <library.h>
-#include <utils/host.h>
+#include <networking/host.h>
 
 typedef struct network_manager_t network_manager_t;
 
 /**
 
 typedef struct network_manager_t network_manager_t;
 
 /**
- * NetworkManager, used to retrieve local IP addresses.
+ * Callback called if connectivity changes somehow.
+ *
+ * Implementation should be quick as the call is made by the Java apps main
+ * thread.
+ *
+ * @param data                                 data supplied during registration
+ * @param disconnected                 TRUE if currently disconnected
+ */
+typedef void (*connectivity_cb_t)(void *data, bool disconnected);
+
+/**
+ * NetworkManager, used to listen for network changes and retrieve local IP
+ * addresses.
  *
  * Communicates with NetworkManager via JNI
  */
  *
  * Communicates with NetworkManager via JNI
  */
@@ -44,6 +56,34 @@ struct network_manager_t {
        host_t *(*get_local_address)(network_manager_t *this, bool ipv4);
 
        /**
        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
+        *
+        * @note Only the first registered callback is currently used
+        *
+        * @param cb                            callback to register
+        * @param data                          data provided to callback
+        */
+       void (*add_connectivity_cb)(network_manager_t *this, connectivity_cb_t cb,
+                                                               void *data);
+
+       /**
+        * Unregister a previously registered callback for connectivity changes
+        *
+        * @param cb                            previously registered callback
+        */
+       void (*remove_connectivity_cb)(network_manager_t *this,
+                                                                  connectivity_cb_t cb);
+
+       /**
         * Destroy a network_manager_t instance
         */
        void (*destroy)(network_manager_t *this);
         * Destroy a network_manager_t instance
         */
        void (*destroy)(network_manager_t *this);
@@ -52,8 +92,9 @@ struct network_manager_t {
 /**
  * Create a network_manager_t instance
  *
 /**
  * Create a network_manager_t instance
  *
+ * @param context                              Context object
  * @return                                             network_manager_t instance
  */
  * @return                                             network_manager_t instance
  */
-network_manager_t *network_manager_create();
+network_manager_t *network_manager_create(jobject context);
 
 #endif /** NETWORK_MANAGER_H_ @}*/
 
 #endif /** NETWORK_MANAGER_H_ @}*/