2 * Copyright (C) 2012-2013 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 android_kernel
21 #ifndef NETWORK_MANAGER_H_
22 #define NETWORK_MANAGER_H_
27 #include <networking/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 * Get the name of the interface on which the given IP address is installed
61 * @param ip the IP address to look for
62 * @param name returns the name of the interface (optional)
63 * @return TRUE if found
65 bool (*get_interface
)(network_manager_t
*this, host_t
*ip
, char **name
);
68 * Register a callback that is called if connectivity changes
70 * @note Only the first registered callback is currently used
72 * @param cb callback to register
73 * @param data data provided to callback
75 void (*add_connectivity_cb
)(network_manager_t
*this, connectivity_cb_t cb
,
79 * Unregister a previously registered callback for connectivity changes
81 * @param cb previously registered callback
83 void (*remove_connectivity_cb
)(network_manager_t
*this,
84 connectivity_cb_t cb
);
87 * Destroy a network_manager_t instance
89 void (*destroy
)(network_manager_t
*this);
93 * Create a network_manager_t instance
95 * @param context Context object
96 * @return network_manager_t instance
98 network_manager_t
*network_manager_create(jobject context
);
100 #endif /** NETWORK_MANAGER_H_ @}*/