qosify_iface_check_device(iface);
vlist_for_each_element(&interfaces, iface, node)
qosify_iface_check_interface(iface);
+ qosify_ubus_update_bridger(false);
}
void qosify_iface_check(void)
return NL_STOP;
}
+static void
+__qosify_iface_get_device(struct blob_buf *b, struct qosify_iface *iface)
+{
+ if (!iface->ifname[0] || !iface->active)
+ return;
+
+ blobmsg_add_string(b, NULL, iface->ifname);
+}
+
+void qosify_iface_get_devices(struct blob_buf *b)
+{
+ struct qosify_iface *iface;
+
+ vlist_for_each_element(&devices, iface, node)
+ __qosify_iface_get_device(b, iface);
+ vlist_for_each_element(&interfaces, iface, node)
+ __qosify_iface_get_device(b, iface);
+}
+
int qosify_iface_init(void)
{
int fd, opt;
void qosify_iface_config_update(struct blob_attr *ifaces, struct blob_attr *devs);
void qosify_iface_check(void);
void qosify_iface_status(struct blob_buf *b);
+void qosify_iface_get_devices(struct blob_buf *b);
void qosify_iface_stop(void);
int qosify_dns_init(void);
int qosify_ubus_init(void);
void qosify_ubus_stop(void);
int qosify_ubus_check_interface(const char *name, char *ifname, int ifname_len);
+void qosify_ubus_update_bridger(bool shutdown);
#endif
path = blobmsg_get_string(attr);
if (!strcmp(path, "dnsmasq.dns"))
qosify_subscribe_dnsmasq(ctx);
+ else if (!strcmp(path, "bridger"))
+ qosify_ubus_update_bridger(false);
}
static struct ubus_auto_conn conn;
+void qosify_ubus_update_bridger(bool shutdown)
+{
+ struct ubus_request req;
+ uint32_t id;
+ void *c;
+
+ if (ubus_lookup_id(&conn.ctx, "bridger", &id))
+ return;
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_string(&b, "name", "qosify");
+ c = blobmsg_open_array(&b, "devices");
+ if (!shutdown)
+ qosify_iface_get_devices(&b);
+ blobmsg_close_array(&b, c);
+
+ ubus_invoke_async(&conn.ctx, id, "set_blacklist", b.head, &req);
+}
+
int qosify_ubus_init(void)
{
conn.cb = ubus_connect_handler;
void qosify_ubus_stop(void)
{
+ qosify_ubus_update_bridger(true);
ubus_auto_shutdown(&conn);
}