diff options
author | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-06-27 18:32:01 +0200 |
---|---|---|
committer | Tristan Schwieren <tristan.schwieren@tum.de> | 2022-06-27 18:32:01 +0200 |
commit | 47e7cc4fd4c9341926f0cd4aca2b38e9cd5aba7e (patch) | |
tree | b3e75ccb67c3fcd077aeabce6231a798d2493fdf /src/reclaim/did_core.c | |
parent | bc05f5201575ac97edbfedbc77d780fd6db558d6 (diff) | |
download | gnunet-47e7cc4fd4c9341926f0cd4aca2b38e9cd5aba7e.tar.gz gnunet-47e7cc4fd4c9341926f0cd4aca2b38e9cd5aba7e.zip |
- missing lib bug
Diffstat (limited to 'src/reclaim/did_core.c')
-rw-r--r-- | src/reclaim/did_core.c | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/src/reclaim/did_core.c b/src/reclaim/did_core.c index 74c715651..d6ee33f93 100644 --- a/src/reclaim/did_core.c +++ b/src/reclaim/did_core.c | |||
@@ -20,9 +20,80 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file reclaim/did_core.c | 22 | * @file reclaim/did_core.c |
23 | * @brief Core functionality for DID | 23 | * @brief Core functionality for DID |
24 | * @author Tristan Schwieren | 24 | * @author Tristan Schwieren |
25 | */ | 25 | */ |
26 | 26 | ||
27 | 27 | ||
28 | #include "did_core.h" \ No newline at end of file | 28 | #include "did_core.h" |
29 | |||
30 | static DID_resolve_callback *resolve_cb; | ||
31 | static DID_action_callback *action_cb; | ||
32 | static void *closure; | ||
33 | |||
34 | /** | ||
35 | * @brief GNS lookup callback. Calls the given callback function | ||
36 | * and gives it the DID Document. | ||
37 | * Fails if there is more than one DID record. | ||
38 | * | ||
39 | * @param cls closure | ||
40 | * @param rd_count number of records in rd | ||
41 | * @param rd the records in the reply | ||
42 | */ | ||
43 | static void | ||
44 | DID_resolve_gns_lookup_cb ( | ||
45 | void *cls, | ||
46 | uint32_t rd_count, | ||
47 | const struct GNUNET_GNSRECORD_Data *rd) | ||
48 | { | ||
49 | /* | ||
50 | * FIXME-MSC: The user may decide to put other records here. | ||
51 | * In general I am fine with the constraint here, but not when | ||
52 | * we move it to "@" | ||
53 | */ | ||
54 | |||
55 | char *didd; | ||
56 | |||
57 | if (rd_count != 1) | ||
58 | resolve_cb (GNUNET_NO, "An ego should only have one DID Document", closure); | ||
59 | |||
60 | if (rd[0].record_type == GNUNET_DNSPARSER_TYPE_TXT) | ||
61 | { | ||
62 | didd = (char *) rd[0].data; | ||
63 | resolve_cb (GNUNET_NO, didd, closure); | ||
64 | } | ||
65 | else | ||
66 | resolve_cb (GNUNET_NO, "DID Document is not a TXT record\n", closure); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @brief Resolve a DID. | ||
71 | * Calls the given callback function with the resolved DID Document and the given closure. | ||
72 | * If the did can not be resolved did_document is NULL. | ||
73 | * | ||
74 | * @param did DID that is resolved | ||
75 | * @param gns_handle pointer to gns handle. | ||
76 | * @param cont callback function | ||
77 | * @param cls closure | ||
78 | */ | ||
79 | enum GNUNET_GenericReturnValue | ||
80 | DID_resolve (const char *did, | ||
81 | struct GNUNET_GNS_Handle *gns_handle, | ||
82 | DID_resolve_callback *cont, | ||
83 | void *cls) | ||
84 | { | ||
85 | struct GNUNET_IDENTITY_PublicKey pkey; | ||
86 | |||
87 | if ((did == NULL) || (gns_handle == NULL) || (cont == NULL)) | ||
88 | return GNUNET_NO; | ||
89 | |||
90 | resolve_cb = cont; | ||
91 | closure = cls; | ||
92 | |||
93 | if (GNUNET_OK != DID_did_to_pkey (did, &pkey)) | ||
94 | return GNUNET_NO; | ||
95 | |||
96 | GNUNET_GNS_lookup (gns_handle, GNUNET_GNS_EMPTY_LABEL_AT, &pkey, | ||
97 | GNUNET_DNSPARSER_TYPE_TXT, | ||
98 | GNUNET_GNS_LO_DEFAULT, &DID_resolve_gns_lookup_cb, NULL); | ||
99 | } \ No newline at end of file | ||