Skip to content

Commit

Permalink
Supports E367 now
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jul 6, 2011
1 parent a1042f5 commit 8c458f8
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 15 deletions.
17 changes: 17 additions & 0 deletions bin/natoff
@@ -0,0 +1,17 @@
#!/bin/bash

echo `date` natoff >> /var/log/ppp0

# delete old configuration, if any
#Flush all the rules in filter and nat tables
iptables --flush
iptables --table nat --flush

# delete all chains that are not in default filter and nat table, if any
iptables --delete-chain
iptables --table nat --delete-chain

echo 0 > /proc/sys/net/ipv4/ip_forward

echo 0 > /sys/devices/platform/leds-gpio/leds/beagleboard::pmu_stat/brightness

28 changes: 22 additions & 6 deletions bin/naton
@@ -1,17 +1,33 @@
#!/bin/bash

echo `date` naton to ppp0 >> /var/log/ppp0

# delete old configuration, if any
#Flush all the rules in filter and nat tables
iptables --flush
iptables --flush
iptables --table nat --flush

# delete all chains that are not in default filter and nat table, if any
iptables --delete-chain
iptables --delete-chain
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading (NAT)
iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
iptables --append FORWARD --in-interface usb0 -j ACCEPT

#forward some ports
#iptables -A PREROUTING -t nat -i ppp0 -p tcp --dport 8080 -j DNAT --to 10.1.1.1:80
#iptables -A INPUT -p tcp -m state --state NEW --dport 80 -i ppp0 -j ACCEPT
#iptables -t nat -A PREROUTING -p tcp -i usb0 -d netbox.20hz.co.uk --dport 8080 -j DNAT --to 10.1.1.1:22
#iptables -A INPUT -p tcp -m state --state NEW --dport 22 -i usb0 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i ppp0 -d netbox.hopto.org --dport 8080 -j DNAT --to 10.1.1.1:80
iptables -A FORWARD -p tcp -i ppp0 -o usb0 -d 10.1.1.1 --dport 80 -m state --state NEW -j ACCEPT

#DROP
iptables -I FORWARD -d swscan.apple.com -j DROP
iptables -I FORWARD -d swquery.apple.com -j DROP

#enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
service bind9 start

echo 1 > /sys/devices/platform/leds-gpio/leds/beagleboard::pmu_stat/brightness
4 changes: 3 additions & 1 deletion bin/umtsoff
@@ -1,4 +1,6 @@
#! /bin/sh

/usr/bin/poff
echo `date` umtsoff >> /var/log/ppp0

/usr/bin/poff -a
killall pppd
30 changes: 24 additions & 6 deletions bin/umtson
@@ -1,17 +1,35 @@
#! /bin/sh

if [ "${ACTION}" = "add" ]
then
echo ${DEVICE} >> /var/log/umts.log
if [ -f /tmp/umtson.lock ] ; then
# the lock file already exists, so what to do?
if [ "$(ps -p `cat /tmp/umtson.lock` | wc -l)" -gt 1 ]; then
# process is still running
echo "$0: quit at start: lingering process `cat /tmp/umtson.lock`"
exit 0
else
# process not running, but lock file not deleted?
echo " $0: orphan lock file warning. Lock file deleted."
rm /tmp/umtson.lock
fi
fi

echo $$ > /tmp/umtson.lock

DEV=$1

if [ -z "$1" ] ; then
DEV="/dev/ttyUSB0"
DEV="/dev/ttyUSB2"
fi

echo `date` umtson with port $DEV >> /var/log/ppp0

set -e

#killall pppd

sleep 10
/usr/sbin/pppd $DEV call three
naton

fi
#fi

rm /tmp/umtson.lock
2 changes: 1 addition & 1 deletion peers/three
@@ -1,4 +1,4 @@
/dev/ttyUSB0
# /dev/ttyUSB2
460800
persist
lock
Expand Down
8 changes: 7 additions & 1 deletion rules.d/91-hsdpa-modem.rules
@@ -1 +1,7 @@
ACTION=="add", SUBSYSTEM=="tty", KERNEL=="ttyUSB0", RUN+="/usr/local/bin/umtson"
ACTION=="add", SUBSYSTEM=="usb", PRODUCT=="19d2/31/0", RUN+="/usr/local/bin/umtson /dev/ttyUSB2"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1506", RUN+="/usr/local/bin/umtson /dev/ttyUSB0"

ACTION=="remove", SUBSYSTEM=="usb", PRODUCT=="19d2/31/0", RUN+="/usr/local/bin/umtsoff"
ACTION=="remove", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1506", RUN+="/usr/local/bin/umtsoff"


1 change: 1 addition & 0 deletions rules.d/92-usb-modem.rules
@@ -0,0 +1 @@
SUBSYSTEM=="usb", ACTION=="add", SYSFS{idVendor}=="12d1", SYSFS{idProduct}=="1446", RUN+="/usr/sbin/usb_modeswitch"
13 changes: 13 additions & 0 deletions update
@@ -0,0 +1,13 @@
#!/bin/bash

cp /etc/udev/rules.d/91-hsdpa-modem.rules rules.d/
cp /etc/udev/rules.d/92-usb-modem.rules rules.d/
cp /etc/ppp/peers/three peers/
cp /etc/ppp/peers/three peers/
cp /etc/chatscripts/three chatscripts/
cp /usr/local/bin/umtson bin/
cp /usr/local/bin/umtsoff bin/
cp /usr/local/bin/naton bin/
cp /usr/local/bin/natoff bin/
cp /etc/usb_modeswitch.d/12d1\:1446 usb_modeswitch.d/

11 changes: 11 additions & 0 deletions usb_modeswitch.d/12d1:1446
@@ -0,0 +1,11 @@
EnableLogging=1

DefaultVendor= 0x12d1
DefaultProduct=0x1446

TargetVendor= 0x12d1
TargetProductList="1001,1406,140b,140c,1412,141b,14ac,1506"

CheckSuccess=20

MessageContent="55534243123456780000000000000011062000000100000000000000000000"

0 comments on commit 8c458f8

Please sign in to comment.