]> git.ipfire.org Git - people/ms/network.git/blobdiff - functions.stp
network: STP: Make protocol version configureable.
[people/ms/network.git] / functions.stp
index 3474f09d4d8fd89b8fb5523dbf169c0e8bd1956c..a85138f75c8ec67e9943acd38c67f17def5b12db 100644 (file)
 #                                                                             #
 ###############################################################################
 
+function stp_init() {
+       module_load stp
+
+       assert binary_exists brctl
+       assert binary_exists rstpctl
+}
+
+init_register stp_init
+
 # XXX Very slow thing, caching?
 function __rstpctl_cmd() {
        local command=$@
@@ -251,3 +260,39 @@ function __stp_wrapper() {
 
        __${proto_version}_${func} $@
 }
+
+function stp_mode() {
+       : # XXX wanted
+}
+
+function stp_enable() {
+       local bridge=${1}
+
+       assert isset bridge
+       assert zone_exists ${bridge}
+
+       brctl stp ${bridge} on
+
+       local mode=$(zone_config_get ${bridge} STP_MODE)
+
+       case "${mode}" in
+               stp)
+                       rstpctl setforcevers ${bridge} slow
+                       ;;
+               rstp)
+                       rstpctl setforcevers ${bridge} normal
+                       ;;
+               *)
+                       error_log "Unknown protocol version: ${mode}."
+                       ;;
+       esac
+}
+
+function stp_disable() {
+       local bridge=${1}
+
+       assert isset bridge
+       assert zone_exists ${bridge}
+
+       brctl stp ${bridge} off
+}