summaryrefslogtreecommitdiff
path: root/src/reducer/anastasis_api_discovery.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/reducer/anastasis_api_discovery.c')
-rw-r--r--src/reducer/anastasis_api_discovery.c88
1 files changed, 63 insertions, 25 deletions
diff --git a/src/reducer/anastasis_api_discovery.c b/src/reducer/anastasis_api_discovery.c
index 0ac7c92..727f00b 100644
--- a/src/reducer/anastasis_api_discovery.c
+++ b/src/reducer/anastasis_api_discovery.c
@@ -95,6 +95,16 @@ struct ANASTASIS_PolicyDiscovery
* have already seen to the value "dummy".
*/
struct GNUNET_CONTAINER_MultiHashMap *dd_map;
+
+ /**
+ * State we are operating on.
+ */
+ json_t *state;
+
+ /**
+ * Number of optional fields in our identity attributes.
+ */
+ json_int_t opt_cnt;
};
@@ -129,18 +139,6 @@ meta_cb (void *cls,
po);
GNUNET_free (po->provider_url);
GNUNET_free (po);
- if (NULL == pd->po_head)
- {
- pd->cb (pd->cb_cls,
- NULL,
- NULL,
- 0,
- 0,
- GNUNET_TIME_UNIT_ZERO_TS,
- NULL);
- ANASTASIS_policy_discovery_stop (pd);
- return;
- }
return;
}
if (GNUNET_YES ==
@@ -172,7 +170,6 @@ meta_cb (void *cls,
* @param id_data our identity data, derived using @a mask
* @param mask the mask describing which optional attributes were removed
* @param provider_url which provider to query
- * @param state state machine state
* @param cursor cursor telling us from where to query
*/
static void
@@ -180,9 +177,9 @@ start_po (struct ANASTASIS_PolicyDiscovery *pd,
const json_t *id_data,
json_int_t mask,
const char *provider_url,
- const json_t *state,
const json_t *cursor)
{
+ const json_t *state = pd->state;
struct ProviderOperation *po;
uint32_t max_version = UINT32_MAX;
struct ANASTASIS_CRYPTO_ProviderSaltP provider_salt;
@@ -214,6 +211,9 @@ start_po (struct ANASTASIS_PolicyDiscovery *pd,
{
/* cursor invalid */
GNUNET_break (0);
+ json_dumpf (obj,
+ stderr,
+ JSON_INDENT (2));
return;
}
if ( (cmask == mask) &&
@@ -227,11 +227,13 @@ start_po (struct ANASTASIS_PolicyDiscovery *pd,
}
if (GNUNET_OK !=
- ANASTASIS_reducer_lookup_salt_ (state,
- provider_url,
- &provider_salt))
+ ANASTASIS_reducer_lookup_salt (state,
+ provider_url,
+ &provider_salt))
{
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "No /config for `%s', skipping provider\n",
+ provider_url);
return;
}
po = GNUNET_new (struct ProviderOperation);
@@ -295,7 +297,7 @@ ANASTASIS_policy_discovery_start (const json_t *state,
(! json_is_array (required_attributes)) )
{
GNUNET_break (0);
- json_dumpf (state,
+ json_dumpf (required_attributes,
stderr,
JSON_INDENT (2));
return NULL;
@@ -327,6 +329,9 @@ ANASTASIS_policy_discovery_start (const json_t *state,
NULL, NULL))
{
GNUNET_break (0);
+ json_dumpf (required_attribute,
+ stderr,
+ JSON_INDENT (2));
return NULL;
}
present = (NULL !=
@@ -335,6 +340,9 @@ ANASTASIS_policy_discovery_start (const json_t *state,
if ((! present) && (! optional))
{
GNUNET_break (0);
+ json_dumpf (master_id,
+ stderr,
+ JSON_INDENT (2));
return NULL;
}
if (present && optional)
@@ -347,6 +355,8 @@ ANASTASIS_policy_discovery_start (const json_t *state,
GNUNET_NO);
pd->cb = cb;
pd->cb_cls = cb_cls;
+ pd->opt_cnt = opt_cnt;
+ pd->state = json_deep_copy (state);
/* Compute 'id_data' for all possible masks, and then
start downloads at all providers for 'id_data' */
@@ -364,18 +374,45 @@ ANASTASIS_policy_discovery_start (const json_t *state,
id_data,
mask,
url,
- state,
cursor);
}
json_decref (id_data);
}
- if (NULL == pd->po_head)
+ return pd;
+}
+
+
+void
+ANASTASIS_policy_discovery_more (struct ANASTASIS_PolicyDiscovery *pd,
+ const char *provider_url,
+ json_t *provider_state)
+{
+ json_t *master_id = json_object_get (pd->state,
+ "identity_attributes");
+ json_t *providers = json_object_get (pd->state,
+ "authentication_providers");
+
+ GNUNET_assert (NULL != master_id);
+ GNUNET_assert (NULL != providers);
+ GNUNET_assert (0 ==
+ json_object_set (providers,
+ provider_url,
+ provider_state));
+ /* Compute 'id_data' for all possible masks, and then
+ start downloads at provider for 'id_data' */
+ for (json_int_t mask = 0; mask < (1LL << pd->opt_cnt); mask++)
{
- GNUNET_break (0);
- ANASTASIS_policy_discovery_stop (pd);
- return NULL;
+ json_t *id_data = ANASTASIS_mask_id_data (pd->state,
+ master_id,
+ mask);
+
+ start_po (pd,
+ id_data,
+ mask,
+ provider_url,
+ NULL);
+ json_decref (id_data);
}
- return pd;
}
@@ -394,6 +431,7 @@ ANASTASIS_policy_discovery_stop (struct ANASTASIS_PolicyDiscovery *pd)
GNUNET_free (po);
}
GNUNET_CONTAINER_multihashmap_destroy (pd->dd_map);
+ json_decref (pd->state);
GNUNET_free (pd);
}