move batman-adv files to subdirectory
[feed/routing.git] / batman-adv / files / lib / netifd / proto / batadv.sh
diff --git a/batman-adv/files/lib/netifd/proto/batadv.sh b/batman-adv/files/lib/netifd/proto/batadv.sh
new file mode 100644 (file)
index 0000000..632a209
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_batadv_init_config() {
+       proto_config_add_string "mesh"
+}
+
+proto_batadv_setup() {
+       local config="$1"
+       local iface="$2"
+
+       local mesh
+       json_get_vars mesh
+
+       echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface"
+       proto_init_update "$iface" 1
+       proto_send_update "$config"
+}
+
+proto_batadv_teardown() {
+       local config="$1"
+       local iface="$2"
+
+       echo "none" > "/sys/class/net/$iface/batman_adv/mesh_iface" || true
+}
+
+add_protocol batadv