From e743275caeff64a9a8eb95d5621843a25c7f6494 Mon Sep 17 00:00:00 2001 From: Martin Willi Date: Thu, 25 Jul 2013 13:39:15 +0200 Subject: [PATCH] ike-cfg: add a method to resolve local/remote hosts with port --- src/libcharon/config/ike_cfg.c | 14 ++++++++++++++ src/libcharon/config/ike_cfg.h | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/libcharon/config/ike_cfg.c b/src/libcharon/config/ike_cfg.c index 54a054e40..3e182a653 100644 --- a/src/libcharon/config/ike_cfg.c +++ b/src/libcharon/config/ike_cfg.c @@ -129,6 +129,18 @@ METHOD(ike_cfg_t, fragmentation, fragmentation_t, return this->fragmentation; } +METHOD(ike_cfg_t, resolve_me, host_t*, + private_ike_cfg_t *this, int family) +{ + return host_create_from_dns(this->me, family, this->my_port); +} + +METHOD(ike_cfg_t, resolve_other, host_t*, + private_ike_cfg_t *this, int family) +{ + return host_create_from_dns(this->other, family, this->other_port); +} + METHOD(ike_cfg_t, get_my_addr, char*, private_ike_cfg_t *this, bool *allow_any) { @@ -333,6 +345,8 @@ ike_cfg_t *ike_cfg_create(ike_version_t version, bool certreq, bool force_encap, .send_certreq = _send_certreq, .force_encap = _force_encap_, .fragmentation = _fragmentation, + .resolve_me = _resolve_me, + .resolve_other = _resolve_other, .get_my_addr = _get_my_addr, .get_other_addr = _get_other_addr, .get_my_port = _get_my_port, diff --git a/src/libcharon/config/ike_cfg.h b/src/libcharon/config/ike_cfg.h index 719ceb9dd..d1db3b463 100644 --- a/src/libcharon/config/ike_cfg.h +++ b/src/libcharon/config/ike_cfg.h @@ -77,6 +77,22 @@ struct ike_cfg_t { */ ike_version_t (*get_version)(ike_cfg_t *this); + /** + * Resolve the local address to use for initiation. + * + * @param family address family to prefer, or AF_UNSPEC + * @return resolved host, NULL on error + */ + host_t* (*resolve_me)(ike_cfg_t *this, int family); + + /** + * Resolve the remote address to use for initiation. + * + * @param family address family to prefer, or AF_UNSPEC + * @return resolved host, NULL on error + */ + host_t* (*resolve_other)(ike_cfg_t *this, int family); + /** * Get own address. *