2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup network_manager network_manager
18 * @{ @ingroup kernel_android
21 #ifndef NETWORK_MANAGER_H_
22 #define NETWORK_MANAGER_H_
27 #include <utils/host.h>
29 typedef struct network_manager_t network_manager_t
;
32 * Callback called if connectivity changes somehow.
34 * Implementation should be quick as the call is made by the Java apps main
37 * @param data data supplied during registration
38 * @param disconnected TRUE if currently disconnected
40 typedef void (*connectivity_cb_t
)(void *data
, bool disconnected
);
43 * NetworkManager, used to listen for network changes and retrieve local IP
46 * Communicates with NetworkManager via JNI
48 struct network_manager_t
{
53 * @param ipv4 TRUE to get an IPv4 address
54 * @return the address or NULL if none available
56 host_t
*(*get_local_address
)(network_manager_t
*this, bool ipv4
);
59 * Register a callback that is called if connectivity changes
61 * @note Only the first registered callback is currently used
63 * @param cb callback to register
64 * @param data data provided to callback
66 void (*add_connectivity_cb
)(network_manager_t
*this, connectivity_cb_t cb
,
70 * Unregister a previously registered callback for connectivity changes
72 * @param cb previously registered callback
74 void (*remove_connectivity_cb
)(network_manager_t
*this,
75 connectivity_cb_t cb
);
78 * Destroy a network_manager_t instance
80 void (*destroy
)(network_manager_t
*this);
84 * Create a network_manager_t instance
86 * @param context Context object
87 * @return network_manager_t instance
89 network_manager_t
*network_manager_create(jobject context
);
91 #endif /** NETWORK_MANAGER_H_ @}*/