strongSwan on Android » History » Version 3
Tobias Brunner, 12.04.2010 16:08
some minor changes
1 | 1 | Tobias Brunner | h1. strongSwan on Android |
---|---|---|---|
2 | 1 | Tobias Brunner | |
3 | 2 | Tobias Brunner | The IKEv2 daemon charon has recently been ported to "Google Android":http://www.android.com. |
4 | 1 | Tobias Brunner | |
5 | 1 | Tobias Brunner | This document describes how to build strongSwan for Android 2.0 (using the emulator). |
6 | 1 | Tobias Brunner | |
7 | 1 | Tobias Brunner | h2. Android Source Tree |
8 | 1 | Tobias Brunner | |
9 | 1 | Tobias Brunner | You will need the complete Android source to build strongSwan. Instructions on how to download and build it can be found on the "Android website":http://source.android.com/download. |
10 | 1 | Tobias Brunner | |
11 | 1 | Tobias Brunner | To checkout a specific branch or tag of the sources, specify it with the @-b@ parameter when using the @repo init@ command. |
12 | 1 | Tobias Brunner | |
13 | 1 | Tobias Brunner | Since building the whole source tree takes quite a while you should probably start with this first: |
14 | 1 | Tobias Brunner | <pre> |
15 | 1 | Tobias Brunner | cd /path/to/android/source |
16 | 1 | Tobias Brunner | . build/envsetup.sh |
17 | 1 | Tobias Brunner | lunch 1 |
18 | 1 | Tobias Brunner | make |
19 | 1 | Tobias Brunner | </pre> |
20 | 1 | Tobias Brunner | |
21 | 1 | Tobias Brunner | h2. Android Kernel |
22 | 1 | Tobias Brunner | |
23 | 3 | Tobias Brunner | The prebuilt kernel that is used for the emulator lacks some modules required for strongSwan to work correctly. It is therefore required to build a custom kernel. |
24 | 3 | Tobias Brunner | To get the current kernel config you can use the "Android Debug Bridge":http://developer.android.com/guide/developing/tools/adb.html to download it from the running emulator. After starting the emulator use |
25 | 1 | Tobias Brunner | <pre> |
26 | 1 | Tobias Brunner | adb pull /proc/config.gz config.gz |
27 | 1 | Tobias Brunner | </pre>to copy the config to the current directory. Then enable the missing modules, this is mainly @CONFIG_XFRM_USER@ and @CONFIG_NET_KEY@ but might include other modules. |
28 | 1 | Tobias Brunner | Please compare your config to the list of [[KernelModules|required modules]] in this wiki (please note that some modules, especially all the IPv6 related modules, are not really required). |
29 | 1 | Tobias Brunner | |
30 | 1 | Tobias Brunner | Clone the kernel sources and checkout an appropriate tag (check the version of the kernel in the emulator). For example: |
31 | 1 | Tobias Brunner | <pre> |
32 | 1 | Tobias Brunner | git clone git://android.git.kernel.org/kernel/common kernel |
33 | 1 | Tobias Brunner | cd kernel |
34 | 1 | Tobias Brunner | git checkout -t origin/android-goldfish-2.6.29 |
35 | 1 | Tobias Brunner | </pre> |
36 | 3 | Tobias Brunner | |
37 | 1 | Tobias Brunner | You can then copy your config to this directory and compile the kernel sources using |
38 | 1 | Tobias Brunner | <pre> |
39 | 1 | Tobias Brunner | export ARCH=arm |
40 | 1 | Tobias Brunner | export CROSS_COMPILE=/path/to/android/source/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- |
41 | 1 | Tobias Brunner | make oldconfig |
42 | 1 | Tobias Brunner | make |
43 | 1 | Tobias Brunner | </pre> |
44 | 1 | Tobias Brunner | |
45 | 3 | Tobias Brunner | To start the emulator using your custom kernel use the following command. |
46 | 1 | Tobias Brunner | <pre> |
47 | 1 | Tobias Brunner | emulator -kernel /path/to/kernel/source/arch/arm/boot/zImage & |
48 | 2 | Tobias Brunner | </pre> |
49 | 1 | Tobias Brunner | |
50 | 2 | Tobias Brunner | h2. Vstr Library |
51 | 2 | Tobias Brunner | |
52 | 3 | Tobias Brunner | strongSwan can be fully integrated in the Android build system. But the required "Vstr string library":http://www.and.org/vstr/ can not (yet). Therefore, you will have to build that library first using "droid-gcc":http://github.com/tmurakam/droid-wrapper. |
53 | 2 | Tobias Brunner | |
54 | 2 | Tobias Brunner | h3. droid-gcc |
55 | 2 | Tobias Brunner | |
56 | 2 | Tobias Brunner | Since droid-gcc is written in Ruby you'll obviously need *Ruby* installed on your build system. Then download droid-gcc by either cloning the "Git tree":git://github.com/tmurakam/droid-wrapper.git or by downloading it "directly":http://github.com/tmurakam/droid-wrapper/raw/master/droid-gcc. |
57 | 2 | Tobias Brunner | |
58 | 2 | Tobias Brunner | If you used Git you can install droid-gcc using @make install@, if you downloaded it directly, you have to manually create two symlinks to droid-gcc named _droid-gcc_ and _droid-ld_ in a directory that is included in your PATH environment variable. |
59 | 2 | Tobias Brunner | |
60 | 1 | Tobias Brunner | h3. Build the Library |
61 | 2 | Tobias Brunner | |
62 | 2 | Tobias Brunner | To simplify building the Vstr library, a build script is attached to this page (attachment:vstr.build). The attached patch (attachment:vstr.patch) and Android Makefile (attachment:vstr.mk) are also required. |
63 | 2 | Tobias Brunner | |
64 | 3 | Tobias Brunner | Download the three helper files to an appropriate working directory and then download and extract the tarball for the Vstr library. |
65 | 2 | Tobias Brunner | <pre> |
66 | 2 | Tobias Brunner | wget http://download.strongswan.org/vstr-1.0.15.tar.bz2 |
67 | 2 | Tobias Brunner | tar xjf vstr-1.0.15.tar.bz2 |
68 | 2 | Tobias Brunner | </pre> |
69 | 2 | Tobias Brunner | |
70 | 2 | Tobias Brunner | Adjust the variables in the build script (@DROID_ROOT@ and optionally @INSTALLDIR@). Then build and install the it using |
71 | 2 | Tobias Brunner | <pre> |
72 | 2 | Tobias Brunner | cd vstr-1.0.15 |
73 | 2 | Tobias Brunner | patch -p1 < ../vstr.patch |
74 | 1 | Tobias Brunner | . ../vstr.build |
75 | 1 | Tobias Brunner | </pre> |
76 | 2 | Tobias Brunner | |
77 | 2 | Tobias Brunner | h2. strongSwan |
78 | 2 | Tobias Brunner | |
79 | 3 | Tobias Brunner | Now you are ready to build strongSwan. Download the current tarball (or build it yourself from the strongSwan source tree) and extract it in @DROID_ROOT/external@. |
80 | 2 | Tobias Brunner | |
81 | 3 | Tobias Brunner | If you changed @INSTALLDIR@ in the build script above, you will have to change the top Android.mk (or Android.mk.in) accordingly. You can also adjust the plugin list in the that file. |
82 | 2 | Tobias Brunner | |
83 | 2 | Tobias Brunner | Now just build the Android source tree. |
84 | 2 | Tobias Brunner | |
85 | 2 | Tobias Brunner | <pre> |
86 | 2 | Tobias Brunner | cd /path/to/android/source |
87 | 2 | Tobias Brunner | make |
88 | 1 | Tobias Brunner | </pre> |