respondd.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /*
  2. Copyright (c) 2016, Matthias Schiffer <mschiffer@universe-factory.net>
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. 1. Redistributions of source code must retain the above copyright notice,
  7. this list of conditions and the following disclaimer.
  8. 2. Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  12. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  13. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  14. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  15. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  16. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  17. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  18. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  20. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. */
  22. #include <respondd.h>
  23. #include <iwinfo.h>
  24. #include <json-c/json.h>
  25. #include <libgluonutil.h>
  26. #include <uci.h>
  27. #include <alloca.h>
  28. #include <glob.h>
  29. #include <inttypes.h>
  30. #include <stdbool.h>
  31. #include <stdio.h>
  32. #include <string.h>
  33. #include <unistd.h>
  34. #include <arpa/inet.h>
  35. #include <net/if.h>
  36. #include <netinet/in.h>
  37. #include <sys/types.h>
  38. #include <sys/ioctl.h>
  39. #include <sys/socket.h>
  40. #include <linux/ethtool.h>
  41. #include <linux/if_addr.h>
  42. #include <linux/sockios.h>
  43. #define _STRINGIFY(s) #s
  44. #define STRINGIFY(s) _STRINGIFY(s)
  45. static struct json_object * get_addresses(void) {
  46. FILE *f = fopen("/proc/net/if_inet6", "r");
  47. if (!f)
  48. return NULL;
  49. char *line = NULL;
  50. size_t len = 0;
  51. struct json_object *ret = json_object_new_array();
  52. while (getline(&line, &len, f) >= 0) {
  53. /* IF_NAMESIZE would be enough, but adding 1 here is simpler than subtracting 1 in the format string */
  54. char ifname[IF_NAMESIZE+1];
  55. unsigned int flags;
  56. struct in6_addr addr;
  57. char buf[INET6_ADDRSTRLEN];
  58. if (sscanf(line,
  59. "%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8
  60. "%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8"%2"SCNx8
  61. " %*2x %*2x %*2x %2x %"STRINGIFY(IF_NAMESIZE)"s",
  62. &addr.s6_addr[0], &addr.s6_addr[1], &addr.s6_addr[2], &addr.s6_addr[3],
  63. &addr.s6_addr[4], &addr.s6_addr[5], &addr.s6_addr[6], &addr.s6_addr[7],
  64. &addr.s6_addr[8], &addr.s6_addr[9], &addr.s6_addr[10], &addr.s6_addr[11],
  65. &addr.s6_addr[12], &addr.s6_addr[13], &addr.s6_addr[14], &addr.s6_addr[15],
  66. &flags, ifname) != 18)
  67. continue;
  68. if (strcmp(ifname, "br-client"))
  69. continue;
  70. if (flags & (IFA_F_TENTATIVE|IFA_F_DEPRECATED))
  71. continue;
  72. inet_ntop(AF_INET6, &addr, buf, sizeof(buf));
  73. json_object_array_add(ret, json_object_new_string(buf));
  74. }
  75. fclose(f);
  76. free(line);
  77. return ret;
  78. }
  79. static void add_if_not_empty(struct json_object *obj, const char *key, struct json_object *val) {
  80. if (json_object_array_length(val))
  81. json_object_object_add(obj, key, val);
  82. else
  83. json_object_put(val);
  84. }
  85. static bool interface_file_exists(const char *ifname, const char *name) {
  86. const char *format = "/sys/class/net/%s/%s";
  87. char path[strlen(format) + strlen(ifname) + strlen(name)];
  88. snprintf(path, sizeof(path), format, ifname, name);
  89. return !access(path, F_OK);
  90. }
  91. static void mesh_add_subif(const char *ifname, struct json_object *wireless,
  92. struct json_object *tunnel, struct json_object *other) {
  93. struct json_object *address = gluonutil_wrap_and_free_string(gluonutil_get_interface_address(ifname));
  94. if (interface_file_exists(ifname, "wireless"))
  95. json_object_array_add(wireless, address);
  96. else if (interface_file_exists(ifname, "tun_flags"))
  97. json_object_array_add(tunnel, address);
  98. else
  99. json_object_array_add(other, address);
  100. }
  101. static struct json_object * get_mesh_subifs(const char *ifname) {
  102. struct json_object *wireless = json_object_new_array();
  103. struct json_object *tunnel = json_object_new_array();
  104. struct json_object *other = json_object_new_array();
  105. const char *format = "/sys/class/net/%s/lower_*";
  106. char pattern[strlen(format) + strlen(ifname) - 1];
  107. snprintf(pattern, sizeof(pattern), format, ifname);
  108. size_t pattern_len = strlen(pattern);
  109. glob_t lower;
  110. if (!glob(pattern, GLOB_NOSORT, NULL, &lower)) {
  111. size_t i;
  112. for (i = 0; i < lower.gl_pathc; i++) {
  113. mesh_add_subif(lower.gl_pathv[i] + pattern_len - 1,
  114. wireless, tunnel, other);
  115. }
  116. globfree(&lower);
  117. }
  118. struct json_object *ret = json_object_new_object();
  119. add_if_not_empty(ret, "wireless", wireless);
  120. add_if_not_empty(ret, "tunnel", tunnel);
  121. add_if_not_empty(ret, "other", other);
  122. return ret;
  123. }
  124. static struct json_object * get_mesh(void) {
  125. struct json_object *ret = json_object_new_object();
  126. struct json_object *bat0_interfaces = json_object_new_object();
  127. json_object_object_add(bat0_interfaces, "interfaces", get_mesh_subifs("bat0"));
  128. json_object_object_add(ret, "bat0", bat0_interfaces);
  129. return ret;
  130. }
  131. static struct json_object * get_batman_adv_compat(void) {
  132. FILE *f = fopen("/lib/gluon/mesh-batman-adv-core/compat", "r");
  133. if (!f)
  134. return NULL;
  135. struct json_object *ret = NULL;
  136. int compat;
  137. if (fscanf(f, "%i", &compat) == 1)
  138. ret = json_object_new_int(compat);
  139. fclose(f);
  140. return ret;
  141. }
  142. static struct json_object * respondd_provider_nodeinfo(void) {
  143. struct json_object *ret = json_object_new_object();
  144. struct json_object *network = json_object_new_object();
  145. json_object_object_add(network, "addresses", get_addresses());
  146. json_object_object_add(network, "mesh", get_mesh());
  147. json_object_object_add(ret, "network", network);
  148. struct json_object *software = json_object_new_object();
  149. struct json_object *software_batman_adv = json_object_new_object();
  150. json_object_object_add(software_batman_adv, "version", gluonutil_wrap_and_free_string(gluonutil_read_line("/sys/module/batman_adv/version")));
  151. json_object_object_add(software_batman_adv, "compat", get_batman_adv_compat());
  152. json_object_object_add(software, "batman-adv", software_batman_adv);
  153. json_object_object_add(ret, "software", software);
  154. return ret;
  155. }
  156. static void add_gateway(struct json_object *obj) {
  157. FILE *f = fopen("/sys/kernel/debug/batman_adv/bat0/gateways", "r");
  158. if (!f)
  159. return;
  160. char *line = NULL;
  161. size_t len = 0;
  162. while (getline(&line, &len, f) >= 0) {
  163. char addr[18];
  164. if (sscanf(line, "=> %17[0-9a-fA-F:]", addr) != 1)
  165. continue;
  166. json_object_object_add(obj, "gateway", json_object_new_string(addr));
  167. break;
  168. }
  169. free(line);
  170. fclose(f);
  171. }
  172. static inline bool ethtool_ioctl(int fd, struct ifreq *ifr, void *data) {
  173. ifr->ifr_data = data;
  174. return (ioctl(fd, SIOCETHTOOL, ifr) >= 0);
  175. }
  176. static uint32_t ethtool_get_stats_length(int fd, struct ifreq *ifr) {
  177. const size_t sset_info_len = sizeof(struct ethtool_sset_info) + sizeof(uint32_t);
  178. struct ethtool_sset_info *sset_info = alloca(sset_info_len);
  179. memset(sset_info, 0, sset_info_len);
  180. sset_info->cmd = ETHTOOL_GSSET_INFO;
  181. sset_info->sset_mask = 1ull << ETH_SS_STATS;
  182. if (!ethtool_ioctl(fd, ifr, sset_info))
  183. return 0;
  184. return sset_info->sset_mask ? sset_info->data[0] : 0;
  185. }
  186. static struct ethtool_gstrings * ethtool_get_stats_strings(int fd, struct ifreq *ifr) {
  187. uint32_t n_stats = ethtool_get_stats_length(fd, ifr);
  188. if (!n_stats)
  189. return NULL;
  190. struct ethtool_gstrings *strings = calloc(1, sizeof(*strings) + n_stats * ETH_GSTRING_LEN);
  191. strings->cmd = ETHTOOL_GSTRINGS;
  192. strings->string_set = ETH_SS_STATS;
  193. strings->len = n_stats;
  194. if (!ethtool_ioctl(fd, ifr, strings)) {
  195. free(strings);
  196. return NULL;
  197. }
  198. return strings;
  199. }
  200. static struct json_object * get_traffic(void) {
  201. struct ethtool_gstrings *strings = NULL;
  202. struct ethtool_stats *stats = NULL;
  203. struct ifreq ifr = {};
  204. strncpy(ifr.ifr_name, "bat0", IF_NAMESIZE);
  205. struct json_object *ret = NULL;
  206. int fd = socket(AF_INET, SOCK_DGRAM, 0);
  207. if (fd < 0)
  208. return NULL;
  209. strings = ethtool_get_stats_strings(fd, &ifr);
  210. if (!strings)
  211. goto out;
  212. stats = calloc(1, sizeof(struct ethtool_stats) + strings->len * sizeof(uint64_t));
  213. stats->cmd = ETHTOOL_GSTATS;
  214. stats->n_stats = strings->len;
  215. if (!ethtool_ioctl(fd, &ifr, stats))
  216. goto out;
  217. struct json_object *rx = json_object_new_object();
  218. struct json_object *tx = json_object_new_object();
  219. struct json_object *forward = json_object_new_object();
  220. struct json_object *mgmt_rx = json_object_new_object();
  221. struct json_object *mgmt_tx = json_object_new_object();
  222. size_t i;
  223. for (i = 0; i < strings->len; i++) {
  224. if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "rx", ETH_GSTRING_LEN))
  225. json_object_object_add(rx, "packets", json_object_new_int64(stats->data[i]));
  226. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "rx_bytes", ETH_GSTRING_LEN))
  227. json_object_object_add(rx, "bytes", json_object_new_int64(stats->data[i]));
  228. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "tx", ETH_GSTRING_LEN))
  229. json_object_object_add(tx, "packets", json_object_new_int64(stats->data[i]));
  230. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "tx_dropped", ETH_GSTRING_LEN))
  231. json_object_object_add(tx, "dropped", json_object_new_int64(stats->data[i]));
  232. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "tx_bytes", ETH_GSTRING_LEN))
  233. json_object_object_add(tx, "bytes", json_object_new_int64(stats->data[i]));
  234. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "forward", ETH_GSTRING_LEN))
  235. json_object_object_add(forward, "packets", json_object_new_int64(stats->data[i]));
  236. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "forward_bytes", ETH_GSTRING_LEN))
  237. json_object_object_add(forward, "bytes", json_object_new_int64(stats->data[i]));
  238. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "mgmt_rx", ETH_GSTRING_LEN))
  239. json_object_object_add(mgmt_rx, "packets", json_object_new_int64(stats->data[i]));
  240. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "mgmt_rx_bytes", ETH_GSTRING_LEN))
  241. json_object_object_add(mgmt_rx, "bytes", json_object_new_int64(stats->data[i]));
  242. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "mgmt_tx", ETH_GSTRING_LEN))
  243. json_object_object_add(mgmt_tx, "packets", json_object_new_int64(stats->data[i]));
  244. else if (!strncmp((const char*)&strings->data[i * ETH_GSTRING_LEN], "mgmt_tx_bytes", ETH_GSTRING_LEN))
  245. json_object_object_add(mgmt_tx, "bytes", json_object_new_int64(stats->data[i]));
  246. }
  247. ret = json_object_new_object();
  248. json_object_object_add(ret, "rx", rx);
  249. json_object_object_add(ret, "tx", tx);
  250. json_object_object_add(ret, "forward", forward);
  251. json_object_object_add(ret, "mgmt_rx", mgmt_rx);
  252. json_object_object_add(ret, "mgmt_tx", mgmt_tx);
  253. out:
  254. free(stats);
  255. free(strings);
  256. close(fd);
  257. return ret;
  258. }
  259. static void count_iface_stations(size_t *wifi24, size_t *wifi5, const char *ifname) {
  260. const struct iwinfo_ops *iw = iwinfo_backend(ifname);
  261. if (!iw)
  262. return;
  263. int freq;
  264. if (iw->frequency(ifname, &freq) < 0)
  265. return;
  266. size_t *wifi;
  267. if (freq >= 2400 && freq < 2500)
  268. wifi = wifi24;
  269. else if (freq >= 5000 && freq < 6000)
  270. wifi = wifi5;
  271. else
  272. return;
  273. int len;
  274. char buf[IWINFO_BUFSIZE];
  275. if (iw->assoclist(ifname, buf, &len) < 0)
  276. return;
  277. struct iwinfo_assoclist_entry *entry;
  278. for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++)
  279. (*wifi)++;
  280. }
  281. static void count_stations(size_t *wifi24, size_t *wifi5) {
  282. struct uci_context *ctx = uci_alloc_context();
  283. ctx->flags &= ~UCI_FLAG_STRICT;
  284. struct uci_package *p;
  285. if (uci_load(ctx, "wireless", &p))
  286. goto end;
  287. struct uci_element *e;
  288. uci_foreach_element(&p->sections, e) {
  289. struct uci_section *s = uci_to_section(e);
  290. if (strcmp(s->type, "wifi-iface"))
  291. continue;
  292. const char *network = uci_lookup_option_string(ctx, s, "network");
  293. if (!network || strcmp(network, "client"))
  294. continue;
  295. const char *mode = uci_lookup_option_string(ctx, s, "mode");
  296. if (!mode || strcmp(mode, "ap"))
  297. continue;
  298. const char *ifname = uci_lookup_option_string(ctx, s, "ifname");
  299. if (!ifname)
  300. continue;
  301. count_iface_stations(wifi24, wifi5, ifname);
  302. }
  303. end:
  304. uci_free_context(ctx);
  305. }
  306. static struct json_object * get_clients(void) {
  307. size_t total = 0, wifi = 0, wifi24 = 0, wifi5 = 0;
  308. FILE *f = fopen("/sys/kernel/debug/batman_adv/bat0/transtable_local", "r");
  309. if (!f)
  310. return NULL;
  311. char *line = NULL;
  312. size_t len = 0;
  313. while (getline(&line, &len, f) >= 0) {
  314. char flags[16];
  315. if (sscanf(line, " * %*[^[] [%15[^]]]", flags) != 1)
  316. continue;
  317. if (strchr(flags, 'P'))
  318. continue;
  319. total++;
  320. if (strchr(flags, 'W'))
  321. wifi++;
  322. }
  323. free(line);
  324. fclose(f);
  325. count_stations(&wifi24, &wifi5);
  326. struct json_object *ret = json_object_new_object();
  327. json_object_object_add(ret, "total", json_object_new_int(total));
  328. json_object_object_add(ret, "wifi", json_object_new_int(wifi));
  329. json_object_object_add(ret, "wifi24", json_object_new_int(wifi24));
  330. json_object_object_add(ret, "wifi5", json_object_new_int(wifi5));
  331. return ret;
  332. }
  333. static struct json_object * respondd_provider_statistics(void) {
  334. struct json_object *ret = json_object_new_object();
  335. json_object_object_add(ret, "clients", get_clients());
  336. json_object_object_add(ret, "traffic", get_traffic());
  337. add_gateway(ret);
  338. return ret;
  339. }
  340. static struct json_object * ifnames2addrs(struct json_object *interfaces) {
  341. struct json_object *ret = json_object_new_object();
  342. json_object_object_foreach(interfaces, ifname, interface) {
  343. char *ifaddr = gluonutil_get_interface_address(ifname);
  344. if (!ifaddr)
  345. continue;
  346. struct json_object *obj = json_object_new_object();
  347. json_object_object_add(obj, "neighbours", json_object_get(interface));
  348. json_object_object_add(ret, ifaddr, obj);
  349. free(ifaddr);
  350. }
  351. json_object_put(interfaces);
  352. return ret;
  353. }
  354. static struct json_object * get_batadv(void) {
  355. FILE *f = fopen("/sys/kernel/debug/batman_adv/bat0/originators", "r");
  356. if (!f)
  357. return NULL;
  358. char *line = NULL;
  359. size_t len = 0;
  360. struct json_object *interfaces = json_object_new_object();
  361. while (getline(&line, &len, f) >= 0) {
  362. char mac1[18], mac2[18];
  363. /* IF_NAMESIZE would be enough, but adding 1 here is simpler than subtracting 1 in the format string */
  364. char ifname[IF_NAMESIZE+1];
  365. double lastseen;
  366. int tq;
  367. if (sscanf(line,
  368. "%17[0-9a-fA-F:] %lfs ( %i ) %17[0-9a-fA-F:] [ %"STRINGIFY(IF_NAMESIZE)"[^]] ]",
  369. mac1, &lastseen, &tq, mac2, ifname) != 5)
  370. continue;
  371. if (strcmp(mac1, mac2))
  372. continue;
  373. struct json_object *interface;
  374. if (!json_object_object_get_ex(interfaces, ifname, &interface)) {
  375. interface = json_object_new_object();
  376. json_object_object_add(interfaces, ifname, interface);
  377. }
  378. struct json_object *obj = json_object_new_object();
  379. json_object_object_add(obj, "tq", json_object_new_int(tq));
  380. json_object_object_add(obj, "lastseen", json_object_new_double(lastseen));
  381. json_object_object_add(interface, mac1, obj);
  382. }
  383. fclose(f);
  384. free(line);
  385. return ifnames2addrs(interfaces);
  386. }
  387. static struct json_object * get_wifi_neighbours(const char *ifname) {
  388. const struct iwinfo_ops *iw = iwinfo_backend(ifname);
  389. if (!iw)
  390. return NULL;
  391. int len;
  392. char buf[IWINFO_BUFSIZE];
  393. if (iw->assoclist(ifname, buf, &len) < 0)
  394. return NULL;
  395. struct json_object *neighbours = json_object_new_object();
  396. struct iwinfo_assoclist_entry *entry;
  397. for (entry = (struct iwinfo_assoclist_entry *)buf; (char*)(entry+1) <= buf + len; entry++) {
  398. struct json_object *obj = json_object_new_object();
  399. json_object_object_add(obj, "signal", json_object_new_int(entry->signal));
  400. json_object_object_add(obj, "noise", json_object_new_int(entry->noise));
  401. json_object_object_add(obj, "inactive", json_object_new_int(entry->inactive));
  402. char mac[18];
  403. snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
  404. entry->mac[0], entry->mac[1], entry->mac[2],
  405. entry->mac[3], entry->mac[4], entry->mac[5]);
  406. json_object_object_add(neighbours, mac, obj);
  407. }
  408. struct json_object *ret = json_object_new_object();
  409. if (json_object_object_length(neighbours))
  410. json_object_object_add(ret, "neighbours", neighbours);
  411. else
  412. json_object_put(neighbours);
  413. return ret;
  414. }
  415. static struct json_object * get_wifi(void) {
  416. const char *mesh = "bat0";
  417. struct json_object *ret = json_object_new_object();
  418. const char *format = "/sys/class/net/%s/lower_*";
  419. char pattern[strlen(format) + strlen(mesh)];
  420. snprintf(pattern, sizeof(pattern), format, mesh);
  421. size_t pattern_len = strlen(pattern);
  422. glob_t lower;
  423. if (!glob(pattern, GLOB_NOSORT, NULL, &lower)) {
  424. size_t i;
  425. for (i = 0; i < lower.gl_pathc; i++) {
  426. const char *ifname = lower.gl_pathv[i] + pattern_len - 1;
  427. char *ifaddr = gluonutil_get_interface_address(ifname);
  428. if (!ifaddr)
  429. continue;
  430. struct json_object *neighbours = get_wifi_neighbours(ifname);
  431. if (neighbours)
  432. json_object_object_add(ret, ifaddr, neighbours);
  433. free(ifaddr);
  434. }
  435. globfree(&lower);
  436. }
  437. return ret;
  438. }
  439. static struct json_object * respondd_provider_neighbours(void) {
  440. struct json_object *ret = json_object_new_object();
  441. struct json_object *batadv = get_batadv();
  442. if (batadv)
  443. json_object_object_add(ret, "batadv", batadv);
  444. struct json_object *wifi = get_wifi();
  445. if (wifi)
  446. json_object_object_add(ret, "wifi", wifi);
  447. return ret;
  448. }
  449. const struct respondd_provider_info respondd_providers[] = {
  450. {"nodeinfo", respondd_provider_nodeinfo},
  451. {"statistics", respondd_provider_statistics},
  452. {"neighbours", respondd_provider_neighbours},
  453. {}
  454. };