};
METHOD(attribute_handler_t, handle, bool,
- private_nm_handler_t *this, identification_t *server,
+ private_nm_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
linked_list_t *list;
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
- private_nm_handler_t *this, identification_t *server, linked_list_t *vips)
+ private_nm_handler_t *this, ike_sa_t *ike_sa, linked_list_t *vips)
{
if (vips->get_count(vips))
{
return &this->public;
}
-
};
METHOD(attribute_handler_t, handle, bool,
- private_android_attr_t *this, identification_t *server,
+ private_android_attr_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
vpnservice_builder_t *builder;
}
METHOD(attribute_handler_t, release, void,
- private_android_attr_t *this, identification_t *server,
+ private_android_attr_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
/* DNS servers cannot be removed from an existing TUN device */
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
- private_android_attr_t *this, identification_t *server, linked_list_t *vips)
+ private_android_attr_t *this, ike_sa_t *ike_sa, linked_list_t *vips)
{
enumerator_t *enumerator;
return &this->public;
}
-
#ifndef ATTRIBUTE_HANDLER_H_
#define ATTRIBUTE_HANDLER_H_
+typedef struct attribute_handler_t attribute_handler_t;
+
+#include <sa/ike_sa.h>
#include <utils/chunk.h>
-#include <utils/identification.h>
#include <collections/linked_list.h>
#include "attributes.h"
-typedef struct attribute_handler_t attribute_handler_t;
-
/**
* Interface to handle configuration payload attributes.
*/
* After receiving a configuration attriubte, it is passed to each
* attribute handler until it is handled.
*
- * @param server server from which the attribute was received
+ * @param ike_sa IKE_SA under which attribute is received
* @param type type of configuration attribute to handle
* @param data associated attribute data
* @return TRUE if attribute handled
*/
- bool (*handle)(attribute_handler_t *this, identification_t *server,
+ bool (*handle)(attribute_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data);
/**
* A handler that handle()d an attribute gets a call to release() when the
* connection gets closed. Depending on the implementation, this is required
* to remove the attribute.
+ *
+ * @param ike_sa IKE_SA which releases attribute
+ * @param type type of configuration attribute to release
+ * @param data associated attribute data
*/
- void (*release)(attribute_handler_t *this, identification_t *server,
+ void (*release)(attribute_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data);
/**
* Enumerate attributes to request from a server.
*
- * @param server server identity to request attributes from
+ * @param ike_sa IKE_SA to request attributes for
* @param vips list of virtual IPs (host_t*) we are requesting
* @return enumerator (configuration_attribute_type_t, chunk_t)
*/
enumerator_t* (*create_attribute_enumerator)(attribute_handler_t *this,
- identification_t *server, linked_list_t *vips);
+ ike_sa_t *ike_sa, linked_list_t *vips);
};
#endif /** ATTRIBUTE_HANDLER_H_ @}*/
chunk_t data)
{
enumerator_t *enumerator;
- identification_t *server;
attribute_handler_t *current, *handled = NULL;
- server = ike_sa->get_other_id(ike_sa);
-
this->lock->read_lock(this->lock);
/* try to find the passed handler */
enumerator = this->handlers->create_enumerator(this->handlers);
while (enumerator->enumerate(enumerator, ¤t))
{
- if (current == handler && current->handle(current, server, type, data))
+ if (current == handler && current->handle(current, ike_sa, type, data))
{
handled = current;
break;
enumerator = this->handlers->create_enumerator(this->handlers);
while (enumerator->enumerate(enumerator, ¤t))
{
- if (current->handle(current, server, type, data))
+ if (current->handle(current, ike_sa, type, data))
{
handled = current;
break;
{
enumerator_t *enumerator;
attribute_handler_t *current;
- identification_t *server;
-
- server = ike_sa->get_other_id(ike_sa);
this->lock->read_lock(this->lock);
enumerator = this->handlers->create_enumerator(this->handlers);
{
if (current == handler)
{
- current->release(current, server, type, data);
+ current->release(current, ike_sa, type, data);
break;
}
}
configuration_attribute_type_t *type,
chunk_t *value)
{
- identification_t *id;
-
- id = this->ike_sa->get_other_id(this->ike_sa);
-
/* enumerate inner attributes using outer handler enumerator */
while (!this->inner || !this->inner->enumerate(this->inner, type, value))
{
}
DESTROY_IF(this->inner);
this->inner = this->handler->create_attribute_enumerator(this->handler,
- id, this->vips);
+ this->ike_sa, this->vips);
}
/* inject the handler as additional attribute */
*handler = this->handler;
}
METHOD(attribute_handler_t, handle, bool,
- private_android_dns_handler_t *this, identification_t *id,
+ private_android_dns_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
switch (type)
}
METHOD(attribute_handler_t, release, void,
- private_android_dns_handler_t *this, identification_t *server,
+ private_android_dns_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
if (type == INTERNAL_IP4_DNS)
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
- private_android_dns_handler_t *this, identification_t *id,
+ private_android_dns_handler_t *this, ike_sa_t *ike_sa,
linked_list_t *vips)
{
enumerator_t *enumerator;
return &this->public;
}
-
}
METHOD(attribute_handler_t, handle, bool,
- private_osx_attr_handler_t *this, identification_t *id,
+ private_osx_attr_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
switch (type)
}
METHOD(attribute_handler_t, release, void,
- private_osx_attr_handler_t *this, identification_t *server,
+ private_osx_attr_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
switch (type)
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
- private_osx_attr_handler_t *this, identification_t *id,
+ private_osx_attr_handler_t *this, ike_sa_t *ike_sa,
linked_list_t *vips)
{
enumerator_t *enumerator;
}
METHOD(attribute_handler_t, handle, bool,
- private_resolve_handler_t *this, identification_t *server,
+ private_resolve_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
+ identification_t *server;
host_t *addr;
bool handled;
DESTROY_IF(addr);
return FALSE;
}
+ server = ike_sa->get_other_id(ike_sa);
this->mutex->lock(this->mutex);
if (this->use_resolvconf)
}
METHOD(attribute_handler_t, release, void,
- private_resolve_handler_t *this, identification_t *server,
+ private_resolve_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
+ identification_t *server;
host_t *addr;
int family;
return;
}
addr = host_create_from_chunk(family, data, 0);
+ server = ike_sa->get_other_id(ike_sa);
this->mutex->lock(this->mutex);
if (this->use_resolvconf)
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
- private_resolve_handler_t *this, identification_t *server,
+ private_resolve_handler_t *this, ike_sa_t *ike_sa,
linked_list_t *vips)
{
attribute_enumerator_t *enumerator;
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
- private_stroke_handler_t *this, identification_t *server,
+ private_stroke_handler_t *this, ike_sa_t *ike_sa,
linked_list_t *vips)
{
- ike_sa_t *ike_sa;
peer_cfg_t *peer_cfg;
enumerator_t *enumerator;
attributes_t *attr;
}
METHOD(attribute_handler_t, handle, bool,
- private_unity_handler_t *this, identification_t *id,
+ private_unity_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
switch (type)
}
METHOD(attribute_handler_t, release, void,
- private_unity_handler_t *this, identification_t *server,
+ private_unity_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
switch (type)
}
METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
- unity_handler_t *this, identification_t *id, linked_list_t *vips)
+ unity_handler_t *this, ike_sa_t *ike_sa, linked_list_t *vips)
{
attribute_enumerator_t *enumerator;
- ike_sa_t *ike_sa;
ike_sa = charon->bus->get_sa(charon->bus);
if (!ike_sa || ike_sa->get_version(ike_sa) != IKEV1 ||
}
METHOD(attribute_handler_t, handle, bool,
- private_updown_handler_t *this, identification_t *server,
+ private_updown_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
attributes_t *current, *attr = NULL;
enumerator_t *enumerator;
- ike_sa_t *ike_sa;
host_t *host;
- ike_sa = charon->bus->get_sa(charon->bus);
- if (!ike_sa)
- {
- return FALSE;
- }
switch (type)
{
case INTERNAL_IP4_DNS:
}
METHOD(attribute_handler_t, release, void,
- private_updown_handler_t *this, identification_t *server,
+ private_updown_handler_t *this, ike_sa_t *ike_sa,
configuration_attribute_type_t type, chunk_t data)
{
attributes_t *attr;
enumerator_t *enumerator, *servers;
- ike_sa_t *ike_sa;
host_t *host;
bool found = FALSE;
int family;
return;
}
- ike_sa = charon->bus->get_sa(charon->bus);
- if (ike_sa)
+ this->lock->write_lock(this->lock);
+ enumerator = this->attrs->create_enumerator(this->attrs);
+ while (enumerator->enumerate(enumerator, &attr))
{
- this->lock->write_lock(this->lock);
- enumerator = this->attrs->create_enumerator(this->attrs);
- while (enumerator->enumerate(enumerator, &attr))
+ if (attr->id == ike_sa->get_unique_id(ike_sa))
{
- if (attr->id == ike_sa->get_unique_id(ike_sa))
+ servers = attr->dns->create_enumerator(attr->dns);
+ while (servers->enumerate(servers, &host))
{
- servers = attr->dns->create_enumerator(attr->dns);
- while (servers->enumerate(servers, &host))
+ if (host->get_family(host) == family &&
+ chunk_equals(data, host->get_address(host)))
{
- if (host->get_family(host) == family &&
- chunk_equals(data, host->get_address(host)))
- {
- attr->dns->remove_at(attr->dns, servers);
- host->destroy(host);
- found = TRUE;
- break;
- }
- }
- servers->destroy(servers);
- if (attr->dns->get_count(attr->dns) == 0)
- {
- this->attrs->remove_at(this->attrs, enumerator);
- attributes_destroy(attr);
+ attr->dns->remove_at(attr->dns, servers);
+ host->destroy(host);
+ found = TRUE;
break;
}
}
- if (found)
+ servers->destroy(servers);
+ if (attr->dns->get_count(attr->dns) == 0)
{
+ this->attrs->remove_at(this->attrs, enumerator);
+ attributes_destroy(attr);
break;
}
}
- enumerator->destroy(enumerator);
- this->lock->unlock(this->lock);
+ if (found)
+ {
+ break;
+ }
}
+ enumerator->destroy(enumerator);
+ this->lock->unlock(this->lock);
}
METHOD(updown_handler_t, create_dns_enumerator, enumerator_t*,