alex1491163117 / android-wifi-tether

Automatically exported from code.google.com/p/android-wifi-tether
0 stars 0 forks source link

HTC Legend Tethering on new roms problem and resolution #388

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi

On new roms for htc legend this section works:

basicly its ip route command that makes it work ill put it in three places for 
me it works but if data connection is dropped this command needs to be executed 
one more time after connection will be up i donk know how to work aroud this :)

Roms that will work with this is 
LEGEIMG_Legend_HTC_WWE_2.03.405.3_Radio_47.39.35.09_7.08.35.21 series
for previous ones it was not necessary.

Regards

  getcfg("device.type") == "legend" && (
      #
      # HTC Legend
      #
      run_program("/system/bin/ip route delete table gprs");  
      module_loaded("sdio") || log(insmod("/system/lib/modules/sdio.ko",""), "Loading sdio.ko module");
      module_loaded("tiwlan_drv") || log(insmod("/system/lib/modules/tiwlan_drv.ko", ""), "Loading tiwlan_drv.ko module");
      run_program("/system/bin/tiwlan_loader -f /system/etc/wifi/Fw1273_CHIP.bin -e " +
                  "/proc/calibration -i /system/etc/wifi/tiwlan.ini");
      sleep("3");
      #
      # Bring up wifi interface
      #
      log(run_program("/data/data/android.tether/bin/ifconfig " +getcfg("wifi.interface") + " " +
                  getcfg("ip.gateway") + " netmask " + getcfg("ip.netmask")) &&
                  run_program("/data/data/android.tether/bin/ifconfig " + getcfg("wifi.interface") + " up"),  "Activating WiFi interface");
      log(run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface")
                      + " mode ad-hoc"), "Setting ad-hoc mode");
      log(run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface")
                      + " essid " + getcfg("wifi.essid")), "Setting essid");
      log(run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface")
                      + " channel " + getcfg("wifi.channel")), "Setting channel");

      run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface") + " commit");
      run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface") +" mode ad-hoc essid "+getcfg("wifi.essid")+ " persist &");
      sleep ("4");
      run_program("/system/bin/ip route delete table gprs");
    );

    getcfg("device.type") == "unknown" && (
      #
      # Unknown device
      #    
      log("Unkown device-type. Your device is not supported!");
    );

    #
    # WEP-Encryption
    #
    getcfg("wifi.encryption") == "wep" && (
      getcfg("wifi.setup") == "iwconfig" && (       
        log(run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface") + " key s:"+getcfg("wifi.wepkey")+"") &&
          run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface") + " key restricted"), "Activating encryption<br/>(iwconfig)");
        run_program("/data/data/android.tether/bin/iwconfig " + getcfg("wifi.interface") + " commit");
      );
      getcfg("wifi.setup") == "wpa_supplicant" && (         
        sleep("2");
    log(run_program("cd /data/local/tmp; mkdir /data/local/tmp/wpa_supplicant; wpa_supplicant -B -D" +
      getcfg("wifi.driver") +
      " -i" + getcfg("wifi.interface") +
      " -c/data/data/android.tether/conf/wpa_supplicant.conf"), "Activating encryption<br/>(wpa_supplicant)");
      );
    );
  );

  getcfg("tether.mode") == "bt" && (
    #
    # Set "mode"-Property
    #
    setprop("tether.mode","bt");

    #
    # Bluetooth - start pand
    #
    run_program("/data/data/android.tether/bin/pand --listen --role NAP " +
                "--devup /data/data/android.tether/bin/blue-up.sh " +
                "--devdown /data/data/android.tether/bin/blue-down.sh " +
                "--pidfile /data/data/android.tether/var/pand.pid");
  );

  #
  # Remove old rules
  #
  run_program("/data/data/android.tether/bin/iptables -N wireless-tether");
  run_program("/data/data/android.tether/bin/iptables -F wireless-tether");  
  run_program("/data/data/android.tether/bin/iptables -t nat -F PREROUTING");
  run_program("/data/data/android.tether/bin/iptables -t nat -F POSTROUTING");
  run_program("/data/data/android.tether/bin/iptables -t nat -F");

  #
  # Bring up NAT rules
  #
  log(
    run_program("/data/data/android.tether/bin/iptables -A wireless-tether -m state --state ESTABLISHED,RELATED -j ACCEPT") &&
    run_program("/data/data/android.tether/bin/iptables -A wireless-tether -s " + getcfg("ip.network") + "/24 -j ACCEPT") &&
    run_program("/data/data/android.tether/bin/iptables -A wireless-tether -j DROP") &&
    run_program("/data/data/android.tether/bin/iptables -A FORWARD -j wireless-tether") &&
    run_program("/data/data/android.tether/bin/iptables -t nat -I POSTROUTING -s " +
               getcfg("ip.network") + "/24 -j MASQUERADE"),
    "Enabling NAT rules");

  #
  # IP forwarding
  #
  log(file_write("/proc/sys/net/ipv4/ip_forward", "1"), "Enabling IP forwarding");

  #
  # dnsmasq for wifi tether (bluetooth has pand start it)
  #
  getcfg("tether.mode") == "wifi" &&
      run_program("/data/data/android.tether/bin/dnsmasq -i " + getcfg("wifi.interface") +" "+
                  "--resolv-file=/data/data/android.tether/conf/resolv.conf " +
                  "--conf-file=/data/data/android.tether/conf/dnsmasq.conf");

  #
  # Access control
  #
  file_exists("/data/data/android.tether/conf/whitelist_mac.conf") &&
    log(
      run_program("/data/data/android.tether/bin/iptables -t nat -I PREROUTING -s " + getcfg("ip.network") + "/24 -j DROP") &&
      whitelist_macs("/data/data/android.tether/conf/whitelist_mac.conf"),
    "Enabling access control."
    );
    run_program("/system/bin/ip route delete table gprs");
  log("Tethering now running");
);

