-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge wifi respondd modules to one wifi statistics modul
- Loading branch information
Showing
17 changed files
with
183 additions
and
226 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
include $(TOPDIR)/rules.mk | ||
|
||
PKG_NAME:=respondd-module-wifi | ||
PKG_VERSION:=1 | ||
PKG_RELEASE:=1 | ||
|
||
PKG_LICENSE:=BSD-2-Clause | ||
|
||
PKG_BUILD_DEPENDS := respondd | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/respondd-module-wifi/Default | ||
SECTION:=net | ||
CATEGORY:=Network | ||
TITLE:=Add wifi statistics to respondd | ||
DEPENDS:=+respondd +libnl-tiny | ||
endef | ||
|
||
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny | ||
|
||
define Package/respondd-module-wifi | ||
$(call Package/respondd-module-wifi/Default) | ||
endef | ||
|
||
define Package/respondd-module-gluonwifi | ||
$(call Package/respondd-module-wifi/Default) | ||
VARIANT:=gluon | ||
TARGET_CFLAGS += -DGLUON | ||
endef | ||
|
||
define Package/respondd-module-wifi/install | ||
$(INSTALL_DIR) $(1)/usr/lib/respondd | ||
$(CP) $(PKG_BUILD_DIR)/respondd.so $(1)/usr/lib/respondd/wifi.so | ||
endef | ||
|
||
Package/respondd-module-gluonwifi/install = $(Package/respondd-module-wifi/install) | ||
|
||
$(eval $(call BuildPackage,respondd-module-wifi)) |
24 changes: 21 additions & 3 deletions
24
net/respondd-module-airtime/README.md → net/respondd-module-wifi/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <linux/nl80211.h> | ||
#include <netlink/genl/genl.h> | ||
|
||
#include "netlink.h" | ||
#include "clients.h" | ||
|
||
static int station_client_handler(struct nl_msg *msg, void *arg) { | ||
int *count = (int *) arg; | ||
|
||
(*count)++; | ||
|
||
return NL_SKIP; | ||
} | ||
bool get_client_counts(int *count, int ifx) { | ||
return nl_send_dump(station_client_handler, count, NL80211_CMD_GET_STATION, ifx); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
__attribute__((visibility("hidden"))) bool get_client_counts(int *count, int ifx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
net/respondd-module-airtime/src/ifaces.h → net/respondd-module-wifi/src/ifaces.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include <json-c/json.h> | ||
#include <respondd.h> | ||
|
||
#include "airtime.h" | ||
#include "clients.h" | ||
#include "ifaces.h" | ||
|
||
static struct json_object *respondd_provider_statistics(void) { | ||
struct json_object *result, *wireless, *clients, *interface; | ||
struct iface_list *ifaces; | ||
int wifi24 = 0, wifi5 = 0, clients_count; | ||
|
||
result = json_object_new_object(); | ||
if (!result) | ||
return NULL; | ||
|
||
wireless = json_object_new_array(); | ||
if (!wireless) { | ||
//TODO why needed? : json_object_put(result); | ||
return NULL; | ||
} | ||
|
||
clients = json_object_new_object(); | ||
if (!clients) { | ||
return NULL; | ||
} | ||
|
||
ifaces = get_ifaces(); | ||
while (ifaces != NULL) { | ||
clients_count = 0; | ||
get_client_counts(&clients_count, ifaces->ifx); | ||
if (ifaces->frequency < 5000) | ||
wifi24 += clients_count; | ||
if (ifaces->frequency > 5000) | ||
wifi5 += clients_count; | ||
|
||
//TODO wiphy only one radio added? (no necessary on gluon - only one ap-ssid at radio) | ||
interface = json_object_new_object(); | ||
if (!interface) { | ||
continue; | ||
} | ||
json_object_object_add(interface, "frequency", json_object_new_int(ifaces->frequency)); | ||
json_object_object_add(interface, "txpower", json_object_new_int(ifaces->txpower)); | ||
get_airtime(interface, ifaces->ifx); | ||
//TODO remove at merge radios (one wiphy radio) | ||
json_object_object_add(interface, "clients", json_object_new_int(clients_count)); | ||
json_object_array_add(wireless, interface); | ||
|
||
void *freeptr = ifaces; | ||
ifaces = ifaces->next; | ||
free(freeptr); | ||
} | ||
|
||
//TODO maybe skip: if (wifi24 > 0 || wifi5 > 0) { | ||
json_object_object_add(clients, "wifi24", json_object_new_int(wifi24)); | ||
json_object_object_add(clients, "wifi5", json_object_new_int(wifi5)); | ||
json_object_object_add(result, "clients", clients); | ||
//} | ||
|
||
json_object_object_add(result, "wireless", wireless); | ||
return result; | ||
} | ||
|
||
const struct respondd_provider_info respondd_providers[] = { | ||
{"statistics", respondd_provider_statistics}, | ||
{0, 0}, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.