Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ root = true
end_of_line = lf
insert_final_newline = true
indent_style = tab

trim_trailing_whitespace = true
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CC ?= gcc
CFLAGS_common ?= -Wall -Wextra -Werror -std=c99 -g
LDFLAGS_common ?=
LDFLAGS_common ?=

PKG_CONFIG ?= pkg-config

Expand Down Expand Up @@ -35,4 +35,4 @@ all:
$(CC) $(CFLAGS) -D_GNU_SOURCE -o node-whisperer daemon.c util.c information.c log.c ubus.c interface.c batadv.c $(LDFLAGS)

monitor:
$(CC) $(CFLAGS_MONITOR) -D_GNU_SOURCE -o monitor monitor.c log.c util.c ieee80211.c information.c $(LDFLAGS_MONITOR)
$(CC) $(CFLAGS_MONITOR) -D_GNU_SOURCE -o monitor monitor.c log.c util.c ieee80211.c information.c $(LDFLAGS_MONITOR)
5 changes: 2 additions & 3 deletions src/batadv.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
if (batadv_genl_missing_attrs(attrs, parse_orig_list_mandatory,
BATADV_ARRAY_SIZE(parse_orig_list_mandatory)))
return NL_OK;

hardif = nla_get_u32(attrs[BATADV_ATTR_HARD_IFINDEX]);
orig = nla_data(attrs[BATADV_ATTR_ORIG_ADDRESS]);
dest = nla_data(attrs[BATADV_ATTR_NEIGH_ADDRESS]);
Expand All @@ -86,7 +86,6 @@ static int parse_orig_list_netlink_cb(struct nl_msg *msg, void *arg)
opts->stats->vpn.tq = nla_get_u8(attrs[BATADV_ATTR_TQ]);
opts->stats->vpn.connected = 1;
}

return NL_OK;
}

Expand Down Expand Up @@ -169,4 +168,4 @@ int nw_get_batadv_clients() {
}

