Skip to content

Commit 6218c70

Browse files
committed
1 parent 5fc003d commit 6218c70

42 files changed

Lines changed: 175 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
diff --git a/net/respondd-module-airtime/src/airtime.c b/net/respondd-module-airtime/src/airtime.c
2+
index 7e27ee0..9af51ad 100644
3+
--- a/net/respondd-module-airtime/src/airtime.c
4+
+++ b/net/respondd-module-airtime/src/airtime.c
5+
@@ -57,7 +57,7 @@
6+
* @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
7+
*/
8+
9+
-static const char const* msg_names[NL80211_SURVEY_INFO_MAX + 1] = {
10+
+static const char *const msg_names[NL80211_SURVEY_INFO_MAX + 1] = {
11+
[NL80211_SURVEY_INFO_FREQUENCY] = "frequency",
12+
[NL80211_SURVEY_INFO_CHANNEL_TIME] = "active",
13+
[NL80211_SURVEY_INFO_CHANNEL_TIME_BUSY] = "busy",
14+
@@ -67,20 +67,26 @@ static const char const* msg_names[NL80211_SURVEY_INFO_MAX + 1] = {
15+
};
16+
17+
static int survey_airtime_handler(struct nl_msg *msg, void *arg) {
18+
- struct json_object *parent_json = (struct json_object *) arg;
19+
+ struct json_object **result = arg;
20+
+ struct json_object *freq_json = NULL;
21+
22+
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
23+
struct nlattr *survey_info = nla_find(genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NL80211_ATTR_SURVEY_INFO);
24+
25+
+ if (*result) {
26+
+ fprintf(stderr, "respondd-module-airtime: callback called again after NL_STOP\n");
27+
+ return NL_STOP;
28+
+ }
29+
+
30+
if (!survey_info) {
31+
fprintf(stderr, "respondd-module-airtime: survey data missing in netlink message\n");
32+
- goto abort;
33+
+ return NL_STOP;
34+
}
35+
36+
- struct json_object *freq_json = json_object_new_object();
37+
+ freq_json = json_object_new_object();
38+
if (!freq_json) {
39+
fprintf(stderr, "respondd-module-airtime: failed allocating JSON object\n");
40+
- goto abort;
41+
+ return NL_STOP;
42+
}
43+
44+
// This variable counts the number of required attributes that are
45+
@@ -129,15 +135,19 @@ static int survey_airtime_handler(struct nl_msg *msg, void *arg) {
46+
json_object_object_add(freq_json, msg_names[type], data_json);
47+
}
48+
49+
- if (req_fields == 3)
50+
- json_object_array_add(parent_json, freq_json);
51+
- else
52+
+ /* The kernel didn't report all required fields: continue with next
53+
+ * record, this entry was off-channel */
54+
+ if (req_fields != 3) {
55+
json_object_put(freq_json);
56+
+ return NL_OK;
57+
+ }
58+
59+
-abort:
60+
- return NL_SKIP;
61+
+ *result = freq_json;
62+
+ return NL_STOP;
63+
}
64+
65+
-bool get_airtime(struct json_object *result, int ifx) {
66+
- return nl_send_dump(survey_airtime_handler, result, NL80211_CMD_GET_SURVEY, ifx);
67+
+struct json_object * get_airtime(int ifx) {
68+
+ struct json_object *result = NULL;
69+
+ nl_send_dump(survey_airtime_handler, &result, NL80211_CMD_GET_SURVEY, ifx);
70+
+ return result;
71+
}
72+
diff --git a/net/respondd-module-airtime/src/airtime.h b/net/respondd-module-airtime/src/airtime.h
73+
index 7adc91e..7db21ec 100644
74+
--- a/net/respondd-module-airtime/src/airtime.h
75+
+++ b/net/respondd-module-airtime/src/airtime.h
76+
@@ -4,4 +4,5 @@
77+
#include <stdint.h>
78+
#include <json-c/json.h>
79+
80+
-__attribute__((visibility("hidden"))) bool get_airtime(struct json_object *result, int ifx);
81+
+__attribute__((visibility("hidden")))
82+
+struct json_object * get_airtime(int ifx);
83+
diff --git a/net/respondd-module-airtime/src/netlink.c b/net/respondd-module-airtime/src/netlink.c
84+
index 2030193..4d12833 100644
85+
--- a/net/respondd-module-airtime/src/netlink.c
86+
+++ b/net/respondd-module-airtime/src/netlink.c
87+
@@ -37,7 +37,7 @@ bool nl_send_dump(nl_recvmsg_msg_cb_t cb, void *cb_arg, int cmd, uint32_t cmd_ar
88+
ERR("nlmsg_alloc() failed\n");
89+
90+
if (!genlmsg_put(msg, 0, 0, ctrl, 0, NLM_F_DUMP, cmd, 0))
91+
- ERR("genlmsg_put() failed while putting cmd %d\n", ret, cmd);
92+
+ ERR("genlmsg_put() failed while putting cmd %d\n", cmd);
93+
94+
if (cmd_arg != 0)
95+
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, cmd_arg);
96+
diff --git a/net/respondd-module-airtime/src/respondd.c b/net/respondd-module-airtime/src/respondd.c
97+
index eaf8182..8f73d68 100644
98+
--- a/net/respondd-module-airtime/src/respondd.c
99+
+++ b/net/respondd-module-airtime/src/respondd.c
100+
@@ -7,9 +7,7 @@
101+
#include "ifaces.h"
102+
103+
static struct json_object *respondd_provider_statistics(void) {
104+
- bool ok;
105+
- int newest_element_index;
106+
- struct json_object *last, *result, *wireless;
107+
+ struct json_object *result, *wireless;
108+
struct iface_list *ifaces;
109+
110+
result = json_object_new_object();
111+
@@ -24,13 +22,9 @@ static struct json_object *respondd_provider_statistics(void) {
112+
113+
ifaces = get_ifaces();
114+
while (ifaces != NULL) {
115+
- ok = get_airtime(wireless, ifaces->ifx);
116+
- if (ok) {
117+
- newest_element_index = json_object_array_length(wireless) - 1;
118+
- last = json_object_array_get_idx(wireless, newest_element_index);
119+
- if (last)
120+
- json_object_object_add(last, "phy", json_object_new_int(ifaces->wiphy));
121+
- }
122+
+ struct json_object *entry = get_airtime(ifaces->ifx);
123+
+ if (entry)
124+
+ json_object_array_add(wireless, entry);
125+
void *freeptr = ifaces;
126+
ifaces = ifaces->next;
127+
free(freeptr);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
echo $PWD
3+
patchfile="../../../patches/respondd2021-1-1-6-radiooffcrash.patch"
4+
#/gluon/packages/gluon/
5+
if ! patch -R -p1 -s -f --ignore-whitespace --dry-run <$patchfile &>/dev/null; then
6+
patch -p1 --ignore-whitespace <$patchfile
7+
fi
8+
grep 'off-channel' net/respondd-module-airtime/src/airtime.c

templates/01_vel-key/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

templates/01_vel/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

templates/02_met-key/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

templates/02_met/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

templates/03_rat-key/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

templates/03_rat/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

templates/04_hld-key/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

templates/04_hld/prepare.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
pushd ../gluon ; git am ../patches/0001-*; popd ; # apply 0001-enumerated patches automaticylly
99
pushd ../gluon ; ../patches/fix-respondd-rsk.sh; popd # change respondd listener address to gluon 2016.x value
10+
pushd ../gluon/packages/gluon ; ../../../patches/respondd2021-1-1-6-radiooffcrash.sh; popd # prevent crashes of respondd if radios installed but turned completly off.
1011
pushd ../gluon ; ../patches/fix-DIR615c1-imagetoobig.sh; popd # remove DIR615C1 beeing too big
1112
pushd ../gluon ; ../patches/add-TPlinkArcherA7V5.sh; popd # adding TP-Link Archer A7-V5
1213
pushd ../gluon ; ../patches/kernelswapon.sh; popd # enable swap for all

0 commit comments

Comments
 (0)