Compare commits
8 Commits
0795a06975
...
5e60d6c115
Author | SHA1 | Date |
---|---|---|
Daniel Ehlers | 5e60d6c115 | |
Matthias Schiffer | 53ea3b8977 | |
Matthias Schiffer | 28a35ea2c9 | |
Matthias Schiffer | dc99bbb906 | |
Christian Buschau | 2cf0156fd7 | |
Matthias Schiffer | ce2e6ac193 | |
Daniel Ehlers | c86c249db4 | |
Daniel Ehlers | 0da60862c5 |
|
@ -1 +0,0 @@
|
|||
template/nosysupgrade.c
|
|
@ -0,0 +1 @@
|
|||
template/subtarget.c
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
Copyright (c) 2015, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <libplatforminfo.h>
|
||||
#include "../common.h"
|
||||
|
||||
|
||||
#define _STRINGIFY(s) #s
|
||||
#define STRINGIFY(s) _STRINGIFY(s)
|
||||
|
||||
|
||||
static char * model = NULL;
|
||||
|
||||
|
||||
__attribute__((constructor)) static void init(void) {
|
||||
model = read_line("/tmp/sysinfo/model");
|
||||
}
|
||||
|
||||
__attribute__((destructor)) static void deinit(void) {
|
||||
free(model);
|
||||
|
||||
model = NULL;
|
||||
}
|
||||
|
||||
|
||||
const char * platforminfo_get_board_name(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char * platforminfo_get_model(void) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const char * platforminfo_get_image_name(void) {
|
||||
return STRINGIFY(TARGET) "-" STRINGIFY(SUBTARGET);
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2015, Matthias Schiffer <mschiffer@universe-factory.net>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include <libplatforminfo.h>
|
||||
#include "../common.h"
|
||||
|
||||
|
||||
#define _STRINGIFY(s) #s
|
||||
#define STRINGIFY(s) _STRINGIFY(s)
|
||||
|
||||
|
||||
static char * model = NULL;
|
||||
|
||||
|
||||
__attribute__((constructor)) static void init(void) {
|
||||
model = read_line("/tmp/sysinfo/model");
|
||||
}
|
||||
|
||||
__attribute__((destructor)) static void deinit(void) {
|
||||
free(model);
|
||||
|
||||
model = NULL;
|
||||
}
|
||||
|
||||
|
||||
const char * platforminfo_get_board_name(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char * platforminfo_get_model(void) {
|
||||
return model;
|
||||
}
|
||||
|
||||
const char * platforminfo_get_image_name(void) {
|
||||
return STRINGIFY(TARGET) "-" STRINGIFY(SUBTARGET);
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
template/subtarget.c
|
|
@ -0,0 +1,33 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=roamguide
|
||||
PKG_VERSION:=0.0.4
|
||||
PKG_RELEASE:=$(GLUON_BRANCH)
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(TOPDIR)/../package/gluon.mk
|
||||
|
||||
define Package/roamguide
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+micrond
|
||||
TITLE:=Helps your client to search for a better AP and have a nice roam experience.
|
||||
endef
|
||||
|
||||
define Package/roamguide/description
|
||||
Helps your client to search for a better AP and have a nice roam experience.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/roamguide/install
|
||||
$(CP) ./files/* $(1)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,roamguide))
|
|
@ -0,0 +1,47 @@
|
|||
ROAM-Guide
|
||||
----------
|
||||
|
||||
Helps your clients to search for a better AP and to have a nice roaming experience.
|
||||
|
||||
The roaming guide runs as a cronjob every minute on your ap and verifies that clients
|
||||
have an acceptable TQ towards the AP. If that isn't the case it will deauth the client
|
||||
by stating that the AP is full, enabling the client to look for an alternative AP.
|
||||
|
||||
This is happening in three definable stages depending on the TQ of the client.
|
||||
When a client has decided to come back after the ban-time it will not be bothered
|
||||
again unless it depletes to the next TQ level or it has been kicked $stage times.
|
||||
For every stage the client is guided, the ban time will be increased. So by default
|
||||
the first stage has a bantime of 500ms, the second 2775ms and the third 10000ms.
|
||||
|
||||
When a client is away for some definable time or is below the first stages TQ,
|
||||
it will be forgotten, and the guiding will be re-enable.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
In '/etc/config/roamguide' the following default configuration is available,
|
||||
to activate it you need to set enabled to '1'.
|
||||
|
||||
config roamguide
|
||||
option device "client0" # wireless AP device we like to guide
|
||||
list signal '-60' # first penality level, in dBm
|
||||
list signal '-77' # second penality level, in dBm
|
||||
list signal '-85' # final penality level. in dBm
|
||||
option bantime_base '500' # on the first level ban for 500ms
|
||||
option bantime_factor '2375' # on the second one for 2775ms,
|
||||
# and in the final 10000ms
|
||||
option forget_time '600' # Forget about a client after 10s
|
||||
option enabled '0' # set to '1' to enable this profile
|
||||
|
||||
This module creates a cronjob calling /usr/bin/roamguide once a minute.
|
||||
If you want to make roamguide more reactive (but also stress your device) you can add some more cron jobs with sleep timers in /usr/lib/micron.d/root:
|
||||
|
||||
* * * * * sleep 20 & /usr/bin/roamguide
|
||||
* * * * * sleep 40 & /usr/bin/roamguide
|
||||
|
||||
### Testing tools
|
||||
|
||||
This will show you the stats, where you are connected to on your client:
|
||||
|
||||
watch -d -n0,5 iw dev $(ip -o -4 route show to default | awk '{print $5}') station dump
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# repeat the following for every wireless AP device you like to guide.
|
||||
config roamguide
|
||||
option device "client0" # wireless AP device we like to guide
|
||||
list signal '-60' # first penality level
|
||||
list signal '-77' # second penality level
|
||||
list signal '-85' # final penality level
|
||||
option bantime_base '500' # on the first level ban for 500ms
|
||||
option bantime_factor '2375' # on the second one for 2775ms,
|
||||
# and in the final 10000ms
|
||||
option forget_time '600' # Forget about a client after 10s
|
||||
option enabled '1' # set to '0' to disable this profile
|
|
@ -0,0 +1,106 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
LOCK="/tmp/roamguide.lock"
|
||||
|
||||
try_lock(){
|
||||
mkdir "$LOCK" || echo "Already running!"
|
||||
trap "rm $LOCK" EXIT
|
||||
}
|
||||
|
||||
wifi_kick(){
|
||||
local dev="$1" ; shift
|
||||
local mac="$1" ; shift
|
||||
local bantime="$1" ; shift
|
||||
ubus call hostapd.${dev} del_client '{ "addr" : "'${mac}'", "reason" : "assoc toomany", "ban_time" : '${bantime}' }'
|
||||
}
|
||||
|
||||
count_file(){
|
||||
echo "/tmp/roam-${1}-${2}"
|
||||
}
|
||||
|
||||
count_get(){
|
||||
local fn=$(count_file $@)
|
||||
if [ -e "$fn" ] ; then
|
||||
touch "$fn"
|
||||
cat $fn
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
}
|
||||
|
||||
count_inc(){
|
||||
expr $(count_get $@) + 1 > $(count_file $@)
|
||||
}
|
||||
|
||||
count_dec(){
|
||||
$(expr $(count_get $@) - 1) > $(count_file $@)
|
||||
}
|
||||
|
||||
count_rm(){
|
||||
local fn=$(count_file $@)
|
||||
if [ -e $fn ] ; then
|
||||
logger -s -t roamguide "forget" $@
|
||||
rm $fn
|
||||
fi
|
||||
}
|
||||
|
||||
count_cleanup() {
|
||||
local device="$1" ; shift
|
||||
local current_time=$(date +%s)
|
||||
for file in $(find /tmp -maxdepth 1 -name "roam-${device}-*" -type f ); do
|
||||
[ "$(expr "$current_time" - $(date +%s -r $file))" -gt "$forget_time" ] && rm $file
|
||||
done
|
||||
}
|
||||
|
||||
client_macs() {
|
||||
local dev="$1"
|
||||
iw dev "${dev}" station dump | grep Station | sed -e 's/^[^ ]\+ \([0-9a-z:]*\) .*/\1/'
|
||||
}
|
||||
|
||||
client_tq() {
|
||||
local dev="$1"
|
||||
local mac="$2"
|
||||
iw dev "${dev}" station get "${mac}" | grep "signal avg" | xargs | cut -d' ' -f 3
|
||||
}
|
||||
|
||||
roamguide() {
|
||||
local s="$1"
|
||||
config_get_bool enabled "$s" 'enabled' 0
|
||||
[ $enabled -ne 0 ] || return 0
|
||||
|
||||
config_get device "$s" device
|
||||
config_get forget_time "$s" forget_time 600
|
||||
config_get bantime_base "$s" bantime_base 500
|
||||
config_get bantime_factor "$s" bantime_factor 2375
|
||||
|
||||
for mac in $(client_macs "${device}") ; do
|
||||
tq=$(client_tq "${device}" "${mac}")
|
||||
level=1
|
||||
config_list_foreach "$s" signal roamlevel "${tq}" "${device}" "${mac}"
|
||||
done
|
||||
count_cleanup ${device}
|
||||
}
|
||||
|
||||
roamlevel(){
|
||||
local roam_tq="$1" ; shift
|
||||
local tq="$1" ; shift
|
||||
local device="$1" ; shift
|
||||
local mac="$1" ; shift
|
||||
if [ ${tq} -le ${roam_tq} ]; then
|
||||
mac_count=$(count_get "${device}" "${mac}")
|
||||
if [ $mac_count -lt $level ] ; then
|
||||
count_inc ${device} ${mac}
|
||||
local bantime=$(expr $bantime_base + $(expr $mac_count \* $mac_count) \* $bantime_factor)
|
||||
logger -s -t roamguide "${device}: ban ${mac} ${tq}dBm for ${bantime}ms"
|
||||
wifi_kick "${device}" "${mac}" "${bantime}"
|
||||
break # quits config_list_foreach
|
||||
fi
|
||||
fi
|
||||
level=$(expr $level + 1)
|
||||
}
|
||||
|
||||
try_lock
|
||||
config_load 'roamguide'
|
||||
config_foreach roamguide 'roamguide'
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOCK="/tmp/roamguide-loop.lock"
|
||||
|
||||
try_lock(){
|
||||
mkdir "$LOCK" || echo "Already running!"
|
||||
trap "rmdir $LOCK" EXIT
|
||||
}
|
||||
|
||||
/sbin/logread -f -e '\<hostapd\>.*\<associated\>' |\
|
||||
while read line ; do
|
||||
/usr/bin/roamguide
|
||||
done
|
|
@ -0,0 +1 @@
|
|||
* * * * * /usr/bin/roamguide
|
|
@ -1,9 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=simple-tc
|
||||
PKG_VERSION:=2
|
||||
|
||||
PKG_CONFIG_DEPENDS := CONFIG_KERNEL_NET_SCH_TBF CONFIG_KERNEL_NET_SCH_INGRESS CONFIG_KERNEL_NET_CLS_BASIC KERNEL_NET_ACT_POLICE
|
||||
PKG_VERSION:=3
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
@ -11,7 +9,7 @@ define Package/simple-tc
|
|||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Simple bandwidth limiting
|
||||
DEPENDS:=+!KERNEL_NET_SCH_TBF:kmod-sched-core +!KERNEL_NET_SCH_INGRESS:kmod-sched-core +!KERNEL_NET_CLS_BASIC:kmod-sched +!KERNEL_NET_ACT_POLICE:kmod-sched +libnl-tiny
|
||||
DEPENDS:=+kmod-sched-core +kmod-sched-act-police +libnl-tiny
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
|
||||
|
|
Loading…
Reference in New Issue