return opts.clients;
}
}
10 changes: 5 additions & 5 deletions src/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ static int nw_daemon_create_vendor_element_buf(struct nw *instance) {
instance->output.buf[5] = 0x04;

/* Length now matches content. Make sure to update on each new information! */

/* Loop through all information-sources */
for (int i = 0; information_sources[i].name; i++) {
for (int i = 0; information_sources[i].name; i++) {
if (!information_sources[i].enabled) {
log_debug("Information source id=%d name=%s is disabled",
information_sources[i].type, information_sources[i].name);
Expand Down Expand Up @@ -121,11 +121,11 @@ static void nw_daemon_collect_information(struct uloop_timeout *timeout) {
if (nw_daemon_create_vendor_element_buf(instance) < 0) {
goto out_free;
}

/* Allocate output buffer */
size_t buf_len = instance->output.len * 2 + 1;
uint8_t *buf_hex = malloc(buf_len);

nw_buffer_to_hexstring(instance->output.buf, instance->output.len, buf_hex);

/* Update nodes */
Expand All @@ -141,7 +141,7 @@ static void nw_daemon_collect_information(struct uloop_timeout *timeout) {

static int start_daemon() {
struct nw instance = {};

INIT_LIST_HEAD(&instance.enabled_interfaces);

uloop_init();
Expand Down
10 changes: 5 additions & 5 deletions src/information.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ int node_whisperer_information_batman_adv_collect(uint8_t *buffer, size_t buffer
ret = nw_get_batadv_neighbor_stats(&stats);
if (ret)
return -1;

ret = nw_get_batadv_clients();
if (ret < 0) {
num_clients = 0;
} else {
num_clients = (uint16_t)ret;
}
}

buffer[0] = stats.vpn.connected ? 1 : 0;
buffer[1] = stats.vpn.tq;
Expand Down Expand Up @@ -245,7 +245,7 @@ int node_whisperer_information_hostname_parse(const uint8_t *ie_buf, size_t ie_l
return 0;
}

int node_whisperer_information_node_id_parse(const uint8_t *ie_buf, size_t ie_len) {
int node_whisperer_information_node_id_parse(const uint8_t *ie_buf, size_t ie_len) {
/* We Print Node-ID on top */

return 0;
Expand All @@ -256,7 +256,7 @@ int node_whisperer_information_batman_adv_parse(const uint8_t *ie_buf, size_t ie

if (ie_len < 8)
return -1;

printf("VPN connected: %s\n", ie_buf[0] ? "Yes" : "No");
printf("VPN-TQ: %d\n", ie_buf[1]);
tmp = (uint16_t *)&ie_buf[2];
Expand Down Expand Up @@ -310,7 +310,7 @@ int node_whisperer_information_domain_parse(const uint8_t *ie_buf, size_t ie_len
tmp = malloc(ie_len + 1);
if (!tmp)
return -1;

memcpy(tmp, ie_buf, ie_len);
tmp[ie_len] = '\0';

Expand Down
2 changes: 1 addition & 1 deletion src/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int nw_interface_update(struct ubus_context *ctx, char *vendor_elements)
/* Delete element */
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "vendor_elements", "");

ret = ubus_invoke(ctx, iface->ubus.id, "set_vendor_elements", b.head, NULL, NULL, 1000);
if (ret) {
log_error("Failed to reset vendor elements for id=%d name=%s code=%d", iface->ubus.id, iface->ubus.name, ret);
Expand Down
12 changes: 6 additions & 6 deletions src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ int nl_get_multicast_id(struct nl80211_sock *sock, const char *family, const cha
ret = -ENOMEM;
goto nla_put_failure;
}

cb = nl_cb_alloc(NL_CB_DEFAULT);
if (!cb) {
log_error("Failed to allocate callback message.");
Expand Down Expand Up @@ -224,7 +224,7 @@ int nl_get_multicast_id(struct nl80211_sock *sock, const char *family, const cha
nl_recvmsgs(sock->nls, cb);

if (ret == 0) {
ret = grp.id;
ret = grp.id;
}
log_debug("Received multicast group ID: %d", ret);

Expand Down Expand Up @@ -281,8 +281,8 @@ int nl80211_trigger_scan(struct nl80211_sock *wifi, int ifindex)
genlmsg_put(msg, 0, 0, wifi->nl80211_id, 0, 0, NL80211_CMD_TRIGGER_SCAN, 0);
nla_put_nested(msg, NL80211_ATTR_SCAN_SSIDS, scan_ssid);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, ifindex);


err = -ENOENT;
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, callback_trigger, &results);
nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &err);
Expand All @@ -294,7 +294,7 @@ int nl80211_trigger_scan(struct nl80211_sock *wifi, int ifindex)

while (err > 0)
ret = nl_recvmsgs(wifi->nls, cb);

if (ret < 0) {
log_debug("ERROR: nl_recvmsgs() returned %d (%s).", ret, nl_geterror(-ret));
goto nla_put_failure;
Expand Down Expand Up @@ -507,7 +507,7 @@ static int callback_dump(struct nl_msg *msg, void *arg)

if (!bss[NL80211_BSS_BSSID] || !bss[NL80211_BSS_INFORMATION_ELEMENTS])
return NL_SKIP;

/* Add Node */
monitor_gluon_node_add(nla_data(bss[NL80211_BSS_BSSID]), nla_data(bss[NL80211_BSS_INFORMATION_ELEMENTS]), nla_len(bss[NL80211_BSS_INFORMATION_ELEMENTS]));

Expand Down
4 changes: 2 additions & 2 deletions src/ubus.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ static int nw_ubus_set_interfaces(struct ubus_context *ctx, struct ubus_object *
ifname = blobmsg_get_string(cur);
if (!ifname)
return UBUS_STATUS_INVALID_ARGUMENT;

log_debug("Add interface %s\n", ifname);

iface = calloc(1, sizeof(*iface));
if (!iface)
return UBUS_STATUS_UNKNOWN_ERROR;

iface->name = strdup(ifname);
if (!iface->name) {
free(iface);
Expand Down