implemented the right|leftallowany feature

This commit is contained in:
Andreas Steffen
2012-06-08 21:24:41 +02:00
parent e5f0f9ff96
commit 1d315bddd3
19 changed files with 137 additions and 77 deletions
+2 -2
View File
@@ -496,8 +496,8 @@ static gboolean connect_(NMVPNPlugin *plugin, NMConnection *connection,
/** /**
* Set up configurations * Set up configurations
*/ */
ike_cfg = ike_cfg_create(TRUE, encap, ike_cfg = ike_cfg_create(TRUE, encap, "0.0.0.0", FALSE, IKEV2_UDP_PORT,
"0.0.0.0", IKEV2_UDP_PORT, (char*)address, IKEV2_UDP_PORT); (char*)address, FALSE, IKEV2_UDP_PORT);
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE)); ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
peer_cfg = peer_cfg_create(priv->name, IKEV2, ike_cfg, peer_cfg = peer_cfg_create(priv->name, IKEV2, ike_cfg,
CERT_SEND_IF_ASKED, UNIQUE_REPLACE, 1, /* keyingtries */ CERT_SEND_IF_ASKED, UNIQUE_REPLACE, 1, /* keyingtries */
+2 -2
View File
@@ -103,9 +103,9 @@ static ike_cfg_t *load_ike_config(private_config_t *this,
ike_cfg = ike_cfg_create(TRUE, ike_cfg = ike_cfg_create(TRUE,
settings->get_bool(settings, "configs.%s.fake_nat", FALSE, config), settings->get_bool(settings, "configs.%s.fake_nat", FALSE, config),
settings->get_str(settings, "configs.%s.lhost", "%any", config), settings->get_str(settings, "configs.%s.lhost", "%any", config), FALSE,
settings->get_int(settings, "configs.%s.lport", 500, config), settings->get_int(settings, "configs.%s.lport", 500, config),
settings->get_str(settings, "configs.%s.rhost", "%any", config), settings->get_str(settings, "configs.%s.rhost", "%any", config), FALSE,
settings->get_int(settings, "configs.%s.rport", 500, config)); settings->get_int(settings, "configs.%s.rport", 500, config));
token = settings->get_str(settings, "configs.%s.proposal", NULL, config); token = settings->get_str(settings, "configs.%s.proposal", NULL, config);
if (token) if (token)
+20 -11
View File
@@ -78,12 +78,14 @@ static enumerator_t *ike_enum_create(backend_t *backend, ike_data_t *data)
static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other) static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other)
{ {
host_t *me_cand, *other_cand; host_t *me_cand, *other_cand;
char *my_addr, *other_addr;
bool my_allow_any, other_allow_any;
ike_cfg_match_t match = MATCH_NONE; ike_cfg_match_t match = MATCH_NONE;
if (me) if (me)
{ {
me_cand = host_create_from_dns(cand->get_my_addr(cand), my_addr = cand->get_my_addr(cand, &my_allow_any);
me->get_family(me), 0); me_cand = host_create_from_dns(my_addr, me->get_family(me), 0);
if (!me_cand) if (!me_cand)
{ {
return MATCH_NONE; return MATCH_NONE;
@@ -92,7 +94,7 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other)
{ {
match += MATCH_ME; match += MATCH_ME;
} }
else if (me_cand->is_anyaddr(me_cand)) else if (my_allow_any || me_cand->is_anyaddr(me_cand))
{ {
match += MATCH_ANY; match += MATCH_ANY;
} }
@@ -110,8 +112,8 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other)
if (other) if (other)
{ {
other_cand = host_create_from_dns(cand->get_other_addr(cand), other_addr = cand->get_other_addr(cand, &other_allow_any);
other->get_family(other), 0); other_cand = host_create_from_dns(other_addr, other->get_family(other), 0);
if (!other_cand) if (!other_cand)
{ {
return MATCH_NONE; return MATCH_NONE;
@@ -120,7 +122,7 @@ static ike_cfg_match_t get_ike_match(ike_cfg_t *cand, host_t *me, host_t *other)
{ {
match += MATCH_OTHER; match += MATCH_OTHER;
} }
else if (other_cand->is_anyaddr(other_cand)) else if (other_allow_any || other_cand->is_anyaddr(other_cand))
{ {
match += MATCH_ANY; match += MATCH_ANY;
} }
@@ -142,6 +144,8 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*,
private_backend_manager_t *this, host_t *me, host_t *other) private_backend_manager_t *this, host_t *me, host_t *other)
{ {
ike_cfg_t *current, *found = NULL; ike_cfg_t *current, *found = NULL;
char *my_addr, *other_addr;
bool my_allow_any, other_allow_any;
enumerator_t *enumerator; enumerator_t *enumerator;
ike_cfg_match_t match, best = MATCH_ANY; ike_cfg_match_t match, best = MATCH_ANY;
ike_data_t *data; ike_data_t *data;
@@ -164,9 +168,11 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*,
DBG3(DBG_CFG, "ike config match: %d (%H %H)", match, me, other); DBG3(DBG_CFG, "ike config match: %d (%H %H)", match, me, other);
if (match) if (match)
{ {
DBG2(DBG_CFG, " candidate: %s...%s, prio %d", my_addr = current->get_my_addr(current, &my_allow_any);
current->get_my_addr(current), other_addr = current->get_other_addr(current, &other_allow_any);
current->get_other_addr(current), match); DBG2(DBG_CFG, " candidate: %s%s...%s%s, prio %d",
my_allow_any ? "%":"", my_addr,
other_allow_any ? "%":"", other_addr, match);
if (match > best) if (match > best)
{ {
DESTROY_IF(found); DESTROY_IF(found);
@@ -180,8 +186,11 @@ METHOD(backend_manager_t, get_ike_cfg, ike_cfg_t*,
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
if (found) if (found)
{ {
DBG2(DBG_CFG, "found matching ike config: %s...%s with prio %d", my_addr = found->get_my_addr(found, &my_allow_any);
found->get_my_addr(found), found->get_other_addr(found), best); other_addr = found->get_other_addr(found, &other_allow_any);
DBG2(DBG_CFG, "found matching ike config: %s%s...%s%s with prio %d",
my_allow_any ? "%":"", my_addr,
other_allow_any ? "%":"", other_addr, best);
} }
return found; return found;
} }
+24 -3
View File
@@ -48,6 +48,16 @@ struct private_ike_cfg_t {
*/ */
char *other; char *other;
/**
* Allow override of local address
*/
bool my_allow_any;
/**
* Allow override of remote address
*/
bool other_allow_any;
/** /**
* our source port * our source port
*/ */
@@ -87,14 +97,22 @@ METHOD(ike_cfg_t, force_encap_, bool,
} }
METHOD(ike_cfg_t, get_my_addr, char*, METHOD(ike_cfg_t, get_my_addr, char*,
private_ike_cfg_t *this) private_ike_cfg_t *this, bool *allow_any)
{ {
if (allow_any)
{
*allow_any = this->my_allow_any;
}
return this->me; return this->me;
} }
METHOD(ike_cfg_t, get_other_addr, char*, METHOD(ike_cfg_t, get_other_addr, char*,
private_ike_cfg_t *this) private_ike_cfg_t *this, bool *allow_any)
{ {
if (allow_any)
{
*allow_any = this->other_allow_any;
}
return this->other; return this->other;
} }
@@ -260,7 +278,8 @@ METHOD(ike_cfg_t, destroy, void,
* Described in header. * Described in header.
*/ */
ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap, ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap,
char *me, u_int16_t my_port, char *other, u_int16_t other_port) char *me, bool my_allow_any, u_int16_t my_port,
char *other, bool other_allow_any, u_int16_t other_port)
{ {
private_ike_cfg_t *this; private_ike_cfg_t *this;
@@ -285,6 +304,8 @@ ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap,
.force_encap = force_encap, .force_encap = force_encap,
.me = strdup(me), .me = strdup(me),
.other = strdup(other), .other = strdup(other),
.my_allow_any = my_allow_any,
.other_allow_any = other_allow_any,
.my_port = my_port, .my_port = my_port,
.other_port = other_port, .other_port = other_port,
.proposals = linked_list_create(), .proposals = linked_list_create(),
+31 -26
View File
@@ -41,28 +41,30 @@ struct ike_cfg_t {
/** /**
* Get own address. * Get own address.
* *
* @return string of address/DNS name * @param allow_any allow any address to match
* @return string of address/DNS name
*/ */
char* (*get_my_addr) (ike_cfg_t *this); char* (*get_my_addr) (ike_cfg_t *this, bool *allow_any);
/** /**
* Get peers address. * Get peer's address.
* *
* @return string of address/DNS name * @param allow_any allow any address to match
* @return string of address/DNS name
*/ */
char* (*get_other_addr) (ike_cfg_t *this); char* (*get_other_addr) (ike_cfg_t *this, bool *allow_any);
/** /**
* Get the port to use as our source port. * Get the port to use as our source port.
* *
* @return source address port, host order * @return source address port, host order
*/ */
u_int16_t (*get_my_port)(ike_cfg_t *this); u_int16_t (*get_my_port)(ike_cfg_t *this);
/** /**
* Get the port to use as destination port. * Get the port to use as destination port.
* *
* @return destination address, host order * @return destination address, host order
*/ */
u_int16_t (*get_other_port)(ike_cfg_t *this); u_int16_t (*get_other_port)(ike_cfg_t *this);
@@ -72,7 +74,7 @@ struct ike_cfg_t {
* The first added proposal has the highest priority, the last * The first added proposal has the highest priority, the last
* added the lowest. * added the lowest.
* *
* @param proposal proposal to add * @param proposal proposal to add
*/ */
void (*add_proposal) (ike_cfg_t *this, proposal_t *proposal); void (*add_proposal) (ike_cfg_t *this, proposal_t *proposal);
@@ -81,7 +83,7 @@ struct ike_cfg_t {
* *
* Returned list and its proposals must be destroyed after use. * Returned list and its proposals must be destroyed after use.
* *
* @return list containing all the proposals * @return list containing all the proposals
*/ */
linked_list_t* (*get_proposals) (ike_cfg_t *this); linked_list_t* (*get_proposals) (ike_cfg_t *this);
@@ -90,9 +92,9 @@ struct ike_cfg_t {
* *
* Returned proposal must be destroyed after use. * Returned proposal must be destroyed after use.
* *
* @param proposals list of proposals to select from * @param proposals list of proposals to select from
* @param private accept algorithms from a private range * @param private accept algorithms from a private range
* @return selected proposal, or NULL if none matches. * @return selected proposal, or NULL if none matches.
*/ */
proposal_t *(*select_proposal) (ike_cfg_t *this, linked_list_t *proposals, proposal_t *(*select_proposal) (ike_cfg_t *this, linked_list_t *proposals,
bool private); bool private);
@@ -100,36 +102,36 @@ struct ike_cfg_t {
/** /**
* Should we send a certificate request in IKE_SA_INIT? * Should we send a certificate request in IKE_SA_INIT?
* *
* @return certificate request sending policy * @return certificate request sending policy
*/ */
bool (*send_certreq) (ike_cfg_t *this); bool (*send_certreq) (ike_cfg_t *this);
/** /**
* Enforce UDP encapsulation by faking NATD notifies? * Enforce UDP encapsulation by faking NATD notifies?
* *
* @return TRUE to enfoce UDP encapsulation * @return TRUE to enfoce UDP encapsulation
*/ */
bool (*force_encap) (ike_cfg_t *this); bool (*force_encap) (ike_cfg_t *this);
/** /**
* Get the DH group to use for IKE_SA setup. * Get the DH group to use for IKE_SA setup.
* *
* @return dh group to use for initialization * @return dh group to use for initialization
*/ */
diffie_hellman_group_t (*get_dh_group)(ike_cfg_t *this); diffie_hellman_group_t (*get_dh_group)(ike_cfg_t *this);
/** /**
* Check if two IKE configs are equal. * Check if two IKE configs are equal.
* *
* @param other other to check for equality * @param other other to check for equality
* @return TRUE if other equal to this * @return TRUE if other equal to this
*/ */
bool (*equals)(ike_cfg_t *this, ike_cfg_t *other); bool (*equals)(ike_cfg_t *this, ike_cfg_t *other);
/** /**
* Increase reference count. * Increase reference count.
* *
* @return reference to this * @return reference to this
*/ */
ike_cfg_t* (*get_ref) (ike_cfg_t *this); ike_cfg_t* (*get_ref) (ike_cfg_t *this);
@@ -147,15 +149,18 @@ struct ike_cfg_t {
* *
* Supplied hosts become owned by ike_cfg, the name gets cloned. * Supplied hosts become owned by ike_cfg, the name gets cloned.
* *
* @param certreq TRUE to send a certificate request * @param certreq TRUE to send a certificate request
* @param force_encap enforce UDP encapsulation by faking NATD notify * @param force_encap enforce UDP encapsulation by faking NATD notify
* @param me address/DNS name of local peer * @param me address/DNS name of local peer
* @param my_port IKE port to use as source, 500 uses IKEv2 port floating * @param my_allow_any allow override of local address by any address
* @param other address/DNS name of remote peer * @param my_port IKE port to use as source, 500 uses IKEv2 port floating
* @param other_port IKE port to use as dest, 500 uses IKEv2 port floating * @param other address/DNS name of remote peer
* @return ike_cfg_t object. * @param other_allow_any allow override of remote address by any address
* @param other_port IKE port to use as dest, 500 uses IKEv2 port floating
* @return ike_cfg_t object.
*/ */
ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap, ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap,
char *me, u_int16_t my_port, char *other, u_int16_t other_port); char *me, bool my_allow_any, u_int16_t my_port,
char *other, bool other_allow_any, u_int16_t other_port);
#endif /** IKE_CFG_H_ @}*/ #endif /** IKE_CFG_H_ @}*/
@@ -269,8 +269,8 @@ static job_requeue_t initiate(private_android_service_t *this)
this->creds->set_username_password(this->creds, user, password); this->creds->set_username_password(this->creds, user, password);
} }
ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", IKEV2_UDP_PORT, ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", FALSE, IKEV2_UDP_PORT,
hostname, IKEV2_UDP_PORT); hostname, FALSE, IKEV2_UDP_PORT);
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE)); ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
peer_cfg = peer_cfg_create("android", IKEV2, ike_cfg, CERT_SEND_IF_ASKED, peer_cfg = peer_cfg_create("android", IKEV2, ike_cfg, CERT_SEND_IF_ASKED,
+2 -2
View File
@@ -203,8 +203,8 @@ static void setup_tunnel(private_ha_tunnel_t *this,
lib->credmgr->add_set(lib->credmgr, &this->creds.public); lib->credmgr->add_set(lib->credmgr, &this->creds.public);
/* create config and backend */ /* create config and backend */
ike_cfg = ike_cfg_create(FALSE, FALSE, local, IKEV2_UDP_PORT, ike_cfg = ike_cfg_create(FALSE, FALSE, local, FALSE, IKEV2_UDP_PORT,
remote, IKEV2_UDP_PORT); remote, FALSE, IKEV2_UDP_PORT);
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE)); ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
peer_cfg = peer_cfg_create("ha", IKEV2, ike_cfg, CERT_NEVER_SEND, peer_cfg = peer_cfg_create("ha", IKEV2, ike_cfg, CERT_NEVER_SEND,
UNIQUE_KEEP, 0, 86400, 0, 7200, 3600, FALSE, FALSE, 30, UNIQUE_KEEP, 0, 86400, 0, 7200, 3600, FALSE, FALSE, 30,
@@ -251,12 +251,14 @@ static peer_cfg_t* generate_config(private_load_tester_config_t *this, uint num)
if (this->port && num) if (this->port && num)
{ {
ike_cfg = ike_cfg_create(FALSE, FALSE, ike_cfg = ike_cfg_create(FALSE, FALSE,
this->local, this->port + num - 1, this->remote, IKEV2_NATT_PORT); this->local, FALSE, this->port + num - 1,
this->remote, FALSE, IKEV2_NATT_PORT);
} }
else else
{ {
ike_cfg = ike_cfg_create(FALSE, FALSE, ike_cfg = ike_cfg_create(FALSE, FALSE,
this->local, IKEV2_UDP_PORT, this->remote, IKEV2_UDP_PORT); this->local, FALSE, IKEV2_UDP_PORT,
this->remote, FALSE, IKEV2_UDP_PORT);
} }
ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal)); ike_cfg->add_proposal(ike_cfg, this->proposal->clone(this->proposal));
peer_cfg = peer_cfg_create("load-test", IKEV2, ike_cfg, peer_cfg = peer_cfg_create("load-test", IKEV2, ike_cfg,
+2 -2
View File
@@ -323,8 +323,8 @@ static gboolean initiate_connection(private_maemo_service_t *this,
NULL); NULL);
} }
ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", IKEV2_UDP_PORT, ike_cfg = ike_cfg_create(TRUE, FALSE, "0.0.0.0", FALSE, IKEV2_UDP_PORT,
hostname, IKEV2_UDP_PORT); hostname, FALSE, IKEV2_UDP_PORT);
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE)); ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
peer_cfg = peer_cfg_create(this->current, IKEV2, ike_cfg, peer_cfg = peer_cfg_create(this->current, IKEV2, ike_cfg,
+5 -3
View File
@@ -119,7 +119,8 @@ METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
return NULL; return NULL;
} }
ike_cfg = ike_cfg_create(FALSE, FALSE, ike_cfg = ike_cfg_create(FALSE, FALSE,
"0.0.0.0", IKEV2_UDP_PORT, address, IKEV2_UDP_PORT); "0.0.0.0", FALSE, IKEV2_UDP_PORT,
address, FALSE, IKEV2_UDP_PORT);
ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE)); ike_cfg->add_proposal(ike_cfg, proposal_create_default(PROTO_IKE));
med_cfg = peer_cfg_create( med_cfg = peer_cfg_create(
"mediation", IKEV2, ike_cfg, "mediation", IKEV2, ike_cfg,
@@ -394,8 +395,9 @@ medcli_config_t *medcli_config_create(database_t *db)
.db = db, .db = db,
.rekey = lib->settings->get_time(lib->settings, "medcli.rekey", 1200), .rekey = lib->settings->get_time(lib->settings, "medcli.rekey", 1200),
.dpd = lib->settings->get_time(lib->settings, "medcli.dpd", 300), .dpd = lib->settings->get_time(lib->settings, "medcli.dpd", 300),
.ike = ike_cfg_create(FALSE, FALSE, "0.0.0.0", IKEV2_UDP_PORT, .ike = ike_cfg_create(FALSE, FALSE,
"0.0.0.0", IKEV2_UDP_PORT), "0.0.0.0", FALSE, IKEV2_UDP_PORT,
"0.0.0.0", FALSE, IKEV2_UDP_PORT),
); );
this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE)); this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
+2 -1
View File
@@ -141,7 +141,8 @@ medsrv_config_t *medsrv_config_create(database_t *db)
.rekey = lib->settings->get_time(lib->settings, "medsrv.rekey", 1200), .rekey = lib->settings->get_time(lib->settings, "medsrv.rekey", 1200),
.dpd = lib->settings->get_time(lib->settings, "medsrv.dpd", 300), .dpd = lib->settings->get_time(lib->settings, "medsrv.dpd", 300),
.ike = ike_cfg_create(FALSE, FALSE, .ike = ike_cfg_create(FALSE, FALSE,
"0.0.0.0", IKEV2_UDP_PORT, "0.0.0.0", IKEV2_UDP_PORT), "0.0.0.0", FALSE, IKEV2_UDP_PORT,
"0.0.0.0", FALSE, IKEV2_UDP_PORT),
); );
this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE)); this->ike->add_proposal(this->ike, proposal_create_default(PROTO_IKE));
+2 -1
View File
@@ -259,7 +259,8 @@ static ike_cfg_t *build_ike_cfg(private_sql_config_t *this, enumerator_t *e,
ike_cfg_t *ike_cfg; ike_cfg_t *ike_cfg;
ike_cfg = ike_cfg_create(certreq, force_encap, ike_cfg = ike_cfg_create(certreq, force_encap,
local, IKEV2_UDP_PORT, remote, IKEV2_UDP_PORT); local, FALSE, IKEV2_UDP_PORT,
remote, FALSE, IKEV2_UDP_PORT);
add_ike_proposals(this, ike_cfg, id); add_ike_proposals(this, ike_cfg, id);
return ike_cfg; return ike_cfg;
} }
+8 -4
View File
@@ -225,9 +225,13 @@ static ike_cfg_t *build_ike_cfg(private_stroke_config_t *this, stroke_msg_t *msg
} }
} }
ike_cfg = ike_cfg_create(msg->add_conn.other.sendcert != CERT_NEVER_SEND, ike_cfg = ike_cfg_create(msg->add_conn.other.sendcert != CERT_NEVER_SEND,
msg->add_conn.force_encap, msg->add_conn.force_encap,
msg->add_conn.me.address, msg->add_conn.me.ikeport, msg->add_conn.me.address,
msg->add_conn.other.address, msg->add_conn.other.ikeport); msg->add_conn.me.allow_any,
msg->add_conn.me.ikeport,
msg->add_conn.other.address,
msg->add_conn.other.allow_any,
msg->add_conn.other.ikeport);
add_proposals(this, msg->add_conn.algorithms.ike, ike_cfg, NULL); add_proposals(this, msg->add_conn.algorithms.ike, ike_cfg, NULL);
return ike_cfg; return ike_cfg;
} }
@@ -625,7 +629,7 @@ static peer_cfg_t *build_peer_cfg(private_stroke_config_t *this,
} }
else else
{ {
if (strchr(ike_cfg->get_my_addr(ike_cfg), ':')) if (strchr(ike_cfg->get_my_addr(ike_cfg, NULL), ':'))
{ {
vip = host_create_any(AF_INET6); vip = host_create_any(AF_INET6);
} }
+9 -3
View File
@@ -500,6 +500,9 @@ METHOD(stroke_list_t, status, void,
charon->backends, NULL, NULL, NULL, NULL, IKE_ANY); charon->backends, NULL, NULL, NULL, NULL, IKE_ANY);
while (enumerator->enumerate(enumerator, &peer_cfg)) while (enumerator->enumerate(enumerator, &peer_cfg))
{ {
char *my_addr, *other_addr;
bool my_allow_any, other_allow_any;
if (name && !streq(name, peer_cfg->get_name(peer_cfg))) if (name && !streq(name, peer_cfg->get_name(peer_cfg)))
{ {
continue; continue;
@@ -507,9 +510,12 @@ METHOD(stroke_list_t, status, void,
ike_cfg = peer_cfg->get_ike_cfg(peer_cfg); ike_cfg = peer_cfg->get_ike_cfg(peer_cfg);
ike_version = peer_cfg->get_ike_version(peer_cfg); ike_version = peer_cfg->get_ike_version(peer_cfg);
fprintf(out, "%12s: %s...%s %N", peer_cfg->get_name(peer_cfg), my_addr = ike_cfg->get_my_addr(ike_cfg, &my_allow_any);
ike_cfg->get_my_addr(ike_cfg), ike_cfg->get_other_addr(ike_cfg), other_addr = ike_cfg->get_other_addr(ike_cfg, &other_allow_any);
ike_version_names, ike_version); fprintf(out, "%12s: %s%s...%s%s %N", peer_cfg->get_name(peer_cfg),
my_allow_any ? "%":"", my_addr,
other_allow_any ? "%":"", other_addr,
ike_version_names, ike_version);
if (ike_version == IKEV1 && peer_cfg->use_aggressive(peer_cfg)) if (ike_version == IKEV1 && peer_cfg->use_aggressive(peer_cfg))
{ {
+5 -3
View File
@@ -169,7 +169,8 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
{ {
DESTROY_IF(this->peer_cfg); DESTROY_IF(this->peer_cfg);
ike_cfg = ike_cfg_create(FALSE, FALSE, ike_cfg = ike_cfg_create(FALSE, FALSE,
local_addr, IKEV2_UDP_PORT, remote_addr, IKEV2_UDP_PORT); local_addr, FALSE, IKEV2_UDP_PORT,
remote_addr, FALSE, IKEV2_UDP_PORT);
ike_cfg->add_proposal(ike_cfg, create_proposal(ike_proposal, PROTO_IKE)); ike_cfg->add_proposal(ike_cfg, create_proposal(ike_proposal, PROTO_IKE));
this->peer_cfg = peer_cfg_create( this->peer_cfg = peer_cfg_create(
name, IKEV2, ike_cfg, CERT_SEND_IF_ASKED, UNIQUE_NO, name, IKEV2, ike_cfg, CERT_SEND_IF_ASKED, UNIQUE_NO,
@@ -265,8 +266,9 @@ METHOD(enumerator_t, ike_enumerator_enumerate, bool,
&local_addr, &remote_addr, &ike_proposal)) &local_addr, &remote_addr, &ike_proposal))
{ {
DESTROY_IF(this->ike_cfg); DESTROY_IF(this->ike_cfg);
this->ike_cfg = ike_cfg_create(FALSE, FALSE, local_addr, IKEV2_UDP_PORT, this->ike_cfg = ike_cfg_create(FALSE, FALSE,
remote_addr, IKEV2_UDP_PORT); local_addr, FALSE, IKEV2_UDP_PORT,
remote_addr, FALSE, IKEV2_UDP_PORT);
this->ike_cfg->add_proposal(this->ike_cfg, this->ike_cfg->add_proposal(this->ike_cfg,
create_proposal(ike_proposal, PROTO_IKE)); create_proposal(ike_proposal, PROTO_IKE));
+13 -8
View File
@@ -1039,8 +1039,12 @@ static void resolve_hosts(private_ike_sa_t *this)
} }
else else
{ {
host = host_create_from_dns(this->ike_cfg->get_other_addr(this->ike_cfg), char *other_addr;
0, this->ike_cfg->get_other_port(this->ike_cfg)); u_int16_t other_port;
other_addr = this->ike_cfg->get_other_addr(this->ike_cfg, NULL);
other_port = this->ike_cfg->get_other_port(this->ike_cfg);
host = host_create_from_dns(other_addr, 0, other_port);
} }
if (host) if (host)
{ {
@@ -1054,6 +1058,8 @@ static void resolve_hosts(private_ike_sa_t *this)
} }
else else
{ {
char *my_addr;
u_int16_t my_port;
int family = 0; int family = 0;
/* use same address family as for other */ /* use same address family as for other */
@@ -1061,8 +1067,9 @@ static void resolve_hosts(private_ike_sa_t *this)
{ {
family = this->other_host->get_family(this->other_host); family = this->other_host->get_family(this->other_host);
} }
host = host_create_from_dns(this->ike_cfg->get_my_addr(this->ike_cfg), my_addr = this->ike_cfg->get_my_addr(this->ike_cfg, NULL);
family, this->ike_cfg->get_my_port(this->ike_cfg)); my_port = this->ike_cfg->get_my_port(this->ike_cfg);
host = host_create_from_dns(my_addr, family, my_port);
if (host && host->is_anyaddr(host) && if (host && host->is_anyaddr(host) &&
!this->other_host->is_anyaddr(this->other_host)) !this->other_host->is_anyaddr(this->other_host))
@@ -1076,9 +1083,7 @@ static void resolve_hosts(private_ike_sa_t *this)
} }
else else
{ /* fallback to address family specific %any(6), if configured */ { /* fallback to address family specific %any(6), if configured */
host = host_create_from_dns( host = host_create_from_dns(my_addr, 0, my_port);
this->ike_cfg->get_my_addr(this->ike_cfg),
0, this->ike_cfg->get_my_port(this->ike_cfg));
} }
} }
} }
@@ -1108,7 +1113,7 @@ METHOD(ike_sa_t, initiate, status_t,
#endif /* ME */ #endif /* ME */
) )
{ {
char *addr = this->ike_cfg->get_other_addr(this->ike_cfg); char *addr = this->ike_cfg->get_other_addr(this->ike_cfg, NULL);
bool is_anyaddr = streq(addr, "%any") || streq(addr, "%any6"); bool is_anyaddr = streq(addr, "%any") || streq(addr, "%any6");
if (is_anyaddr || !this->retry_initiate_interval) if (is_anyaddr || !this->retry_initiate_interval)
+2 -2
View File
@@ -127,14 +127,14 @@ METHOD(trap_manager_t, install, u_int32_t,
/* try to resolve addresses */ /* try to resolve addresses */
ike_cfg = peer->get_ike_cfg(peer); ike_cfg = peer->get_ike_cfg(peer);
other = host_create_from_dns(ike_cfg->get_other_addr(ike_cfg), other = host_create_from_dns(ike_cfg->get_other_addr(ike_cfg, NULL),
0, ike_cfg->get_other_port(ike_cfg)); 0, ike_cfg->get_other_port(ike_cfg));
if (!other || other->is_anyaddr(other)) if (!other || other->is_anyaddr(other))
{ {
DBG1(DBG_CFG, "installing trap failed, remote address unknown"); DBG1(DBG_CFG, "installing trap failed, remote address unknown");
return 0; return 0;
} }
me = host_create_from_dns(ike_cfg->get_my_addr(ike_cfg), me = host_create_from_dns(ike_cfg->get_my_addr(ike_cfg, NULL),
other->get_family(other), ike_cfg->get_my_port(ike_cfg)); other->get_family(other), ike_cfg->get_my_port(ike_cfg));
if (!me || me->is_anyaddr(me)) if (!me || me->is_anyaddr(me))
{ {
+1
View File
@@ -186,6 +186,7 @@ static void starter_stroke_add_end(stroke_msg_t *msg, stroke_end_t *msg_end, sta
msg_end->sendcert = conn_end->sendcert; msg_end->sendcert = conn_end->sendcert;
msg_end->hostaccess = conn_end->hostaccess; msg_end->hostaccess = conn_end->hostaccess;
msg_end->tohost = !conn_end->has_client; msg_end->tohost = !conn_end->has_client;
msg_end->allow_any = conn_end->allow_any;
msg_end->protocol = conn_end->protocol; msg_end->protocol = conn_end->protocol;
msg_end->port = conn_end->port; msg_end->port = conn_end->port;
} }
+1
View File
@@ -162,6 +162,7 @@ struct stroke_end_t {
int sendcert; int sendcert;
int hostaccess; int hostaccess;
int tohost; int tohost;
int allow_any;
u_int8_t protocol; u_int8_t protocol;
u_int16_t port; u_int16_t port;
}; };