From: Michael Tremer Date: Sat, 6 Sep 2014 19:44:13 +0000 (+0200) Subject: wireless monitor: Use proper port name X-Git-Tag: 007~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a23fdc0ecea5960d68c516cf8b41e2d90dda9328;p=network.git wireless monitor: Use proper port name --- diff --git a/src/functions/functions.constants b/src/functions/functions.constants index e47b4c13..1d353831 100644 --- a/src/functions/functions.constants +++ b/src/functions/functions.constants @@ -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" diff --git a/src/functions/functions.device b/src/functions/functions.device index 55654764..3f1a7e46 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -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 diff --git a/src/functions/functions.wireless b/src/functions/functions.wireless index 50358816..eb7b0a7a 100644 --- a/src/functions/functions.wireless +++ b/src/functions/functions.wireless @@ -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" diff --git a/src/udev/network-hotplug b/src/udev/network-hotplug index 9767ac59..09bdd937 100644 --- a/src/udev/network-hotplug +++ b/src/udev/network-hotplug @@ -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