HIPL on Android

This section explains how to install HIP on Android (emulator or a real device). See http://infrahip.hiit.fi/hipl/contrib/android/ for binary images.

Prerequisites

  1. The kernel needs to be updated to support the various features required by HIPL that aren't present in the standard distribution. These include ipv6 support and various IPSec- and packet filtering related options

  2. iptables and ip6tables tool. Android ships with iptables, so we would also need ip6tables

  3. Any ipv6 ready tool for testing connectivity. Like ping6 or wget

  4. There is no DNS proxy support. The one in HIPL is written in python, which cannot be run in Android due to lack of python support. So the mappings will have to be added in "/etc/hosts" or "/data/hip/hosts" file

  5. There is no LD_PRELOAD support. The reasons being: Android'd linker doesn't have support for LD_PRELOAD environment variable, and also most of the Android applications are java based, they are launched in a different way, not much use for LD_PRELOAD.

Installing/Running from pre-compiled binaries

We are providing precompiled images for emulator and Android "HTC Dream" G1, though they may not be always uptodate, so compiling from source is recommended.

  1. Emulator

    1. Download and unzip the SDK (android-sdk-hipl*.zip) from the infrahip page

    2. Run the emulator

      $ cd android-sdk
      $ tools/emulator -data platforms/android-1.5/images/userdata.img &
                      

    3. Test the connection

      $ tools/adb shell # Log into emulator shell
      # hipd -k 2>/dev/null &
      # hipfw -klpF 2>/dev/null &
      # hipconf add map 2001:1b:a9be:c6a6:34e5:8361:c07f:a990 193.167.187.134 # We don't have dns proxy
      # wget http://[2001:001b:a9be:c6a6:34e5:8361:c07f:a990] -O- #LSI also can be used here

      If you need to see the output, run each binary in its own "adb shell".

  2. Device - Android "HTC Dream" G1

    Please see here for more generic details

    1. Download the pre-compiled flashable images(android-dream-hipl*.zip) from the infrahip page and unzip them

    2. Flash the downloaded images(boot.img and system.img) into device by following the instructions at HTC page. We don't need to update all the images, just the boot and system images.

      $ ./fastboot boot boot.img
      $ ./fastboot system system.img

      WARNING: The system and boot partitions will be overwritten, though the data partition would remain same

    3. Test the connection

      Remember to connect the device into USB port

      $ tools/adb shell # Log into device shell
      # hipd -k 2>/dev/null &
      # hipfw -klpF 2>/dev/null &
      # hipconf add map 2001:1b:a9be:c6a6:34e5:8361:c07f:a990 193.167.187.134 # We don't have dns proxy
      # wget http://[2001:001b:a9be:c6a6:34e5:8361:c07f:a990] -O- #LSI also can be used here

      If you need to see the output, run each binary in its own "adb shell".

Compiling from source

This section explains how to compile HIP either for emulator or a device

  1. Compiling for emulator

    1. Get source by following the guidelines specified at android.com. Use "cupcake" branch

    2. Inside .repo directory(within android source directory), create a file called "local_manifest.xml". This file contains description of extra packages required for HIP support

      <?xml version="1.0" encoding="UTF-8"?>
      <manifest>
        <remote  name="surki-github" fetch="git://github.com/surki/" />
      
        <remove-project name="platform/external/iptables" />
      
        <project path="kernel" name="kernel/common" revision="refs/heads/android-goldfish-2.6.29" />
        <project path="external/iptables" name="iptables" revision="refs/heads/android-hipl" remote="surki-github" />
        <project path="external/wget" name="wget" revision="refs/heads/android-hipl" remote="surki-github" />
        <project path="external/hipl" name="hipl" revision="refs/heads/android-hipl" remote="surki-github" />
      </manifest>

      and do a

      repo sync

      which will bring all the HIPL specific changes into local repository

    3. Compile the source

      $ cd ~/src/mydroid #Android source directory
      $ source build/envsetup.sh
      $ lunch generic-eng #Chooses a generic build for emulator and sets up the required env. variables
      $ make TARGET_PRODUCT:=generic

    4. Compile the kernel

      $ cd ~/src/mydroid #Android source directory
      $ source build/envsetup.sh
      $ lunch generic-eng #Chooses a generic build and sets up the required env. variables
      $ cd kernel # Kernel source
      $ export CROSS_COMPILE=arm-eabi- ARCH=arm
      $ make goldfish_defconfig
      $ make menuconfig #To select HIPL specific kernel options

      Select the HIP specific kernel options as mentioned in HIP "Compiling the Kernel" page.

      $ make

    5. Test the connection

      $ export PATH=$PATH:~/src/mydroid/out/host/linux-x86/bin
      $ emulator -kernel kernel/arch/arm/boot/zImage -system out/target/product/generic/system.img -data out/target/product/generic/userdata.img &
      $ adb shell # Log into emulator shell
      # hipd -k 2>/dev/null &
      # hipfw -klpF 2>/dev/null &
      # hipconf add map 2001:1b:a9be:c6a6:34e5:8361:c07f:a990 193.167.187.134 # We don't have dns proxy
      # wget http://[2001:001b:a9be:c6a6:34e5:8361:c07f:a990] -O- #LSI also can be used here

      If you need to debug, run each binary in its own "adb shell".

  2. Compiling for device Android "HTC Dream" G1

    Please refer to Android site for more generic details

    1. Get the source(follow it up from Android site). Cupcake

    2. Apply this local manifest

                        
      <?xml version="1.0" encoding="UTF-8"?>
      <manifest>
        <remote  name="surki-github" fetch="git://github.com/surki/" />
      
        <remove-project name="platform/external/iptables" />
      
        <project path="kernel" name="kernel/common" revision="refs/heads/android-msm-2.6.29" />
        <project path="external/iptables" name="iptables" revision="refs/heads/android-hipl" remote="surki-github" />
        <project path="external/wget" name="wget" revision="refs/heads/android-hipl" remote="surki-github" />
        <project path="external/hipl" name="hipl" revision="refs/heads/android-hipl" remote="surki-github" />
      </manifest>

      and do a

      repo sync

    3. Compile the kernel as specified in the above section

    4. make TARGET_PRODUCT:=dream TARGET_PREBUILT_KERNEL:=kernel/arch/arm/boot/zImage

    5. Flash the built images(boot.img and system.img) into device by following the instructions at HTC page. We don't need to update all the images, just the boot and system images.

      $ fastboot boot out/target/product/dream-open/boot.img
      $ fastboot system out/target/product/dream-open/system.img

      WARNING: The system and boot partitions will be overwritten, though the data partition would remain same

    6. Test the connection

      Remember to connect the device into USB port

      $ tools/adb shell # Log into device shell
      # hipd -k 2>/dev/null &
      # hipfw -klpF 2>/dev/null &
      # hipconf add map 2001:1b:a9be:c6a6:34e5:8361:c07f:a990 193.167.187.134 # We don't have dns proxy
      # wget http://[2001:001b:a9be:c6a6:34e5:8361:c07f:a990] -O- #LSI also can be used here

      If you need to see the output, run each binary in its own "adb shell".

    7. Flashing the device

Notes

  1. During development, to update hip binaries, you will have to use "adb". So use something like

    $ adb sync

    from the android source directory

  2. During development, to update hip binaries, you will have to remount /system partition read/write(by default system directory is readonly). So use something like

    # mount -oremount,rw /dev/block/mtdblock0 /system

  3. HIP configuration files are located at "/data/hip/"

  4. hipd crashes sometimes when run in simulator. Restarting will be required if it crashes