gluon-mesh-batman-adv: make respondd provider batman-adv-legacy aware
With this patch, the gluon-mesh-batman-adv respondd provider determins the compat version through the selected algorithm in /etc/config/batman-adv (BATMAN_IV_LEGACY vs. BATMAN_IV/BATMAN_V) instead of the file previously placed in /lib/gluon/mesh-batman-adv/compat. Also, the kernel module's new namespace (batman_adv -> batman_adv_legacy) is used to determine the module release version. Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
This commit is contained in:
parent
7fcf08970d
commit
c10c54e807
@ -209,24 +209,32 @@ static struct json_object * get_mesh(void) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct json_object * get_batman_adv_compat(void) {
|
static int get_batman_adv_compat(void) {
|
||||||
FILE *f = fopen("/lib/gluon/mesh-batman-adv/compat", "r");
|
char path[] = "batman-adv.bat0.routing_algo";
|
||||||
if (!f)
|
struct uci_ptr ptr;
|
||||||
return NULL;
|
struct uci_context *ctx = uci_alloc_context();
|
||||||
|
int compat = 15;
|
||||||
|
|
||||||
struct json_object *ret = NULL;
|
if (!ctx)
|
||||||
|
return compat;
|
||||||
|
|
||||||
int compat;
|
if (uci_lookup_ptr(ctx, &ptr, path, true) != UCI_OK)
|
||||||
if (fscanf(f, "%i", &compat) == 1)
|
goto end;
|
||||||
ret = json_object_new_int(compat);
|
|
||||||
|
|
||||||
fclose(f);
|
if (!ptr.o || ptr.o->type != UCI_TYPE_STRING || !ptr.o->v.string)
|
||||||
|
goto end;
|
||||||
|
|
||||||
return ret;
|
if (strncmp("BATMAN_IV_LEGACY", ptr.o->v.string, strlen("BATMAN_IV_LEGACY")) == 0)
|
||||||
|
compat = 14;
|
||||||
|
end:
|
||||||
|
uci_free_context(ctx);
|
||||||
|
return compat;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct json_object * respondd_provider_nodeinfo(void) {
|
static struct json_object * respondd_provider_nodeinfo(void) {
|
||||||
struct json_object *ret = json_object_new_object();
|
struct json_object *ret = json_object_new_object();
|
||||||
|
int compat = get_batman_adv_compat();
|
||||||
|
const char *version_path;
|
||||||
|
|
||||||
struct json_object *network = json_object_new_object();
|
struct json_object *network = json_object_new_object();
|
||||||
json_object_object_add(network, "addresses", get_addresses());
|
json_object_object_add(network, "addresses", get_addresses());
|
||||||
@ -235,8 +243,14 @@ static struct json_object * respondd_provider_nodeinfo(void) {
|
|||||||
|
|
||||||
struct json_object *software = json_object_new_object();
|
struct json_object *software = json_object_new_object();
|
||||||
struct json_object *software_batman_adv = json_object_new_object();
|
struct json_object *software_batman_adv = json_object_new_object();
|
||||||
json_object_object_add(software_batman_adv, "version", gluonutil_wrap_and_free_string(gluonutil_read_line("/sys/module/batman_adv/version")));
|
json_object_object_add(software_batman_adv, "compat", json_object_new_int(compat));
|
||||||
json_object_object_add(software_batman_adv, "compat", get_batman_adv_compat());
|
|
||||||
|
if (compat == 14)
|
||||||
|
version_path = "/sys/module/batman_adv_legacy/version";
|
||||||
|
else
|
||||||
|
version_path = "/sys/module/batman_adv/version";
|
||||||
|
|
||||||
|
json_object_object_add(software_batman_adv, "version", gluonutil_wrap_and_free_string(gluonutil_read_line(version_path)));
|
||||||
json_object_object_add(software, "batman-adv", software_batman_adv);
|
json_object_object_add(software, "batman-adv", software_batman_adv);
|
||||||
json_object_object_add(ret, "software", software);
|
json_object_object_add(ret, "software", software);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user