Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set_3g_led() {
- # set on WRT54G3G only
- [ -d /proc/diag ] || return 0
- grep WRT54G3G /proc/diag/model >/dev/null || return 0
- echo "$1" > /proc/diag/led/3g_green
- echo "$2" > /proc/diag/led/3g_blue
- echo "$3" > /proc/diag/led/3g_blink
- }
- scan_3g() {
- local device
- scan_ppp "$@"
- config_get device "$1" device
- # enable 3G with the 3G button by default
- config_get button "$1" button
- [ -z "$button" ] && {
- config_set "$1" button 1
- }
- }
- stop_interface_3g() {
- set_3g_led 0 0 0
- if ifconfig hso0 2>&- >&- ; then
- /usr/bin/gcom -d "/dev/ttyHS0" -s /etc/gcom/hso-disconnect.gcom
- env -i ACTION="ifdown" INTERFACE="wan" DEVICE="hso0" PROTO=hso /sbin/hotplug-call "iface"
- ifconfig hso0 down
- # remove the interface's network state
- uci_revert_state network "wan"
- fi
- }
- setup_interface_3g() {
- local iface="$1"
- local config="$2"
- config_get device "$config" device
- config_get maxwait "$config" maxwait
- maxwait=${maxwait:-20}
- while [ ! -e "$device" -a $maxwait -gt 0 ];do # wait for driver loading to catch up
- maxwait=$(($maxwait - 1))
- sleep 1
- done
- config_get apn "$config" apn
- config_get service "$config" service
- config_get pincode "$config" pincode
- config_get mtu "$config" mtu
- config_get password "$config" password
- config_get username "$config" username
- case "$service" in
- cdma|gprs*) ledcode="1 0";;
- evdo|umts*) ledcode="0 1";;
- *) ledcode="0 0";; #shouldn't happen
- esac
- set_3g_led $ledcode 1
- #Check to see if it is an HSO or a regular USB device
- if grep "Vendor=0af0" < /proc/bus/usb/devices 2>&- >&- ; then
- for module in rfkill hso; do
- /sbin/insmod $module 2>&- >&-
- done
- RESOLV_CONF="/tmp/resolv.conf.auto"
- DATA=$(USE_PASS="$password" USE_USER="$username" USE_APN="$apn" SERVICE="$service" PINCODE="$pincode" /usr/bin/gcom -d "$device" -s /etc/gcom/hso-connect.gcom)
- DATA=$(echo $DATA | tr -d " " | grep -v ^$)
- IP=$(echo $DATA | cut -d , -f 2)
- DNS1=$(echo $DATA | cut -d , -f 4)
- DNS2=$(echo $DATA | cut -d , -f 5)
- ifconfig hso0 $IP netmask 255.255.255.255 up
- route add default dev hso0
- uci_set_state network "wan" unit "0"
- uci_set_state network "wan" ipaddr "$IP"
- echo "#Configured by HSO" > $RESOLV_CONF
- [ -n "$DNS1" ] && echo "nameserver $DNS1" >> $RESOLV_CONF
- [ -n "$DNS2" ] && echo "nameserver $DNS2" >> $RESOLV_CONF
- local dns="$DNS1${DNS2:+ $DNS2}"
- [ -n "$dns" ] && uci_set_state network "wan" dns "$dns"
- env -i ACTION="ifup" INTERFACE="wan" DEVICE="hso0" PROTO=hso /sbin/hotplug-call "iface"
- else
- for module in usbserial option crc-ccitt slhc ppp_generic ppp_async; do
- /sbin/insmod $module 2>&- >&-
- done
- config_set "$config" "connect" "USE_APN=$apn SERVICE=$service PINCODE=$pincode /usr/bin/gcom -s -d $device /etc/gcom/3g.gcom"
- start_pppd "$config" \
- novj \
- nobsdcomp \
- noauth \
- crtscts \
- updetach \
- ${mtu:+mtu $mtu mru $mtu} \
- 460800 "$device"
- fi
- set_3g_led $ledcode 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement