Migrate all enumerators to venumerate() interface change
This commit is contained in:
@@ -182,12 +182,15 @@ METHOD(attribute_handler_t, release, void,
|
||||
}
|
||||
|
||||
METHOD(enumerator_t, enumerate_dns, bool,
|
||||
enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
|
||||
enumerator_t *this, va_list args)
|
||||
{
|
||||
configuration_attribute_type_t *type;
|
||||
chunk_t *data;
|
||||
|
||||
VA_ARGS_VGET(args, type, data);
|
||||
*type = INTERNAL_IP4_DNS;
|
||||
*data = chunk_empty;
|
||||
/* stop enumeration */
|
||||
this->enumerate = (void*)return_false;
|
||||
this->venumerate = return_false;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -198,7 +201,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
||||
enumerator_t *enumerator;
|
||||
|
||||
INIT(enumerator,
|
||||
.enumerate = (void*)_enumerate_dns,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate_dns,
|
||||
.destroy = (void*)free,
|
||||
);
|
||||
return enumerator;
|
||||
|
||||
@@ -75,12 +75,15 @@ typedef struct {
|
||||
} cert_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||
cert_enumerator_t *this, certificate_t **cert)
|
||||
cert_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t **cert;
|
||||
dnscert_t *cur_crt;
|
||||
rr_t *cur_rr;
|
||||
chunk_t certificate;
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
/* Get the next supported CERT using the inner enumerator. */
|
||||
while (this->inner->enumerate(this->inner, &cur_rr))
|
||||
{
|
||||
@@ -175,7 +178,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cert_enumerator_enumerate,
|
||||
.destroy = _cert_enumerator_destroy,
|
||||
},
|
||||
.inner = response->get_rr_set(response)->create_rr_enumerator(
|
||||
|
||||
@@ -404,11 +404,13 @@ typedef struct {
|
||||
attr_t *current;
|
||||
} attribute_enumerator_t;
|
||||
|
||||
|
||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||
attribute_enumerator_t *this, configuration_attribute_type_t *type,
|
||||
chunk_t *data)
|
||||
attribute_enumerator_t *this, va_list args)
|
||||
{
|
||||
configuration_attribute_type_t *type;
|
||||
chunk_t *data;
|
||||
|
||||
VA_ARGS_VGET(args, type, data);
|
||||
if (this->current)
|
||||
{
|
||||
destroy_attr(this->current);
|
||||
@@ -446,7 +448,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_attribute_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _attribute_enumerate,
|
||||
.destroy = _attribute_destroy,
|
||||
},
|
||||
.list = linked_list_create(),
|
||||
|
||||
@@ -79,10 +79,8 @@ typedef struct {
|
||||
private_eap_sim_file_triplets_t *this;
|
||||
} triplet_enumerator_t;
|
||||
|
||||
/**
|
||||
* destroy a triplet enumerator
|
||||
*/
|
||||
static void enumerator_destroy(triplet_enumerator_t *e)
|
||||
METHOD(enumerator_t, enumerator_destroy, void,
|
||||
triplet_enumerator_t *e)
|
||||
{
|
||||
if (e->current)
|
||||
{
|
||||
@@ -97,13 +95,14 @@ static void enumerator_destroy(triplet_enumerator_t *e)
|
||||
free(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* enumerate through triplets
|
||||
*/
|
||||
static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **imsi,
|
||||
char **rand, char **sres, char **kc)
|
||||
METHOD(enumerator_t, enumerator_enumerate, bool,
|
||||
triplet_enumerator_t *e, va_list args)
|
||||
{
|
||||
identification_t **imsi;
|
||||
triplet_t *triplet;
|
||||
char **rand, **sres, **kc;
|
||||
|
||||
VA_ARGS_VGET(args, imsi, rand, sres, kc);
|
||||
|
||||
if (e->inner->enumerate(e->inner, &triplet))
|
||||
{
|
||||
@@ -124,12 +123,15 @@ METHOD(eap_sim_file_triplets_t, create_enumerator, enumerator_t*,
|
||||
triplet_enumerator_t *enumerator = malloc_thing(triplet_enumerator_t);
|
||||
|
||||
this->mutex->lock(this->mutex);
|
||||
enumerator->public.enumerate = (void*)enumerator_enumerate;
|
||||
enumerator->public.destroy = (void*)enumerator_destroy;
|
||||
enumerator->inner = this->triplets->create_enumerator(this->triplets);
|
||||
enumerator->current = NULL;
|
||||
enumerator->this = this;
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerator_enumerate,
|
||||
.destroy = _enumerator_destroy,
|
||||
},
|
||||
.inner = this->triplets->create_enumerator(this->triplets),
|
||||
.this = this,
|
||||
);
|
||||
return &enumerator->public;
|
||||
}
|
||||
|
||||
|
||||
@@ -331,10 +331,12 @@ typedef struct {
|
||||
} attribute_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||
attribute_enumerator_t *this, ha_message_attribute_t *attr_out,
|
||||
ha_message_value_t *value)
|
||||
attribute_enumerator_t *this, va_list args)
|
||||
{
|
||||
ha_message_attribute_t attr;
|
||||
ha_message_attribute_t attr, *attr_out;
|
||||
ha_message_value_t *value;
|
||||
|
||||
VA_ARGS_VGET(args, attr_out, value);
|
||||
|
||||
if (this->cleanup)
|
||||
{
|
||||
@@ -602,7 +604,8 @@ METHOD(ha_message_t, create_attribute_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_attribute_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _attribute_enumerate,
|
||||
.destroy = _enum_destroy,
|
||||
},
|
||||
.buf = chunk_skip(this->buf, 2),
|
||||
|
||||
@@ -111,8 +111,12 @@ typedef struct {
|
||||
} shared_enum_t;
|
||||
|
||||
METHOD(enumerator_t, shared_enumerate, bool,
|
||||
shared_enum_t *this, shared_key_t **key, id_match_t *me, id_match_t *other)
|
||||
shared_enum_t *this, va_list args)
|
||||
{
|
||||
shared_key_t **key;
|
||||
id_match_t *me, *other;
|
||||
|
||||
VA_ARGS_VGET(args, key, me, other);
|
||||
if (this->key)
|
||||
{
|
||||
if (me)
|
||||
@@ -151,7 +155,8 @@ METHOD(ha_creds_t, create_shared_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_shared_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _shared_enumerate,
|
||||
.destroy = (void*)free,
|
||||
},
|
||||
.key = this->key,
|
||||
|
||||
@@ -62,13 +62,16 @@ typedef struct {
|
||||
} cert_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||
cert_enumerator_t *this, certificate_t **cert)
|
||||
cert_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t **cert;
|
||||
ipseckey_t *cur_ipseckey;
|
||||
public_key_t *public;
|
||||
rr_t *cur_rr;
|
||||
chunk_t key;
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
/* Get the next supported IPSECKEY using the inner enumerator. */
|
||||
while (this->inner->enumerate(this->inner, &cur_rr))
|
||||
{
|
||||
@@ -211,7 +214,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cert_enumerator_enumerate,
|
||||
.destroy = _cert_enumerator_destroy,
|
||||
},
|
||||
.inner = rrset->create_rr_enumerator(rrset),
|
||||
|
||||
@@ -466,9 +466,12 @@ typedef struct {
|
||||
} addr_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, addr_enumerate, bool,
|
||||
addr_enumerator_t *this, host_t **host)
|
||||
addr_enumerator_t *this, va_list args)
|
||||
{
|
||||
iface_t *entry;
|
||||
host_t **host;
|
||||
|
||||
VA_ARGS_VGET(args, host);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
@@ -523,7 +526,8 @@ METHOD(kernel_net_t, create_address_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_addr_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _addr_enumerate,
|
||||
.destroy = _addr_destroy,
|
||||
},
|
||||
.which = which,
|
||||
|
||||
@@ -2165,8 +2165,14 @@ METHOD(enumerator_t, destroy_subnet_enumerator, void,
|
||||
}
|
||||
|
||||
METHOD(enumerator_t, enumerate_subnets, bool,
|
||||
subnet_enumerator_t *this, host_t **net, uint8_t *mask, char **ifname)
|
||||
subnet_enumerator_t *this, va_list args)
|
||||
{
|
||||
host_t **net;
|
||||
uint8_t *mask;
|
||||
char **ifname;
|
||||
|
||||
VA_ARGS_VGET(args, net, mask, ifname);
|
||||
|
||||
if (!this->current)
|
||||
{
|
||||
this->current = this->msg;
|
||||
@@ -2270,7 +2276,8 @@ METHOD(kernel_net_t, create_local_subnet_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_enumerate_subnets,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate_subnets,
|
||||
.destroy = _destroy_subnet_enumerator,
|
||||
},
|
||||
.private = this,
|
||||
|
||||
@@ -601,9 +601,12 @@ typedef struct {
|
||||
} rt_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, rt_enumerate, bool,
|
||||
rt_enumerator_t *this, int *xtype, struct sockaddr **addr)
|
||||
rt_enumerator_t *this, va_list args)
|
||||
{
|
||||
int i, type;
|
||||
struct sockaddr **addr;
|
||||
int i, type, *xtype;
|
||||
|
||||
VA_ARGS_VGET(args, xtype, addr);
|
||||
|
||||
if (this->remaining < sizeof(this->addr->sa_len) ||
|
||||
this->remaining < this->addr->sa_len)
|
||||
@@ -637,7 +640,8 @@ static enumerator_t *create_rt_enumerator(int types, int remaining,
|
||||
|
||||
INIT(this,
|
||||
.public = {
|
||||
.enumerate = (void*)_rt_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _rt_enumerate,
|
||||
.destroy = (void*)free,
|
||||
},
|
||||
.types = types,
|
||||
@@ -1789,13 +1793,18 @@ METHOD(enumerator_t, destroy_subnet_enumerator, void,
|
||||
}
|
||||
|
||||
METHOD(enumerator_t, enumerate_subnets, bool,
|
||||
subnet_enumerator_t *this, host_t **net, uint8_t *mask, char **ifname)
|
||||
subnet_enumerator_t *this, va_list args)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
host_t **net;
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr *addr;
|
||||
uint8_t *mask;
|
||||
char **ifname;
|
||||
int type;
|
||||
|
||||
VA_ARGS_VGET(args, net, mask, ifname);
|
||||
|
||||
if (!this->current)
|
||||
{
|
||||
this->current = this->buf;
|
||||
@@ -1888,7 +1897,8 @@ METHOD(kernel_net_t, create_local_subnet_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_enumerate_subnets,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate_subnets,
|
||||
.destroy = _destroy_subnet_enumerator,
|
||||
},
|
||||
.buf = buf,
|
||||
|
||||
@@ -223,10 +223,11 @@ typedef struct {
|
||||
} peer_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||
peer_enumerator_t *this, peer_cfg_t **cfg)
|
||||
peer_enumerator_t *this, va_list args)
|
||||
{
|
||||
char *name, *local_net, *remote_net;
|
||||
chunk_t me, other;
|
||||
peer_cfg_t **cfg;
|
||||
child_cfg_t *child_cfg;
|
||||
auth_cfg_t *auth;
|
||||
peer_cfg_create_t peer = {
|
||||
@@ -249,6 +250,8 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||
.mode = MODE_TUNNEL,
|
||||
};
|
||||
|
||||
VA_ARGS_VGET(args, cfg);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
if (!this->inner->enumerate(this->inner, &name, &me, &other,
|
||||
&local_net, &remote_net))
|
||||
@@ -295,7 +298,8 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_peer_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _peer_enumerator_enumerate,
|
||||
.destroy = _peer_enumerator_destroy,
|
||||
},
|
||||
.ike = this->ike,
|
||||
|
||||
@@ -50,10 +50,13 @@ typedef struct {
|
||||
} private_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, private_enumerator_enumerate, bool,
|
||||
private_enumerator_t *this, private_key_t **key)
|
||||
private_enumerator_t *this, va_list args)
|
||||
{
|
||||
private_key_t **key;
|
||||
chunk_t chunk;
|
||||
|
||||
VA_ARGS_VGET(args, key);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &chunk))
|
||||
{
|
||||
@@ -92,7 +95,8 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_private_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _private_enumerator_enumerate,
|
||||
.destroy = _private_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
@@ -123,11 +127,14 @@ typedef struct {
|
||||
} cert_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||
cert_enumerator_t *this, certificate_t **cert)
|
||||
cert_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t **cert;
|
||||
public_key_t *public;
|
||||
chunk_t chunk;
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &chunk))
|
||||
{
|
||||
@@ -180,7 +187,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cert_enumerator_enumerate,
|
||||
.destroy = _cert_enumerator_destroy,
|
||||
},
|
||||
.type = key,
|
||||
|
||||
@@ -52,12 +52,14 @@ typedef struct {
|
||||
} cert_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||
cert_enumerator_t *this, certificate_t **cert)
|
||||
cert_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t *trusted;
|
||||
certificate_t *trusted, **cert;
|
||||
public_key_t *public;
|
||||
chunk_t chunk;
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &chunk))
|
||||
{
|
||||
@@ -110,7 +112,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cert_enumerator_enumerate,
|
||||
.destroy = _cert_enumerator_destroy,
|
||||
},
|
||||
.type = key,
|
||||
|
||||
@@ -218,12 +218,15 @@ METHOD(attribute_handler_t, release, void,
|
||||
}
|
||||
|
||||
METHOD(enumerator_t, enumerate_dns, bool,
|
||||
enumerator_t *this, configuration_attribute_type_t *type, chunk_t *data)
|
||||
enumerator_t *this, va_list args)
|
||||
{
|
||||
configuration_attribute_type_t *type;
|
||||
chunk_t *data;
|
||||
|
||||
VA_ARGS_VGET(args, type, data);
|
||||
*type = INTERNAL_IP4_DNS;
|
||||
*data = chunk_empty;
|
||||
/* stop enumeration */
|
||||
this->enumerate = (void*)return_false;
|
||||
this->venumerate = (void*)return_false;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -234,7 +237,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
||||
enumerator_t *enumerator;
|
||||
|
||||
INIT(enumerator,
|
||||
.enumerate = (void*)_enumerate_dns,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate_dns,
|
||||
.destroy = (void*)free,
|
||||
);
|
||||
return enumerator;
|
||||
|
||||
@@ -83,9 +83,12 @@ typedef struct {
|
||||
} attr_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, enumerate_attrs, bool,
|
||||
attr_enumerator_t *this, configuration_attribute_type_t *type,
|
||||
chunk_t *data)
|
||||
attr_enumerator_t *this, va_list args)
|
||||
{
|
||||
configuration_attribute_type_t *type;
|
||||
chunk_t *data;
|
||||
|
||||
VA_ARGS_VGET(args, type, data);
|
||||
if (this->request_ipv4)
|
||||
{
|
||||
*type = P_CSCF_IP4_ADDRESS;
|
||||
@@ -132,7 +135,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_enumerate_attrs,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate_attrs,
|
||||
.destroy = (void*)free,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -391,10 +391,13 @@ typedef struct {
|
||||
bool v6;
|
||||
} attribute_enumerator_t;
|
||||
|
||||
static bool attribute_enumerate(attribute_enumerator_t *this,
|
||||
configuration_attribute_type_t *type,
|
||||
chunk_t *data)
|
||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||
attribute_enumerator_t *this, va_list args)
|
||||
{
|
||||
configuration_attribute_type_t *type;
|
||||
chunk_t *data;
|
||||
|
||||
VA_ARGS_VGET(args, type, data);
|
||||
if (this->v4)
|
||||
{
|
||||
*type = INTERNAL_IP4_DNS;
|
||||
@@ -443,7 +446,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)attribute_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _attribute_enumerate,
|
||||
.destroy = (void*)free,
|
||||
},
|
||||
.v4 = has_host_family(vips, AF_INET),
|
||||
|
||||
@@ -504,11 +504,12 @@ typedef struct {
|
||||
ike_cfg_t *current;
|
||||
} ike_enumerator_t;
|
||||
|
||||
/**
|
||||
* Implementation of ike_enumerator_t.public.enumerate
|
||||
*/
|
||||
static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
|
||||
METHOD(enumerator_t, ike_enumerator_enumerate, bool,
|
||||
ike_enumerator_t *this, va_list args)
|
||||
{
|
||||
ike_cfg_t **cfg;
|
||||
|
||||
VA_ARGS_VGET(args, cfg);
|
||||
DESTROY_IF(this->current);
|
||||
this->current = build_ike_cfg(this->this, this->inner, this->me, this->other);
|
||||
if (this->current)
|
||||
@@ -519,10 +520,8 @@ static bool ike_enumerator_enumerate(ike_enumerator_t *this, ike_cfg_t **cfg)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of ike_enumerator_t.public.destroy
|
||||
*/
|
||||
static void ike_enumerator_destroy(ike_enumerator_t *this)
|
||||
METHOD(enumerator_t, ike_enumerator_destroy, void,
|
||||
ike_enumerator_t *this)
|
||||
{
|
||||
DESTROY_IF(this->current);
|
||||
this->inner->destroy(this->inner);
|
||||
@@ -532,19 +531,22 @@ static void ike_enumerator_destroy(ike_enumerator_t *this)
|
||||
METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
|
||||
private_sql_config_t *this, host_t *me, host_t *other)
|
||||
{
|
||||
ike_enumerator_t *e = malloc_thing(ike_enumerator_t);
|
||||
|
||||
e->this = this;
|
||||
e->me = me;
|
||||
e->other = other;
|
||||
e->current = NULL;
|
||||
e->public.enumerate = (void*)ike_enumerator_enumerate;
|
||||
e->public.destroy = (void*)ike_enumerator_destroy;
|
||||
ike_enumerator_t *e;
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _ike_enumerator_enumerate,
|
||||
.destroy = _ike_enumerator_destroy,
|
||||
},
|
||||
.this = this,
|
||||
.me = me,
|
||||
.other = other,
|
||||
);
|
||||
e->inner = this->db->query(this->db,
|
||||
"SELECT id, certreq, force_encap, local, remote "
|
||||
"FROM ike_configs",
|
||||
DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
|
||||
"SELECT id, certreq, force_encap, local, remote "
|
||||
"FROM ike_configs",
|
||||
DB_INT, DB_INT, DB_INT, DB_TEXT, DB_TEXT);
|
||||
if (!e->inner)
|
||||
{
|
||||
free(e);
|
||||
@@ -569,11 +571,12 @@ typedef struct {
|
||||
peer_cfg_t *current;
|
||||
} peer_enumerator_t;
|
||||
|
||||
/**
|
||||
* Implementation of peer_enumerator_t.public.enumerate
|
||||
*/
|
||||
static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
|
||||
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||
peer_enumerator_t *this, va_list args)
|
||||
{
|
||||
peer_cfg_t **cfg;
|
||||
|
||||
VA_ARGS_VGET(args, cfg);
|
||||
DESTROY_IF(this->current);
|
||||
this->current = build_peer_cfg(this->this, this->inner, this->me, this->other);
|
||||
if (this->current)
|
||||
@@ -584,10 +587,8 @@ static bool peer_enumerator_enumerate(peer_enumerator_t *this, peer_cfg_t **cfg)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of peer_enumerator_t.public.destroy
|
||||
*/
|
||||
static void peer_enumerator_destroy(peer_enumerator_t *this)
|
||||
METHOD(enumerator_t, peer_enumerator_destroy, void,
|
||||
peer_enumerator_t *this)
|
||||
{
|
||||
DESTROY_IF(this->current);
|
||||
this->inner->destroy(this->inner);
|
||||
@@ -599,12 +600,16 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
||||
{
|
||||
peer_enumerator_t *e = malloc_thing(peer_enumerator_t);
|
||||
|
||||
e->this = this;
|
||||
e->me = me;
|
||||
e->other = other;
|
||||
e->current = NULL;
|
||||
e->public.enumerate = (void*)peer_enumerator_enumerate;
|
||||
e->public.destroy = (void*)peer_enumerator_destroy;
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _peer_enumerator_enumerate,
|
||||
.destroy = _peer_enumerator_destroy,
|
||||
},
|
||||
.this = this,
|
||||
.me = me,
|
||||
.other = other,
|
||||
);
|
||||
|
||||
/* TODO: only get configs whose IDs match exactly or contain wildcards */
|
||||
e->inner = this->db->query(this->db,
|
||||
|
||||
@@ -52,11 +52,14 @@ typedef struct {
|
||||
} private_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, private_enumerator_enumerate, bool,
|
||||
private_enumerator_t *this, private_key_t **key)
|
||||
private_enumerator_t *this, va_list args)
|
||||
{
|
||||
private_key_t **key;
|
||||
chunk_t blob;
|
||||
int type;
|
||||
|
||||
VA_ARGS_VGET(args, key);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||
{
|
||||
@@ -88,7 +91,8 @@ METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_private_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _private_enumerator_enumerate,
|
||||
.destroy = _private_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
@@ -132,11 +136,14 @@ typedef struct {
|
||||
} cert_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, cert_enumerator_enumerate, bool,
|
||||
cert_enumerator_t *this, certificate_t **cert)
|
||||
cert_enumerator_t *this, va_list args)
|
||||
{
|
||||
certificate_t **cert;
|
||||
chunk_t blob;
|
||||
int type;
|
||||
|
||||
VA_ARGS_VGET(args, cert);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||
{
|
||||
@@ -169,7 +176,8 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cert_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cert_enumerator_enumerate,
|
||||
.destroy = _cert_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
@@ -221,12 +229,15 @@ typedef struct {
|
||||
} shared_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, shared_enumerator_enumerate, bool,
|
||||
shared_enumerator_t *this, shared_key_t **shared,
|
||||
id_match_t *me, id_match_t *other)
|
||||
shared_enumerator_t *this, va_list args)
|
||||
{
|
||||
shared_key_t **shared;
|
||||
id_match_t *me, *other;
|
||||
chunk_t blob;
|
||||
int type;
|
||||
|
||||
VA_ARGS_VGET(args, shared, me, other);
|
||||
|
||||
DESTROY_IF(this->current);
|
||||
while (this->inner->enumerate(this->inner, &type, &blob))
|
||||
{
|
||||
@@ -265,7 +276,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_shared_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _shared_enumerator_enumerate,
|
||||
.destroy = _shared_enumerator_destroy,
|
||||
},
|
||||
.me = me,
|
||||
@@ -340,9 +352,11 @@ typedef enum {
|
||||
} cdp_type_t;
|
||||
|
||||
METHOD(enumerator_t, cdp_enumerator_enumerate, bool,
|
||||
cdp_enumerator_t *this, char **uri)
|
||||
cdp_enumerator_t *this, va_list args)
|
||||
{
|
||||
char *text;
|
||||
char *text, **uri;
|
||||
|
||||
VA_ARGS_VGET(args, uri);
|
||||
|
||||
free(this->current);
|
||||
while (this->inner->enumerate(this->inner, &text))
|
||||
@@ -384,7 +398,8 @@ METHOD(credential_set_t, create_cdp_enumerator, enumerator_t*,
|
||||
}
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_cdp_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _cdp_enumerator_enumerate,
|
||||
.destroy = _cdp_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -118,11 +118,12 @@ static u_int create_rekey(char *string)
|
||||
}
|
||||
|
||||
METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||
peer_enumerator_t *this, peer_cfg_t **cfg)
|
||||
peer_enumerator_t *this, va_list args)
|
||||
{
|
||||
char *name, *ike_proposal, *esp_proposal, *ike_rekey, *esp_rekey;
|
||||
char *local_id, *local_addr, *local_net;
|
||||
char *remote_id, *remote_addr, *remote_net;
|
||||
peer_cfg_t **cfg;
|
||||
child_cfg_t *child_cfg;
|
||||
ike_cfg_t *ike_cfg;
|
||||
auth_cfg_t *auth;
|
||||
@@ -145,6 +146,8 @@ METHOD(enumerator_t, peer_enumerator_enumerate, bool,
|
||||
.mode = MODE_TUNNEL,
|
||||
};
|
||||
|
||||
VA_ARGS_VGET(args, cfg);
|
||||
|
||||
/* defaults */
|
||||
name = "unnamed";
|
||||
local_id = NULL;
|
||||
@@ -212,7 +215,8 @@ METHOD(backend_t, create_peer_cfg_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_peer_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _peer_enumerator_enumerate,
|
||||
.destroy = _peer_enumerator_destroy,
|
||||
},
|
||||
.inner = this->parser->create_section_enumerator(this->parser,
|
||||
@@ -241,10 +245,13 @@ typedef struct {
|
||||
} ike_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, ike_enumerator_enumerate, bool,
|
||||
ike_enumerator_t *this, ike_cfg_t **cfg)
|
||||
ike_enumerator_t *this, va_list args)
|
||||
{
|
||||
ike_cfg_t **cfg;
|
||||
char *local_addr, *remote_addr, *ike_proposal;
|
||||
|
||||
VA_ARGS_VGET(args, cfg);
|
||||
|
||||
/* defaults */
|
||||
local_addr = "0.0.0.0";
|
||||
remote_addr = "0.0.0.0";
|
||||
@@ -282,7 +289,8 @@ METHOD(backend_t, create_ike_cfg_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_ike_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _ike_enumerator_enumerate,
|
||||
.destroy = _ike_enumerator_destroy,
|
||||
},
|
||||
.inner = this->parser->create_section_enumerator(this->parser,
|
||||
|
||||
@@ -52,12 +52,15 @@ typedef struct {
|
||||
} shared_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, shared_enumerator_enumerate, bool,
|
||||
shared_enumerator_t *this, shared_key_t **key, id_match_t *me,
|
||||
id_match_t *other)
|
||||
shared_enumerator_t *this, va_list args)
|
||||
{
|
||||
shared_key_t **key;
|
||||
id_match_t *me, *other;
|
||||
char *local_id, *remote_id, *psk;
|
||||
identification_t *local, *remote;
|
||||
|
||||
VA_ARGS_VGET(args, key, me, other);
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
/* defaults */
|
||||
@@ -126,7 +129,8 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
|
||||
|
||||
INIT(e,
|
||||
.public = {
|
||||
.enumerate = (void*)_shared_enumerator_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _shared_enumerator_enumerate,
|
||||
.destroy = _shared_enumerator_destroy,
|
||||
},
|
||||
.me = me,
|
||||
|
||||
@@ -58,11 +58,10 @@ typedef struct {
|
||||
} section_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
||||
section_enumerator_t *this, ...)
|
||||
section_enumerator_t *this, va_list args)
|
||||
{
|
||||
struct uci_element *element;
|
||||
char **value;
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
if (&this->current->list == this->list)
|
||||
@@ -70,8 +69,6 @@ METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
va_start(args, this);
|
||||
|
||||
value = va_arg(args, char**);
|
||||
if (value)
|
||||
{
|
||||
@@ -96,7 +93,6 @@ METHOD(enumerator_t, section_enumerator_enumerate, bool,
|
||||
*value = uci_to_option(element)->value;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
|
||||
this->current = list_to_element(this->current->list.next);
|
||||
return TRUE;
|
||||
@@ -124,7 +120,13 @@ METHOD(uci_parser_t, create_section_enumerator, enumerator_t*,
|
||||
i++;
|
||||
}
|
||||
va_end(args);
|
||||
e = malloc(sizeof(section_enumerator_t) + sizeof(char*) * i);
|
||||
INIT_EXTRA(e, sizeof(char*) * i,
|
||||
.public = {
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _section_enumerator_enumerate,
|
||||
.destroy = _section_enumerator_destroy,
|
||||
},
|
||||
);
|
||||
i = 0;
|
||||
va_start(args, this);
|
||||
do
|
||||
@@ -134,9 +136,6 @@ METHOD(uci_parser_t, create_section_enumerator, enumerator_t*,
|
||||
while (e->keywords[i++]);
|
||||
va_end(args);
|
||||
|
||||
e->public.enumerate = (void*)_section_enumerator_enumerate;
|
||||
e->public.destroy = _section_enumerator_destroy;
|
||||
|
||||
/* load uci context */
|
||||
e->ctx = uci_alloc_context();
|
||||
if (uci_load(e->ctx, this->package, &e->package) != UCI_OK)
|
||||
|
||||
@@ -368,9 +368,12 @@ typedef struct {
|
||||
} attribute_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, enumerate_attributes, bool,
|
||||
attribute_enumerator_t *this, configuration_attribute_type_t *type,
|
||||
chunk_t *data)
|
||||
attribute_enumerator_t *this, va_list args)
|
||||
{
|
||||
configuration_attribute_type_t *type;
|
||||
chunk_t *data;
|
||||
|
||||
VA_ARGS_VGET(args, type, data);
|
||||
if (this->i < countof(attributes))
|
||||
{
|
||||
*type = attributes[this->i++];
|
||||
@@ -393,7 +396,8 @@ METHOD(attribute_handler_t, create_attribute_enumerator, enumerator_t *,
|
||||
}
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_enumerate_attributes,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _enumerate_attributes,
|
||||
.destroy = (void*)free,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -77,12 +77,15 @@ static void append_ts(bio_writer_t *writer, traffic_selector_t *ts)
|
||||
}
|
||||
|
||||
METHOD(enumerator_t, attribute_enumerate, bool,
|
||||
attribute_enumerator_t *this, configuration_attribute_type_t *type,
|
||||
chunk_t *attr)
|
||||
attribute_enumerator_t *this, va_list args)
|
||||
{
|
||||
configuration_attribute_type_t *type;
|
||||
chunk_t *attr;
|
||||
traffic_selector_t *ts;
|
||||
bio_writer_t *writer;
|
||||
|
||||
VA_ARGS_VGET(args, type, attr);
|
||||
|
||||
if (this->list->get_count(this->list) == 0)
|
||||
{
|
||||
return FALSE;
|
||||
@@ -183,7 +186,8 @@ METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
|
||||
|
||||
INIT(attr_enum,
|
||||
.public = {
|
||||
.enumerate = (void*)_attribute_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _attribute_enumerate,
|
||||
.destroy = _attribute_destroy,
|
||||
},
|
||||
.list = list,
|
||||
|
||||
@@ -122,9 +122,14 @@ typedef struct {
|
||||
endecode_test_t *next;
|
||||
} endecode_enum_t;
|
||||
|
||||
static bool endecode_enumerate(endecode_enum_t *this, vici_type_t *type,
|
||||
char **name, chunk_t *data)
|
||||
METHOD(enumerator_t, endecode_enumerate, bool,
|
||||
endecode_enum_t *this, va_list args)
|
||||
{
|
||||
vici_type_t *type;
|
||||
chunk_t *data;
|
||||
char **name;
|
||||
|
||||
VA_ARGS_VGET(args, type, name, data);
|
||||
if (this->next)
|
||||
{
|
||||
*type = this->next->type;
|
||||
@@ -149,7 +154,8 @@ static enumerator_t *endecode_create_enumerator(endecode_test_t *test)
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)endecode_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _endecode_enumerate,
|
||||
.destroy = (void*)free,
|
||||
},
|
||||
.next = test,
|
||||
|
||||
@@ -135,11 +135,16 @@ typedef struct {
|
||||
} parse_enumerator_t;
|
||||
|
||||
METHOD(enumerator_t, parse_enumerate, bool,
|
||||
parse_enumerator_t *this, vici_type_t *out, char **name, chunk_t *value)
|
||||
parse_enumerator_t *this, va_list args)
|
||||
{
|
||||
vici_type_t *out;
|
||||
chunk_t *value;
|
||||
char **name;
|
||||
uint8_t type;
|
||||
chunk_t data;
|
||||
|
||||
VA_ARGS_VGET(args, out, name, value);
|
||||
|
||||
if (!this->reader->remaining(this->reader) ||
|
||||
!this->reader->read_uint8(this->reader, &type))
|
||||
{
|
||||
@@ -218,7 +223,8 @@ METHOD(vici_message_t, create_enumerator, enumerator_t*,
|
||||
|
||||
INIT(enumerator,
|
||||
.public = {
|
||||
.enumerate = (void*)_parse_enumerate,
|
||||
.enumerate = enumerator_enumerate_default,
|
||||
.venumerate = _parse_enumerate,
|
||||
.destroy = _parse_destroy,
|
||||
},
|
||||
.reader = bio_reader_create(this->encoding),
|
||||
|
||||
Reference in New Issue
Block a user