summaryrefslogtreecommitdiffstats
path: root/package/trelay/files
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-03-28 11:02:38 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2012-03-28 11:02:38 +0000
commit751ddce33684c31f0769eaa05f3c465826e0aaec (patch)
treeea3504f5c5f7d282928600a4ed42474e62073a04 /package/trelay/files
parent36dba7bb1a3db687e7447a4a9266e9a991e3a584 (diff)
add trelay, a trivial ethernet relay which allows pseudo-bridging ad-hoc or client mode devices over vlans to other hosts
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31122 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/trelay/files')
-rw-r--r--package/trelay/files/trelay.config4
-rw-r--r--package/trelay/files/trelay.hotplug5
-rw-r--r--package/trelay/files/trelay.init32
3 files changed, 41 insertions, 0 deletions
diff --git a/package/trelay/files/trelay.config b/package/trelay/files/trelay.config
new file mode 100644
index 000000000..eb0501305
--- /dev/null
+++ b/package/trelay/files/trelay.config
@@ -0,0 +1,4 @@
+config trelay
+ option enabled 0
+ option dev1 eth0
+ option dev2 wlan0
diff --git a/package/trelay/files/trelay.hotplug b/package/trelay/files/trelay.hotplug
new file mode 100644
index 000000000..31f737840
--- /dev/null
+++ b/package/trelay/files/trelay.hotplug
@@ -0,0 +1,5 @@
+case "$ACTION" in
+ add|register)
+ [ -f /var/run/trelay.active ] && /etc/init.d/trelay start
+ ;;
+esac
diff --git a/package/trelay/files/trelay.init b/package/trelay/files/trelay.init
new file mode 100644
index 000000000..c812e12c6
--- /dev/null
+++ b/package/trelay/files/trelay.init
@@ -0,0 +1,32 @@
+#!/bin/sh /etc/rc.common
+START=80
+
+check_relay() {
+ local cfg="$1"
+
+ config_get_bool enabled "$cfg" enabled 1
+ [ "$enabled" -gt 0 ] || return
+
+ config_get dev1 "$cfg" dev1
+ config_get dev2 "$cfg" dev2
+
+ [ -d "/sys/kernel/debug/trelay/${dev1}-${dev2}" ] && return
+ [ -d "/sys/class/net/${dev1}" -a -d "/sys/class/net/${dev2}" ] || return
+
+ ifconfig "$dev1" up
+ ifconfig "$dev2" up
+ echo "${dev1}-${dev2},${dev1},${dev2}" > /sys/kernel/debug/trelay/add
+}
+
+start() {
+ config_load trelay
+ config_foreach check_relay trelay
+ touch /var/run/trelay.active
+}
+
+stop() {
+ rm -f /var/run/trelay.active
+ for relay in /sys/kernel/debug/trelay/*; do
+ [ -d "$relay" ] && echo > "$relay/remove"
+ done
+}