load-tester: Migrate NULL DH implementation to INIT/METHOD macros
authorMartin Willi <martin@revosec.ch>
Mon, 23 Mar 2015 09:44:55 +0000 (10:44 +0100)
committerMartin Willi <martin@revosec.ch>
Mon, 23 Mar 2015 16:54:02 +0000 (17:54 +0100)
src/libcharon/plugins/load_tester/load_tester_diffie_hellman.c

index d5ec359..94e1acc 100644 (file)
 
 #include "load_tester_diffie_hellman.h"
 
-/**
- * Implementation of gmp_diffie_hellman_t.get_my_public_value.
- */
-static void get_my_public_value(load_tester_diffie_hellman_t *this,
-                                                               chunk_t *value)
+METHOD(diffie_hellman_t, get_my_public_value, void,
+       load_tester_diffie_hellman_t *this, chunk_t *value)
 {
        *value = chunk_empty;
 }
 
-/**
- * Implementation of gmp_diffie_hellman_t.get_shared_secret.
- */
-static status_t get_shared_secret(load_tester_diffie_hellman_t *this,
-                                                                 chunk_t *secret)
+METHOD(diffie_hellman_t, set_other_public_value, void,
+       load_tester_diffie_hellman_t *this, chunk_t value)
+{
+}
+
+METHOD(diffie_hellman_t, get_shared_secret, status_t,
+       load_tester_diffie_hellman_t *this, chunk_t *secret)
 {
        *secret = chunk_empty;
        return SUCCESS;
 }
 
-/**
- * Implementation of gmp_diffie_hellman_t.get_dh_group.
- */
-static diffie_hellman_group_t get_dh_group(load_tester_diffie_hellman_t *this)
+METHOD(diffie_hellman_t, get_dh_group, diffie_hellman_group_t,
+       load_tester_diffie_hellman_t *this)
 {
        return MODP_NULL;
 }
 
+METHOD(diffie_hellman_t, destroy, void,
+       load_tester_diffie_hellman_t *this)
+{
+       free(this);
+}
+
 /**
  * See header
  */
@@ -55,13 +58,15 @@ load_tester_diffie_hellman_t *load_tester_diffie_hellman_create(
                return NULL;
        }
 
-       this = malloc_thing(load_tester_diffie_hellman_t);
-
-       this->dh.get_shared_secret = (status_t (*)(diffie_hellman_t *, chunk_t *))get_shared_secret;
-       this->dh.set_other_public_value = (void (*)(diffie_hellman_t *, chunk_t ))nop;
-       this->dh.get_my_public_value = (void (*)(diffie_hellman_t *, chunk_t *))get_my_public_value;
-       this->dh.get_dh_group = (diffie_hellman_group_t (*)(diffie_hellman_t *))get_dh_group;
-       this->dh.destroy = (void (*)(diffie_hellman_t *))free;
+       INIT(this,
+               .dh = {
+                       .get_shared_secret = _get_shared_secret,
+                       .set_other_public_value = _set_other_public_value,
+                       .get_my_public_value = _get_my_public_value,
+                       .get_dh_group = _get_dh_group,
+                       .destroy = _destroy,
+               }
+       );
 
        return this;
 }