--- a/net/pppd.sh 2008-06-25 12:50:19.136643288 +0100 +++ b/net/pppd.sh 2008-11-19 12:53:03.505238098 +0100 @@ -136,13 +136,14 @@ fi # Add plugins - local haspppoa=false haspppoe=false plugins="$(_get_array "plugins_${IFVAR}")" + local bluetooth=false haspppoa=false haspppoe=false plugins="$(_get_array "plugins_${IFVAR}")" local IFS="$__IFS" for i in ${plugins}; do unset IFS set -- ${i} case "$1" in passwordfd) continue;; + bluetooth) bluetooth=true; continue;; pppoa) shift; set -- "pppoatm" "$@";; pppoe) shift; set -- "rp-pppoe" "$@";; capi) shift; set -- "capiplugin" "$@";; @@ -193,6 +194,50 @@ fi fi + + if ${bluetooth}; then + if [ ! -f /sys/class/bluetooth/rfcomm ]; then + # Load the rfcomm kernel module + if ! modprobe rfcomm; then + eerror "kernel does not support rfcomm" + return 1 + fi + fi + + if [ ! -x "$(which sdptool)" ]; then + # Bluetooth tools are unavailble + if ! modprobe rfcomm; then + eerror "system does not have net-wireless/bluez-utils installed" + return 1 + fi + fi + + local channel hci_if= rfcomm_dev= + eval hci_if=\$hci_${IFVAR} + eval rfcomm_dev=\$rfcomm_${IFVAR} + [ -n "${hci_if}" ] || hci_if="hci0" + [ -n "${rfcomm_dev}" ] || rfcomm_dev="rfcomm$(( ${IFVAR#ppp} + 7 ))" + if [ "${link}" != "/dev/null" ]; then + channel=$(sdptool search --bdaddr "${link}" DUN | + egrep Channel | + cut -d: -f2) + if [ -z ${channel} ]; then + eerror "failed to locate bluetooth DUN service on ${link}" + return 1 + fi + if [ -c /dev/${rfcomm_dev} ]; then + rfcomm -i "${hci_if}" release "${rfcomm_dev}" + fi + if ! ( rfcomm -i "${hci_if}" bind "${rfcomm_dev}" "${link}" "$channel" ); then + eerror "failed to bind rfcomm device ${rfcomm_dev} to ${link} channel ${channel}" + return 1 + fi + link="/dev/${rfcomm_dev}" + else + ewarn "WARNING: A BD Address was expected in link_${IFVAR}" + fi + + fi [ "${insert_link_in_opts}" = "0" ] || opts="${link} ${opts}" ebegin "Starting pppd in ${IFACE}"