+
+ config_get ipaddr "$cfg" ipaddr
+ config_get netmask "$cfg" netmask
+
+ [ -n "$ipaddr" ] && {
+ iptables -t nat -I luci_splash_prerouting -d "$ipaddr/${netmask:-32}" -j RETURN
+ iptables -t filter -I luci_splash_forwarding -d "$ipaddr/${netmask:-32}" -j RETURN
+ }
+}
+
+qos_iface_add() {
+ local iface="$1"
+
+ # 77 -> download root qdisc
+ # 78 -> upload root qdisc
+ # 79 -> fwmark: client->inet
+ # 80 -> fwmark: inet->client
+
+ silent tc qdisc del dev "$iface" root handle 77:
+
+ if [ "$LIMIT_UP" -gt 0 -a "$LIMIT_DOWN" -gt 0 ]; then
+ tc qdisc add dev "$iface" root handle 77: htb
+
+ # assume maximum rate of 20.000 kilobit for wlan
+ tc class add dev "$iface" parent 77: classid 77:1 htb rate 20000kbit
+
+ # set download limit and burst
+ tc class add dev "$iface" parent 77:1 classid 77:10 htb \
+ rate ${LIMIT_DOWN}kbit ceil ${LIMIT_DOWN_BURST}kbit prio 2
+
+ tc qdisc add dev "$iface" parent 77:10 handle 78: sfq perturb 10
+
+ # adding ingress can result in "File exists" if qos-scripts are active
+ silent tc qdisc add dev "$iface" ingress
+
+ # set client download speed
+ tc filter add dev "$iface" parent 77: protocol ip prio 2 \
+ handle 80 fw flowid 77:10
+
+ # set client upload speed
+ tc filter add dev "$iface" parent ffff: protocol ip prio 1 \
+ handle 79 fw police rate ${LIMIT_UP}kbit mtu 6k burst 6k drop
+ fi
+}
+
+qos_iface_del() {
+ local iface="$1"
+
+ silent tc qdisc del dev "$iface" root handle 77:
+ silent tc qdisc del dev "$iface" root handle 78:
+ silent tc filter del dev "$iface" parent ffff: protocol ip prio 1 handle 79 fw
+}
+
+boot() {
+ ### Setup splash-relay
+ uci get uhttpd.splash 2>/dev/null || {
+uci batch <<EOF
+ set uhttpd.splash=uhttpd
+ set uhttpd.splash.home="/www/cgi-bin/splash/"
+ set uhttpd.splash.interpreter=".sh=/bin/ash"
+ set uhttpd.splash.listen_http="8082"
+ set uhttpd.splash.index_page="splash.sh"
+ set uhttpd.splash.error_page="/splash.sh"
+
+ commit uhttpd
+EOF
+ }
+
+ ### We are started by the firewall include
+ exit 0