Original issue reported on code.google.com by pogo1...@gmail.com on 15 Jun 2010 at 4:11

Attachments:

GoogleCodeExporter commented 9 years ago
Could you please try the latest test-release?
http://android-wifi-tether.googlecode.com/files/wireless_tether_2_0_5-pre2-test1
.apk

This one renames the wifi-interface-name. I don't know if that makes it run 
without deleting that "iproute" but please give it try. 

Deleting that "ip route" is a bit problematic.

Original comment by harald....@gmail.com on 15 Jun 2010 at 8:35

GoogleCodeExporter commented 9 years ago
Ok, I think renaming the interface does not make any difference. Could you 
please check where to find applied routing-rules in /proc (maybe it's in 'cat 
/proc/net/route')?

The only way to solve this problem is to write a background process which 
checks for exactly that rule and removes it. 

Original comment by harald....@gmail.com on 16 Jun 2010 at 8:34

GoogleCodeExporter commented 9 years ago
And ... what shows "ip route show table gprs"? Maybe it would be easier to add 
the wifi-network to the routing table (gprs)?

Original comment by harald....@gmail.com on 16 Jun 2010 at 10:33

GoogleCodeExporter commented 9 years ago
Hi

# ip route show table gprs
ip route show table gprs
91.94.26.80/28 dev rmnet0  scope link  src 91.94.26.87
default via 91.94.26.81 dev rmnet0
#

And

cat /proc/net/route
Iface   Destination     Gateway         Flags   RefCnt  Use     Metric  Mask    
        MTU     Window  IRTT

rmnet0  501A5E5B        00000000        0001    0       0       0       
F0FFFFFF        0       0   0

rmnet0  00000000        511A5E5B        0003    0       0       0       
00000000        0       0   0

Something like that

Original comment by pogo1...@gmail.com on 16 Jun 2010 at 10:02

GoogleCodeExporter commented 9 years ago
Ok thanks. I'm just shooting into the dark. Could you please try this version:
http://android-wifi-tether.googlecode.com/files/wireless_tether_2_0_5-pre3-test2
.apk

It disables /proc/sys/net/ipv4/conf/all/rp_filter
http://kernel.xc.net/html/linux-2.6.0-test4/s390/IP_ADVANCED_ROUTER 

I'm not sure if it helps but I guess it's not worth to try.

Thanks.

Original comment by harald....@gmail.com on 16 Jun 2010 at 10:22

GoogleCodeExporter commented 9 years ago
Hi

It does not work :( maybe version with adding tiwlan0 to gprs routing table 
will work.

Regards 
Jarek

Original comment by pogo1...@gmail.com on 17 Jun 2010 at 6:40

GoogleCodeExporter commented 9 years ago
Yes, maybe. Could you please try something like that:
ip route add table gprs 192.168.2.0/24 dev tiwlan0 scope link

or
ip route add table gprs 192.168.2.0/24 dev tiwlan0 scope link src 192.168.2.100

192.168.2.100 = client-ip-address 

Original comment by harald....@gmail.com on 17 Jun 2010 at 8:59

GoogleCodeExporter commented 9 years ago
or maybe ...

ip route add table gprs 192.168.2.0/24 dev tiwlan0 proto kernel  scope link  
src 192.168.2.254 

Original comment by harald....@gmail.com on 17 Jun 2010 at 10:42

GoogleCodeExporter commented 9 years ago
Hi

this command works:

ip route add table gprs 192.168.2.0/24 dev tiwlan0 proto kernel  scope link  
src 192.168.2.254 

but like i said before when data connection is dropped and reconnected it stops 
working :( I think this is deeper issue

so you have to write some demon to check for existance of sprs table. 

When cellular data connection is active:

# ip route show table gprs
ip route show table gprs
87.96.83.152/29 dev rmnet0  scope link  src 87.96.83.155
default via 87.96.83.153 dev rmnet0

And When it is inactive:
# ip route show table gprs
ip route show table gprs

I dont know it will be possible :) i'm not a programmer. just a storage guy ;)

Regards 

JArek 

Original comment by pogo1...@gmail.com on 18 Jun 2010 at 9:34

GoogleCodeExporter commented 9 years ago
With this version 
http://android-wifi-tether.googlecode.com/files/wireless_tether_2_0_5-pre3-test2
.apk

it took longer to obtain ip adress on client

Original comment by pogo1...@gmail.com on 18 Jun 2010 at 9:44

GoogleCodeExporter commented 9 years ago
Hi again.

Could you please try:
http://android-wifi-tether.googlecode.com/files/wireless_tether_2_0_5-pre3-test3
.apk

After installation (please remove an older version of the app first) you should 
see a script named "fixroute.sh" in /data/data/android.tether/bin.
http://code.google.com/p/android-wifi-tether/source/browse/trunk/res/raw/fixrout
e_sh

This script runs in background and checks if that needed route exists.

Thanks for testing. 

Original comment by harald....@gmail.com on 20 Jun 2010 at 9:14

GoogleCodeExporter commented 9 years ago
Could you please give pre3-test3 a try?
Thanks.

Original comment by harald....@gmail.com on 22 Jun 2010 at 7:21

GoogleCodeExporter commented 9 years ago
Hi i have cheked it and it works :)

when data connection i lost and reconnected tethering works again :)

Regards
Jarek

Original comment by pogo1...@gmail.com on 24 Jun 2010 at 10:07