-stp_is_userspace() {
- local bridge=${1}
- assert isset bridge
-
- local state=$(__device_get_file ${bridge} bridge/stp_state)
- case "${state}" in
- 2)
- return ${EXIT_TRUE}
- ;;
- *)
- return ${EXIT_FALSE}
- ;;
- esac
-}
-
-stp_get_name() {
- local proto=${1}
-
- case "${proto}" in
- stp)
- echo "Spanning Tree Protocol"
- ;;
- rstp)
- echo "Rapid Spanning Tree Protocol"
- ;;
- mstp)
- echo "Multiple Spanning Tree Protocol"
- ;;
- esac
-
- return ${EXIT_OK}
-}
-
-stp_bridge_set_protocol() {
- local bridge=${1}
- assert isset bridge
-
- local mode=${2}
- assert isset mode
-
- if ! list_match ${mode} ${STP_ALLOWED_MODES}; then
- log WARNING "Unknown protocol version: ${mode}."
- log WARNING "Using default mode."
-
- mode="${STP_DEFAULT_MODE}"
- fi
-
- cmd mstpctl setforcevers ${bridge} ${mode}
- assert [ $? -eq 0 ]
-}
-
-stp_bridge_get_protocol() {
- local bridge=${1}
-
- assert isset bridge
-
- # Let's check what the kernel is telling us about it's STP state.
- local state=$(__device_get_file ${bridge} "bridge/stp_state")
-
- case "${state}" in
- 0)
- # STP is disabled.
- return ${EXIT_OK}
- ;;
- 1)
- # Kernel mode STP is running.
- echo "stp"
- return ${EXIT_OK}
- ;;
- 2)
- # User-space STP is running.
- ;;
- *)
- log ERROR "Kernel is running in an unknown STP state."
- return ${EXIT_ERROR}
- ;;
- esac
-
- # We get here, when STP is running in user-space mode.
-
- # Get the current protocol version.
- mstpctl showbridge ${bridge} force-protocol-version 2>/dev/null
-
- return ${EXIT_OK}
-}
-