blob: 222b2f867f33c27e6f4fd351c7218c262f800f69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
timeout=6000
chain_prefix=splash_db_
chain_id_file=/tmp/splash_chain_id
tbl=/tmp/p2ptbl/splash
have_splash_iptable () {
state=${1:-$(fsm get inetable)}
[ "$state" == "queen" ]
}
# $mac
add_splash_iptable () {
iptables -t nat -I $chain_prefix$chain_id \
-m mac --mac-source "$1" -j ACCEPT
}
# $mac $time
add_splash_p2ptbl () {
p2ptbl update $tbl "$1" "${2:-$(($(date +%s) + $timeout))}" br-mesh
}
# determine current splash iptable iteration
chain_id=$(cat $chain_id_file 2>/dev/null || true)
if ! [ "$chain_id" -gt 0 ] &>/dev/null; then
# first -> create id file
chain_id=1
echo $chain_id > $chain_id_file
# create splash p2ptbl and add own MAC addr to it with an at least
# year 2033 timeout
p2ptbl init $tbl
add_splash_p2ptbl \
$(ifconfig br-mesh | egrep -o '([0-9A-F]{2}:){5}[0-9A-F]{2}') \
2000000000
fi
|