3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-23 22:42:37 +01:00

client: Add INTERFACE_TYPE

This commit is contained in:
Tim Kourt 2017-04-13 09:56:13 -07:00 committed by Denis Kenzior
parent 6c2eae6999
commit ef394579b0
2 changed files with 42 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include <config.h>
#endif
#include <stdio.h>
#include <ell/ell.h>
#include "dbus-proxy.h"
@ -421,8 +422,13 @@ void proxy_interface_type_unregister(
l_queue_remove(proxy_interface_types, (void *) interface_type);
}
extern struct interface_type_desc __start___interface[];
extern struct interface_type_desc __stop___interface[];
bool dbus_proxy_init(void)
{
struct interface_type_desc *desc;
if (dbus)
return true;
@ -433,6 +439,16 @@ bool dbus_proxy_init(void)
proxy_interface_types = l_queue_new();
proxy_interfaces = l_queue_new();
if (__start___interface == NULL || __stop___interface == NULL)
return false;
for (desc = __start___interface; desc < __stop___interface; desc++) {
if (!desc->init)
continue;
desc->init();
}
l_dbus_set_disconnect_handler(dbus, dbus_disconnect_callback, NULL,
NULL);
@ -445,6 +461,18 @@ bool dbus_proxy_init(void)
bool dbus_proxy_exit(void)
{
struct interface_type_desc *desc;
if (__start___interface == NULL || __stop___interface == NULL)
return false;
for (desc = __start___interface; desc < __stop___interface; desc++) {
if (!desc->exit)
continue;
desc->exit();
}
l_queue_destroy(proxy_interface_types, NULL);
proxy_interface_types = NULL;

View File

@ -20,6 +20,8 @@
*
*/
#include <stdio.h>
struct proxy_interface;
#define IWD_ADAPTER_INTERFACE "net.connman.iwd.Adapter"
@ -57,5 +59,17 @@ void proxy_interface_type_register(
void proxy_interface_type_unregister(
const struct proxy_interface_type *interface_type);
struct interface_type_desc {
const char *interface;
int (*init)(void);
void (*exit)(void);
} __attribute__((aligned(8)));
#define INTERFACE_TYPE(interface, init, exit) \
static struct interface_type_desc __interface_type_ ## interface\
__attribute__((used, section("__interface"), aligned(8))) = {\
#interface, init, exit \
}; \
bool dbus_proxy_init(void);
bool dbus_proxy_exit(void);