XDANDROID Eclair WiFi Tethering

Most of the devices supported by XDANDROID have had both WiFi and 3G working for a while now. In Windows Mobile, there are third party programs that allow you to bridge the 3G connection to an ad-hoc WiFi connection, providing a wireless tether for a notebook computer. After some work last night, I’ve been able to whip up a solution for WiFi-based tethering for Android on our handsets, complete with a friendly GUI. Read on to see what you’ll need to do for this to work on your XDANDROID phone.

There are a couple of minor system modifications needed to get WiFi tethering to work. The basic pieces needed for WiFi tethering include 3G and WiFi support (which we already have) and kernel and userland tethering support. For those of you familiar with connection sharing in Linux systems, this means that the kernel needs IPTables support with full NAT and masquerading. The userland iptables utility is also necessary, and for simplicity the phone should run a small DHCP server and DNS forwarder to provide autoconfiguration to the notebook computer.

On the kernel side, I’ve built a kernel package with the needed IPTables modules enabled. Each module takes up some memory (as in RAM) while it’s loaded, so we’d like to have those modules unloaded while tethering is inactive. For this, the rootfs must be modified to properly rearrange the modules and provide depmod support (for modprobe and rmmod to work). Otherwise, those utilities would fail complaining about not being able to find modules or locate symbols. I’ve pushed the relevant changes to rootfs and a prebuilt image is now available.

On the userland side, we need an application that can provide IPTables support, a small DHCP server and a DNS forwarder. And of utmost importance is a nice, easy-to-use Android frontend for all of this magic. For this, I’ve decided to use android-wifi-tether as a base, with some minor modifications (see the patch) needed to have it working for our phones. This includes all the original functionality of the app (start an ad-hoc network, set up IPTables rules, and run dnsmasq for DHCP and DNS). In addition, it has to handle our subtle differences for WiFi loading, as well as loading and unloading the IPTables kernel modules as needed. After applying our modifications, I built a new package which end-users should be able to run smoothly. As an added bonus, building with an updated SDK gave us native VGA resolution support. You’ll need to enable Unknown sources in the Android Applications settings.

So, to sum things up:

  • Grab the kernel and modules with IPTables support for tethering
  • Grab the rootfs with modprobe and rmmod support
  • Grab the Android application which does all the magic for you (install it via adb or the sdcard AndroidApps directory). In case you didn’t read, android-wifi-tether won’t work out of the box.

And that’s it. Reboot, try it out, let me know. Thanks!