Make it easy to check if an address is locally usable via changed get_interface() method
This commit is contained in:
@@ -191,42 +191,34 @@ static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg
|
||||
{
|
||||
stroke_end_t tmp_end;
|
||||
ike_cfg_t *ike_cfg;
|
||||
char *interface;
|
||||
host_t *host;
|
||||
u_int16_t ikeport;
|
||||
|
||||
host = host_create_from_dns(msg->add_conn.other.address, 0, 0);
|
||||
if (host)
|
||||
{
|
||||
interface = hydra->kernel_interface->get_interface(
|
||||
hydra->kernel_interface, host);
|
||||
host->destroy(host);
|
||||
if (interface)
|
||||
if (hydra->kernel_interface->get_interface(hydra->kernel_interface,
|
||||
host, NULL))
|
||||
{
|
||||
DBG2(DBG_CFG, "left is other host, swapping ends");
|
||||
tmp_end = msg->add_conn.me;
|
||||
msg->add_conn.me = msg->add_conn.other;
|
||||
msg->add_conn.other = tmp_end;
|
||||
free(interface);
|
||||
host->destroy(host);
|
||||
}
|
||||
else
|
||||
{
|
||||
host->destroy(host);
|
||||
host = host_create_from_dns(msg->add_conn.me.address, 0, 0);
|
||||
if (host)
|
||||
{
|
||||
interface = hydra->kernel_interface->get_interface(
|
||||
hydra->kernel_interface, host);
|
||||
host->destroy(host);
|
||||
if (!interface)
|
||||
if (!hydra->kernel_interface->get_interface(
|
||||
hydra->kernel_interface, host, NULL))
|
||||
{
|
||||
DBG1(DBG_CFG, "left nor right host is our side, "
|
||||
"assuming left=local");
|
||||
}
|
||||
else
|
||||
{
|
||||
free(interface);
|
||||
}
|
||||
|
||||
host->destroy(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,9 +267,8 @@ METHOD(listener_t, child_updown, bool,
|
||||
|
||||
if (up)
|
||||
{
|
||||
iface = hydra->kernel_interface->get_interface(
|
||||
hydra->kernel_interface, me);
|
||||
if (iface)
|
||||
if (hydra->kernel_interface->get_interface(hydra->kernel_interface,
|
||||
me, &iface))
|
||||
{
|
||||
cache_iface(this, child_sa->get_reqid(child_sa), iface);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user