From c9ab318abc155247a7264e303b7d7ebc96628638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Thu, 30 Dec 2021 11:13:42 +0100 Subject: [PATCH] mark out todos --- src/exchange/taler-exchange-httpd.c | 34 ++------------ src/exchange/taler-exchange-httpd.h | 2 +- .../taler-exchange-httpd_extensions.c | 45 ++++++++++++++++++- ...ler-exchange-httpd_management_extensions.c | 4 ++ 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c index 12764ca45..d9d372809 100644 --- a/src/exchange/taler-exchange-httpd.c +++ b/src/exchange/taler-exchange-httpd.c @@ -148,37 +148,9 @@ int TEH_check_invariants_flag; bool TEH_suicide; /** - * The global manifest with the list supported extensions, sorted by - * TALER_Extension_Type. - * - * TODO: This needs to become a dynamic list, once we have a model for - * extensions as plugins. - **/ -const struct TALER_Extension TEH_extensions[] = { - [TALER_Extension_AgeRestriction] = { - .type = TALER_Extension_AgeRestriction, - .name = "age_restriction", - .critical = false, - .config = NULL, // disabled per default - /* TODO: - .parse_config = &TALER_Extension_AgeRestriction_parse_config, - .config_to_json = &TALER_Extension_AgeRestriction_config_to_json, - */ - }, - [TALER_Extension_Peer2Peer] = { - .type = TALER_Extension_Peer2Peer, - .name = "peer2peer", - .critical = false, - .config = NULL, // disabled per default - }, - /* terminator */ - [TALER_Extension_Max] = { - .type = TALER_Extension_Max, - .name = NULL, - .critical = false, - .config = NULL, - }, -}; + * Global register of extensions + */ +struct TALER_Extension *TEH_extensions; /** * Value to return from main() diff --git a/src/exchange/taler-exchange-httpd.h b/src/exchange/taler-exchange-httpd.h index e252e1c58..543d1b90f 100644 --- a/src/exchange/taler-exchange-httpd.h +++ b/src/exchange/taler-exchange-httpd.h @@ -204,7 +204,7 @@ extern struct GNUNET_CURL_Context *TEH_curl_ctx; /** * The manifest of the available extensions, NULL terminated */ -extern const struct TALER_Extension TEH_extensions[]; +extern struct TALER_Extension *TEH_extensions; /** * @brief Struct describing an URL and the handler for it. diff --git a/src/exchange/taler-exchange-httpd_extensions.c b/src/exchange/taler-exchange-httpd_extensions.c index 5da270622..24d4dc469 100644 --- a/src/exchange/taler-exchange-httpd_extensions.c +++ b/src/exchange/taler-exchange-httpd_extensions.c @@ -26,6 +26,47 @@ #include "taler_mhd_lib.h" #include +/** + * Create a list with the extensions for Age Restriction and Peer2Peer + * + * TODO oec + */ +static struct TALER_Extension * +register_known_extensions () +{ + /* TODO oec + * - create list of correct size, or linked list? + * - fill data for age restriction and peer2peer + * - set function pointers for parser and json-converter + * - set function pointers for notimplemented? + */ +/** + * The global manifest with the list supported extensions, sorted by + * TALER_Extension_Type. + * + * TODO: This needs to become a dynamic list, once we have a model for + * extensions as plugins. +struct TALER_Extension *TEH_extensions[] = { + [TALER_Extension_AgeRestriction] = { + .type = TALER_Extension_AgeRestriction, + .name = "age_restriction", + .critical = false, + .config = NULL, // disabled per default + // .parse_config = &TALER_Extension_AgeRestriction_parse_config, + // .config_to_json = &TALER_Extension_AgeRestriction_config_to_json, + }, + [TALER_Extension_Peer2Peer] = { + .type = TALER_Extension_Peer2Peer, + .name = "peer2peer", + .critical = false, + .config = NULL, // disabled per default + }, +}; + **/ + + return NULL; +} + /** * Handler listening for extensions updates by other exchange @@ -85,7 +126,7 @@ extension_update_event_cb (void *cls, } /* - * TODO: + * TODO oec: * - parse string as json * - update global config */ @@ -98,6 +139,8 @@ extension_update_event_cb (void *cls, enum GNUNET_GenericReturnValue TEH_extensions_init () { + // TEH_extensions = register_known_extensions(); + struct GNUNET_DB_EventHeaderP ev = { .size = htons (sizeof (ev)), .type = htons (TALER_DBEVENT_EXCHANGE_EXTENSIONS_UPDATED), diff --git a/src/exchange/taler-exchange-httpd_management_extensions.c b/src/exchange/taler-exchange-httpd_management_extensions.c index 319e1882c..4902677ae 100644 --- a/src/exchange/taler-exchange-httpd_management_extensions.c +++ b/src/exchange/taler-exchange-httpd_management_extensions.c @@ -179,6 +179,7 @@ TEH_handler_management_post_extensions ( }; MHD_RESULT ret; + // Parse the top level json structure { enum GNUNET_GenericReturnValue res; @@ -191,6 +192,7 @@ TEH_handler_management_post_extensions ( return MHD_YES; /* failure */ } + // Ensure we have two arrays of the same size if (! (json_is_array (extensions) && json_is_array (extensions_sigs)) ) { @@ -223,6 +225,7 @@ TEH_handler_management_post_extensions ( sec.extensions_sigs = GNUNET_new_array (sec.num_extensions, struct TALER_MasterSignatureP); + // Now parse individual extensions and signatures from those arrays. for (unsigned int i = 0; i