-
Notifications
You must be signed in to change notification settings - Fork 6
/
ubus.c
54 lines (45 loc) · 1.23 KB
/
ubus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright (C) 2017 John Crispin <john@phrozen.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "ustatusd.h"
struct ubus_auto_conn conn;
static void ubus_state_handler(struct ubus_context *ctx, struct ubus_object *obj);
static struct ubus_object_type ubus_object_type =
{
.name = "network.status"
};
struct ubus_object ubus_object = {
.name = "network.status",
.type = &ubus_object_type,
.subscribe_cb = ubus_state_handler,
};
static void
ubus_connect_handler(struct ubus_context *ctx)
{
ubus_add_object(ctx, &ubus_object);
}
static void ubus_state_handler(struct ubus_context *ctx, struct ubus_object *obj)
{
if (!ubus_object.has_subscribers)
return;
rtnl_enum();
nl80211_enum();
}
void ubus_init(void)
{
conn.cb = ubus_connect_handler;
ubus_auto_connect(&conn);
}
void ubus_uninit(void)
{
ubus_auto_shutdown(&conn);
}