Add virtual IP to the TUN device builder
authorTobias Brunner <tobias@strongswan.org>
Wed, 8 Aug 2012 12:46:22 +0000 (14:46 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 13 Aug 2012 09:09:34 +0000 (11:09 +0200)
After the CHILD_SA is established we can easily get this address from
the IKE_SA.

src/frontends/android/jni/libandroidbridge/backend/android_service.c

index 691d5fc..d44bebc 100644 (file)
@@ -80,13 +80,21 @@ static bool setup_tun_device(private_android_service_t *this,
                                                         ike_sa_t *ike_sa, child_sa_t *child_sa)
 {
        vpnservice_builder_t *builder;
+       host_t *vip;
        int tunfd;
 
        DBG1(DBG_DMN, "setting up TUN device for CHILD_SA %s{%u}",
                 child_sa->get_name(child_sa), child_sa->get_reqid(child_sa));
+       vip = ike_sa->get_virtual_ip(ike_sa, TRUE);
+       if (!vip || vip->is_anyaddr(vip))
+       {
+               DBG1(DBG_DMN, "setting up TUN device failed, no virtual IP found");
+               return FALSE;
+       }
 
        builder = charonservice->get_vpnservice_builder(charonservice);
-       if (!builder->set_mtu(builder, TUN_DEFAULT_MTU))
+       if (!builder->add_address(builder, vip) ||
+               !builder->set_mtu(builder, TUN_DEFAULT_MTU))
        {
                return FALSE;
        }