Migrated load_tester_creds to INIT/METHOD macros

This commit is contained in:
Martin Willi
2011-05-16 15:24:13 +02:00
parent e13819507e
commit 8e67b5413c
@@ -184,11 +184,8 @@ static char psk[] = {
*/ */
static char pwd[] = "test#123"; static char pwd[] = "test#123";
/** METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
* Implements credential_set_t.create_private_enumerator private_load_tester_creds_t *this, key_type_t type, identification_t *id)
*/
static enumerator_t* create_private_enumerator(private_load_tester_creds_t *this,
key_type_t type, identification_t *id)
{ {
if (this->private == NULL) if (this->private == NULL)
{ {
@@ -208,12 +205,9 @@ static enumerator_t* create_private_enumerator(private_load_tester_creds_t *this
return enumerator_create_single(this->private, NULL); return enumerator_create_single(this->private, NULL);
} }
/** METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
* Implements credential_set_t.create_cert_enumerator private_load_tester_creds_t *this, certificate_type_t cert, key_type_t key,
*/ identification_t *id, bool trusted)
static enumerator_t* create_cert_enumerator(private_load_tester_creds_t *this,
certificate_type_t cert, key_type_t key,
identification_t *id, bool trusted)
{ {
certificate_t *peer_cert; certificate_t *peer_cert;
public_key_t *peer_key, *ca_key; public_key_t *peer_key, *ca_key;
@@ -274,6 +268,9 @@ static enumerator_t* create_cert_enumerator(private_load_tester_creds_t *this,
return NULL; return NULL;
} }
/**
* Filter function for shared keys, returning ID matches
*/
static bool shared_filter(void *null, shared_key_t **in, shared_key_t **out, static bool shared_filter(void *null, shared_key_t **in, shared_key_t **out,
void **un1, id_match_t *me, void **un2, id_match_t *other) void **un1, id_match_t *me, void **un2, id_match_t *other)
{ {
@@ -289,12 +286,9 @@ static bool shared_filter(void *null, shared_key_t **in, shared_key_t **out,
return TRUE; return TRUE;
} }
/** METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
* Implements credential_set_t.create_shared_enumerator private_load_tester_creds_t *this, shared_key_type_t type,
*/ identification_t *me, identification_t *other)
static enumerator_t* create_shared_enumerator(private_load_tester_creds_t *this,
shared_key_type_t type, identification_t *me,
identification_t *other)
{ {
shared_key_t *shared; shared_key_t *shared;
@@ -314,10 +308,8 @@ static enumerator_t* create_shared_enumerator(private_load_tester_creds_t *this,
(void*)shared_filter, NULL, NULL); (void*)shared_filter, NULL, NULL);
} }
/** METHOD(load_tester_creds_t, destroy, void,
* Implementation of load_tester_creds_t.destroy private_load_tester_creds_t *this)
*/
static void destroy(private_load_tester_creds_t *this)
{ {
DESTROY_IF(this->private); DESTROY_IF(this->private);
DESTROY_IF(this->ca); DESTROY_IF(this->ca);
@@ -328,29 +320,31 @@ static void destroy(private_load_tester_creds_t *this)
load_tester_creds_t *load_tester_creds_create() load_tester_creds_t *load_tester_creds_create()
{ {
private_load_tester_creds_t *this = malloc_thing(private_load_tester_creds_t); private_load_tester_creds_t *this;
this->public.credential_set.create_shared_enumerator = (enumerator_t*(*)(credential_set_t*, shared_key_type_t, identification_t*, identification_t*))create_shared_enumerator; INIT(this,
this->public.credential_set.create_private_enumerator = (enumerator_t*(*) (credential_set_t*, key_type_t, identification_t*))create_private_enumerator; .public = {
this->public.credential_set.create_cert_enumerator = (enumerator_t*(*) (credential_set_t*, certificate_type_t, key_type_t,identification_t *, bool))create_cert_enumerator; .credential_set = {
this->public.credential_set.create_cdp_enumerator = (enumerator_t*(*) (credential_set_t *,certificate_type_t, identification_t *))return_null; .create_shared_enumerator = _create_shared_enumerator,
this->public.credential_set.cache_cert = (void (*)(credential_set_t *, certificate_t *))nop; .create_private_enumerator = _create_private_enumerator,
this->public.destroy = (void(*) (load_tester_creds_t*))destroy; .create_cert_enumerator = _create_cert_enumerator,
.create_cdp_enumerator = (void*)return_null,
this->private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA, .cache_cert = (void*)nop,
BUILD_BLOB_ASN1_DER, chunk_create(private, sizeof(private)), },
BUILD_END); .destroy = _destroy,
},
this->ca = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509, .private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
BUILD_BLOB_ASN1_DER, chunk_create(cert, sizeof(cert)), BUILD_BLOB_ASN1_DER, chunk_create(private, sizeof(private)),
BUILD_X509_FLAG, X509_CA, BUILD_END),
BUILD_END); .ca = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_BLOB_ASN1_DER, chunk_create(cert, sizeof(cert)),
this->psk = shared_key_create(SHARED_IKE, BUILD_X509_FLAG, X509_CA,
chunk_clone(chunk_create(psk, sizeof(psk)))); BUILD_END),
this->pwd = shared_key_create(SHARED_EAP, .psk = shared_key_create(SHARED_IKE,
chunk_clone(chunk_create(pwd, strlen(pwd)))); chunk_clone(chunk_create(psk, sizeof(psk)))),
this->serial = 0; .pwd = shared_key_create(SHARED_EAP,
chunk_clone(chunk_create(pwd, strlen(pwd)))),
);
return &this->public; return &this->public;
} }