android: Add a custom kernel-net implementation to replace kernel-netlink
[strongswan.git] / src / frontends / android / jni / libandroidbridge / kernel / network_manager.h
1 /*
2 * Copyright (C) 2012-2013 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 /**
17 * @defgroup network_manager network_manager
18 * @{ @ingroup android_kernel
19 */
20
21 #ifndef NETWORK_MANAGER_H_
22 #define NETWORK_MANAGER_H_
23
24 #include <jni.h>
25
26 #include <library.h>
27 #include <networking/host.h>
28
29 typedef struct network_manager_t network_manager_t;
30
31 /**
32 * Callback called if connectivity changes somehow.
33 *
34 * Implementation should be quick as the call is made by the Java apps main
35 * thread.
36 *
37 * @param data data supplied during registration
38 * @param disconnected TRUE if currently disconnected
39 */
40 typedef void (*connectivity_cb_t)(void *data, bool disconnected);
41
42 /**
43 * NetworkManager, used to listen for network changes.
44 *
45 * Communicates with NetworkManager via JNI
46 */
47 struct network_manager_t {
48
49 /**
50 * Register a callback that is called if connectivity changes
51 *
52 * @note Only the first registered callback is currently used
53 *
54 * @param cb callback to register
55 * @param data data provided to callback
56 */
57 void (*add_connectivity_cb)(network_manager_t *this, connectivity_cb_t cb,
58 void *data);
59
60 /**
61 * Unregister a previously registered callback for connectivity changes
62 *
63 * @param cb previously registered callback
64 */
65 void (*remove_connectivity_cb)(network_manager_t *this,
66 connectivity_cb_t cb);
67
68 /**
69 * Destroy a network_manager_t instance
70 */
71 void (*destroy)(network_manager_t *this);
72 };
73
74 /**
75 * Create a network_manager_t instance
76 *
77 * @param context Context object
78 * @return network_manager_t instance
79 */
80 network_manager_t *network_manager_create(jobject context);
81
82 #endif /** NETWORK_MANAGER_H_ @}*/