mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-17 17:31:27 +00:00
opensync: extend ubus API
We need to be able to pass a different ev_loop context. Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
parent
bd28d088fc
commit
43444774f0
@ -13,12 +13,13 @@ struct ubus_watch_list {
|
|||||||
struct ubus_instance {
|
struct ubus_instance {
|
||||||
ubus_connect_handler_t connect;
|
ubus_connect_handler_t connect;
|
||||||
ubus_handler_t notify;
|
ubus_handler_t notify;
|
||||||
|
void (*subscribed)(const char *path, uint32_t id, int add);
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
struct ubus_watch_list list[];
|
struct ubus_watch_list list[];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int ubus_init(struct ubus_instance *instance);
|
extern int ubus_init(struct ubus_instance *instance, struct ev_loop *_loop);
|
||||||
extern uint32_t ubus_lookup_remote(char *name);
|
extern uint32_t ubus_lookup_remote(char *name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
#include "ubus.h"
|
#include "ubus.h"
|
||||||
static struct ubus_context *ubus;
|
static struct ubus_context *ubus;
|
||||||
|
extern struct ev_loop *wifihal_evloop;
|
||||||
|
|
||||||
int hapd_rrm_enable(char *name, int neighbor, int beacon)
|
int hapd_rrm_enable(char *name, int neighbor, int beacon)
|
||||||
{
|
{
|
||||||
@ -140,5 +141,5 @@ static struct ubus_instance ubus_instance = {
|
|||||||
|
|
||||||
int radio_ubus_init(void)
|
int radio_ubus_init(void)
|
||||||
{
|
{
|
||||||
return ubus_init(&ubus_instance);
|
return ubus_init(&ubus_instance, wifihal_evloop);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ struct ubus_remote {
|
|||||||
uint32_t id;
|
uint32_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct ev_loop *wifihal_evloop;
|
struct ev_loop *loop;
|
||||||
static ev_io ubus_io;
|
static ev_io ubus_io;
|
||||||
|
|
||||||
static struct ubus_context ubus;
|
static struct ubus_context ubus;
|
||||||
@ -79,6 +79,9 @@ static void ubus_handle_subscribe(const char *path, uint32_t id, int add)
|
|||||||
avl_delete(&ubus_tree, &remote->avl);
|
avl_delete(&ubus_tree, &remote->avl);
|
||||||
free(remote);
|
free(remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ubus_instance->subscribed)
|
||||||
|
ubus_instance->subscribed(path, id, add);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ubus_event_handler_cb(struct ubus_context *ctx, struct ubus_event_handler *ev,
|
static void ubus_event_handler_cb(struct ubus_context *ctx, struct ubus_event_handler *ev,
|
||||||
@ -128,7 +131,7 @@ static void ubus_reconnect_cb(void *arg);
|
|||||||
|
|
||||||
static void ubus_connection_lost_cb(struct ubus_context *ctx)
|
static void ubus_connection_lost_cb(struct ubus_context *ctx)
|
||||||
{
|
{
|
||||||
ev_io_stop(wifihal_evloop, &ubus_io);
|
ev_io_stop(loop, &ubus_io);
|
||||||
evsched_task(&ubus_reconnect_cb, NULL, EVSCHED_SEC(1));
|
evsched_task(&ubus_reconnect_cb, NULL, EVSCHED_SEC(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +147,7 @@ static void ubus_reconnect_cb(void *arg)
|
|||||||
ubus.connection_lost = ubus_connection_lost_cb;
|
ubus.connection_lost = ubus_connection_lost_cb;
|
||||||
|
|
||||||
ev_io_init(&ubus_io, ubus_ev, ubus.sock.fd, EV_READ);
|
ev_io_init(&ubus_io, ubus_ev, ubus.sock.fd, EV_READ);
|
||||||
ev_io_start(wifihal_evloop, &ubus_io);
|
ev_io_start(loop, &ubus_io);
|
||||||
|
|
||||||
if (ubus_instance->connect)
|
if (ubus_instance->connect)
|
||||||
ubus_instance->connect(&ubus);
|
ubus_instance->connect(&ubus);
|
||||||
@ -162,11 +165,11 @@ static void ubus_reconnect_cb(void *arg)
|
|||||||
ubus_lookup(&ubus, NULL, ubus_lookup_cb, NULL);
|
ubus_lookup(&ubus, NULL, ubus_lookup_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ubus_init(struct ubus_instance *instance)
|
int ubus_init(struct ubus_instance *instance, struct ev_loop *_loop)
|
||||||
{
|
{
|
||||||
ubus_instance = instance;
|
ubus_instance = instance;
|
||||||
|
loop = _loop;
|
||||||
evsched_task(&ubus_reconnect_cb, NULL, EVSCHED_SEC(1));
|
evsched_task(&ubus_reconnect_cb, NULL, EVSCHED_SEC(2));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user