]> git.ipfire.org Git - people/stevee/network.git/commitdiff
wireless monitor: Use proper port name
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 19:44:13 +0000 (21:44 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 19:44:13 +0000 (21:44 +0200)
src/functions/functions.constants
src/functions/functions.device
src/functions/functions.wireless
src/udev/network-hotplug

index e47b4c13da9f25ef71df4f26a4a582eb889790f1..1d353831e54d35fcedaa0a76faa832a0b552a33b 100644 (file)
@@ -86,3 +86,4 @@ PORT_PATTERN_ACCESSPOINT="apN"
 PORT_PATTERN_BATMAN_ADV="batN"
 PORT_PATTERN_BATMAN_ADV_PORT="batpN"
 PORT_PATTERN_WIRELESS="wN"
+PORT_PATTERN_WIRELESS_MONITOR="wmonN"
index 55654764da967a24277f8c1ebf3f232f6f681f6f..3f1a7e46e015ffc32b041484741ccc90c47f4b53 100644 (file)
@@ -73,6 +73,19 @@ function device_exists() {
        serial_exists ${device}
 }
 
+function device_matches_pattern() {
+       local device="${1}"
+       assert isset device
+
+       local pattern="${2}"
+       assert isset pattern
+
+       pattern="^${pattern//N/[[:digit:]]+}$"
+
+       [[ ${device} =~ ${pattern} ]] \
+               && return ${EXIT_TRUE} || return ${EXIT_FALSE}
+}
+
 function device_delete() {
        local device=${1}
        assert isset device
@@ -193,6 +206,14 @@ function device_is_bridge_attached() {
        [ -d "${SYS_CLASS_NET}/${device}/brport" ]
 }
 
+function device_is_wireless_monitor() {
+       local device="${1}"
+       assert isset device
+
+       device_is_wireless "${device}" && \
+               device_matches_pattern "${device}" "${PORT_PATTERN_WIRELESS_MONITOR}"
+}
+
 function device_get_bridge() {
        local device=${1}
        assert isset device
index 50358816aa90c24d77238d936a29c4744edaa07f..eb7b0a7aa7524387fac35cb155928eaa2c7c4f6e 100644 (file)
@@ -249,7 +249,7 @@ function wireless_monitor() {
        assert isset device
        shift
 
-       local monitor_device="mon$$"
+       local monitor_device="$(port_find_free "${PORT_PATTERN_WIRELESS_MONITOR}")"
 
        # Create an 802.11 monitoring device
        wireless_create "${monitor_device}" --phy="${device}" --type="monitor"
index 9767ac59b6a36560b56c1f26bab5706ad862b675..09bdd937d4b0294bf665bb54449c6be061466b33 100644 (file)
@@ -36,6 +36,11 @@ assert isset INTERFACE
 # Check, if the device is a physical network interface and
 # if we can handle it.
 if device_exists ${INTERFACE}; then
+       # Skip wireless monitor devices
+       if device_is_wireless_monitor "${INTERFACE}"; then
+               exit ${EXIT_OK}
+       fi
+
        type="$(device_get_type "${INTERFACE}")"
        case "${type}" in
                # Remove automatically created bonding interface without any configuration