X-Git-Url: http://git.ipfire.org/?p=people%2Fms%2Fnetwork.git;a=blobdiff_plain;f=src%2Ffunctions%2Ffunctions.device;h=d1f60c436572fee5c48ea825967959631efb3f3c;hp=10677716f11d5195dd9b21b672c93ba8f4057338;hb=5ee61d861950b44ce011c9d9845ca1b38209ac3a;hpb=8707df4b3840a2edaea38cb5dd06cc7fb5bef9a3 diff --git a/src/functions/functions.device b/src/functions/functions.device index 10677716..d1f60c43 100644 --- a/src/functions/functions.device +++ b/src/functions/functions.device @@ -248,13 +248,25 @@ device_get_vlans() { done < ${PROC_NET_VLAN_CONFIG} } +__device_type_matches() { + local device="${1}" + local type="${2}" + + local _type="$(__device_get_file "${device}" "type")" + + if [ "${type}" = "${_type}" ]; then + return ${EXIT_TRUE} + fi + + return ${EXIT_FALSE} +} + # Check if the device is a ppp device device_is_ppp() { - local device=${1} - - local type=$(__device_get_file ${device} type) + local device="${1}" + assert isset device - [ "${type}" = "512" ] && return ${EXIT_OK} || return ${EXIT_ERROR} + __device_type_matches "${device}" 512 } # Check if the device is a pointopoint device. @@ -293,19 +305,17 @@ device_is_wireless() { } device_is_vti() { - local device=${1} - - local type=$(__device_get_file ${device} type) + local device="${1}" + assert isset device - [ "${type}" = "768" ] && return ${EXIT_OK} || return ${EXIT_ERROR} + __device_type_matches "${device}" 768 } device_is_vti6() { - local device=${1} - - local type=$(__device_get_file ${device} type) + local device="${1}" + assert isset device - [ "${type}" = "769" ] && return ${EXIT_OK} || return ${EXIT_ERROR} + __device_type_matches "${device}" 769 } device_get_phy() {