/*
+ * Copyright (C) 2012-2015 Tobias Brunner
* Copyright (C) 2005-2007 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
enumerator->destroy(enumerator);
}
+/**
+ * Described in header.
+ */
+int ike_cfg_get_family(ike_cfg_t *cfg, bool local)
+{
+ private_ike_cfg_t *this = (private_ike_cfg_t*)cfg;
+ enumerator_t *enumerator;
+ host_t *host;
+ char *str;
+ int family = AF_UNSPEC;
+
+ if (local)
+ {
+ enumerator = this->my_hosts->create_enumerator(this->my_hosts);
+ }
+ else
+ {
+ enumerator = this->other_hosts->create_enumerator(this->other_hosts);
+ }
+ while (enumerator->enumerate(enumerator, &str))
+ {
+ if (streq(str, "%any"))
+ { /* ignore %any as its family is undetermined */
+ continue;
+ }
+ host = host_create_from_string(str, 0);
+ if (host)
+ {
+ if (family == AF_UNSPEC)
+ {
+ family = host->get_family(host);
+ }
+ else if (family != host->get_family(host))
+ {
+ /* more than one address family defined */
+ family = AF_UNSPEC;
+ host->destroy(host);
+ break;
+ }
+ }
+ DESTROY_IF(host);
+ }
+ enumerator->destroy(enumerator);
+ return family;
+}
+
/**
* Described in header.
*/
/*
- * Copyright (C) 2012 Tobias Brunner
+ * Copyright (C) 2012-2015 Tobias Brunner
* Copyright (C) 2005-2007 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
char *other, u_int16_t other_port,
fragmentation_t fragmentation, u_int8_t dscp);
+/**
+ * Determine the address family of the local or remtoe address(es). If multiple
+ * families are configured AF_UNSPEC is returned. %any is ignored (%any4|6 are
+ * not though).
+ *
+ * @param local TRUE to check local addresses, FALSE for remote
+ * @return address family of address(es) if distinct
+ */
+int ike_cfg_get_family(ike_cfg_t *this, bool local);
+
+
#endif /** IKE_CFG_H_ @}*/