On 28/04/13 16:31, Arne Schwabe wrote:
> On Android 4.0 (TARGET_ANDROID) the real opening of the tun is
> handled by the (Java) application controlling OpenVPN. Instead of calling
> ifconfig/route call the management to do the work. When running openvpn
> as root openvpn should be compiled as TARGET_LINUX
> 
> Signed-off-by: Arne Schwabe <a...@rfc2549.org>
> ---
>  src/openvpn/manage.c  |   14 ++++++++
>  src/openvpn/manage.h  |    4 +++
>  src/openvpn/options.c |    6 ++++
>  src/openvpn/route.c   |   18 ++++++++--
>  src/openvpn/socket.c  |   10 ++++++
>  src/openvpn/ssl.c     |    2 ++
>  src/openvpn/syshead.h |    2 +-
>  src/openvpn/tun.c     |   87 
> +++++++++++++++++++++++++++++++++++++++++++++++--
>  src/openvpn/tun.h     |    8 ++++-
>  9 files changed, 145 insertions(+), 6 deletions(-)

[...snip...]

> diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
> index a361233..ac8b544 100644
> --- a/src/openvpn/tun.c
> +++ b/src/openvpn/tun.c
[...snip...]
> @@ -1368,8 +1397,62 @@ close_tun_generic (struct tuntap *tt)
>  
>  #endif
>  
> -#if defined(TARGET_LINUX)
> +#if defined (TARGET_ANDROID)
> +void
> +open_tun (const char *dev, const char *dev_type, const char *dev_node, 
> struct tuntap *tt)
> +{
> +#define ANDROID_TUNNAME "vpnservice-tun"
> +  int i;
> +  struct user_pass up;
> +  struct gc_arena gc = gc_new ();
> +  bool opentun;
> +  
> +  for (i = 0; i < tt->options.dns_len; ++i) {
> +    management_android_control (management, "DNSSERVER",
> +                                print_in_addr_t(tt->options.dns[i], 0, &gc));
> +  }
> +
> +  if(tt->options.domain) 
> +    management_android_control (management, "DNSDOMAIN", tt->options.domain);
> +    
> +  opentun = management_android_control (management, "OPENTUN", dev);
> +
> +  /* Pick up the fd from management interface after calling the OPENTUN 
> command */
> +  tt->fd = management->connection.lastfdreceived;
> +  management->connection.lastfdreceived=-1;
> +    
> +  /* Set the actual name to a dummy name */
> +  tt->actual_name = strdup (ANDROID_TUNNAME);

Just nit-picking ... anything wrong with string_alloc() which is used in
similar places?  And which can make use of gc (if that is available
here, didn't check that) and it will do the proper malloc() checks too.

Otherwise, code looks find.  I don't fully understand all the tun magic
needed on Android, but OpenVPN on Android have been well tested, so I
would say that should count as well.


--
kind regards,

David Sommerseth


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to