-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provides a simple ICMP based whatching system which changes the AP SSID if the node does not have network connection. Signed-off-by: p4u <p4u@dabax.net>
- Loading branch information
Showing
6 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
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,38 @@ | ||
# | ||
# Copyright (C) 2016 Libre-Mesh.org | ||
# | ||
# This is free software, licensed under the GNU General Public License v3. | ||
# | ||
|
||
include $(TOPDIR)/rules.mk | ||
|
||
GIT_COMMIT_DATE:=$(shell git log -n 1 --pretty=%ad --date=short . ) | ||
GIT_COMMIT_TSTAMP:=$(shell git log -n 1 --pretty=%at . ) | ||
|
||
PKG_NAME:=lime-auto-ap-watchping | ||
PKG_VERSION=$(GIT_COMMIT_DATE)-$(GIT_COMMIT_TSTAMP) | ||
|
||
include $(INCLUDE_DIR)/package.mk | ||
|
||
define Package/$(PKG_NAME) | ||
TITLE:=Automatic AP failing ssid control based on watchping | ||
SECTION:=lime | ||
CATEGORY:=LiMe | ||
MAINTAINER:=Pau Escrich <p4u@dabax.et> | ||
URL:=http://libre-mesh.org | ||
DEPENDS:=+watchping | ||
endef | ||
|
||
define Package/$(PKG_NAME)/description | ||
Watchping hooks and daemon for automatic AP ssid changing if network problems | ||
endef | ||
|
||
define Build/Compile | ||
endef | ||
|
||
define Package/$(PKG_NAME)/install | ||
$(INSTALL_DIR) $(1)/ | ||
$(CP) ./files/* $(1)/ | ||
endef | ||
|
||
$(eval $(call BuildPackage,$(PKG_NAME))) |
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,15 @@ | ||
In MESH networks with high density of nodes, | ||
if a single node is working wrong (bad channel, VLAN, random crash, etc.), | ||
as the AP SSID is always the same, the client devices attach to it | ||
will keep trying to use it, but their network connection will be broken. | ||
|
||
Instead, lime-auto-ap-watchping provides a simple ICMP based whatching system | ||
which changes the AP SSID to let other nodes working handle the clients. | ||
By default the new SSID will be $HOSTNAME-down, so it will be easy to find and fix it if possible. | ||
Because of the layer2 batman-adv roaming feature included in libre-mesh, | ||
clients won't even notice the difference if there is another neighbour node which can handle them. | ||
|
||
There are two options available in lime.network config file: | ||
|
||
1. autoap_enabled: [1/0] turn on/off this feature | ||
2. autoap_hosts: list of hosts used for whatchping, usually one or more backbone nodes of the network |
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,46 @@ | ||
#!/bin/sh /etc/rc.common | ||
# Copyright (C) 2016 libre-mesh.org | ||
# This is free software, licensed under the GNU General Public License v3. | ||
|
||
START=99 | ||
|
||
PIDFILE="/tmp/run/autoAP" | ||
|
||
load_autoAP() { | ||
config_load lime | ||
config_get enabled network autoap_enabled | ||
config_get hosts network autoap_hosts | ||
[ -z "$enabled" -o $enabled -eq 0 ] && { | ||
echo "autoAP disabled in lime config" | ||
exit 0 | ||
} | ||
pinghosts=${hosts:-8.8.8.8 8.8.4.4} | ||
timeout=120 | ||
pinginterval=20 | ||
interface=autoAP | ||
/usr/bin/watchping none "$timeout" "$pinghosts" "$pinginterval" "$interface" 2>/tmp/autoAP.err.log & | ||
[ $? -eq 0 ] && { | ||
echo $! >> "${PIDFILE}" | ||
echo "autoAP wathcping started" | ||
logger -t autoAP "watchping started" | ||
} || { | ||
echo "error starting watchping" | ||
logger -t autoAP "error starting watchping" | ||
} | ||
} | ||
|
||
stop() { | ||
[ -f "$PIDFILE" ] && { | ||
kill -9 $(cat $PIDFILE) | ||
rm -f "$PIDFILE" | ||
logger -t autoAP "Stopped" | ||
} | ||
} | ||
|
||
start() { | ||
[ -f "$PIDFILE" ] && { | ||
echo "Already started" | ||
exit 1 | ||
} | ||
load_autoAP | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/lime-auto-ap-watchping/files/etc/uci-defaults/91_autoAP
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,4 @@ | ||
#!/bin/sh | ||
uci -q get lime.network.autoap_enabled || uci set lime.network.autoap_enabled=0 | ||
uci -q get lime.network.autoap_hosts || uci set lime.network.autoap_hosts="8.8.8.8 8.8.4.4" | ||
exit 0 |
27 changes: 27 additions & 0 deletions
27
packages/lime-auto-ap-watchping/files/etc/watchping/autoAP-fail.d/auto-ap
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,27 @@ | ||
#!/bin/sh | ||
FAIL_SSID_TEMPLATE="#hostname-down" | ||
TMP_DIR="/tmp/auto-ap" | ||
mkdir -p $TMP_DIR | ||
|
||
[ -f $TMP_DIR/autoAP.fail-state ] && echo "Already in fail state, doing nothing" && exit 0 | ||
|
||
set_ap_fail() { | ||
uci_url=$(echo $1 | cut -d= -f1) | ||
ssid=$(echo $1 | cut -d= -f2 | tr -d \') | ||
ap_name=$(echo $1 | cut -d. -f2) | ||
# Save original SSID | ||
echo $ssid > $TMP_DIR/$ap_name | ||
# Set fail essid | ||
fail_ssid=$(echo $FAIL_SSID_TEMPLATE | sed s/#hostname/$HOSTNAME/g) | ||
uci set ${uci_url}=$fail_ssid | ||
logger -t autoAP "Change AP ssid for $ap_name to $fail_ssid" | ||
} | ||
# Get ssid and uci url from APs | ||
for ap in $(uci show wireless | egrep "lm_.*_ap_.*ssid") | ||
do | ||
set_ap_fail $ap | ||
done | ||
rm -f $TMP_DIR/autoAP.ok-state | ||
touch $TMP_DIR/autoAP.fail-state | ||
wifi |
30 changes: 30 additions & 0 deletions
30
packages/lime-auto-ap-watchping/files/etc/watchping/autoAP-ok.d/auto-ap
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,30 @@ | ||
#!/bin/sh | ||
TMP_DIR="/tmp/auto-ap" | ||
mkdir -p $TMP_DIR | ||
|
||
[ -f $TMP_DIR/autoAP.ok-state ] && logger -t autoAP "Already in OK state, doing nothing" && exit 0 | ||
|
||
set_ap_ok() { | ||
uci_url=$(echo $1 | cut -d= -f1) | ||
ssid=$(echo $1 | cut -d= -f2 | tr -d \') | ||
ap_name=$(echo $1 | cut -d. -f2) | ||
|
||
ssid=$(cat $TMP_DIR/$ap_name 2>/dev/null) | ||
[ -z "$ssid" ] && return | ||
|
||
# Set original essid | ||
uci set ${uci_url}=$ssid | ||
logger -t autoAP "Change AP ssid from $ap_name to $ssid" | ||
rm -f $TMP_DIR/$ap_name | ||
} | ||
|
||
# Get original ssid and uci url | ||
for ap in $(uci show wireless | egrep "lm_.*_ap_.*ssid" | cut -d= -f1) | ||
do | ||
set_ap_ok $ap | ||
done | ||
|
||
# Apply changes | ||
rm -f $TMP_DIR/autoAP.fail-state | ||
touch $TMP_DIR/autoAP.ok-state | ||
wifi |
a278018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's a silly question but, just to be sure:
is the automatic change of ESSID going to trigger the change in batadv vlan as would happen with the current default configuration when changing the essid manually in the config files as documented here?
Thanks
a278018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a278018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great :D