diff options
author | Phil <phil.buschmann@tum.de> | 2018-08-09 10:23:29 +0200 |
---|---|---|
committer | Phil <phil.buschmann@tum.de> | 2018-08-09 10:23:29 +0200 |
commit | e083dd6ae0b96f30328d0d54bc7a55f6cd34b2b4 (patch) | |
tree | 8c993110fb5958c30f41f40794bd75941a42aca0 /src | |
parent | cffad0ad30400dda7c7c4ef77ed7625013193dbe (diff) | |
parent | b3932f39b028d5db0d2e641e8593679c657b6bd1 (diff) | |
download | gnunet-e083dd6ae0b96f30328d0d54bc7a55f6cd34b2b4.tar.gz gnunet-e083dd6ae0b96f30328d0d54bc7a55f6cd34b2b4.zip |
-Merge branch 'master' into gsoc2018/rest_api
Diffstat (limited to 'src')
63 files changed, 2942 insertions, 2145 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 00f30adc3..4ded81891 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -19,11 +19,13 @@ if HAVE_EXPERIMENTAL | |||
19 | social | 19 | social |
20 | # dv (FTBFS) | 20 | # dv (FTBFS) |
21 | if HAVE_ABE | 21 | if HAVE_ABE |
22 | if HAVE_JSON | ||
22 | EXP_DIR += \ | 23 | EXP_DIR += \ |
23 | abe \ | 24 | abe \ |
24 | credential \ | 25 | credential \ |
25 | identity-attribute \ | 26 | reclaim-attribute \ |
26 | identity-provider | 27 | reclaim |
28 | endif | ||
27 | endif | 29 | endif |
28 | if HAVE_JSON | 30 | if HAVE_JSON |
29 | EXP_DIR += \ | 31 | EXP_DIR += \ |
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 4a7d51bc7..f15bca2db 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c | |||
@@ -343,7 +343,10 @@ init () | |||
343 | cfg = GNUNET_CONFIGURATION_create (); | 343 | cfg = GNUNET_CONFIGURATION_create (); |
344 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, | 344 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, |
345 | "test_arm_api_data.conf")) | 345 | "test_arm_api_data.conf")) |
346 | { | ||
347 | GNUNET_CONFIGURATION_destroy (cfg); | ||
346 | return GNUNET_SYSERR; | 348 | return GNUNET_SYSERR; |
349 | } | ||
347 | if (NULL == getcwd (pwd, PATH_MAX)) | 350 | if (NULL == getcwd (pwd, PATH_MAX)) |
348 | return GNUNET_SYSERR; | 351 | return GNUNET_SYSERR; |
349 | GNUNET_assert (0 < GNUNET_asprintf (&binary, | 352 | GNUNET_assert (0 < GNUNET_asprintf (&binary, |
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 319279110..92dd39b97 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -841,6 +841,7 @@ handle_mq_error (void *cls, | |||
841 | h); | 841 | h); |
842 | GNUNET_MQ_destroy (h->mq); | 842 | GNUNET_MQ_destroy (h->mq); |
843 | h->mq = NULL; | 843 | h->mq = NULL; |
844 | GNUNET_assert (NULL == h->reconnect_task); | ||
844 | h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_time, | 845 | h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_time, |
845 | &reconnect_cbk, | 846 | &reconnect_cbk, |
846 | h); | 847 | h); |
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 4cc5b4bcd..c7c71f1f1 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -143,6 +143,8 @@ do_shutdown (void *cls) | |||
143 | unsigned long long delta; | 143 | unsigned long long delta; |
144 | 144 | ||
145 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; | 145 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; |
146 | if (0 == delta) | ||
147 | delta = 1; | ||
146 | FPRINTF (stderr, | 148 | FPRINTF (stderr, |
147 | "\nThroughput was %llu kb/s\n", | 149 | "\nThroughput was %llu kb/s\n", |
148 | total_bytes * 1000000LL / 1024 / delta); | 150 | total_bytes * 1000000LL / 1024 / delta); |
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index a15105556..caff045f0 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -227,7 +227,8 @@ measurement_stop (void *cls) | |||
227 | running = GNUNET_NO; | 227 | running = GNUNET_NO; |
228 | 228 | ||
229 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; | 229 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; |
230 | 230 | if (0 == delta) | |
231 | delta = 1; | ||
231 | throughput_out = total_bytes_sent * 1000000LL / delta; /* convert to bytes/s */ | 232 | throughput_out = total_bytes_sent * 1000000LL / delta; /* convert to bytes/s */ |
232 | throughput_in = total_bytes_recv * 1000000LL / delta; /* convert to bytes/s */ | 233 | throughput_in = total_bytes_recv * 1000000LL / delta; /* convert to bytes/s */ |
233 | 234 | ||
diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 4684e514c..dc4236a8b 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -749,7 +749,8 @@ libgnunet_plugin_datacache_sqlite_init (void *cls) | |||
749 | " value BLOB NOT NULL," | 749 | " value BLOB NOT NULL," |
750 | " path BLOB DEFAULT '')"); | 750 | " path BLOB DEFAULT '')"); |
751 | SQLITE3_EXEC (dbh, "CREATE INDEX idx_hashidx ON ds091 (key,type,expire)"); | 751 | SQLITE3_EXEC (dbh, "CREATE INDEX idx_hashidx ON ds091 (key,type,expire)"); |
752 | SQLITE3_EXEC (dbh, "CREATE INDEX idx_expire ON ds091 (prox,expire)"); | 752 | SQLITE3_EXEC (dbh, "CREATE INDEX idx_prox_expire ON ds091 (prox,expire)"); |
753 | SQLITE3_EXEC (dbh, "CREATE INDEX idx_expire_only ON ds091 (expire)"); | ||
753 | plugin = GNUNET_new (struct Plugin); | 754 | plugin = GNUNET_new (struct Plugin); |
754 | plugin->env = env; | 755 | plugin->env = env; |
755 | plugin->dbh = dbh; | 756 | plugin->dbh = dbh; |
diff --git a/src/identity-provider/identity-token.conf b/src/identity-provider/identity-token.conf deleted file mode 100644 index f29f6cdf3..000000000 --- a/src/identity-provider/identity-token.conf +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | [identity-token] | ||
2 | BINARY=gnunet-service-identity-token | ||
diff --git a/src/identity-provider/jwt.c b/src/identity-provider/jwt.c deleted file mode 100644 index 1a984f7b5..000000000 --- a/src/identity-provider/jwt.c +++ /dev/null | |||
@@ -1,189 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /** | ||
20 | * @file identity-provider/jwt.c | ||
21 | * @brief helper library for JSON-Web-Tokens | ||
22 | * @author Martin Schanzenbach | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_util_lib.h" | ||
26 | #include "gnunet_signatures.h" | ||
27 | #include "gnunet_identity_attribute_lib.h" | ||
28 | #include <jansson.h> | ||
29 | |||
30 | |||
31 | #define JWT_ALG "alg" | ||
32 | |||
33 | /*TODO is this the correct way to define new algs? */ | ||
34 | #define JWT_ALG_VALUE "urn:org:gnunet:jwt:alg:ecdsa:ed25519" | ||
35 | |||
36 | #define JWT_TYP "typ" | ||
37 | |||
38 | #define JWT_TYP_VALUE "jwt" | ||
39 | |||
40 | //TODO change server address | ||
41 | #define SERVER_ADDRESS "https://localhost" | ||
42 | |||
43 | static char* | ||
44 | create_jwt_header(void) | ||
45 | { | ||
46 | json_t *root; | ||
47 | char *json_str; | ||
48 | |||
49 | root = json_object (); | ||
50 | json_object_set_new (root, JWT_ALG, json_string (JWT_ALG_VALUE)); | ||
51 | json_object_set_new (root, JWT_TYP, json_string (JWT_TYP_VALUE)); | ||
52 | |||
53 | json_str = json_dumps (root, JSON_INDENT(1)); | ||
54 | json_decref (root); | ||
55 | return json_str; | ||
56 | } | ||
57 | |||
58 | /** | ||
59 | * Create a JWT from attributes | ||
60 | * | ||
61 | * @param aud_key the public of the subject | ||
62 | * @param attrs the attribute list | ||
63 | * @param priv_key the key used to sign the JWT | ||
64 | * @return a new base64-encoded JWT string. | ||
65 | */ | ||
66 | char* | ||
67 | jwt_create_from_list (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, | ||
68 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | ||
69 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key) | ||
70 | { | ||
71 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | ||
72 | struct GNUNET_CRYPTO_EcdsaPublicKey sub_key; | ||
73 | struct GNUNET_CRYPTO_EcdsaSignature signature; | ||
74 | struct GNUNET_CRYPTO_EccSignaturePurpose *purpose; | ||
75 | char* audience; | ||
76 | char* subject; | ||
77 | char* header; | ||
78 | char* padding; | ||
79 | char* body_str; | ||
80 | char* result; | ||
81 | char* header_base64; | ||
82 | char* body_base64; | ||
83 | char* signature_target; | ||
84 | char* signature_base64; | ||
85 | char* attr_val_str; | ||
86 | json_t* body; | ||
87 | |||
88 | //exp REQUIRED time expired from config | ||
89 | //iat REQUIRED time now | ||
90 | //auth_time only if max_age | ||
91 | //nonce only if nonce | ||
92 | // OPTIONAL acr,amr,azp | ||
93 | GNUNET_CRYPTO_ecdsa_key_get_public (priv_key, &sub_key); | ||
94 | /* TODO maybe we should use a local identity here */ | ||
95 | subject = GNUNET_STRINGS_data_to_string_alloc (&sub_key, | ||
96 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
97 | audience = GNUNET_STRINGS_data_to_string_alloc (aud_key, | ||
98 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
99 | header = create_jwt_header (); | ||
100 | body = json_object (); | ||
101 | /* TODO who is the issuer? local IdP or subject ? See self-issued tokens? */ | ||
102 | //iss REQUIRED case sensitive server uri with https | ||
103 | json_object_set_new (body, | ||
104 | "iss", json_string (SERVER_ADDRESS)); | ||
105 | //sub REQUIRED public key identity, not exceed 255 ASCII length | ||
106 | json_object_set_new (body, | ||
107 | "sub", json_string (subject)); | ||
108 | /* TODO what should be in here exactly? */ | ||
109 | //aud REQUIRED public key client_id must be there | ||
110 | json_object_set_new (body, | ||
111 | "aud", json_string (audience)); | ||
112 | for (le = attrs->list_head; NULL != le; le = le->next) | ||
113 | { | ||
114 | /** | ||
115 | * TODO here we should have a function that | ||
116 | * calls the Attribute plugins to create a | ||
117 | * json representation for its value | ||
118 | */ | ||
119 | attr_val_str = GNUNET_IDENTITY_ATTRIBUTE_value_to_string (le->claim->type, | ||
120 | le->claim->data, | ||
121 | le->claim->data_size); | ||
122 | json_object_set_new (body, | ||
123 | le->claim->name, | ||
124 | json_string (attr_val_str)); | ||
125 | GNUNET_free (attr_val_str); | ||
126 | } | ||
127 | body_str = json_dumps (body, JSON_INDENT(0)); | ||
128 | json_decref (body); | ||
129 | |||
130 | GNUNET_STRINGS_base64_encode (header, | ||
131 | strlen (header), | ||
132 | &header_base64); | ||
133 | //Remove GNUNET padding of base64 | ||
134 | padding = strtok(header_base64, "="); | ||
135 | while (NULL != padding) | ||
136 | padding = strtok(NULL, "="); | ||
137 | |||
138 | GNUNET_STRINGS_base64_encode (body_str, | ||
139 | strlen (body_str), | ||
140 | &body_base64); | ||
141 | |||
142 | //Remove GNUNET padding of base64 | ||
143 | padding = strtok(body_base64, "="); | ||
144 | while (NULL != padding) | ||
145 | padding = strtok(NULL, "="); | ||
146 | |||
147 | GNUNET_free (subject); | ||
148 | GNUNET_free (audience); | ||
149 | |||
150 | /** | ||
151 | * TODO | ||
152 | * Creating the JWT signature. This might not be | ||
153 | * standards compliant, check. | ||
154 | */ | ||
155 | GNUNET_asprintf (&signature_target, "%s,%s", header_base64, body_base64); | ||
156 | |||
157 | purpose = | ||
158 | GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + | ||
159 | strlen (signature_target)); | ||
160 | purpose->size = | ||
161 | htonl (strlen (signature_target) + sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose)); | ||
162 | purpose->purpose = htonl(GNUNET_SIGNATURE_PURPOSE_GNUID_TOKEN); | ||
163 | GNUNET_memcpy (&purpose[1], signature_target, strlen (signature_target)); | ||
164 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_sign (priv_key, | ||
165 | purpose, | ||
166 | (struct GNUNET_CRYPTO_EcdsaSignature *)&signature)) | ||
167 | { | ||
168 | GNUNET_free (signature_target); | ||
169 | GNUNET_free (body_str); | ||
170 | GNUNET_free (body_base64); | ||
171 | GNUNET_free (header_base64); | ||
172 | GNUNET_free (purpose); | ||
173 | return NULL; | ||
174 | } | ||
175 | GNUNET_STRINGS_base64_encode ((const char*)&signature, | ||
176 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature), | ||
177 | &signature_base64); | ||
178 | GNUNET_asprintf (&result, "%s.%s.%s", | ||
179 | header_base64, body_base64, signature_base64); | ||
180 | |||
181 | GNUNET_free (signature_target); | ||
182 | GNUNET_free (header); | ||
183 | GNUNET_free (body_str); | ||
184 | GNUNET_free (signature_base64); | ||
185 | GNUNET_free (body_base64); | ||
186 | GNUNET_free (header_base64); | ||
187 | GNUNET_free (purpose); | ||
188 | return result; | ||
189 | } | ||
diff --git a/src/identity-provider/jwt.h b/src/identity-provider/jwt.h deleted file mode 100644 index 072958973..000000000 --- a/src/identity-provider/jwt.h +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #ifndef JWT_H | ||
2 | #define JWT_H | ||
3 | |||
4 | char* | ||
5 | jwt_create_from_list (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, | ||
6 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | ||
7 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key); | ||
8 | |||
9 | #endif | ||
diff --git a/src/identity-provider/test_idp.conf b/src/identity-provider/test_idp.conf deleted file mode 100644 index 3e4df561a..000000000 --- a/src/identity-provider/test_idp.conf +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | @INLINE@ test_idp_defaults.conf | ||
2 | |||
3 | [PATHS] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-idp-peer-1/ | ||
5 | |||
6 | [dht] | ||
7 | START_ON_DEMAND = YES | ||
8 | |||
9 | [rest] | ||
10 | START_ON_DEMAND = YES | ||
11 | PREFIX = valgrind --leak-check=full --track-origins=yes --log-file=$GNUNET_TMP/restlog | ||
12 | |||
13 | [transport] | ||
14 | PLUGINS = | ||
15 | |||
16 | [identity-provider] | ||
17 | START_ON_DEMAND = YES | ||
18 | #PREFIX = valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --log-file=$GNUNET_TMP/idplog | ||
19 | |||
20 | [gns] | ||
21 | #PREFIX = valgrind --leak-check=full --track-origins=yes | ||
22 | START_ON_DEMAND = YES | ||
23 | AUTO_IMPORT_PKEY = YES | ||
24 | MAX_PARALLEL_BACKGROUND_QUERIES = 10 | ||
25 | DEFAULT_LOOKUP_TIMEOUT = 15 s | ||
26 | RECORD_PUT_INTERVAL = 1 h | ||
27 | ZONE_PUBLISH_TIME_WINDOW = 1 h | ||
28 | DNS_ROOT=PD67SGHF3E0447TU9HADIVU9OM7V4QHTOG0EBU69TFRI2LG63DR0 | ||
29 | |||
30 | [identity-rest-plugin] | ||
31 | address = http://localhost:8000/#/login | ||
32 | psw = mysupersecretpassword | ||
33 | expiration_time = 3600 | ||
diff --git a/src/identity-provider/test_idp.sh b/src/identity-provider/test_idp.sh deleted file mode 100755 index 598d1008c..000000000 --- a/src/identity-provider/test_idp.sh +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | #trap "gnunet-arm -e -c test_idp_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_idp.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_idp.conf | ||
27 | gnunet-identity -C testego -c test_idp.conf | ||
28 | valgrind gnunet-idp -e testego -a email -V john@doe.gnu -c test_idp.conf | ||
29 | gnunet-idp -e testego -a name -V John -c test_idp.conf | ||
30 | gnunet-idp -e testego -D -c test_idp.conf | ||
31 | gnunet-arm -e -c test_idp.conf | ||
diff --git a/src/identity-provider/test_idp_attribute.sh b/src/identity-provider/test_idp_attribute.sh deleted file mode 100755 index 7f0f06dac..000000000 --- a/src/identity-provider/test_idp_attribute.sh +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_idp.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_idp.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_idp.conf | ||
27 | #gnunet-arm -i rest -c test_idp.conf | ||
28 | gnunet-identity -C testego -c test_idp.conf | ||
29 | gnunet-identity -C rpego -c test_idp.conf | ||
30 | TEST_KEY=$(gnunet-identity -d -c test_idp.conf | grep testego | awk '{print $3}') | ||
31 | gnunet-idp -e testego -a email -V john@doe.gnu -c test_idp.conf | ||
32 | gnunet-idp -e testego -a name -V John -c test_idp.conf > /dev/null 2>&1 | ||
33 | if test $? != 0 | ||
34 | then | ||
35 | echo "Failed." | ||
36 | exit 1 | ||
37 | fi | ||
38 | |||
39 | #curl localhost:7776/idp/attributes/testego | ||
40 | gnunet-arm -e -c test_idp.conf | ||
diff --git a/src/identity-provider/test_idp_consume.sh b/src/identity-provider/test_idp_consume.sh deleted file mode 100755 index 11f6865a4..000000000 --- a/src/identity-provider/test_idp_consume.sh +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_idp.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_idp.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_idp.conf | ||
27 | #gnunet-arm -i rest -c test_idp.conf | ||
28 | gnunet-identity -C testego -c test_idp.conf | ||
29 | gnunet-identity -C rpego -c test_idp.conf | ||
30 | SUBJECT_KEY=$(gnunet-identity -d -c test_idp.conf | grep rpego | awk '{print $3}') | ||
31 | TEST_KEY=$(gnunet-identity -d -c test_idp.conf | grep testego | awk '{print $3}') | ||
32 | gnunet-idp -e testego -a email -V john@doe.gnu -c test_idp.conf | ||
33 | gnunet-idp -e testego -a name -V John -c test_idp.conf | ||
34 | TICKET=$(gnunet-idp -e testego -i "email,name" -r $SUBJECT_KEY -c test_idp.conf | awk '{print $1}') | ||
35 | gnunet-idp -e rpego -C $TICKET -c test_idp.conf > /dev/null 2>&1 | ||
36 | |||
37 | if test $? != 0 | ||
38 | then | ||
39 | "Failed." | ||
40 | exit 1 | ||
41 | fi | ||
42 | #curl http://localhost:7776/idp/tickets/testego | ||
43 | gnunet-arm -e -c test_idp.conf | ||
diff --git a/src/identity-provider/test_idp_issue.sh b/src/identity-provider/test_idp_issue.sh deleted file mode 100755 index 90487ee73..000000000 --- a/src/identity-provider/test_idp_issue.sh +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_idp.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_idp.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_idp.conf | ||
27 | #gnunet-arm -i rest -c test_idp.conf | ||
28 | gnunet-identity -C testego -c test_idp.conf | ||
29 | gnunet-identity -C rpego -c test_idp.conf | ||
30 | SUBJECT_KEY=$(gnunet-identity -d -c test_idp.conf | grep rpego | awk '{print $3}') | ||
31 | TEST_KEY=$(gnunet-identity -d -c test_idp.conf | grep testego | awk '{print $3}') | ||
32 | gnunet-idp -e testego -a email -V john@doe.gnu -c test_idp.conf > /dev/null 2>&1 | ||
33 | gnunet-idp -e testego -a name -V John -c test_idp.conf > /dev/null 2>&1 | ||
34 | #gnunet-idp -e testego -D -c test_idp.conf | ||
35 | gnunet-idp -e testego -i "email,name" -r $SUBJECT_KEY -c test_idp.conf > /dev/null 2>&1 | ||
36 | if test $? != 0 | ||
37 | then | ||
38 | echo "Failed." | ||
39 | exit 1 | ||
40 | fi | ||
41 | #curl http://localhost:7776/idp/attributes/testego | ||
42 | gnunet-arm -e -c test_idp.conf | ||
diff --git a/src/identity-provider/test_idp_revoke.sh b/src/identity-provider/test_idp_revoke.sh deleted file mode 100755 index 7a3f5d030..000000000 --- a/src/identity-provider/test_idp_revoke.sh +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_idp.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_idp.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_idp.conf 2&>1 > /dev/null | ||
27 | gnunet-identity -C alice -c test_idp.conf | ||
28 | gnunet-identity -C bob -c test_idp.conf | ||
29 | gnunet-identity -C eve -c test_idp.conf | ||
30 | ALICE_KEY=$(gnunet-identity -d -c test_idp.conf | grep alice | awk '{print $3}') | ||
31 | BOB_KEY=$(gnunet-identity -d -c test_idp.conf | grep bob | awk '{print $3}') | ||
32 | EVE_KEY=$(gnunet-identity -d -c test_idp.conf | grep eve | awk '{print $3}') | ||
33 | |||
34 | gnunet-idp -e alice -E 15s -a email -V john@doe.gnu -c test_idp.conf | ||
35 | gnunet-idp -e alice -E 15s -a name -V John -c test_idp.conf | ||
36 | TICKET_BOB=$(gnunet-idp -e alice -i "email,name" -r $BOB_KEY -c test_idp.conf | awk '{print $1}') | ||
37 | #gnunet-idp -e bob -C $TICKET_BOB -c test_idp.conf | ||
38 | TICKET_EVE=$(gnunet-idp -e alice -i "email" -r $EVE_KEY -c test_idp.conf | awk '{print $1}') | ||
39 | |||
40 | #echo "Consuming $TICKET" | ||
41 | #gnunet-idp -e eve -C $TICKET_EVE -c test_idp.conf | ||
42 | gnunet-idp -e alice -R $TICKET_EVE -c test_idp.conf | ||
43 | |||
44 | #sleep 6 | ||
45 | |||
46 | gnunet-idp -e eve -C $TICKET_EVE -c test_idp.conf 2&>1 >/dev/null | ||
47 | if test $? == 0 | ||
48 | then | ||
49 | echo "Eve can still resolve attributes..." | ||
50 | gnunet-arm -e -c test_idp.conf | ||
51 | exit 1 | ||
52 | fi | ||
53 | |||
54 | gnunet-arm -e -c test_idp.conf | ||
55 | gnunet-arm -s -c test_idp.conf 2&>1 > /dev/null | ||
56 | |||
57 | gnunet-idp -e bob -C $TICKET_BOB -c test_idp.conf 2&>1 >/dev/null | ||
58 | if test $? != 0 | ||
59 | then | ||
60 | echo "Bob cannot resolve attributes..." | ||
61 | gnunet-arm -e -c test_idp.conf | ||
62 | exit 1 | ||
63 | fi | ||
64 | |||
65 | gnunet-arm -e -c test_idp.conf | ||
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c index 6b8e21806..266f5ccc3 100644 --- a/src/identity/gnunet-service-identity.c +++ b/src/identity/gnunet-service-identity.c | |||
@@ -371,11 +371,12 @@ handle_get_default_message (void *cls, | |||
371 | struct GNUNET_MQ_Envelope *env; | 371 | struct GNUNET_MQ_Envelope *env; |
372 | struct GNUNET_SERVICE_Client *client = cls; | 372 | struct GNUNET_SERVICE_Client *client = cls; |
373 | struct Ego *ego; | 373 | struct Ego *ego; |
374 | const char *name; | 374 | char *name; |
375 | char *identifier; | 375 | char *identifier; |
376 | 376 | ||
377 | 377 | ||
378 | name = (const char *) &gdm[1]; | 378 | name = GNUNET_strdup ((const char *) &gdm[1]); |
379 | GNUNET_STRINGS_utf8_tolower ((const char *) &gdm[1], name); | ||
379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 380 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
380 | "Received GET_DEFAULT for service `%s' from client\n", | 381 | "Received GET_DEFAULT for service `%s' from client\n", |
381 | name); | 382 | name); |
@@ -387,6 +388,7 @@ handle_get_default_message (void *cls, | |||
387 | { | 388 | { |
388 | send_result_code (client, 1, gettext_noop ("no default known")); | 389 | send_result_code (client, 1, gettext_noop ("no default known")); |
389 | GNUNET_SERVICE_client_continue (client); | 390 | GNUNET_SERVICE_client_continue (client); |
391 | GNUNET_free (name); | ||
390 | return; | 392 | return; |
391 | } | 393 | } |
392 | for (ego = ego_head; NULL != ego; ego = ego->next) | 394 | for (ego = ego_head; NULL != ego; ego = ego->next) |
@@ -399,6 +401,7 @@ handle_get_default_message (void *cls, | |||
399 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); | 401 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (client), env); |
400 | GNUNET_SERVICE_client_continue (client); | 402 | GNUNET_SERVICE_client_continue (client); |
401 | GNUNET_free (identifier); | 403 | GNUNET_free (identifier); |
404 | GNUNET_free (name); | ||
402 | return; | 405 | return; |
403 | } | 406 | } |
404 | } | 407 | } |
@@ -406,6 +409,7 @@ handle_get_default_message (void *cls, | |||
406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 409 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
407 | "Failed to find ego `%s'\n", | 410 | "Failed to find ego `%s'\n", |
408 | name); | 411 | name); |
412 | GNUNET_free (name); | ||
409 | send_result_code (client, 1, | 413 | send_result_code (client, 1, |
410 | gettext_noop ("default configured, but ego unknown (internal error)")); | 414 | gettext_noop ("default configured, but ego unknown (internal error)")); |
411 | GNUNET_SERVICE_client_continue (client); | 415 | GNUNET_SERVICE_client_continue (client); |
@@ -477,9 +481,11 @@ handle_set_default_message (void *cls, | |||
477 | { | 481 | { |
478 | struct Ego *ego; | 482 | struct Ego *ego; |
479 | struct GNUNET_SERVICE_Client *client = cls; | 483 | struct GNUNET_SERVICE_Client *client = cls; |
480 | const char *str; | 484 | char *str; |
485 | |||
486 | str = GNUNET_strdup ((const char *) &sdm[1]); | ||
487 | GNUNET_STRINGS_utf8_tolower ((const char *) &sdm[1], str); | ||
481 | 488 | ||
482 | str = (const char *) &sdm[1]; | ||
483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
484 | "Received SET_DEFAULT for service `%s' from client\n", | 490 | "Received SET_DEFAULT for service `%s' from client\n", |
485 | str); | 491 | str); |
@@ -500,10 +506,12 @@ handle_set_default_message (void *cls, | |||
500 | subsystem_cfg_file); | 506 | subsystem_cfg_file); |
501 | send_result_code (client, 0, NULL); | 507 | send_result_code (client, 0, NULL); |
502 | GNUNET_SERVICE_client_continue (client); | 508 | GNUNET_SERVICE_client_continue (client); |
509 | GNUNET_free (str); | ||
503 | return; | 510 | return; |
504 | } | 511 | } |
505 | } | 512 | } |
506 | send_result_code (client, 1, _("Unknown ego specified for service (internal error)")); | 513 | send_result_code (client, 1, _("Unknown ego specified for service (internal error)")); |
514 | GNUNET_free (str); | ||
507 | GNUNET_SERVICE_client_continue (client); | 515 | GNUNET_SERVICE_client_continue (client); |
508 | } | 516 | } |
509 | 517 | ||
@@ -585,12 +593,13 @@ handle_create_message (void *cls, | |||
585 | { | 593 | { |
586 | struct GNUNET_SERVICE_Client *client = cls; | 594 | struct GNUNET_SERVICE_Client *client = cls; |
587 | struct Ego *ego; | 595 | struct Ego *ego; |
588 | const char *str; | 596 | char *str; |
589 | char *fn; | 597 | char *fn; |
590 | 598 | ||
591 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 599 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
592 | "Received CREATE message from client\n"); | 600 | "Received CREATE message from client\n"); |
593 | str = (const char *) &crm[1]; | 601 | str = GNUNET_strdup ((const char *) &crm[1]); |
602 | GNUNET_STRINGS_utf8_tolower ((const char *) &crm[1], str); | ||
594 | for (ego = ego_head; NULL != ego; ego = ego->next) | 603 | for (ego = ego_head; NULL != ego; ego = ego->next) |
595 | { | 604 | { |
596 | if (0 == strcmp (ego->identifier, | 605 | if (0 == strcmp (ego->identifier, |
@@ -598,6 +607,7 @@ handle_create_message (void *cls, | |||
598 | { | 607 | { |
599 | send_result_code (client, 1, gettext_noop ("identifier already in use for another ego")); | 608 | send_result_code (client, 1, gettext_noop ("identifier already in use for another ego")); |
600 | GNUNET_SERVICE_client_continue (client); | 609 | GNUNET_SERVICE_client_continue (client); |
610 | GNUNET_free (str); | ||
601 | return; | 611 | return; |
602 | } | 612 | } |
603 | } | 613 | } |
@@ -620,6 +630,7 @@ handle_create_message (void *cls, | |||
620 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, | 630 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, |
621 | "write", fn); | 631 | "write", fn); |
622 | GNUNET_free (fn); | 632 | GNUNET_free (fn); |
633 | GNUNET_free (str); | ||
623 | notify_listeners (ego); | 634 | notify_listeners (ego); |
624 | GNUNET_SERVICE_client_continue (client); | 635 | GNUNET_SERVICE_client_continue (client); |
625 | } | 636 | } |
@@ -726,18 +737,22 @@ handle_rename_message (void *cls, | |||
726 | { | 737 | { |
727 | uint16_t old_name_len; | 738 | uint16_t old_name_len; |
728 | struct Ego *ego; | 739 | struct Ego *ego; |
729 | const char *old_name; | 740 | char *old_name; |
730 | const char *new_name; | 741 | char *new_name; |
731 | struct RenameContext rename_ctx; | 742 | struct RenameContext rename_ctx; |
732 | struct GNUNET_SERVICE_Client *client = cls; | 743 | struct GNUNET_SERVICE_Client *client = cls; |
733 | char *fn_old; | 744 | char *fn_old; |
734 | char *fn_new; | 745 | char *fn_new; |
746 | const char *old_name_tmp; | ||
735 | 747 | ||
736 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 748 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
737 | "Received RENAME message from client\n"); | 749 | "Received RENAME message from client\n"); |
738 | old_name_len = ntohs (rm->old_name_len); | 750 | old_name_len = ntohs (rm->old_name_len); |
739 | old_name = (const char *) &rm[1]; | 751 | old_name_tmp = (const char *) &rm[1]; |
740 | new_name = &old_name[old_name_len]; | 752 | old_name = GNUNET_strdup (old_name_tmp); |
753 | GNUNET_STRINGS_utf8_tolower (old_name_tmp, old_name); | ||
754 | new_name = GNUNET_strdup (&old_name_tmp[old_name_len]); | ||
755 | GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], old_name); | ||
741 | 756 | ||
742 | /* check if new name is already in use */ | 757 | /* check if new name is already in use */ |
743 | for (ego = ego_head; NULL != ego; ego = ego->next) | 758 | for (ego = ego_head; NULL != ego; ego = ego->next) |
@@ -747,6 +762,8 @@ handle_rename_message (void *cls, | |||
747 | { | 762 | { |
748 | send_result_code (client, 1, gettext_noop ("target name already exists")); | 763 | send_result_code (client, 1, gettext_noop ("target name already exists")); |
749 | GNUNET_SERVICE_client_continue (client); | 764 | GNUNET_SERVICE_client_continue (client); |
765 | GNUNET_free (old_name); | ||
766 | GNUNET_free (new_name); | ||
750 | return; | 767 | return; |
751 | } | 768 | } |
752 | } | 769 | } |
@@ -776,6 +793,8 @@ handle_rename_message (void *cls, | |||
776 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old); | 793 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rename", fn_old); |
777 | GNUNET_free (fn_old); | 794 | GNUNET_free (fn_old); |
778 | GNUNET_free (fn_new); | 795 | GNUNET_free (fn_new); |
796 | GNUNET_free (old_name); | ||
797 | GNUNET_free (new_name); | ||
779 | notify_listeners (ego); | 798 | notify_listeners (ego); |
780 | send_result_code (client, 0, NULL); | 799 | send_result_code (client, 0, NULL); |
781 | GNUNET_SERVICE_client_continue (client); | 800 | GNUNET_SERVICE_client_continue (client); |
@@ -785,6 +804,8 @@ handle_rename_message (void *cls, | |||
785 | 804 | ||
786 | /* failed to locate old name */ | 805 | /* failed to locate old name */ |
787 | send_result_code (client, 1, gettext_noop ("no matching ego found")); | 806 | send_result_code (client, 1, gettext_noop ("no matching ego found")); |
807 | GNUNET_free (old_name); | ||
808 | GNUNET_free (new_name); | ||
788 | GNUNET_SERVICE_client_continue (client); | 809 | GNUNET_SERVICE_client_continue (client); |
789 | } | 810 | } |
790 | 811 | ||
@@ -868,13 +889,15 @@ handle_delete_message (void *cls, | |||
868 | const struct DeleteMessage *dm) | 889 | const struct DeleteMessage *dm) |
869 | { | 890 | { |
870 | struct Ego *ego; | 891 | struct Ego *ego; |
871 | const char *name; | 892 | char *name; |
872 | char *fn; | 893 | char *fn; |
873 | struct GNUNET_SERVICE_Client *client = cls; | 894 | struct GNUNET_SERVICE_Client *client = cls; |
874 | 895 | ||
875 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 896 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
876 | "Received DELETE message from client\n"); | 897 | "Received DELETE message from client\n"); |
877 | name = (const char *) &dm[1]; | 898 | name = GNUNET_strdup ((const char *) &dm[1]); |
899 | GNUNET_STRINGS_utf8_tolower ((const char *) &dm[1], name); | ||
900 | |||
878 | for (ego = ego_head; NULL != ego; ego = ego->next) | 901 | for (ego = ego_head; NULL != ego; ego = ego->next) |
879 | { | 902 | { |
880 | if (0 == strcmp (ego->identifier, | 903 | if (0 == strcmp (ego->identifier, |
@@ -901,6 +924,7 @@ handle_delete_message (void *cls, | |||
901 | notify_listeners (ego); | 924 | notify_listeners (ego); |
902 | GNUNET_free (ego->pk); | 925 | GNUNET_free (ego->pk); |
903 | GNUNET_free (ego); | 926 | GNUNET_free (ego); |
927 | GNUNET_free (name); | ||
904 | send_result_code (client, 0, NULL); | 928 | send_result_code (client, 0, NULL); |
905 | GNUNET_SERVICE_client_continue (client); | 929 | GNUNET_SERVICE_client_continue (client); |
906 | return; | 930 | return; |
@@ -908,6 +932,7 @@ handle_delete_message (void *cls, | |||
908 | } | 932 | } |
909 | 933 | ||
910 | send_result_code (client, 1, gettext_noop ("no matching ego found")); | 934 | send_result_code (client, 1, gettext_noop ("no matching ego found")); |
935 | GNUNET_free (name); | ||
911 | GNUNET_SERVICE_client_continue (client); | 936 | GNUNET_SERVICE_client_continue (client); |
912 | } | 937 | } |
913 | 938 | ||
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 08e9dd156..41b2b1382 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -66,7 +66,7 @@ gnunetinclude_HEADERS = \ | |||
66 | gnunet_hello_lib.h \ | 66 | gnunet_hello_lib.h \ |
67 | gnunet_helper_lib.h \ | 67 | gnunet_helper_lib.h \ |
68 | gnunet_identity_service.h \ | 68 | gnunet_identity_service.h \ |
69 | gnunet_identity_provider_service.h \ | 69 | gnunet_reclaim_service.h \ |
70 | gnunet_json_lib.h \ | 70 | gnunet_json_lib.h \ |
71 | gnunet_jsonapi_lib.h \ | 71 | gnunet_jsonapi_lib.h \ |
72 | gnunet_jsonapi_util.h \ | 72 | gnunet_jsonapi_util.h \ |
diff --git a/src/include/gnunet_abe_lib.h b/src/include/gnunet_abe_lib.h index d380c9b03..554d4488b 100644 --- a/src/include/gnunet_abe_lib.h +++ b/src/include/gnunet_abe_lib.h | |||
@@ -87,7 +87,7 @@ GNUNET_ABE_cpabe_create_key (struct GNUNET_ABE_AbeMasterKey *key, | |||
87 | * Delete a CP-ABE key. | 87 | * Delete a CP-ABE key. |
88 | * | 88 | * |
89 | * @param key the key to delete | 89 | * @param key the key to delete |
90 | * @param delete_pub GNUNE_YES if the public key should also be freed (bug in gabe) | 90 | * @param delete_pub GNUNET_YES if the public key should also be freed (bug in gabe) |
91 | * @return fresh private key; free using #GNUNET_free | 91 | * @return fresh private key; free using #GNUNET_free |
92 | */ | 92 | */ |
93 | void | 93 | void |
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 0bffef212..8a591fa09 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h | |||
@@ -206,14 +206,15 @@ struct GNUNET_CRYPTO_EcdsaSignature | |||
206 | 206 | ||
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Public ECC key (always for Curve25519) encoded in a format suitable | 209 | * Public ECC key (always for curve Ed25519) encoded in a format |
210 | * for network transmission and EdDSA signatures. | 210 | * suitable for network transmission and EdDSA signatures. |
211 | */ | 211 | */ |
212 | struct GNUNET_CRYPTO_EddsaPublicKey | 212 | struct GNUNET_CRYPTO_EddsaPublicKey |
213 | { | 213 | { |
214 | /** | 214 | /** |
215 | * Q consists of an x- and a y-value, each mod p (256 bits), given | 215 | * Point Q consists of a y-value mod p (256 bits); the x-value is |
216 | * here in affine coordinates and Ed25519 standard compact format. | 216 | * always positive. The point is stored in Ed25519 standard |
217 | * compact format. | ||
217 | */ | 218 | */ |
218 | unsigned char q_y[256 / 8]; | 219 | unsigned char q_y[256 / 8]; |
219 | 220 | ||
@@ -725,6 +726,23 @@ GNUNET_CRYPTO_hash_context_abort (struct GNUNET_HashContext *hc); | |||
725 | 726 | ||
726 | 727 | ||
727 | /** | 728 | /** |
729 | * Calculate HMAC of a message (RFC 2104) | ||
730 | * TODO: Shouldn' this be the standard hmac function and | ||
731 | * the above be renamed? | ||
732 | * | ||
733 | * @param key secret key | ||
734 | * @param key_len secret key length | ||
735 | * @param plaintext input plaintext | ||
736 | * @param plaintext_len length of @a plaintext | ||
737 | * @param hmac where to store the hmac | ||
738 | */ | ||
739 | void | ||
740 | GNUNET_CRYPTO_hmac_raw (const void *key, size_t key_len, | ||
741 | const void *plaintext, size_t plaintext_len, | ||
742 | struct GNUNET_HashCode *hmac); | ||
743 | |||
744 | |||
745 | /** | ||
728 | * @ingroup hash | 746 | * @ingroup hash |
729 | * Calculate HMAC of a message (RFC 2104) | 747 | * Calculate HMAC of a message (RFC 2104) |
730 | * | 748 | * |
diff --git a/src/include/gnunet_gnsrecord_lib.h b/src/include/gnunet_gnsrecord_lib.h index 20846238b..693cc6cdb 100644 --- a/src/include/gnunet_gnsrecord_lib.h +++ b/src/include/gnunet_gnsrecord_lib.h | |||
@@ -132,6 +132,16 @@ extern "C" | |||
132 | #define GNUNET_GNSRECORD_TYPE_ABE_MASTER 65551 | 132 | #define GNUNET_GNSRECORD_TYPE_ABE_MASTER 65551 |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * Record type for reclaim OIDC clients | ||
136 | */ | ||
137 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT 65552 | ||
138 | |||
139 | /** | ||
140 | * Record type for reclaim OIDC redirect URIs | ||
141 | */ | ||
142 | #define GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT 65553 | ||
143 | |||
144 | /** | ||
135 | * Flags that can be set for a record. | 145 | * Flags that can be set for a record. |
136 | */ | 146 | */ |
137 | enum GNUNET_GNSRECORD_Flags | 147 | enum GNUNET_GNSRECORD_Flags |
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 36aa424b4..4400db7e1 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2656,35 +2656,35 @@ extern "C" | |||
2656 | * | 2656 | * |
2657 | * IDENTITY PROVIDER MESSAGE TYPES | 2657 | * IDENTITY PROVIDER MESSAGE TYPES |
2658 | */ | 2658 | */ |
2659 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE 961 | 2659 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE 961 |
2660 | 2660 | ||
2661 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE 962 | 2661 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE 962 |
2662 | 2662 | ||
2663 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_START 963 | 2663 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START 963 |
2664 | 2664 | ||
2665 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_STOP 964 | 2665 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP 964 |
2666 | 2666 | ||
2667 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_NEXT 965 | 2667 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT 965 |
2668 | 2668 | ||
2669 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT 966 | 2669 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT 966 |
2670 | 2670 | ||
2671 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_TICKET 967 | 2671 | #define GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET 967 |
2672 | 2672 | ||
2673 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT 968 | 2673 | #define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT 968 |
2674 | 2674 | ||
2675 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET 969 | 2675 | #define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET 969 |
2676 | 2676 | ||
2677 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT 970 | 2677 | #define GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT 970 |
2678 | 2678 | ||
2679 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET 971 | 2679 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET 971 |
2680 | 2680 | ||
2681 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT 972 | 2681 | #define GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT 972 |
2682 | 2682 | ||
2683 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_START 973 | 2683 | #define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START 973 |
2684 | 2684 | ||
2685 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_STOP 974 | 2685 | #define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP 974 |
2686 | 2686 | ||
2687 | #define GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_NEXT 975 | 2687 | #define GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT 975 |
2688 | 2688 | ||
2689 | /************************************************** | 2689 | /************************************************** |
2690 | * | 2690 | * |
diff --git a/src/include/gnunet_identity_attribute_lib.h b/src/include/gnunet_reclaim_attribute_lib.h index eb01f7ac2..df5356d76 100644 --- a/src/include/gnunet_identity_attribute_lib.h +++ b/src/include/gnunet_reclaim_attribute_lib.h | |||
@@ -25,8 +25,8 @@ | |||
25 | * @defgroup identity-provider Identity Provider service | 25 | * @defgroup identity-provider Identity Provider service |
26 | * @{ | 26 | * @{ |
27 | */ | 27 | */ |
28 | #ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H | 28 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H |
29 | #define GNUNET_IDENTITY_ATTRIBUTE_LIB_H | 29 | #define GNUNET_RECLAIM_ATTRIBUTE_LIB_H |
30 | 30 | ||
31 | #ifdef __cplusplus | 31 | #ifdef __cplusplus |
32 | extern "C" | 32 | extern "C" |
@@ -42,19 +42,19 @@ extern "C" | |||
42 | /** | 42 | /** |
43 | * No value attribute. | 43 | * No value attribute. |
44 | */ | 44 | */ |
45 | #define GNUNET_IDENTITY_ATTRIBUTE_TYPE_NONE 0 | 45 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_NONE 0 |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * String attribute. | 48 | * String attribute. |
49 | */ | 49 | */ |
50 | #define GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING 1 | 50 | #define GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING 1 |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | /** | 54 | /** |
55 | * An attribute. | 55 | * An attribute. |
56 | */ | 56 | */ |
57 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim | 57 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim |
58 | { | 58 | { |
59 | /** | 59 | /** |
60 | * The name of the attribute. Note "name" must never be individually | 60 | * The name of the attribute. Note "name" must never be individually |
@@ -86,35 +86,35 @@ struct GNUNET_IDENTITY_ATTRIBUTE_Claim | |||
86 | 86 | ||
87 | }; | 87 | }; |
88 | 88 | ||
89 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList | 89 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList |
90 | { | 90 | { |
91 | /** | 91 | /** |
92 | * List head | 92 | * List head |
93 | */ | 93 | */ |
94 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_head; | 94 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_head; |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * List tail | 97 | * List tail |
98 | */ | 98 | */ |
99 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *list_tail; | 99 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *list_tail; |
100 | }; | 100 | }; |
101 | 101 | ||
102 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry | 102 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry |
103 | { | 103 | { |
104 | /** | 104 | /** |
105 | * DLL | 105 | * DLL |
106 | */ | 106 | */ |
107 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *prev; | 107 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *prev; |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * DLL | 110 | * DLL |
111 | */ | 111 | */ |
112 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *next; | 112 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *next; |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * The attribute claim | 115 | * The attribute claim |
116 | */ | 116 | */ |
117 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim; | 117 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | /** | 120 | /** |
@@ -126,8 +126,8 @@ struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry | |||
126 | * @param data_size the attribute value size | 126 | * @param data_size the attribute value size |
127 | * @return the new attribute | 127 | * @return the new attribute |
128 | */ | 128 | */ |
129 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim * | 129 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
130 | GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name, | 130 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name, |
131 | uint32_t type, | 131 | uint32_t type, |
132 | const void* data, | 132 | const void* data, |
133 | size_t data_size); | 133 | size_t data_size); |
@@ -141,13 +141,13 @@ GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name, | |||
141 | * @return the required buffer size | 141 | * @return the required buffer size |
142 | */ | 142 | */ |
143 | size_t | 143 | size_t |
144 | GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs); | 144 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); |
145 | 145 | ||
146 | void | 146 | void |
147 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs); | 147 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); |
148 | 148 | ||
149 | void | 149 | void |
150 | GNUNET_IDENTITY_ATTRIBUTE_list_add (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | 150 | GNUNET_RECLAIM_ATTRIBUTE_list_add (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
151 | const char* attr_name, | 151 | const char* attr_name, |
152 | uint32_t type, | 152 | uint32_t type, |
153 | const void* data, | 153 | const void* data, |
@@ -162,7 +162,7 @@ GNUNET_IDENTITY_ATTRIBUTE_list_add (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList * | |||
162 | * @return length of serialized data | 162 | * @return length of serialized data |
163 | */ | 163 | */ |
164 | size_t | 164 | size_t |
165 | GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | 165 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
166 | char *result); | 166 | char *result); |
167 | 167 | ||
168 | /** | 168 | /** |
@@ -173,8 +173,8 @@ GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE | |||
173 | * | 173 | * |
174 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller | 174 | * @return a GNUNET_IDENTITY_PROVIDER_AttributeList, must be free'd by caller |
175 | */ | 175 | */ |
176 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList * | 176 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * |
177 | GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (const char* data, | 177 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char* data, |
178 | size_t data_size); | 178 | size_t data_size); |
179 | 179 | ||
180 | 180 | ||
@@ -186,7 +186,7 @@ GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (const char* data, | |||
186 | * @return the required buffer size | 186 | * @return the required buffer size |
187 | */ | 187 | */ |
188 | size_t | 188 | size_t |
189 | GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr); | 189 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr); |
190 | 190 | ||
191 | 191 | ||
192 | 192 | ||
@@ -199,7 +199,7 @@ GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRI | |||
199 | * @return length of serialized data | 199 | * @return length of serialized data |
200 | */ | 200 | */ |
201 | size_t | 201 | size_t |
202 | GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr, | 202 | GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
203 | char *result); | 203 | char *result); |
204 | 204 | ||
205 | /** | 205 | /** |
@@ -210,12 +210,12 @@ GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Clai | |||
210 | * | 210 | * |
211 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller | 211 | * @return a GNUNET_IDENTITY_PROVIDER_Attribute, must be free'd by caller |
212 | */ | 212 | */ |
213 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim * | 213 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
214 | GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data, | 214 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char* data, |
215 | size_t data_size); | 215 | size_t data_size); |
216 | 216 | ||
217 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList* | 217 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList* |
218 | GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs); | 218 | GNUNET_RECLAIM_ATTRIBUTE_list_dup (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Convert a type name to the corresponding number | 221 | * Convert a type name to the corresponding number |
@@ -224,7 +224,7 @@ GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim | |||
224 | * @return corresponding number, UINT32_MAX on error | 224 | * @return corresponding number, UINT32_MAX on error |
225 | */ | 225 | */ |
226 | uint32_t | 226 | uint32_t |
227 | GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename); | 227 | GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename); |
228 | 228 | ||
229 | /** | 229 | /** |
230 | * Convert human-readable version of a 'claim' of an attribute to the binary | 230 | * Convert human-readable version of a 'claim' of an attribute to the binary |
@@ -237,7 +237,7 @@ GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename); | |||
237 | * @return #GNUNET_OK on success | 237 | * @return #GNUNET_OK on success |
238 | */ | 238 | */ |
239 | int | 239 | int |
240 | GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type, | 240 | GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, |
241 | const char *s, | 241 | const char *s, |
242 | void **data, | 242 | void **data, |
243 | size_t *data_size); | 243 | size_t *data_size); |
@@ -251,7 +251,7 @@ GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type, | |||
251 | * @return NULL on error, otherwise human-readable representation of the claim | 251 | * @return NULL on error, otherwise human-readable representation of the claim |
252 | */ | 252 | */ |
253 | char * | 253 | char * |
254 | GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type, | 254 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, |
255 | const void* data, | 255 | const void* data, |
256 | size_t data_size); | 256 | size_t data_size); |
257 | 257 | ||
@@ -262,7 +262,7 @@ GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type, | |||
262 | * @return corresponding typestring, NULL on error | 262 | * @return corresponding typestring, NULL on error |
263 | */ | 263 | */ |
264 | const char* | 264 | const char* |
265 | GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type); | 265 | GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type); |
266 | 266 | ||
267 | 267 | ||
268 | #if 0 /* keep Emacsens' auto-indent happy */ | 268 | #if 0 /* keep Emacsens' auto-indent happy */ |
@@ -273,9 +273,9 @@ GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type); | |||
273 | #endif | 273 | #endif |
274 | 274 | ||
275 | 275 | ||
276 | /* ifndef GNUNET_IDENTITY_ATTRIBUTE_LIB_H */ | 276 | /* ifndef GNUNET_RECLAIM_ATTRIBUTE_LIB_H */ |
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | /** @} */ /* end of group identity */ | 279 | /** @} */ /* end of group identity */ |
280 | 280 | ||
281 | /* end of gnunet_identity_attribute_lib.h */ | 281 | /* end of gnunet_reclaim_attribute_lib.h */ |
diff --git a/src/include/gnunet_identity_attribute_plugin.h b/src/include/gnunet_reclaim_attribute_plugin.h index 7c399c616..cf0bb141a 100644 --- a/src/include/gnunet_identity_attribute_plugin.h +++ b/src/include/gnunet_reclaim_attribute_plugin.h | |||
@@ -26,11 +26,11 @@ | |||
26 | * Plugin API for the idp database backend | 26 | * Plugin API for the idp database backend |
27 | * @{ | 27 | * @{ |
28 | */ | 28 | */ |
29 | #ifndef GNUNET_IDENTITY_ATTRIBUTE_PLUGIN_H | 29 | #ifndef GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H |
30 | #define GNUNET_IDENTITY_ATTRIBUTE_PLUGIN_H | 30 | #define GNUNET_RECLAIM_ATTRIBUTE_PLUGIN_H |
31 | 31 | ||
32 | #include "gnunet_util_lib.h" | 32 | #include "gnunet_util_lib.h" |
33 | #include "gnunet_identity_attribute_lib.h" | 33 | #include "gnunet_reclaim_attribute_lib.h" |
34 | 34 | ||
35 | #ifdef __cplusplus | 35 | #ifdef __cplusplus |
36 | extern "C" | 36 | extern "C" |
@@ -51,7 +51,7 @@ extern "C" | |||
51 | * @param data_size number of bytes in @a data | 51 | * @param data_size number of bytes in @a data |
52 | * @return NULL on error, otherwise human-readable representation of the value | 52 | * @return NULL on error, otherwise human-readable representation of the value |
53 | */ | 53 | */ |
54 | typedef char * (*GNUNET_IDENTITY_ATTRIBUTE_ValueToStringFunction) (void *cls, | 54 | typedef char * (*GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction) (void *cls, |
55 | uint32_t type, | 55 | uint32_t type, |
56 | const void *data, | 56 | const void *data, |
57 | size_t data_size); | 57 | size_t data_size); |
@@ -69,7 +69,7 @@ typedef char * (*GNUNET_IDENTITY_ATTRIBUTE_ValueToStringFunction) (void *cls, | |||
69 | * @param data_size set to number of bytes in @a data | 69 | * @param data_size set to number of bytes in @a data |
70 | * @return #GNUNET_OK on success | 70 | * @return #GNUNET_OK on success |
71 | */ | 71 | */ |
72 | typedef int (*GNUNET_IDENTITY_ATTRIBUTE_StringToValueFunction) (void *cls, | 72 | typedef int (*GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction) (void *cls, |
73 | uint32_t type, | 73 | uint32_t type, |
74 | const char *s, | 74 | const char *s, |
75 | void **data, | 75 | void **data, |
@@ -84,7 +84,7 @@ typedef int (*GNUNET_IDENTITY_ATTRIBUTE_StringToValueFunction) (void *cls, | |||
84 | * @param typename name to convert | 84 | * @param typename name to convert |
85 | * @return corresponding number, UINT32_MAX on error | 85 | * @return corresponding number, UINT32_MAX on error |
86 | */ | 86 | */ |
87 | typedef uint32_t (*GNUNET_IDENTITY_ATTRIBUTE_TypenameToNumberFunction) (void *cls, | 87 | typedef uint32_t (*GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction) (void *cls, |
88 | const char *typename); | 88 | const char *typename); |
89 | 89 | ||
90 | 90 | ||
@@ -96,7 +96,7 @@ typedef uint32_t (*GNUNET_IDENTITY_ATTRIBUTE_TypenameToNumberFunction) (void *cl | |||
96 | * @param type number of a type to convert | 96 | * @param type number of a type to convert |
97 | * @return corresponding typestring, NULL on error | 97 | * @return corresponding typestring, NULL on error |
98 | */ | 98 | */ |
99 | typedef const char * (*GNUNET_IDENTITY_ATTRIBUTE_NumberToTypenameFunction) (void *cls, | 99 | typedef const char * (*GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction) (void *cls, |
100 | uint32_t type); | 100 | uint32_t type); |
101 | 101 | ||
102 | 102 | ||
@@ -104,7 +104,7 @@ typedef const char * (*GNUNET_IDENTITY_ATTRIBUTE_NumberToTypenameFunction) (void | |||
104 | * Each plugin is required to return a pointer to a struct of this | 104 | * Each plugin is required to return a pointer to a struct of this |
105 | * type as the return value from its entry point. | 105 | * type as the return value from its entry point. |
106 | */ | 106 | */ |
107 | struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions | 107 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions |
108 | { | 108 | { |
109 | 109 | ||
110 | /** | 110 | /** |
@@ -115,22 +115,22 @@ struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions | |||
115 | /** | 115 | /** |
116 | * Conversion to string. | 116 | * Conversion to string. |
117 | */ | 117 | */ |
118 | GNUNET_IDENTITY_ATTRIBUTE_ValueToStringFunction value_to_string; | 118 | GNUNET_RECLAIM_ATTRIBUTE_ValueToStringFunction value_to_string; |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Conversion to binary. | 121 | * Conversion to binary. |
122 | */ | 122 | */ |
123 | GNUNET_IDENTITY_ATTRIBUTE_StringToValueFunction string_to_value; | 123 | GNUNET_RECLAIM_ATTRIBUTE_StringToValueFunction string_to_value; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Typename to number. | 126 | * Typename to number. |
127 | */ | 127 | */ |
128 | GNUNET_IDENTITY_ATTRIBUTE_TypenameToNumberFunction typename_to_number; | 128 | GNUNET_RECLAIM_ATTRIBUTE_TypenameToNumberFunction typename_to_number; |
129 | 129 | ||
130 | /** | 130 | /** |
131 | * Number to typename. | 131 | * Number to typename. |
132 | */ | 132 | */ |
133 | GNUNET_IDENTITY_ATTRIBUTE_NumberToTypenameFunction number_to_typename; | 133 | GNUNET_RECLAIM_ATTRIBUTE_NumberToTypenameFunction number_to_typename; |
134 | 134 | ||
135 | }; | 135 | }; |
136 | 136 | ||
diff --git a/src/include/gnunet_identity_provider_plugin.h b/src/include/gnunet_reclaim_plugin.h index 2330066dd..c400af64c 100644 --- a/src/include/gnunet_identity_provider_plugin.h +++ b/src/include/gnunet_reclaim_plugin.h | |||
@@ -22,15 +22,15 @@ | |||
22 | * @file | 22 | * @file |
23 | * Plugin API for the idp database backend | 23 | * Plugin API for the idp database backend |
24 | * | 24 | * |
25 | * @defgroup identity-provider-plugin IdP service plugin API | 25 | * @defgroup reclaim-plugin IdP service plugin API |
26 | * Plugin API for the idp database backend | 26 | * Plugin API for the idp database backend |
27 | * @{ | 27 | * @{ |
28 | */ | 28 | */ |
29 | #ifndef GNUNET_IDENTITY_PROVIDER_PLUGIN_H | 29 | #ifndef GNUNET_RECLAIM_PLUGIN_H |
30 | #define GNUNET_IDENTITY_PROVIDER_PLUGIN_H | 30 | #define GNUNET_RECLAIM_PLUGIN_H |
31 | 31 | ||
32 | #include "gnunet_util_lib.h" | 32 | #include "gnunet_util_lib.h" |
33 | #include "gnunet_identity_provider_service.h" | 33 | #include "gnunet_reclaim_service.h" |
34 | 34 | ||
35 | #ifdef __cplusplus | 35 | #ifdef __cplusplus |
36 | extern "C" | 36 | extern "C" |
@@ -47,15 +47,15 @@ extern "C" | |||
47 | * @param cls closure | 47 | * @param cls closure |
48 | * @param ticket the ticket | 48 | * @param ticket the ticket |
49 | */ | 49 | */ |
50 | typedef void (*GNUNET_IDENTITY_PROVIDER_TicketIterator) (void *cls, | 50 | typedef void (*GNUNET_RECLAIM_TicketIterator) (void *cls, |
51 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 51 | const struct GNUNET_RECLAIM_Ticket *ticket, |
52 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs); | 52 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); |
53 | 53 | ||
54 | 54 | ||
55 | /** | 55 | /** |
56 | * @brief struct returned by the initialization function of the plugin | 56 | * @brief struct returned by the initialization function of the plugin |
57 | */ | 57 | */ |
58 | struct GNUNET_IDENTITY_PROVIDER_PluginFunctions | 58 | struct GNUNET_RECLAIM_PluginFunctions |
59 | { | 59 | { |
60 | 60 | ||
61 | /** | 61 | /** |
@@ -71,8 +71,8 @@ struct GNUNET_IDENTITY_PROVIDER_PluginFunctions | |||
71 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 71 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
72 | */ | 72 | */ |
73 | int (*store_ticket) (void *cls, | 73 | int (*store_ticket) (void *cls, |
74 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 74 | const struct GNUNET_RECLAIM_Ticket *ticket, |
75 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs); | 75 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Delete a ticket from the database. | 78 | * Delete a ticket from the database. |
@@ -82,7 +82,7 @@ struct GNUNET_IDENTITY_PROVIDER_PluginFunctions | |||
82 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 82 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
83 | */ | 83 | */ |
84 | int (*delete_ticket) (void *cls, | 84 | int (*delete_ticket) (void *cls, |
85 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket); | 85 | const struct GNUNET_RECLAIM_Ticket *ticket); |
86 | 86 | ||
87 | 87 | ||
88 | 88 | ||
@@ -101,11 +101,11 @@ struct GNUNET_IDENTITY_PROVIDER_PluginFunctions | |||
101 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 101 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
102 | int audience, | 102 | int audience, |
103 | uint64_t offset, | 103 | uint64_t offset, |
104 | GNUNET_IDENTITY_PROVIDER_TicketIterator iter, void *iter_cls); | 104 | GNUNET_RECLAIM_TicketIterator iter, void *iter_cls); |
105 | 105 | ||
106 | int (*get_ticket_attributes) (void* cls, | 106 | int (*get_ticket_attributes) (void* cls, |
107 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 107 | const struct GNUNET_RECLAIM_Ticket *ticket, |
108 | GNUNET_IDENTITY_PROVIDER_TicketIterator iter, | 108 | GNUNET_RECLAIM_TicketIterator iter, |
109 | void *iter_cls); | 109 | void *iter_cls); |
110 | }; | 110 | }; |
111 | 111 | ||
diff --git a/src/include/gnunet_identity_provider_service.h b/src/include/gnunet_reclaim_service.h index 0c72556e8..7e668cd62 100644 --- a/src/include/gnunet_identity_provider_service.h +++ b/src/include/gnunet_reclaim_service.h | |||
@@ -22,11 +22,11 @@ | |||
22 | * @file | 22 | * @file |
23 | * Identity provider service; implements identity provider for GNUnet | 23 | * Identity provider service; implements identity provider for GNUnet |
24 | * | 24 | * |
25 | * @defgroup identity-provider Identity Provider service | 25 | * @defgroup reclaim Identity Provider service |
26 | * @{ | 26 | * @{ |
27 | */ | 27 | */ |
28 | #ifndef GNUNET_IDENTITY_PROVIDER_SERVICE_H | 28 | #ifndef GNUNET_RECLAIM_SERVICE_H |
29 | #define GNUNET_IDENTITY_PROVIDER_SERVICE_H | 29 | #define GNUNET_RECLAIM_SERVICE_H |
30 | 30 | ||
31 | #ifdef __cplusplus | 31 | #ifdef __cplusplus |
32 | extern "C" | 32 | extern "C" |
@@ -37,27 +37,27 @@ extern "C" | |||
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #include "gnunet_util_lib.h" | 39 | #include "gnunet_util_lib.h" |
40 | #include "gnunet_identity_attribute_lib.h" | 40 | #include "gnunet_reclaim_attribute_lib.h" |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Version number of GNUnet Identity Provider API. | 43 | * Version number of GNUnet Identity Provider API. |
44 | */ | 44 | */ |
45 | #define GNUNET_IDENTITY_PROVIDER_VERSION 0x00000000 | 45 | #define GNUNET_RECLAIM_VERSION 0x00000000 |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Handle to access the identity service. | 48 | * Handle to access the identity service. |
49 | */ | 49 | */ |
50 | struct GNUNET_IDENTITY_PROVIDER_Handle; | 50 | struct GNUNET_RECLAIM_Handle; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Handle for a token. | 53 | * Handle for a token. |
54 | */ | 54 | */ |
55 | struct GNUNET_IDENTITY_PROVIDER_Token; | 55 | struct GNUNET_RECLAIM_Token; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * The ticket | 58 | * The ticket |
59 | */ | 59 | */ |
60 | struct GNUNET_IDENTITY_PROVIDER_Ticket | 60 | struct GNUNET_RECLAIM_Ticket |
61 | { | 61 | { |
62 | /** | 62 | /** |
63 | * The ticket issuer | 63 | * The ticket issuer |
@@ -78,7 +78,7 @@ struct GNUNET_IDENTITY_PROVIDER_Ticket | |||
78 | /** | 78 | /** |
79 | * Handle for an operation with the identity provider service. | 79 | * Handle for an operation with the identity provider service. |
80 | */ | 80 | */ |
81 | struct GNUNET_IDENTITY_PROVIDER_Operation; | 81 | struct GNUNET_RECLAIM_Operation; |
82 | 82 | ||
83 | 83 | ||
84 | /** | 84 | /** |
@@ -87,8 +87,8 @@ struct GNUNET_IDENTITY_PROVIDER_Operation; | |||
87 | * @param cfg Configuration to contact the identity provider service. | 87 | * @param cfg Configuration to contact the identity provider service. |
88 | * @return handle to communicate with identity provider service | 88 | * @return handle to communicate with identity provider service |
89 | */ | 89 | */ |
90 | struct GNUNET_IDENTITY_PROVIDER_Handle * | 90 | struct GNUNET_RECLAIM_Handle * |
91 | GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); | 91 | GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg); |
92 | 92 | ||
93 | /** | 93 | /** |
94 | * Continuation called to notify client about result of the | 94 | * Continuation called to notify client about result of the |
@@ -101,7 +101,7 @@ GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
101 | * @param emsg NULL on success, otherwise an error message | 101 | * @param emsg NULL on success, otherwise an error message |
102 | */ | 102 | */ |
103 | typedef void | 103 | typedef void |
104 | (*GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus) (void *cls, | 104 | (*GNUNET_RECLAIM_ContinuationWithStatus) (void *cls, |
105 | int32_t success, | 105 | int32_t success, |
106 | const char *emsg); | 106 | const char *emsg); |
107 | 107 | ||
@@ -118,12 +118,12 @@ typedef void | |||
118 | * @param cont_cls closure for @a cont | 118 | * @param cont_cls closure for @a cont |
119 | * @return handle to abort the request | 119 | * @return handle to abort the request |
120 | */ | 120 | */ |
121 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 121 | struct GNUNET_RECLAIM_Operation * |
122 | GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 122 | GNUNET_RECLAIM_attribute_store (struct GNUNET_RECLAIM_Handle *h, |
123 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 123 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
124 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr, | 124 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
125 | const struct GNUNET_TIME_Relative *exp_interval, | 125 | const struct GNUNET_TIME_Relative *exp_interval, |
126 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont, | 126 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
127 | void *cont_cls); | 127 | void *cont_cls); |
128 | 128 | ||
129 | 129 | ||
@@ -135,19 +135,19 @@ GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
135 | * @param attr the attribute | 135 | * @param attr the attribute |
136 | */ | 136 | */ |
137 | typedef void | 137 | typedef void |
138 | (*GNUNET_IDENTITY_PROVIDER_AttributeResult) (void *cls, | 138 | (*GNUNET_RECLAIM_AttributeResult) (void *cls, |
139 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 139 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
140 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr); | 140 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr); |
141 | 141 | ||
142 | 142 | ||
143 | 143 | ||
144 | /** | 144 | /** |
145 | * List all attributes for a local identity. | 145 | * List all attributes for a local identity. |
146 | * This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle` | 146 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` |
147 | * for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and | 147 | * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and |
148 | * #GNUNET_IDENTITY_PROVIDER_get_attributes_stop. @a proc will be called once | 148 | * #GNUNET_RECLAIM_get_attributes_stop. @a proc will be called once |
149 | * immediately, and then again after | 149 | * immediately, and then again after |
150 | * #GNUNET_IDENTITY_PROVIDER_get_attributes_next() is invoked. | 150 | * #GNUNET_RECLAIM_get_attributes_next() is invoked. |
151 | * | 151 | * |
152 | * On error (disconnect), @a error_cb will be invoked. | 152 | * On error (disconnect), @a error_cb will be invoked. |
153 | * On normal completion, @a finish_cb proc will be | 153 | * On normal completion, @a finish_cb proc will be |
@@ -166,36 +166,36 @@ typedef void | |||
166 | * @param finish_cb_cls closure for @a finish_cb | 166 | * @param finish_cb_cls closure for @a finish_cb |
167 | * @return an iterator handle to use for iteration | 167 | * @return an iterator handle to use for iteration |
168 | */ | 168 | */ |
169 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator * | 169 | struct GNUNET_RECLAIM_AttributeIterator * |
170 | GNUNET_IDENTITY_PROVIDER_get_attributes_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 170 | GNUNET_RECLAIM_get_attributes_start (struct GNUNET_RECLAIM_Handle *h, |
171 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 171 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
172 | GNUNET_SCHEDULER_TaskCallback error_cb, | 172 | GNUNET_SCHEDULER_TaskCallback error_cb, |
173 | void *error_cb_cls, | 173 | void *error_cb_cls, |
174 | GNUNET_IDENTITY_PROVIDER_AttributeResult proc, | 174 | GNUNET_RECLAIM_AttributeResult proc, |
175 | void *proc_cls, | 175 | void *proc_cls, |
176 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 176 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
177 | void *finish_cb_cls); | 177 | void *finish_cb_cls); |
178 | 178 | ||
179 | 179 | ||
180 | /** | 180 | /** |
181 | * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_get_attributes_start | 181 | * Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start |
182 | * for the next record. | 182 | * for the next record. |
183 | * | 183 | * |
184 | * @param it the iterator | 184 | * @param it the iterator |
185 | */ | 185 | */ |
186 | void | 186 | void |
187 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it); | 187 | GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it); |
188 | 188 | ||
189 | 189 | ||
190 | /** | 190 | /** |
191 | * Stops iteration and releases the idp handle for further calls. Must | 191 | * Stops iteration and releases the idp handle for further calls. Must |
192 | * be called on any iteration that has not yet completed prior to calling | 192 | * be called on any iteration that has not yet completed prior to calling |
193 | * #GNUNET_IDENTITY_PROVIDER_disconnect. | 193 | * #GNUNET_RECLAIM_disconnect. |
194 | * | 194 | * |
195 | * @param it the iterator | 195 | * @param it the iterator |
196 | */ | 196 | */ |
197 | void | 197 | void |
198 | GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it); | 198 | GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it); |
199 | 199 | ||
200 | 200 | ||
201 | /** | 201 | /** |
@@ -207,12 +207,12 @@ GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_At | |||
207 | * @param ticket the ticket | 207 | * @param ticket the ticket |
208 | */ | 208 | */ |
209 | typedef void | 209 | typedef void |
210 | (*GNUNET_IDENTITY_PROVIDER_TicketCallback)(void *cls, | 210 | (*GNUNET_RECLAIM_TicketCallback)(void *cls, |
211 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket); | 211 | const struct GNUNET_RECLAIM_Ticket *ticket); |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Issues a ticket to another identity. The identity may use | 214 | * Issues a ticket to another identity. The identity may use |
215 | * GNUNET_IDENTITY_PROVIDER_ticket_consume to consume the ticket | 215 | * GNUNET_RECLAIM_ticket_consume to consume the ticket |
216 | * and retrieve the attributes specified in the AttributeList. | 216 | * and retrieve the attributes specified in the AttributeList. |
217 | * | 217 | * |
218 | * @param h the identity provider to use | 218 | * @param h the identity provider to use |
@@ -223,12 +223,12 @@ typedef void | |||
223 | * @param cb_cls the callback closure | 223 | * @param cb_cls the callback closure |
224 | * @return handle to abort the operation | 224 | * @return handle to abort the operation |
225 | */ | 225 | */ |
226 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 226 | struct GNUNET_RECLAIM_Operation * |
227 | GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 227 | GNUNET_RECLAIM_ticket_issue (struct GNUNET_RECLAIM_Handle *h, |
228 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, | 228 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, |
229 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, | 229 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, |
230 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | 230 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
231 | GNUNET_IDENTITY_PROVIDER_TicketCallback cb, | 231 | GNUNET_RECLAIM_TicketCallback cb, |
232 | void *cb_cls); | 232 | void *cb_cls); |
233 | 233 | ||
234 | /** | 234 | /** |
@@ -242,11 +242,11 @@ GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h | |||
242 | * @param cb_cls the callback closure | 242 | * @param cb_cls the callback closure |
243 | * @return handle to abort the operation | 243 | * @return handle to abort the operation |
244 | */ | 244 | */ |
245 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 245 | struct GNUNET_RECLAIM_Operation * |
246 | GNUNET_IDENTITY_PROVIDER_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 246 | GNUNET_RECLAIM_ticket_revoke (struct GNUNET_RECLAIM_Handle *h, |
247 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 247 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
248 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 248 | const struct GNUNET_RECLAIM_Ticket *ticket, |
249 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cb, | 249 | GNUNET_RECLAIM_ContinuationWithStatus cb, |
250 | void *cb_cls); | 250 | void *cb_cls); |
251 | 251 | ||
252 | 252 | ||
@@ -262,11 +262,11 @@ GNUNET_IDENTITY_PROVIDER_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Handle * | |||
262 | * @param cb_cls the callback closure | 262 | * @param cb_cls the callback closure |
263 | * @return handle to abort the operation | 263 | * @return handle to abort the operation |
264 | */ | 264 | */ |
265 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 265 | struct GNUNET_RECLAIM_Operation * |
266 | GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 266 | GNUNET_RECLAIM_ticket_consume (struct GNUNET_RECLAIM_Handle *h, |
267 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 267 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
268 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 268 | const struct GNUNET_RECLAIM_Ticket *ticket, |
269 | GNUNET_IDENTITY_PROVIDER_AttributeResult cb, | 269 | GNUNET_RECLAIM_AttributeResult cb, |
270 | void *cb_cls); | 270 | void *cb_cls); |
271 | 271 | ||
272 | /** | 272 | /** |
@@ -286,12 +286,12 @@ GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
286 | * @param finish_cb_cls closure for @a finish_cb | 286 | * @param finish_cb_cls closure for @a finish_cb |
287 | * @return an iterator handle to use for iteration | 287 | * @return an iterator handle to use for iteration |
288 | */ | 288 | */ |
289 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator * | 289 | struct GNUNET_RECLAIM_TicketIterator * |
290 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 290 | GNUNET_RECLAIM_ticket_iteration_start (struct GNUNET_RECLAIM_Handle *h, |
291 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 291 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
292 | GNUNET_SCHEDULER_TaskCallback error_cb, | 292 | GNUNET_SCHEDULER_TaskCallback error_cb, |
293 | void *error_cb_cls, | 293 | void *error_cb_cls, |
294 | GNUNET_IDENTITY_PROVIDER_TicketCallback proc, | 294 | GNUNET_RECLAIM_TicketCallback proc, |
295 | void *proc_cls, | 295 | void *proc_cls, |
296 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 296 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
297 | void *finish_cb_cls); | 297 | void *finish_cb_cls); |
@@ -313,34 +313,34 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER | |||
313 | * @param finish_cb_cls closure for @a finish_cb | 313 | * @param finish_cb_cls closure for @a finish_cb |
314 | * @return an iterator handle to use for iteration | 314 | * @return an iterator handle to use for iteration |
315 | */ | 315 | */ |
316 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator * | 316 | struct GNUNET_RECLAIM_TicketIterator * |
317 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_start_rp (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 317 | GNUNET_RECLAIM_ticket_iteration_start_rp (struct GNUNET_RECLAIM_Handle *h, |
318 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 318 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
319 | GNUNET_SCHEDULER_TaskCallback error_cb, | 319 | GNUNET_SCHEDULER_TaskCallback error_cb, |
320 | void *error_cb_cls, | 320 | void *error_cb_cls, |
321 | GNUNET_IDENTITY_PROVIDER_TicketCallback proc, | 321 | GNUNET_RECLAIM_TicketCallback proc, |
322 | void *proc_cls, | 322 | void *proc_cls, |
323 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 323 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
324 | void *finish_cb_cls); | 324 | void *finish_cb_cls); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_ticket_iteration_start | 327 | * Calls the record processor specified in #GNUNET_RECLAIM_ticket_iteration_start |
328 | * for the next record. | 328 | * for the next record. |
329 | * | 329 | * |
330 | * @param it the iterator | 330 | * @param it the iterator |
331 | */ | 331 | */ |
332 | void | 332 | void |
333 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_next (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it); | 333 | GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it); |
334 | 334 | ||
335 | /** | 335 | /** |
336 | * Stops iteration and releases the idp handle for further calls. Must | 336 | * Stops iteration and releases the idp handle for further calls. Must |
337 | * be called on any iteration that has not yet completed prior to calling | 337 | * be called on any iteration that has not yet completed prior to calling |
338 | * #GNUNET_IDENTITY_PROVIDER_disconnect. | 338 | * #GNUNET_RECLAIM_disconnect. |
339 | * | 339 | * |
340 | * @param it the iterator | 340 | * @param it the iterator |
341 | */ | 341 | */ |
342 | void | 342 | void |
343 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it); | 343 | GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it); |
344 | 344 | ||
345 | /** | 345 | /** |
346 | * Disconnect from identity provider service. | 346 | * Disconnect from identity provider service. |
@@ -348,7 +348,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (struct GNUNET_IDENTITY_PROVIDER_ | |||
348 | * @param h identity provider service to disconnect | 348 | * @param h identity provider service to disconnect |
349 | */ | 349 | */ |
350 | void | 350 | void |
351 | GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h); | 351 | GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h); |
352 | 352 | ||
353 | 353 | ||
354 | /** | 354 | /** |
@@ -360,7 +360,7 @@ GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h); | |||
360 | * @param op operation to cancel | 360 | * @param op operation to cancel |
361 | */ | 361 | */ |
362 | void | 362 | void |
363 | GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op); | 363 | GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op); |
364 | 364 | ||
365 | #if 0 /* keep Emacsens' auto-indent happy */ | 365 | #if 0 /* keep Emacsens' auto-indent happy */ |
366 | { | 366 | { |
@@ -370,9 +370,9 @@ GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op); | |||
370 | #endif | 370 | #endif |
371 | 371 | ||
372 | 372 | ||
373 | /* ifndef GNUNET_IDENTITY_PROVIDER_SERVICE_H */ | 373 | /* ifndef GNUNET_RECLAIM_SERVICE_H */ |
374 | #endif | 374 | #endif |
375 | 375 | ||
376 | /** @} */ /* end of group identity */ | 376 | /** @} */ /* end of group identity */ |
377 | 377 | ||
378 | /* end of gnunet_identity_provider_service.h */ | 378 | /* end of gnunet_reclaim_service.h */ |
diff --git a/src/include/gnunet_signatures.h b/src/include/gnunet_signatures.h index d7accaf2c..829f8be7e 100644 --- a/src/include/gnunet_signatures.h +++ b/src/include/gnunet_signatures.h | |||
@@ -151,12 +151,12 @@ extern "C" | |||
151 | /** | 151 | /** |
152 | * Signature for the first round of distributed key generation. | 152 | * Signature for the first round of distributed key generation. |
153 | */ | 153 | */ |
154 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG1 22 | 154 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG1 21 |
155 | 155 | ||
156 | /** | 156 | /** |
157 | * Signature for the second round of distributed key generation. | 157 | * Signature for the second round of distributed key generation. |
158 | */ | 158 | */ |
159 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2 23 | 159 | #define GNUNET_SIGNATURE_PURPOSE_SECRETSHARING_DKG2 22 |
160 | 160 | ||
161 | /** | 161 | /** |
162 | * Signature for cooperatice decryption. | 162 | * Signature for cooperatice decryption. |
@@ -181,7 +181,7 @@ extern "C" | |||
181 | /** | 181 | /** |
182 | * Signature for a GNUid Ticket | 182 | * Signature for a GNUid Ticket |
183 | */ | 183 | */ |
184 | #define GNUNET_SIGNATURE_PURPOSE_GNUID_TICKET 27 | 184 | #define GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN 27 |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * Signature for a GNUnet credential | 187 | * Signature for a GNUnet credential |
diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index 20d29b906..f8441cc2b 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c | |||
@@ -1449,17 +1449,15 @@ check_client_member_join (void *cls, | |||
1449 | struct GNUNET_PeerIdentity *relays = (struct GNUNET_PeerIdentity *) &msg[1]; | 1449 | struct GNUNET_PeerIdentity *relays = (struct GNUNET_PeerIdentity *) &msg[1]; |
1450 | uint32_t relay_count = ntohl (msg->relay_count); | 1450 | uint32_t relay_count = ntohl (msg->relay_count); |
1451 | 1451 | ||
1452 | if (0 == relay_count) | 1452 | if (0 != relay_count) |
1453 | { | 1453 | { |
1454 | GNUNET_break (0); | 1454 | if (UINT32_MAX / relay_count < sizeof (*relays)){ |
1455 | return GNUNET_SYSERR; | 1455 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1456 | } | 1456 | "relay_count (%lu) * sizeof (*relays) (%lu) exceeds UINT32_MAX!\n", |
1457 | if (UINT32_MAX / relay_count < sizeof (*relays)){ | 1457 | (unsigned long)relay_count, |
1458 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1458 | sizeof (*relays)); |
1459 | "relay_count (%lu) * sizeof (*relays) (%lu) exceeds UINT32_MAX!\n", | 1459 | return GNUNET_SYSERR; |
1460 | (unsigned long)relay_count, | 1460 | } |
1461 | sizeof (*relays)); | ||
1462 | return GNUNET_SYSERR; | ||
1463 | } | 1461 | } |
1464 | uint32_t relay_size = relay_count * sizeof (*relays); | 1462 | uint32_t relay_size = relay_count * sizeof (*relays); |
1465 | struct GNUNET_MessageHeader *join_msg = NULL; | 1463 | struct GNUNET_MessageHeader *join_msg = NULL; |
diff --git a/src/multicast/test_multicast_multipeer.c b/src/multicast/test_multicast_multipeer.c index 3a7c6d961..7766ff875 100644 --- a/src/multicast/test_multicast_multipeer.c +++ b/src/multicast/test_multicast_multipeer.c | |||
@@ -160,6 +160,7 @@ notify (void *cls, | |||
160 | 160 | ||
161 | *data_size = sizeof (struct pingpong_msg); | 161 | *data_size = sizeof (struct pingpong_msg); |
162 | GNUNET_memcpy(data, pp_msg, *data_size); | 162 | GNUNET_memcpy(data, pp_msg, *data_size); |
163 | GNUNET_free (pp_msg); | ||
163 | 164 | ||
164 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 165 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
165 | "Peer #%u sents ping to origin\n", mc_peer->peer); | 166 | "Peer #%u sents ping to origin\n", mc_peer->peer); |
@@ -328,6 +329,7 @@ origin_notify (void *cls, | |||
328 | pp_msg->msg = PONG; | 329 | pp_msg->msg = PONG; |
329 | *data_size = sizeof (struct pingpong_msg); | 330 | *data_size = sizeof (struct pingpong_msg); |
330 | GNUNET_memcpy(data, pp_msg, *data_size); | 331 | GNUNET_memcpy(data, pp_msg, *data_size); |
332 | GNUNET_free (pp_msg); | ||
331 | 333 | ||
332 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends pong\n"); | 334 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends pong\n"); |
333 | 335 | ||
diff --git a/src/identity-attribute/Makefile.am b/src/reclaim-attribute/Makefile.am index 2c73a443e..7db2925b1 100644 --- a/src/identity-attribute/Makefile.am +++ b/src/reclaim-attribute/Makefile.am | |||
@@ -17,28 +17,28 @@ if USE_COVERAGE | |||
17 | endif | 17 | endif |
18 | 18 | ||
19 | lib_LTLIBRARIES = \ | 19 | lib_LTLIBRARIES = \ |
20 | libgnunetidentityattribute.la | 20 | libgnunetreclaimattribute.la |
21 | 21 | ||
22 | libgnunetidentityattribute_la_SOURCES = \ | 22 | libgnunetreclaimattribute_la_SOURCES = \ |
23 | identity_attribute.c | 23 | reclaim_attribute.c |
24 | libgnunetidentityattribute_la_LIBADD = \ | 24 | libgnunetreclaimattribute_la_LIBADD = \ |
25 | $(top_builddir)/src/util/libgnunetutil.la \ | 25 | $(top_builddir)/src/util/libgnunetutil.la \ |
26 | $(GN_LIBINTL) | 26 | $(GN_LIBINTL) |
27 | libgnunetidentityattribute_la_LDFLAGS = \ | 27 | libgnunetreclaimattribute_la_LDFLAGS = \ |
28 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | 28 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ |
29 | -version-info 0:0:0 | 29 | -version-info 0:0:0 |
30 | 30 | ||
31 | 31 | ||
32 | plugin_LTLIBRARIES = \ | 32 | plugin_LTLIBRARIES = \ |
33 | libgnunet_plugin_identity_attribute_gnuid.la | 33 | libgnunet_plugin_reclaim_attribute_gnuid.la |
34 | 34 | ||
35 | 35 | ||
36 | libgnunet_plugin_identity_attribute_gnuid_la_SOURCES = \ | 36 | libgnunet_plugin_reclaim_attribute_gnuid_la_SOURCES = \ |
37 | plugin_identity_attribute_gnuid.c | 37 | plugin_reclaim_attribute_gnuid.c |
38 | libgnunet_plugin_identity_attribute_gnuid_la_LIBADD = \ | 38 | libgnunet_plugin_reclaim_attribute_gnuid_la_LIBADD = \ |
39 | $(top_builddir)/src/util/libgnunetutil.la \ | 39 | $(top_builddir)/src/util/libgnunetutil.la \ |
40 | $(LTLIBINTL) | 40 | $(LTLIBINTL) |
41 | libgnunet_plugin_identity_attribute_gnuid_la_LDFLAGS = \ | 41 | libgnunet_plugin_reclaim_attribute_gnuid_la_LDFLAGS = \ |
42 | $(GN_PLUGIN_LDFLAGS) | 42 | $(GN_PLUGIN_LDFLAGS) |
43 | 43 | ||
44 | 44 | ||
diff --git a/src/identity-attribute/plugin_identity_attribute_gnuid.c b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c index c09b167f5..48afc0732 100644 --- a/src/identity-attribute/plugin_identity_attribute_gnuid.c +++ b/src/reclaim-attribute/plugin_reclaim_attribute_gnuid.c | |||
@@ -17,7 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @file identity-attribute/plugin_identity_attribute_gnuid.c | 20 | * @file reclaim-attribute/plugin_reclaim_attribute_gnuid.c |
21 | * @brief identity attribute plugin to provide the API for fundamental | 21 | * @brief identity attribute plugin to provide the API for fundamental |
22 | * attribute types. | 22 | * attribute types. |
23 | * | 23 | * |
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_identity_attribute_plugin.h" | 28 | #include "gnunet_reclaim_attribute_plugin.h" |
29 | #include <inttypes.h> | 29 | #include <inttypes.h> |
30 | 30 | ||
31 | 31 | ||
@@ -47,7 +47,7 @@ gnuid_value_to_string (void *cls, | |||
47 | 47 | ||
48 | switch (type) | 48 | switch (type) |
49 | { | 49 | { |
50 | case GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING: | 50 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: |
51 | return GNUNET_strndup (data, data_size); | 51 | return GNUNET_strndup (data, data_size); |
52 | default: | 52 | default: |
53 | return NULL; | 53 | return NULL; |
@@ -78,7 +78,7 @@ gnuid_string_to_value (void *cls, | |||
78 | switch (type) | 78 | switch (type) |
79 | { | 79 | { |
80 | 80 | ||
81 | case GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING: | 81 | case GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING: |
82 | *data = GNUNET_strdup (s); | 82 | *data = GNUNET_strdup (s); |
83 | *data_size = strlen (s); | 83 | *data_size = strlen (s); |
84 | return GNUNET_OK; | 84 | return GNUNET_OK; |
@@ -96,7 +96,7 @@ static struct { | |||
96 | const char *name; | 96 | const char *name; |
97 | uint32_t number; | 97 | uint32_t number; |
98 | } gnuid_name_map[] = { | 98 | } gnuid_name_map[] = { |
99 | { "STRING", GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING }, | 99 | { "STRING", GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING }, |
100 | { NULL, UINT32_MAX } | 100 | { NULL, UINT32_MAX } |
101 | }; | 101 | }; |
102 | 102 | ||
@@ -151,11 +151,11 @@ gnuid_number_to_typename (void *cls, | |||
151 | * @return the exported block API | 151 | * @return the exported block API |
152 | */ | 152 | */ |
153 | void * | 153 | void * |
154 | libgnunet_plugin_identity_attribute_gnuid_init (void *cls) | 154 | libgnunet_plugin_reclaim_attribute_gnuid_init (void *cls) |
155 | { | 155 | { |
156 | struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api; | 156 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api; |
157 | 157 | ||
158 | api = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions); | 158 | api = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions); |
159 | api->value_to_string = &gnuid_value_to_string; | 159 | api->value_to_string = &gnuid_value_to_string; |
160 | api->string_to_value = &gnuid_string_to_value; | 160 | api->string_to_value = &gnuid_string_to_value; |
161 | api->typename_to_number = &gnuid_typename_to_number; | 161 | api->typename_to_number = &gnuid_typename_to_number; |
@@ -171,12 +171,12 @@ libgnunet_plugin_identity_attribute_gnuid_init (void *cls) | |||
171 | * @return NULL | 171 | * @return NULL |
172 | */ | 172 | */ |
173 | void * | 173 | void * |
174 | libgnunet_plugin_identity_attribute_gnuid_done (void *cls) | 174 | libgnunet_plugin_reclaim_attribute_gnuid_done (void *cls) |
175 | { | 175 | { |
176 | struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api = cls; | 176 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = cls; |
177 | 177 | ||
178 | GNUNET_free (api); | 178 | GNUNET_free (api); |
179 | return NULL; | 179 | return NULL; |
180 | } | 180 | } |
181 | 181 | ||
182 | /* end of plugin_identity_attribute_type_gnuid.c */ | 182 | /* end of plugin_reclaim_attribute_type_gnuid.c */ |
diff --git a/src/identity-attribute/identity_attribute.c b/src/reclaim-attribute/reclaim_attribute.c index 7d47c46a7..74d668ea8 100644 --- a/src/identity-attribute/identity_attribute.c +++ b/src/reclaim-attribute/reclaim_attribute.c | |||
@@ -17,14 +17,14 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @file identity-attribute/identity_attribute.c | 20 | * @file reclaim-attribute/reclaim_attribute.c |
21 | * @brief helper library to manage identity attributes | 21 | * @brief helper library to manage identity attributes |
22 | * @author Martin Schanzenbach | 22 | * @author Martin Schanzenbach |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_util_lib.h" | 25 | #include "gnunet_util_lib.h" |
26 | #include "identity_attribute.h" | 26 | #include "reclaim_attribute.h" |
27 | #include "gnunet_identity_attribute_plugin.h" | 27 | #include "gnunet_reclaim_attribute_plugin.h" |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Handle for a plugin | 30 | * Handle for a plugin |
@@ -39,7 +39,7 @@ struct Plugin | |||
39 | /** | 39 | /** |
40 | * Plugin API | 40 | * Plugin API |
41 | */ | 41 | */ |
42 | struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api; | 42 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /** | 45 | /** |
@@ -65,7 +65,7 @@ add_plugin (void* cls, | |||
65 | const char *library_name, | 65 | const char *library_name, |
66 | void *lib_ret) | 66 | void *lib_ret) |
67 | { | 67 | { |
68 | struct GNUNET_IDENTITY_ATTRIBUTE_PluginFunctions *api = lib_ret; | 68 | struct GNUNET_RECLAIM_ATTRIBUTE_PluginFunctions *api = lib_ret; |
69 | struct Plugin *plugin; | 69 | struct Plugin *plugin; |
70 | 70 | ||
71 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 71 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -86,7 +86,7 @@ init() | |||
86 | if (GNUNET_YES == initialized) | 86 | if (GNUNET_YES == initialized) |
87 | return; | 87 | return; |
88 | initialized = GNUNET_YES; | 88 | initialized = GNUNET_YES; |
89 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_identity_attribute_", NULL, | 89 | GNUNET_PLUGIN_load_all ("libgnunet_plugin_reclaim_attribute_", NULL, |
90 | &add_plugin, NULL); | 90 | &add_plugin, NULL); |
91 | } | 91 | } |
92 | 92 | ||
@@ -97,7 +97,7 @@ init() | |||
97 | * @return corresponding number, UINT32_MAX on error | 97 | * @return corresponding number, UINT32_MAX on error |
98 | */ | 98 | */ |
99 | uint32_t | 99 | uint32_t |
100 | GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename) | 100 | GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (const char *typename) |
101 | { | 101 | { |
102 | unsigned int i; | 102 | unsigned int i; |
103 | struct Plugin *plugin; | 103 | struct Plugin *plugin; |
@@ -121,7 +121,7 @@ GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (const char *typename) | |||
121 | * @return corresponding typestring, NULL on error | 121 | * @return corresponding typestring, NULL on error |
122 | */ | 122 | */ |
123 | const char* | 123 | const char* |
124 | GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type) | 124 | GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (uint32_t type) |
125 | { | 125 | { |
126 | unsigned int i; | 126 | unsigned int i; |
127 | struct Plugin *plugin; | 127 | struct Plugin *plugin; |
@@ -149,7 +149,7 @@ GNUNET_IDENTITY_ATTRIBUTE_number_to_typename (uint32_t type) | |||
149 | * @return #GNUNET_OK on success | 149 | * @return #GNUNET_OK on success |
150 | */ | 150 | */ |
151 | int | 151 | int |
152 | GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type, | 152 | GNUNET_RECLAIM_ATTRIBUTE_string_to_value (uint32_t type, |
153 | const char *s, | 153 | const char *s, |
154 | void **data, | 154 | void **data, |
155 | size_t *data_size) | 155 | size_t *data_size) |
@@ -180,7 +180,7 @@ GNUNET_IDENTITY_ATTRIBUTE_string_to_value (uint32_t type, | |||
180 | * @return NULL on error, otherwise human-readable representation of the claim | 180 | * @return NULL on error, otherwise human-readable representation of the claim |
181 | */ | 181 | */ |
182 | char * | 182 | char * |
183 | GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type, | 183 | GNUNET_RECLAIM_ATTRIBUTE_value_to_string (uint32_t type, |
184 | const void* data, | 184 | const void* data, |
185 | size_t data_size) | 185 | size_t data_size) |
186 | { | 186 | { |
@@ -210,16 +210,16 @@ GNUNET_IDENTITY_ATTRIBUTE_value_to_string (uint32_t type, | |||
210 | * @param data_size the attribute value size | 210 | * @param data_size the attribute value size |
211 | * @return the new attribute | 211 | * @return the new attribute |
212 | */ | 212 | */ |
213 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim * | 213 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
214 | GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name, | 214 | GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name, |
215 | uint32_t type, | 215 | uint32_t type, |
216 | const void* data, | 216 | const void* data, |
217 | size_t data_size) | 217 | size_t data_size) |
218 | { | 218 | { |
219 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr; | 219 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; |
220 | char *write_ptr; | 220 | char *write_ptr; |
221 | 221 | ||
222 | attr = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_ATTRIBUTE_Claim) + | 222 | attr = GNUNET_malloc (sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + |
223 | strlen (attr_name) + 1 + | 223 | strlen (attr_name) + 1 + |
224 | data_size); | 224 | data_size); |
225 | attr->type = type; | 225 | attr->type = type; |
@@ -249,15 +249,15 @@ GNUNET_IDENTITY_ATTRIBUTE_claim_new (const char* attr_name, | |||
249 | * @return | 249 | * @return |
250 | */ | 250 | */ |
251 | void | 251 | void |
252 | GNUNET_IDENTITY_ATTRIBUTE_list_add (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *claim_list, | 252 | GNUNET_RECLAIM_ATTRIBUTE_list_add (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *claim_list, |
253 | const char* attr_name, | 253 | const char* attr_name, |
254 | uint32_t type, | 254 | uint32_t type, |
255 | const void* data, | 255 | const void* data, |
256 | size_t data_size) | 256 | size_t data_size) |
257 | { | 257 | { |
258 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 258 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
259 | le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); | 259 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
260 | le->claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name, | 260 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, |
261 | type, | 261 | type, |
262 | data, | 262 | data, |
263 | data_size); | 263 | data_size); |
@@ -267,20 +267,20 @@ GNUNET_IDENTITY_ATTRIBUTE_list_add (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList * | |||
267 | } | 267 | } |
268 | 268 | ||
269 | size_t | 269 | size_t |
270 | GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 270 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
271 | { | 271 | { |
272 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 272 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
273 | size_t len = 0; | 273 | size_t len = 0; |
274 | for (le = attrs->list_head; NULL != le; le = le->next) | 274 | for (le = attrs->list_head; NULL != le; le = le->next) |
275 | len += GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (le->claim); | 275 | len += GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim); |
276 | return len; | 276 | return len; |
277 | } | 277 | } |
278 | 278 | ||
279 | size_t | 279 | size_t |
280 | GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | 280 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
281 | char *result) | 281 | char *result) |
282 | { | 282 | { |
283 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 283 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
284 | size_t len; | 284 | size_t len; |
285 | size_t total_len; | 285 | size_t total_len; |
286 | char* write_ptr; | 286 | char* write_ptr; |
@@ -289,7 +289,7 @@ GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE | |||
289 | total_len = 0; | 289 | total_len = 0; |
290 | for (le = attrs->list_head; NULL != le; le = le->next) | 290 | for (le = attrs->list_head; NULL != le; le = le->next) |
291 | { | 291 | { |
292 | len = GNUNET_IDENTITY_ATTRIBUTE_serialize (le->claim, | 292 | len = GNUNET_RECLAIM_ATTRIBUTE_serialize (le->claim, |
293 | write_ptr); | 293 | write_ptr); |
294 | total_len += len; | 294 | total_len += len; |
295 | write_ptr += len; | 295 | write_ptr += len; |
@@ -297,49 +297,49 @@ GNUNET_IDENTITY_ATTRIBUTE_list_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE | |||
297 | return total_len; | 297 | return total_len; |
298 | } | 298 | } |
299 | 299 | ||
300 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList * | 300 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList * |
301 | GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (const char* data, | 301 | GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (const char* data, |
302 | size_t data_size) | 302 | size_t data_size) |
303 | { | 303 | { |
304 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs; | 304 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; |
305 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 305 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
306 | size_t attr_len; | 306 | size_t attr_len; |
307 | const char* read_ptr; | 307 | const char* read_ptr; |
308 | 308 | ||
309 | if (data_size < sizeof (struct Attribute)) | 309 | if (data_size < sizeof (struct Attribute)) |
310 | return NULL; | 310 | return NULL; |
311 | 311 | ||
312 | attrs = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); | 312 | attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
313 | read_ptr = data; | 313 | read_ptr = data; |
314 | while (((data + data_size) - read_ptr) >= sizeof (struct Attribute)) | 314 | while (((data + data_size) - read_ptr) >= sizeof (struct Attribute)) |
315 | { | 315 | { |
316 | 316 | ||
317 | le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); | 317 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
318 | le->claim = GNUNET_IDENTITY_ATTRIBUTE_deserialize (read_ptr, | 318 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (read_ptr, |
319 | data_size - (read_ptr - data)); | 319 | data_size - (read_ptr - data)); |
320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
321 | "Deserialized attribute %s\n", le->claim->name); | 321 | "Deserialized attribute %s\n", le->claim->name); |
322 | GNUNET_CONTAINER_DLL_insert (attrs->list_head, | 322 | GNUNET_CONTAINER_DLL_insert (attrs->list_head, |
323 | attrs->list_tail, | 323 | attrs->list_tail, |
324 | le); | 324 | le); |
325 | attr_len = GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (le->claim); | 325 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (le->claim); |
326 | read_ptr += attr_len; | 326 | read_ptr += attr_len; |
327 | } | 327 | } |
328 | return attrs; | 328 | return attrs; |
329 | } | 329 | } |
330 | 330 | ||
331 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList* | 331 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList* |
332 | GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 332 | GNUNET_RECLAIM_ATTRIBUTE_list_dup (const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
333 | { | 333 | { |
334 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 334 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
335 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *result_le; | 335 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *result_le; |
336 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *result; | 336 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *result; |
337 | 337 | ||
338 | result = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); | 338 | result = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
339 | for (le = attrs->list_head; NULL != le; le = le->next) | 339 | for (le = attrs->list_head; NULL != le; le = le->next) |
340 | { | 340 | { |
341 | result_le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); | 341 | result_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
342 | result_le->claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (le->claim->name, | 342 | result_le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (le->claim->name, |
343 | le->claim->type, | 343 | le->claim->type, |
344 | le->claim->data, | 344 | le->claim->data, |
345 | le->claim->data_size); | 345 | le->claim->data_size); |
@@ -352,10 +352,10 @@ GNUNET_IDENTITY_ATTRIBUTE_list_dup (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim | |||
352 | 352 | ||
353 | 353 | ||
354 | void | 354 | void |
355 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 355 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
356 | { | 356 | { |
357 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 357 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
358 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *tmp_le; | 358 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *tmp_le; |
359 | 359 | ||
360 | for (le = attrs->list_head; NULL != le;) | 360 | for (le = attrs->list_head; NULL != le;) |
361 | { | 361 | { |
@@ -369,7 +369,7 @@ GNUNET_IDENTITY_ATTRIBUTE_list_destroy (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimLi | |||
369 | } | 369 | } |
370 | 370 | ||
371 | size_t | 371 | size_t |
372 | GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) | 372 | GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
373 | { | 373 | { |
374 | return sizeof (struct Attribute) | 374 | return sizeof (struct Attribute) |
375 | + strlen (attr->name) | 375 | + strlen (attr->name) |
@@ -377,7 +377,7 @@ GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (const struct GNUNET_IDENTITY_ATTRI | |||
377 | } | 377 | } |
378 | 378 | ||
379 | size_t | 379 | size_t |
380 | GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr, | 380 | GNUNET_RECLAIM_ATTRIBUTE_serialize (const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
381 | char *result) | 381 | char *result) |
382 | { | 382 | { |
383 | size_t data_len_ser; | 383 | size_t data_len_ser; |
@@ -403,11 +403,11 @@ GNUNET_IDENTITY_ATTRIBUTE_serialize (const struct GNUNET_IDENTITY_ATTRIBUTE_Clai | |||
403 | return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size; | 403 | return sizeof (struct Attribute) + strlen (attr->name) + attr->data_size; |
404 | } | 404 | } |
405 | 405 | ||
406 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim * | 406 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim * |
407 | GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data, | 407 | GNUNET_RECLAIM_ATTRIBUTE_deserialize (const char* data, |
408 | size_t data_size) | 408 | size_t data_size) |
409 | { | 409 | { |
410 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr; | 410 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; |
411 | struct Attribute *attr_ser; | 411 | struct Attribute *attr_ser; |
412 | size_t data_len; | 412 | size_t data_len; |
413 | size_t name_len; | 413 | size_t name_len; |
@@ -419,7 +419,7 @@ GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data, | |||
419 | attr_ser = (struct Attribute*)data; | 419 | attr_ser = (struct Attribute*)data; |
420 | data_len = ntohs (attr_ser->data_size); | 420 | data_len = ntohs (attr_ser->data_size); |
421 | name_len = ntohs (attr_ser->name_len); | 421 | name_len = ntohs (attr_ser->name_len); |
422 | attr = GNUNET_malloc (sizeof (struct GNUNET_IDENTITY_ATTRIBUTE_Claim) | 422 | attr = GNUNET_malloc (sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim) |
423 | + data_len + name_len + 1); | 423 | + data_len + name_len + 1); |
424 | attr->type = ntohs (attr_ser->attribute_type); | 424 | attr->type = ntohs (attr_ser->attribute_type); |
425 | attr->version = ntohl (attr_ser->attribute_version); | 425 | attr->version = ntohl (attr_ser->attribute_version); |
@@ -441,4 +441,4 @@ GNUNET_IDENTITY_ATTRIBUTE_deserialize (const char* data, | |||
441 | 441 | ||
442 | } | 442 | } |
443 | 443 | ||
444 | /* end of identity_attribute.c */ | 444 | /* end of reclaim_attribute.c */ |
diff --git a/src/identity-attribute/identity_attribute.h b/src/reclaim-attribute/reclaim_attribute.h index 2346dcde1..746d32980 100644 --- a/src/identity-attribute/identity_attribute.h +++ b/src/reclaim-attribute/reclaim_attribute.h | |||
@@ -17,14 +17,14 @@ | |||
17 | */ | 17 | */ |
18 | /** | 18 | /** |
19 | * @author Martin Schanzenbach | 19 | * @author Martin Schanzenbach |
20 | * @file identity-attribute/identity_attribute.h | 20 | * @file reclaim-attribute/reclaim_attribute.h |
21 | * @brief GNUnet Identity attributes | 21 | * @brief GNUnet reclaim identity attributes |
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | #ifndef IDENTITY_ATTRIBUTE_H | 24 | #ifndef RECLAIM_ATTRIBUTE_H |
25 | #define IDENTITY_ATTRIBUTE_H | 25 | #define RECLAIM_ATTRIBUTE_H |
26 | 26 | ||
27 | #include "gnunet_identity_provider_service.h" | 27 | #include "gnunet_reclaim_service.h" |
28 | 28 | ||
29 | struct Attribute | 29 | struct Attribute |
30 | { | 30 | { |
diff --git a/src/identity-provider/.gitignore b/src/reclaim/.gitignore index ef77fccdc..ef77fccdc 100644 --- a/src/identity-provider/.gitignore +++ b/src/reclaim/.gitignore | |||
diff --git a/src/identity-provider/Makefile.am b/src/reclaim/Makefile.am index 2eb699542..2ee43d21a 100644 --- a/src/identity-provider/Makefile.am +++ b/src/reclaim/Makefile.am | |||
@@ -13,12 +13,12 @@ if USE_COVERAGE | |||
13 | endif | 13 | endif |
14 | 14 | ||
15 | if HAVE_SQLITE | 15 | if HAVE_SQLITE |
16 | SQLITE_PLUGIN = libgnunet_plugin_identity_provider_sqlite.la | 16 | SQLITE_PLUGIN = libgnunet_plugin_reclaim_sqlite.la |
17 | endif | 17 | endif |
18 | 18 | ||
19 | EXTRA_DIST = \ | 19 | EXTRA_DIST = \ |
20 | test_idp_defaults.conf \ | 20 | test_reclaim_defaults.conf \ |
21 | test_idp.conf \ | 21 | test_reclaim.conf \ |
22 | $(check_SCRIPTS) | 22 | $(check_SCRIPTS) |
23 | 23 | ||
24 | pkgcfgdir= $(pkgdatadir)/config.d/ | 24 | pkgcfgdir= $(pkgdatadir)/config.d/ |
@@ -26,46 +26,46 @@ pkgcfgdir= $(pkgdatadir)/config.d/ | |||
26 | libexecdir= $(pkglibdir)/libexec/ | 26 | libexecdir= $(pkglibdir)/libexec/ |
27 | 27 | ||
28 | pkgcfg_DATA = \ | 28 | pkgcfg_DATA = \ |
29 | identity-provider.conf | 29 | reclaim.conf |
30 | 30 | ||
31 | lib_LTLIBRARIES = \ | 31 | lib_LTLIBRARIES = \ |
32 | libgnunetidentityprovider.la | 32 | libgnunetreclaim.la |
33 | plugin_LTLIBRARIES = \ | 33 | plugin_LTLIBRARIES = \ |
34 | libgnunet_plugin_rest_identity_provider.la \ | 34 | libgnunet_plugin_rest_reclaim.la \ |
35 | libgnunet_plugin_rest_openid_connect.la \ | 35 | libgnunet_plugin_rest_openid_connect.la \ |
36 | libgnunet_plugin_gnsrecord_identity_provider.la \ | 36 | libgnunet_plugin_gnsrecord_reclaim.la \ |
37 | $(SQLITE_PLUGIN) | 37 | $(SQLITE_PLUGIN) |
38 | 38 | ||
39 | bin_PROGRAMS = \ | 39 | bin_PROGRAMS = \ |
40 | gnunet-idp | 40 | gnunet-reclaim |
41 | 41 | ||
42 | libexec_PROGRAMS = \ | 42 | libexec_PROGRAMS = \ |
43 | gnunet-service-identity-provider | 43 | gnunet-service-reclaim |
44 | 44 | ||
45 | libgnunet_plugin_gnsrecord_identity_provider_la_SOURCES = \ | 45 | libgnunet_plugin_gnsrecord_reclaim_la_SOURCES = \ |
46 | plugin_gnsrecord_identity_provider.c | 46 | plugin_gnsrecord_reclaim.c |
47 | libgnunet_plugin_gnsrecord_identity_provider_la_LIBADD = \ | 47 | libgnunet_plugin_gnsrecord_reclaim_la_LIBADD = \ |
48 | $(top_builddir)/src/util/libgnunetutil.la \ | 48 | $(top_builddir)/src/util/libgnunetutil.la \ |
49 | $(LTLIBINTL) | 49 | $(LTLIBINTL) |
50 | libgnunet_plugin_gnsrecord_identity_provider_la_LDFLAGS = \ | 50 | libgnunet_plugin_gnsrecord_reclaim_la_LDFLAGS = \ |
51 | $(GN_PLUGIN_LDFLAGS) | 51 | $(GN_PLUGIN_LDFLAGS) |
52 | 52 | ||
53 | libgnunet_plugin_identity_provider_sqlite_la_SOURCES = \ | 53 | libgnunet_plugin_reclaim_sqlite_la_SOURCES = \ |
54 | plugin_identity_provider_sqlite.c | 54 | plugin_reclaim_sqlite.c |
55 | libgnunet_plugin_identity_provider_sqlite_la_LIBADD = \ | 55 | libgnunet_plugin_reclaim_sqlite_la_LIBADD = \ |
56 | libgnunetidentityprovider.la \ | 56 | libgnunetreclaim.la \ |
57 | $(top_builddir)/src/sq/libgnunetsq.la \ | 57 | $(top_builddir)/src/sq/libgnunetsq.la \ |
58 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 58 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
59 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \ | 59 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) -lsqlite3 \ |
60 | $(LTLIBINTL) | 60 | $(LTLIBINTL) |
61 | libgnunet_plugin_identity_provider_sqlite_la_LDFLAGS = \ | 61 | libgnunet_plugin_reclaim_sqlite_la_LDFLAGS = \ |
62 | $(GN_PLUGIN_LDFLAGS) | 62 | $(GN_PLUGIN_LDFLAGS) |
63 | 63 | ||
64 | 64 | ||
65 | 65 | ||
66 | gnunet_service_identity_provider_SOURCES = \ | 66 | gnunet_service_reclaim_SOURCES = \ |
67 | gnunet-service-identity-provider.c | 67 | gnunet-service-reclaim.c |
68 | gnunet_service_identity_provider_LDADD = \ | 68 | gnunet_service_reclaim_LDADD = \ |
69 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | 69 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ |
70 | $(top_builddir)/src/util/libgnunetutil.la \ | 70 | $(top_builddir)/src/util/libgnunetutil.la \ |
71 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | 71 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ |
@@ -73,66 +73,67 @@ gnunet_service_identity_provider_LDADD = \ | |||
73 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 73 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
74 | $(top_builddir)/src/abe/libgnunetabe.la \ | 74 | $(top_builddir)/src/abe/libgnunetabe.la \ |
75 | $(top_builddir)/src/credential/libgnunetcredential.la \ | 75 | $(top_builddir)/src/credential/libgnunetcredential.la \ |
76 | $(top_builddir)/src/identity-attribute/libgnunetidentityattribute.la \ | 76 | $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \ |
77 | libgnunetidentityprovider.la \ | 77 | libgnunetreclaim.la \ |
78 | $(top_builddir)/src/gns/libgnunetgns.la \ | 78 | $(top_builddir)/src/gns/libgnunetgns.la \ |
79 | $(GN_LIBINTL) | 79 | $(GN_LIBINTL) |
80 | 80 | ||
81 | libgnunetidentityprovider_la_SOURCES = \ | 81 | libgnunetreclaim_la_SOURCES = \ |
82 | identity_provider_api.c \ | 82 | reclaim_api.c \ |
83 | identity_provider.h | 83 | reclaim.h |
84 | libgnunetidentityprovider_la_LIBADD = \ | 84 | libgnunetreclaim_la_LIBADD = \ |
85 | $(top_builddir)/src/util/libgnunetutil.la \ | 85 | $(top_builddir)/src/util/libgnunetutil.la \ |
86 | $(GN_LIBINTL) $(XLIB) | 86 | $(GN_LIBINTL) $(XLIB) |
87 | libgnunetidentityprovider_la_LDFLAGS = \ | 87 | libgnunetreclaim_la_LDFLAGS = \ |
88 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ | 88 | $(GN_LIB_LDFLAGS) $(WINFLAGS) \ |
89 | -version-info 0:0:0 | 89 | -version-info 0:0:0 |
90 | 90 | ||
91 | libgnunet_plugin_rest_identity_provider_la_SOURCES = \ | 91 | libgnunet_plugin_rest_reclaim_la_SOURCES = \ |
92 | plugin_rest_identity_provider.c \ | 92 | plugin_rest_reclaim.c |
93 | jwt.c | 93 | libgnunet_plugin_rest_reclaim_la_LIBADD = \ |
94 | libgnunet_plugin_rest_identity_provider_la_LIBADD = \ | ||
95 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 94 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
96 | libgnunetidentityprovider.la \ | 95 | libgnunetreclaim.la \ |
97 | $(top_builddir)/src/rest/libgnunetrest.la \ | 96 | $(top_builddir)/src/rest/libgnunetrest.la \ |
98 | $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \ | 97 | $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \ |
99 | $(top_builddir)/src/identity-attribute/libgnunetidentityattribute.la \ | 98 | $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \ |
100 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | 99 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ |
101 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | 100 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ |
102 | $(LTLIBINTL) -ljansson -lmicrohttpd | 101 | $(LTLIBINTL) -ljansson -lmicrohttpd |
103 | libgnunet_plugin_rest_identity_provider_la_LDFLAGS = \ | 102 | libgnunet_plugin_rest_reclaim_la_LDFLAGS = \ |
104 | $(GN_PLUGIN_LDFLAGS) | 103 | $(GN_PLUGIN_LDFLAGS) |
105 | 104 | ||
106 | libgnunet_plugin_rest_openid_connect_la_SOURCES = \ | 105 | libgnunet_plugin_rest_openid_connect_la_SOURCES = \ |
107 | plugin_rest_openid_connect.c \ | 106 | plugin_rest_openid_connect.c \ |
108 | jwt.c | 107 | oidc_helper.c |
109 | libgnunet_plugin_rest_openid_connect_la_LIBADD = \ | 108 | libgnunet_plugin_rest_openid_connect_la_LIBADD = \ |
110 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 109 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
111 | libgnunetidentityprovider.la \ | 110 | libgnunetreclaim.la \ |
112 | $(top_builddir)/src/rest/libgnunetrest.la \ | 111 | $(top_builddir)/src/rest/libgnunetrest.la \ |
113 | $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \ | 112 | $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \ |
114 | $(top_builddir)/src/identity-attribute/libgnunetidentityattribute.la \ | 113 | $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \ |
115 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | 114 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ |
115 | $(top_builddir)/src/gns/libgnunetgns.la \ | ||
116 | $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \ | ||
116 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | 117 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ |
117 | $(LTLIBINTL) -ljansson -lmicrohttpd | 118 | $(LTLIBINTL) -ljansson -lmicrohttpd |
118 | libgnunet_plugin_rest_openid_connect_la_LDFLAGS = \ | 119 | libgnunet_plugin_rest_openid_connect_la_LDFLAGS = \ |
119 | $(GN_PLUGIN_LDFLAGS) | 120 | $(GN_PLUGIN_LDFLAGS) |
120 | 121 | ||
121 | gnunet_idp_SOURCES = \ | 122 | gnunet_reclaim_SOURCES = \ |
122 | gnunet-idp.c | 123 | gnunet-reclaim.c |
123 | gnunet_idp_LDADD = \ | 124 | gnunet_reclaim_LDADD = \ |
124 | $(top_builddir)/src/util/libgnunetutil.la \ | 125 | $(top_builddir)/src/util/libgnunetutil.la \ |
125 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ | 126 | $(top_builddir)/src/namestore/libgnunetnamestore.la \ |
126 | libgnunetidentityprovider.la \ | 127 | libgnunetreclaim.la \ |
127 | $(top_builddir)/src/identity/libgnunetidentity.la \ | 128 | $(top_builddir)/src/identity/libgnunetidentity.la \ |
128 | $(top_builddir)/src/identity-attribute/libgnunetidentityattribute.la \ | 129 | $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \ |
129 | $(GN_LIBINTL) | 130 | $(GN_LIBINTL) |
130 | 131 | ||
131 | check_SCRIPTS = \ | 132 | check_SCRIPTS = \ |
132 | test_idp_attribute.sh \ | 133 | test_reclaim_attribute.sh \ |
133 | test_idp_issue.sh \ | 134 | test_reclaim_issue.sh \ |
134 | test_idp_consume.sh \ | 135 | test_reclaim_consume.sh \ |
135 | test_idp_revoke.sh | 136 | test_reclaim_revoke.sh |
136 | 137 | ||
137 | if ENABLE_TEST_RUN | 138 | if ENABLE_TEST_RUN |
138 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; | 139 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME; |
diff --git a/src/identity-provider/gnunet-idp.c b/src/reclaim/gnunet-reclaim.c index 79e4f8d27..9947eac6d 100644 --- a/src/identity-provider/gnunet-idp.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -17,7 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | /** | 18 | /** |
19 | * @author Martin Schanzenbach | 19 | * @author Martin Schanzenbach |
20 | * @file src/identity-provider/gnunet-idp.c | 20 | * @file src/reclaim/gnunet-reclaim.c |
21 | * @brief Identity Provider utility | 21 | * @brief Identity Provider utility |
22 | * | 22 | * |
23 | */ | 23 | */ |
@@ -25,7 +25,7 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
27 | #include "gnunet_namestore_service.h" | 27 | #include "gnunet_namestore_service.h" |
28 | #include "gnunet_identity_provider_service.h" | 28 | #include "gnunet_reclaim_service.h" |
29 | #include "gnunet_identity_service.h" | 29 | #include "gnunet_identity_service.h" |
30 | #include "gnunet_signatures.h" | 30 | #include "gnunet_signatures.h" |
31 | 31 | ||
@@ -85,19 +85,19 @@ static char* ego_name; | |||
85 | static struct GNUNET_IDENTITY_Handle *identity_handle; | 85 | static struct GNUNET_IDENTITY_Handle *identity_handle; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * IdP handle | 88 | * reclaim handle |
89 | */ | 89 | */ |
90 | static struct GNUNET_IDENTITY_PROVIDER_Handle *idp_handle; | 90 | static struct GNUNET_RECLAIM_Handle *reclaim_handle; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * IdP operation | 93 | * reclaim operation |
94 | */ | 94 | */ |
95 | static struct GNUNET_IDENTITY_PROVIDER_Operation *idp_op; | 95 | static struct GNUNET_RECLAIM_Operation *reclaim_op; |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Attribute iterator | 98 | * Attribute iterator |
99 | */ | 99 | */ |
100 | static struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *attr_iterator; | 100 | static struct GNUNET_RECLAIM_AttributeIterator *attr_iterator; |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Master ABE key | 103 | * Master ABE key |
@@ -117,12 +117,12 @@ static struct GNUNET_CRYPTO_EcdsaPublicKey rp_key; | |||
117 | /** | 117 | /** |
118 | * Ticket to consume | 118 | * Ticket to consume |
119 | */ | 119 | */ |
120 | static struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 120 | static struct GNUNET_RECLAIM_Ticket ticket; |
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Attribute list | 123 | * Attribute list |
124 | */ | 124 | */ |
125 | static struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attr_list; | 125 | static struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list; |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * Attribute expiration interval | 128 | * Attribute expiration interval |
@@ -139,12 +139,12 @@ do_cleanup(void *cls) | |||
139 | { | 139 | { |
140 | if (NULL != timeout) | 140 | if (NULL != timeout) |
141 | GNUNET_SCHEDULER_cancel (timeout); | 141 | GNUNET_SCHEDULER_cancel (timeout); |
142 | if (NULL != idp_op) | 142 | if (NULL != reclaim_op) |
143 | GNUNET_IDENTITY_PROVIDER_cancel (idp_op); | 143 | GNUNET_RECLAIM_cancel (reclaim_op); |
144 | if (NULL != attr_iterator) | 144 | if (NULL != attr_iterator) |
145 | GNUNET_IDENTITY_PROVIDER_get_attributes_stop (attr_iterator); | 145 | GNUNET_RECLAIM_get_attributes_stop (attr_iterator); |
146 | if (NULL != idp_handle) | 146 | if (NULL != reclaim_handle) |
147 | GNUNET_IDENTITY_PROVIDER_disconnect (idp_handle); | 147 | GNUNET_RECLAIM_disconnect (reclaim_handle); |
148 | if (NULL != identity_handle) | 148 | if (NULL != identity_handle) |
149 | GNUNET_IDENTITY_disconnect (identity_handle); | 149 | GNUNET_IDENTITY_disconnect (identity_handle); |
150 | if (NULL != abe_key) | 150 | if (NULL != abe_key) |
@@ -155,13 +155,13 @@ do_cleanup(void *cls) | |||
155 | 155 | ||
156 | static void | 156 | static void |
157 | ticket_issue_cb (void* cls, | 157 | ticket_issue_cb (void* cls, |
158 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket) | 158 | const struct GNUNET_RECLAIM_Ticket *ticket) |
159 | { | 159 | { |
160 | char* ticket_str; | 160 | char* ticket_str; |
161 | idp_op = NULL; | 161 | reclaim_op = NULL; |
162 | if (NULL != ticket) { | 162 | if (NULL != ticket) { |
163 | ticket_str = GNUNET_STRINGS_data_to_string_alloc (ticket, | 163 | ticket_str = GNUNET_STRINGS_data_to_string_alloc (ticket, |
164 | sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket)); | 164 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
165 | printf("%s\n", | 165 | printf("%s\n", |
166 | ticket_str); | 166 | ticket_str); |
167 | GNUNET_free (ticket_str); | 167 | GNUNET_free (ticket_str); |
@@ -174,7 +174,7 @@ store_attr_cont (void *cls, | |||
174 | int32_t success, | 174 | int32_t success, |
175 | const char*emsg) | 175 | const char*emsg) |
176 | { | 176 | { |
177 | idp_op = NULL; | 177 | reclaim_op = NULL; |
178 | if (GNUNET_SYSERR == success) { | 178 | if (GNUNET_SYSERR == success) { |
179 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 179 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
180 | "%s\n", emsg); | 180 | "%s\n", emsg); |
@@ -185,12 +185,12 @@ store_attr_cont (void *cls, | |||
185 | static void | 185 | static void |
186 | process_attrs (void *cls, | 186 | process_attrs (void *cls, |
187 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 187 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
188 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) | 188 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
189 | { | 189 | { |
190 | char *value_str; | 190 | char *value_str; |
191 | if (NULL == identity) | 191 | if (NULL == identity) |
192 | { | 192 | { |
193 | idp_op = NULL; | 193 | reclaim_op = NULL; |
194 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 194 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
195 | return; | 195 | return; |
196 | } | 196 | } |
@@ -199,9 +199,9 @@ process_attrs (void *cls, | |||
199 | ret = 1; | 199 | ret = 1; |
200 | return; | 200 | return; |
201 | } | 201 | } |
202 | value_str = GNUNET_IDENTITY_ATTRIBUTE_value_to_string (attr->type, | 202 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, |
203 | attr->data, | 203 | attr->data, |
204 | attr->data_size); | 204 | attr->data_size); |
205 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 205 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
206 | "%s: %s\n", attr->name, value_str); | 206 | "%s: %s\n", attr->name, value_str); |
207 | } | 207 | } |
@@ -229,7 +229,7 @@ timeout_task (void *cls) | |||
229 | static void | 229 | static void |
230 | process_rvk (void *cls, int success, const char* msg) | 230 | process_rvk (void *cls, int success, const char* msg) |
231 | { | 231 | { |
232 | idp_op = NULL; | 232 | reclaim_op = NULL; |
233 | if (GNUNET_OK != success) | 233 | if (GNUNET_OK != success) |
234 | { | 234 | { |
235 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 235 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
@@ -242,7 +242,7 @@ process_rvk (void *cls, int success, const char* msg) | |||
242 | static void | 242 | static void |
243 | iter_finished (void *cls) | 243 | iter_finished (void *cls) |
244 | { | 244 | { |
245 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim; | 245 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
246 | char *data; | 246 | char *data; |
247 | size_t data_size; | 247 | size_t data_size; |
248 | int type; | 248 | int type; |
@@ -256,21 +256,21 @@ iter_finished (void *cls) | |||
256 | 256 | ||
257 | if (issue_attrs) | 257 | if (issue_attrs) |
258 | { | 258 | { |
259 | idp_op = GNUNET_IDENTITY_PROVIDER_ticket_issue (idp_handle, | 259 | reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle, |
260 | pkey, | 260 | pkey, |
261 | &rp_key, | 261 | &rp_key, |
262 | attr_list, | 262 | attr_list, |
263 | &ticket_issue_cb, | 263 | &ticket_issue_cb, |
264 | NULL); | 264 | NULL); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | if (consume_ticket) | 267 | if (consume_ticket) |
268 | { | 268 | { |
269 | idp_op = GNUNET_IDENTITY_PROVIDER_ticket_consume (idp_handle, | 269 | reclaim_op = GNUNET_RECLAIM_ticket_consume (reclaim_handle, |
270 | pkey, | 270 | pkey, |
271 | &ticket, | 271 | &ticket, |
272 | &process_attrs, | 272 | &process_attrs, |
273 | NULL); | 273 | NULL); |
274 | timeout = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), | 274 | timeout = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), |
275 | &timeout_task, | 275 | &timeout_task, |
276 | NULL); | 276 | NULL); |
@@ -278,34 +278,34 @@ iter_finished (void *cls) | |||
278 | } | 278 | } |
279 | if (revoke_ticket) | 279 | if (revoke_ticket) |
280 | { | 280 | { |
281 | idp_op = GNUNET_IDENTITY_PROVIDER_ticket_revoke (idp_handle, | 281 | reclaim_op = GNUNET_RECLAIM_ticket_revoke (reclaim_handle, |
282 | pkey, | 282 | pkey, |
283 | &ticket, | 283 | &ticket, |
284 | &process_rvk, | 284 | &process_rvk, |
285 | NULL); | 285 | NULL); |
286 | return; | 286 | return; |
287 | } | 287 | } |
288 | if (attr_name) | 288 | if (attr_name) |
289 | { | 289 | { |
290 | if (NULL == type_str) | 290 | if (NULL == type_str) |
291 | type = GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING; | 291 | type = GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING; |
292 | else | 292 | else |
293 | type = GNUNET_IDENTITY_ATTRIBUTE_typename_to_number (type_str); | 293 | type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str); |
294 | 294 | ||
295 | GNUNET_assert (GNUNET_SYSERR != GNUNET_IDENTITY_ATTRIBUTE_string_to_value (type, | 295 | GNUNET_assert (GNUNET_SYSERR != GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type, |
296 | attr_value, | 296 | attr_value, |
297 | (void**)&data, | 297 | (void**)&data, |
298 | &data_size)); | 298 | &data_size)); |
299 | claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr_name, | 299 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, |
300 | type, | 300 | type, |
301 | data, | 301 | data, |
302 | data_size); | 302 | data_size); |
303 | idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (idp_handle, | 303 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, |
304 | pkey, | 304 | pkey, |
305 | claim, | 305 | claim, |
306 | &exp_interval, | 306 | &exp_interval, |
307 | &store_attr_cont, | 307 | &store_attr_cont, |
308 | NULL); | 308 | NULL); |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 311 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
@@ -314,9 +314,9 @@ iter_finished (void *cls) | |||
314 | static void | 314 | static void |
315 | iter_cb (void *cls, | 315 | iter_cb (void *cls, |
316 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 316 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
317 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) | 317 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
318 | { | 318 | { |
319 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 319 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
320 | char *attrs_tmp; | 320 | char *attrs_tmp; |
321 | char *attr_str; | 321 | char *attr_str; |
322 | 322 | ||
@@ -329,11 +329,11 @@ iter_cb (void *cls, | |||
329 | attr_str = strtok (NULL, ","); | 329 | attr_str = strtok (NULL, ","); |
330 | continue; | 330 | continue; |
331 | } | 331 | } |
332 | le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); | 332 | le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
333 | le->claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr->name, | 333 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, |
334 | attr->type, | 334 | attr->type, |
335 | attr->data, | 335 | attr->data, |
336 | attr->data_size); | 336 | attr->data_size); |
337 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, | 337 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, |
338 | attr_list->list_tail, | 338 | attr_list->list_tail, |
339 | le); | 339 | le); |
@@ -344,7 +344,7 @@ iter_cb (void *cls, | |||
344 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 344 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, |
345 | "%s: %s\n", attr->name, (char*)attr->data); | 345 | "%s: %s\n", attr->name, (char*)attr->data); |
346 | } | 346 | } |
347 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (attr_iterator); | 347 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); |
348 | } | 348 | } |
349 | 349 | ||
350 | static void | 350 | static void |
@@ -365,24 +365,24 @@ ego_iter_finished (void *cls) | |||
365 | GNUNET_STRINGS_string_to_data (consume_ticket, | 365 | GNUNET_STRINGS_string_to_data (consume_ticket, |
366 | strlen (consume_ticket), | 366 | strlen (consume_ticket), |
367 | &ticket, | 367 | &ticket, |
368 | sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket)); | 368 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
369 | if (NULL != revoke_ticket) | 369 | if (NULL != revoke_ticket) |
370 | GNUNET_STRINGS_string_to_data (revoke_ticket, | 370 | GNUNET_STRINGS_string_to_data (revoke_ticket, |
371 | strlen (revoke_ticket), | 371 | strlen (revoke_ticket), |
372 | &ticket, | 372 | &ticket, |
373 | sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket)); | 373 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
374 | 374 | ||
375 | 375 | ||
376 | attr_list = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); | 376 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
377 | 377 | ||
378 | attr_iterator = GNUNET_IDENTITY_PROVIDER_get_attributes_start (idp_handle, | 378 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, |
379 | pkey, | 379 | pkey, |
380 | &iter_error, | 380 | &iter_error, |
381 | NULL, | 381 | NULL, |
382 | &iter_cb, | 382 | &iter_cb, |
383 | NULL, | 383 | NULL, |
384 | &iter_finished, | 384 | &iter_finished, |
385 | NULL); | 385 | NULL); |
386 | 386 | ||
387 | 387 | ||
388 | } | 388 | } |
@@ -439,7 +439,7 @@ run (void *cls, | |||
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | 441 | ||
442 | idp_handle = GNUNET_IDENTITY_PROVIDER_connect (c); | 442 | reclaim_handle = GNUNET_RECLAIM_connect (c); |
443 | //Get Ego | 443 | //Get Ego |
444 | identity_handle = GNUNET_IDENTITY_connect (c, | 444 | identity_handle = GNUNET_IDENTITY_connect (c, |
445 | &ego_cb, | 445 | &ego_cb, |
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/reclaim/gnunet-service-reclaim.c index c53e72477..bf8780a92 100644 --- a/src/identity-provider/gnunet-service-identity-provider.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -17,8 +17,8 @@ | |||
17 | */ | 17 | */ |
18 | /** | 18 | /** |
19 | * @author Martin Schanzenbach | 19 | * @author Martin Schanzenbach |
20 | * @file src/identity-provider/gnunet-service-identity-provider.c | 20 | * @file src/reclaim/gnunet-service-reclaim.c |
21 | * @brief Identity Token Service | 21 | * @brief reclaim Service |
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
@@ -32,10 +32,10 @@ | |||
32 | #include "gnunet_credential_service.h" | 32 | #include "gnunet_credential_service.h" |
33 | #include "gnunet_statistics_service.h" | 33 | #include "gnunet_statistics_service.h" |
34 | #include "gnunet_gns_service.h" | 34 | #include "gnunet_gns_service.h" |
35 | #include "gnunet_identity_provider_plugin.h" | 35 | #include "gnunet_reclaim_plugin.h" |
36 | #include "gnunet_identity_attribute_lib.h" | 36 | #include "gnunet_reclaim_attribute_lib.h" |
37 | #include "gnunet_signatures.h" | 37 | #include "gnunet_signatures.h" |
38 | #include "identity_provider.h" | 38 | #include "reclaim.h" |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * First pass state | 41 | * First pass state |
@@ -65,7 +65,7 @@ static struct GNUNET_IDENTITY_Handle *identity_handle; | |||
65 | /** | 65 | /** |
66 | * Database handle | 66 | * Database handle |
67 | */ | 67 | */ |
68 | static struct GNUNET_IDENTITY_PROVIDER_PluginFunctions *TKT_database; | 68 | static struct GNUNET_RECLAIM_PluginFunctions *TKT_database; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Name of DB plugin | 71 | * Name of DB plugin |
@@ -396,7 +396,7 @@ struct AttributeStoreHandle | |||
396 | /** | 396 | /** |
397 | * The attribute to store | 397 | * The attribute to store |
398 | */ | 398 | */ |
399 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim *claim; | 399 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; |
400 | 400 | ||
401 | /** | 401 | /** |
402 | * The attribute expiration interval | 402 | * The attribute expiration interval |
@@ -433,7 +433,7 @@ struct ConsumeTicketHandle | |||
433 | /** | 433 | /** |
434 | * Ticket | 434 | * Ticket |
435 | */ | 435 | */ |
436 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 436 | struct GNUNET_RECLAIM_Ticket ticket; |
437 | 437 | ||
438 | /** | 438 | /** |
439 | * LookupRequest | 439 | * LookupRequest |
@@ -473,7 +473,7 @@ struct ConsumeTicketHandle | |||
473 | /** | 473 | /** |
474 | * Attributes | 474 | * Attributes |
475 | */ | 475 | */ |
476 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs; | 476 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; |
477 | 477 | ||
478 | /** | 478 | /** |
479 | * Lookup time | 479 | * Lookup time |
@@ -535,12 +535,12 @@ struct TicketRevocationHandle | |||
535 | /** | 535 | /** |
536 | * Attributes to reissue | 536 | * Attributes to reissue |
537 | */ | 537 | */ |
538 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs; | 538 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; |
539 | 539 | ||
540 | /** | 540 | /** |
541 | * Attributes to revoke | 541 | * Attributes to revoke |
542 | */ | 542 | */ |
543 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *rvk_attrs; | 543 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *rvk_attrs; |
544 | 544 | ||
545 | /** | 545 | /** |
546 | * Issuer Key | 546 | * Issuer Key |
@@ -550,7 +550,7 @@ struct TicketRevocationHandle | |||
550 | /** | 550 | /** |
551 | * Ticket to issue | 551 | * Ticket to issue |
552 | */ | 552 | */ |
553 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 553 | struct GNUNET_RECLAIM_Ticket ticket; |
554 | 554 | ||
555 | /** | 555 | /** |
556 | * QueueEntry | 556 | * QueueEntry |
@@ -603,7 +603,7 @@ struct TicketIssueHandle | |||
603 | /** | 603 | /** |
604 | * Attributes to issue | 604 | * Attributes to issue |
605 | */ | 605 | */ |
606 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs; | 606 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; |
607 | 607 | ||
608 | /** | 608 | /** |
609 | * Issuer Key | 609 | * Issuer Key |
@@ -613,7 +613,7 @@ struct TicketIssueHandle | |||
613 | /** | 613 | /** |
614 | * Ticket to issue | 614 | * Ticket to issue |
615 | */ | 615 | */ |
616 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 616 | struct GNUNET_RECLAIM_Ticket ticket; |
617 | 617 | ||
618 | /** | 618 | /** |
619 | * QueueEntry | 619 | * QueueEntry |
@@ -861,7 +861,7 @@ static void | |||
861 | cleanup_ticket_issue_handle (struct TicketIssueHandle *handle) | 861 | cleanup_ticket_issue_handle (struct TicketIssueHandle *handle) |
862 | { | 862 | { |
863 | if (NULL != handle->attrs) | 863 | if (NULL != handle->attrs) |
864 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (handle->attrs); | 864 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (handle->attrs); |
865 | if (NULL != handle->ns_qe) | 865 | if (NULL != handle->ns_qe) |
866 | GNUNET_NAMESTORE_cancel (handle->ns_qe); | 866 | GNUNET_NAMESTORE_cancel (handle->ns_qe); |
867 | GNUNET_free (handle); | 867 | GNUNET_free (handle); |
@@ -871,12 +871,12 @@ cleanup_ticket_issue_handle (struct TicketIssueHandle *handle) | |||
871 | static void | 871 | static void |
872 | send_ticket_result (struct IdpClient *client, | 872 | send_ticket_result (struct IdpClient *client, |
873 | uint32_t r_id, | 873 | uint32_t r_id, |
874 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 874 | const struct GNUNET_RECLAIM_Ticket *ticket, |
875 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 875 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
876 | { | 876 | { |
877 | struct TicketResultMessage *irm; | 877 | struct TicketResultMessage *irm; |
878 | struct GNUNET_MQ_Envelope *env; | 878 | struct GNUNET_MQ_Envelope *env; |
879 | struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket_buf; | 879 | struct GNUNET_RECLAIM_Ticket *ticket_buf; |
880 | 880 | ||
881 | /* store ticket in DB */ | 881 | /* store ticket in DB */ |
882 | if (GNUNET_OK != TKT_database->store_ticket (TKT_database->cls, | 882 | if (GNUNET_OK != TKT_database->store_ticket (TKT_database->cls, |
@@ -889,9 +889,9 @@ send_ticket_result (struct IdpClient *client, | |||
889 | } | 889 | } |
890 | 890 | ||
891 | env = GNUNET_MQ_msg_extra (irm, | 891 | env = GNUNET_MQ_msg_extra (irm, |
892 | sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket), | 892 | sizeof (struct GNUNET_RECLAIM_Ticket), |
893 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT); | 893 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); |
894 | ticket_buf = (struct GNUNET_IDENTITY_PROVIDER_Ticket *)&irm[1]; | 894 | ticket_buf = (struct GNUNET_RECLAIM_Ticket *)&irm[1]; |
895 | *ticket_buf = *ticket; | 895 | *ticket_buf = *ticket; |
896 | irm->id = htonl (r_id); | 896 | irm->id = htonl (r_id); |
897 | GNUNET_MQ_send (client->mq, | 897 | GNUNET_MQ_send (client->mq, |
@@ -927,14 +927,14 @@ store_ticket_issue_cont (void *cls, | |||
927 | 927 | ||
928 | 928 | ||
929 | int | 929 | int |
930 | serialize_abe_keyinfo2 (const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 930 | serialize_abe_keyinfo2 (const struct GNUNET_RECLAIM_Ticket *ticket, |
931 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | 931 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
932 | const struct GNUNET_ABE_AbeKey *rp_key, | 932 | const struct GNUNET_ABE_AbeKey *rp_key, |
933 | struct GNUNET_CRYPTO_EcdhePrivateKey **ecdh_privkey, | 933 | struct GNUNET_CRYPTO_EcdhePrivateKey **ecdh_privkey, |
934 | char **result) | 934 | char **result) |
935 | { | 935 | { |
936 | struct GNUNET_CRYPTO_EcdhePublicKey ecdh_pubkey; | 936 | struct GNUNET_CRYPTO_EcdhePublicKey ecdh_pubkey; |
937 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 937 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
938 | char *enc_keyinfo; | 938 | char *enc_keyinfo; |
939 | char *serialized_key; | 939 | char *serialized_key; |
940 | char *buf; | 940 | char *buf; |
@@ -1009,7 +1009,7 @@ issue_ticket_after_abe_bootstrap (void *cls, | |||
1009 | struct GNUNET_ABE_AbeMasterKey *abe_key) | 1009 | struct GNUNET_ABE_AbeMasterKey *abe_key) |
1010 | { | 1010 | { |
1011 | struct TicketIssueHandle *ih = cls; | 1011 | struct TicketIssueHandle *ih = cls; |
1012 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 1012 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
1013 | struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; | 1013 | struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; |
1014 | struct GNUNET_GNSRECORD_Data code_record[1]; | 1014 | struct GNUNET_GNSRECORD_Data code_record[1]; |
1015 | struct GNUNET_ABE_AbeKey *rp_key; | 1015 | struct GNUNET_ABE_AbeKey *rp_key; |
@@ -1101,7 +1101,7 @@ handle_issue_ticket_message (void *cls, | |||
1101 | 1101 | ||
1102 | ih = GNUNET_new (struct TicketIssueHandle); | 1102 | ih = GNUNET_new (struct TicketIssueHandle); |
1103 | attrs_len = ntohs (im->attr_len); | 1103 | attrs_len = ntohs (im->attr_len); |
1104 | ih->attrs = GNUNET_IDENTITY_ATTRIBUTE_list_deserialize ((char*)&im[1], attrs_len); | 1104 | ih->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char*)&im[1], attrs_len); |
1105 | ih->r_id = ntohl (im->id); | 1105 | ih->r_id = ntohl (im->id); |
1106 | ih->client = idp; | 1106 | ih->client = idp; |
1107 | ih->identity = im->identity; | 1107 | ih->identity = im->identity; |
@@ -1132,9 +1132,9 @@ static void | |||
1132 | cleanup_revoke_ticket_handle (struct TicketRevocationHandle *rh) | 1132 | cleanup_revoke_ticket_handle (struct TicketRevocationHandle *rh) |
1133 | { | 1133 | { |
1134 | if (NULL != rh->attrs) | 1134 | if (NULL != rh->attrs) |
1135 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (rh->attrs); | 1135 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (rh->attrs); |
1136 | if (NULL != rh->rvk_attrs) | 1136 | if (NULL != rh->rvk_attrs) |
1137 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (rh->rvk_attrs); | 1137 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (rh->rvk_attrs); |
1138 | if (NULL != rh->abe_key) | 1138 | if (NULL != rh->abe_key) |
1139 | GNUNET_ABE_cpabe_delete_master_key (rh->abe_key); | 1139 | GNUNET_ABE_cpabe_delete_master_key (rh->abe_key); |
1140 | if (NULL != rh->ns_qe) | 1140 | if (NULL != rh->ns_qe) |
@@ -1157,9 +1157,12 @@ send_revocation_finished (struct TicketRevocationHandle *rh, | |||
1157 | { | 1157 | { |
1158 | struct GNUNET_MQ_Envelope *env; | 1158 | struct GNUNET_MQ_Envelope *env; |
1159 | struct RevokeTicketResultMessage *trm; | 1159 | struct RevokeTicketResultMessage *trm; |
1160 | |||
1161 | GNUNET_break(TKT_database->delete_ticket (TKT_database->cls, | ||
1162 | &rh->ticket)); | ||
1160 | 1163 | ||
1161 | env = GNUNET_MQ_msg (trm, | 1164 | env = GNUNET_MQ_msg (trm, |
1162 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT); | 1165 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT); |
1163 | trm->id = htonl (rh->r_id); | 1166 | trm->id = htonl (rh->r_id); |
1164 | trm->success = htonl (success); | 1167 | trm->success = htonl (success); |
1165 | GNUNET_MQ_send (rh->client->mq, | 1168 | GNUNET_MQ_send (rh->client->mq, |
@@ -1179,8 +1182,8 @@ send_revocation_finished (struct TicketRevocationHandle *rh, | |||
1179 | */ | 1182 | */ |
1180 | static void | 1183 | static void |
1181 | ticket_reissue_proc (void *cls, | 1184 | ticket_reissue_proc (void *cls, |
1182 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 1185 | const struct GNUNET_RECLAIM_Ticket *ticket, |
1183 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs); | 1186 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs); |
1184 | 1187 | ||
1185 | static void | 1188 | static void |
1186 | revocation_reissue_tickets (struct TicketRevocationHandle *rh); | 1189 | revocation_reissue_tickets (struct TicketRevocationHandle *rh); |
@@ -1206,9 +1209,6 @@ reissue_ticket_cont (void *cls, | |||
1206 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", | 1209 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", |
1207 | "Unknown Error\n"); | 1210 | "Unknown Error\n"); |
1208 | send_revocation_finished (rh, GNUNET_SYSERR); | 1211 | send_revocation_finished (rh, GNUNET_SYSERR); |
1209 | GNUNET_CONTAINER_DLL_remove (rh->client->revoke_op_head, | ||
1210 | rh->client->revoke_op_tail, | ||
1211 | rh); | ||
1212 | cleanup_revoke_ticket_handle (rh); | 1212 | cleanup_revoke_ticket_handle (rh); |
1213 | return; | 1213 | return; |
1214 | } | 1214 | } |
@@ -1226,12 +1226,12 @@ reissue_ticket_cont (void *cls, | |||
1226 | */ | 1226 | */ |
1227 | static void | 1227 | static void |
1228 | ticket_reissue_proc (void *cls, | 1228 | ticket_reissue_proc (void *cls, |
1229 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 1229 | const struct GNUNET_RECLAIM_Ticket *ticket, |
1230 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 1230 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
1231 | { | 1231 | { |
1232 | struct TicketRevocationHandle *rh = cls; | 1232 | struct TicketRevocationHandle *rh = cls; |
1233 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 1233 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
1234 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le_rollover; | 1234 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le_rollover; |
1235 | struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; | 1235 | struct GNUNET_CRYPTO_EcdhePrivateKey *ecdhe_privkey; |
1236 | struct GNUNET_GNSRECORD_Data code_record[1]; | 1236 | struct GNUNET_GNSRECORD_Data code_record[1]; |
1237 | struct GNUNET_ABE_AbeKey *rp_key; | 1237 | struct GNUNET_ABE_AbeKey *rp_key; |
@@ -1258,9 +1258,18 @@ ticket_reissue_proc (void *cls, | |||
1258 | { | 1258 | { |
1259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1259 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1260 | "Do not reissue for this identity.!\n"); | 1260 | "Do not reissue for this identity.!\n"); |
1261 | 1261 | label = GNUNET_STRINGS_data_to_string_alloc (&rh->ticket.rnd, | |
1262 | rh->offset++; | 1262 | sizeof (uint64_t)); |
1263 | GNUNET_SCHEDULER_add_now (&reissue_next, rh); | 1263 | //Delete record |
1264 | rh->ns_qe = GNUNET_NAMESTORE_records_store (ns_handle, | ||
1265 | &rh->identity, | ||
1266 | label, | ||
1267 | 0, | ||
1268 | NULL, | ||
1269 | &reissue_ticket_cont, | ||
1270 | rh); | ||
1271 | |||
1272 | GNUNET_free (label); | ||
1264 | return; | 1273 | return; |
1265 | } | 1274 | } |
1266 | 1275 | ||
@@ -1374,9 +1383,6 @@ revocation_reissue_tickets (struct TicketRevocationHandle *rh) | |||
1374 | if (GNUNET_NO == ret) | 1383 | if (GNUNET_NO == ret) |
1375 | { | 1384 | { |
1376 | send_revocation_finished (rh, GNUNET_OK); | 1385 | send_revocation_finished (rh, GNUNET_OK); |
1377 | GNUNET_CONTAINER_DLL_remove (rh->client->revoke_op_head, | ||
1378 | rh->client->revoke_op_tail, | ||
1379 | rh); | ||
1380 | cleanup_revoke_ticket_handle (rh); | 1386 | cleanup_revoke_ticket_handle (rh); |
1381 | return; | 1387 | return; |
1382 | } | 1388 | } |
@@ -1391,10 +1397,8 @@ check_attr_error (void *cls) | |||
1391 | struct TicketRevocationHandle *rh = cls; | 1397 | struct TicketRevocationHandle *rh = cls; |
1392 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1398 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1393 | "Unable to check for existing attribute\n"); | 1399 | "Unable to check for existing attribute\n"); |
1400 | rh->ns_qe = NULL; | ||
1394 | send_revocation_finished (rh, GNUNET_SYSERR); | 1401 | send_revocation_finished (rh, GNUNET_SYSERR); |
1395 | GNUNET_CONTAINER_DLL_remove (rh->client->revoke_op_head, | ||
1396 | rh->client->revoke_op_tail, | ||
1397 | rh); | ||
1398 | cleanup_revoke_ticket_handle (rh); | 1402 | cleanup_revoke_ticket_handle (rh); |
1399 | } | 1403 | } |
1400 | 1404 | ||
@@ -1426,15 +1430,16 @@ check_attr_cb (void *cls, | |||
1426 | char* policy; | 1430 | char* policy; |
1427 | uint32_t attr_ver; | 1431 | uint32_t attr_ver; |
1428 | 1432 | ||
1433 | rh->ns_qe = NULL; | ||
1429 | if (1 != rd_count) { | 1434 | if (1 != rd_count) { |
1430 | GNUNET_SCHEDULER_add_now (&reenc_next_attribute, | 1435 | GNUNET_SCHEDULER_add_now (&reenc_next_attribute, |
1431 | rh); | 1436 | rh); |
1432 | return; | 1437 | return; |
1433 | } | 1438 | } |
1434 | 1439 | ||
1435 | buf_size = GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (rh->attrs->list_head->claim); | 1440 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (rh->attrs->list_head->claim); |
1436 | buf = GNUNET_malloc (buf_size); | 1441 | buf = GNUNET_malloc (buf_size); |
1437 | GNUNET_IDENTITY_ATTRIBUTE_serialize (rh->attrs->list_head->claim, | 1442 | GNUNET_RECLAIM_ATTRIBUTE_serialize (rh->attrs->list_head->claim, |
1438 | buf); | 1443 | buf); |
1439 | rh->attrs->list_head->claim->version++; | 1444 | rh->attrs->list_head->claim->version++; |
1440 | GNUNET_asprintf (&policy, "%s_%lu", | 1445 | GNUNET_asprintf (&policy, "%s_%lu", |
@@ -1458,9 +1463,6 @@ check_attr_cb (void *cls, | |||
1458 | policy); | 1463 | policy); |
1459 | GNUNET_free (policy); | 1464 | GNUNET_free (policy); |
1460 | send_revocation_finished (rh, GNUNET_SYSERR); | 1465 | send_revocation_finished (rh, GNUNET_SYSERR); |
1461 | GNUNET_CONTAINER_DLL_remove (rh->client->revoke_op_head, | ||
1462 | rh->client->revoke_op_tail, | ||
1463 | rh); | ||
1464 | cleanup_revoke_ticket_handle (rh); | 1466 | cleanup_revoke_ticket_handle (rh); |
1465 | return; | 1467 | return; |
1466 | } | 1468 | } |
@@ -1525,8 +1527,9 @@ attr_reenc_cont (void *cls, | |||
1525 | const char *emsg) | 1527 | const char *emsg) |
1526 | { | 1528 | { |
1527 | struct TicketRevocationHandle *rh = cls; | 1529 | struct TicketRevocationHandle *rh = cls; |
1528 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 1530 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
1529 | 1531 | ||
1532 | rh->ns_qe = NULL; | ||
1530 | if (GNUNET_SYSERR == success) | 1533 | if (GNUNET_SYSERR == success) |
1531 | { | 1534 | { |
1532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1535 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -1558,12 +1561,12 @@ attr_reenc_cont (void *cls, | |||
1558 | 1561 | ||
1559 | static void | 1562 | static void |
1560 | process_attributes_to_update (void *cls, | 1563 | process_attributes_to_update (void *cls, |
1561 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 1564 | const struct GNUNET_RECLAIM_Ticket *ticket, |
1562 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 1565 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
1563 | { | 1566 | { |
1564 | struct TicketRevocationHandle *rh = cls; | 1567 | struct TicketRevocationHandle *rh = cls; |
1565 | 1568 | ||
1566 | rh->attrs = GNUNET_IDENTITY_ATTRIBUTE_list_dup (attrs); | 1569 | rh->attrs = GNUNET_RECLAIM_ATTRIBUTE_list_dup (attrs); |
1567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1570 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1568 | "Revocation Phase I: Collecting attributes\n"); | 1571 | "Revocation Phase I: Collecting attributes\n"); |
1569 | /* Reencrypt all attributes with new key */ | 1572 | /* Reencrypt all attributes with new key */ |
@@ -1571,9 +1574,6 @@ process_attributes_to_update (void *cls, | |||
1571 | { | 1574 | { |
1572 | /* No attributes to reencrypt */ | 1575 | /* No attributes to reencrypt */ |
1573 | send_revocation_finished (rh, GNUNET_OK); | 1576 | send_revocation_finished (rh, GNUNET_OK); |
1574 | GNUNET_CONTAINER_DLL_remove (rh->client->revoke_op_head, | ||
1575 | rh->client->revoke_op_tail, | ||
1576 | rh); | ||
1577 | cleanup_revoke_ticket_handle (rh); | 1577 | cleanup_revoke_ticket_handle (rh); |
1578 | return; | 1578 | return; |
1579 | } else { | 1579 | } else { |
@@ -1621,11 +1621,11 @@ handle_revoke_ticket_message (void *cls, | |||
1621 | { | 1621 | { |
1622 | struct TicketRevocationHandle *rh; | 1622 | struct TicketRevocationHandle *rh; |
1623 | struct IdpClient *idp = cls; | 1623 | struct IdpClient *idp = cls; |
1624 | struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket; | 1624 | struct GNUNET_RECLAIM_Ticket *ticket; |
1625 | 1625 | ||
1626 | rh = GNUNET_new (struct TicketRevocationHandle); | 1626 | rh = GNUNET_new (struct TicketRevocationHandle); |
1627 | ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket*)&rm[1]; | 1627 | ticket = (struct GNUNET_RECLAIM_Ticket*)&rm[1]; |
1628 | rh->rvk_attrs = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); | 1628 | rh->rvk_attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
1629 | rh->ticket = *ticket; | 1629 | rh->ticket = *ticket; |
1630 | rh->r_id = ntohl (rm->id); | 1630 | rh->r_id = ntohl (rm->id); |
1631 | rh->client = idp; | 1631 | rh->client = idp; |
@@ -1667,7 +1667,7 @@ cleanup_consume_ticket_handle (struct ConsumeTicketHandle *handle) | |||
1667 | GNUNET_ABE_cpabe_delete_key (handle->key, | 1667 | GNUNET_ABE_cpabe_delete_key (handle->key, |
1668 | GNUNET_YES); | 1668 | GNUNET_YES); |
1669 | if (NULL != handle->attrs) | 1669 | if (NULL != handle->attrs) |
1670 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (handle->attrs); | 1670 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (handle->attrs); |
1671 | GNUNET_free (handle); | 1671 | GNUNET_free (handle); |
1672 | } | 1672 | } |
1673 | 1673 | ||
@@ -1698,7 +1698,7 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count, | |||
1698 | struct ConsumeTicketHandle *handle = parallel_lookup->handle; | 1698 | struct ConsumeTicketHandle *handle = parallel_lookup->handle; |
1699 | struct ConsumeTicketResultMessage *crm; | 1699 | struct ConsumeTicketResultMessage *crm; |
1700 | struct GNUNET_MQ_Envelope *env; | 1700 | struct GNUNET_MQ_Envelope *env; |
1701 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *attr_le; | 1701 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *attr_le; |
1702 | struct GNUNET_TIME_Absolute decrypt_duration; | 1702 | struct GNUNET_TIME_Absolute decrypt_duration; |
1703 | char *data; | 1703 | char *data; |
1704 | char *data_tmp; | 1704 | char *data_tmp; |
@@ -1741,8 +1741,8 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count, | |||
1741 | 1, | 1741 | 1, |
1742 | GNUNET_YES); | 1742 | GNUNET_YES); |
1743 | 1743 | ||
1744 | attr_le = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); | 1744 | attr_le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
1745 | attr_le->claim = GNUNET_IDENTITY_ATTRIBUTE_deserialize (data, | 1745 | attr_le->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize (data, |
1746 | attr_len); | 1746 | attr_len); |
1747 | attr_le->claim->version = ntohl(*(uint32_t*)rd->data); | 1747 | attr_le->claim->version = ntohl(*(uint32_t*)rd->data); |
1748 | GNUNET_CONTAINER_DLL_insert (handle->attrs->list_head, | 1748 | GNUNET_CONTAINER_DLL_insert (handle->attrs->list_head, |
@@ -1766,15 +1766,15 @@ process_parallel_lookup2 (void *cls, uint32_t rd_count, | |||
1766 | } | 1766 | } |
1767 | 1767 | ||
1768 | GNUNET_SCHEDULER_cancel (handle->kill_task); | 1768 | GNUNET_SCHEDULER_cancel (handle->kill_task); |
1769 | attrs_len = GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (handle->attrs); | 1769 | attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (handle->attrs); |
1770 | env = GNUNET_MQ_msg_extra (crm, | 1770 | env = GNUNET_MQ_msg_extra (crm, |
1771 | attrs_len, | 1771 | attrs_len, |
1772 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT); | 1772 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT); |
1773 | crm->id = htonl (handle->r_id); | 1773 | crm->id = htonl (handle->r_id); |
1774 | crm->attrs_len = htons (attrs_len); | 1774 | crm->attrs_len = htons (attrs_len); |
1775 | crm->identity = handle->ticket.identity; | 1775 | crm->identity = handle->ticket.identity; |
1776 | data_tmp = (char *) &crm[1]; | 1776 | data_tmp = (char *) &crm[1]; |
1777 | GNUNET_IDENTITY_ATTRIBUTE_list_serialize (handle->attrs, | 1777 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (handle->attrs, |
1778 | data_tmp); | 1778 | data_tmp); |
1779 | GNUNET_MQ_send (handle->client->mq, env); | 1779 | GNUNET_MQ_send (handle->client->mq, env); |
1780 | GNUNET_CONTAINER_DLL_remove (handle->client->consume_op_head, | 1780 | GNUNET_CONTAINER_DLL_remove (handle->client->consume_op_head, |
@@ -1805,7 +1805,7 @@ abort_parallel_lookups2 (void *cls) | |||
1805 | lu = tmp; | 1805 | lu = tmp; |
1806 | } | 1806 | } |
1807 | env = GNUNET_MQ_msg (arm, | 1807 | env = GNUNET_MQ_msg (arm, |
1808 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT); | 1808 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); |
1809 | arm->id = htonl (handle->r_id); | 1809 | arm->id = htonl (handle->r_id); |
1810 | arm->attr_len = htons (0); | 1810 | arm->attr_len = htons (0); |
1811 | GNUNET_MQ_send (handle->client->mq, env); | 1811 | GNUNET_MQ_send (handle->client->mq, env); |
@@ -1918,10 +1918,10 @@ handle_consume_ticket_message (void *cls, | |||
1918 | ch->r_id = ntohl (cm->id); | 1918 | ch->r_id = ntohl (cm->id); |
1919 | ch->client = idp; | 1919 | ch->client = idp; |
1920 | ch->identity = cm->identity; | 1920 | ch->identity = cm->identity; |
1921 | ch->attrs = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); | 1921 | ch->attrs = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
1922 | GNUNET_CRYPTO_ecdsa_key_get_public (&ch->identity, | 1922 | GNUNET_CRYPTO_ecdsa_key_get_public (&ch->identity, |
1923 | &ch->identity_pub); | 1923 | &ch->identity_pub); |
1924 | ch->ticket = *((struct GNUNET_IDENTITY_PROVIDER_Ticket*)&cm[1]); | 1924 | ch->ticket = *((struct GNUNET_RECLAIM_Ticket*)&cm[1]); |
1925 | rnd_label = GNUNET_STRINGS_data_to_string_alloc (&ch->ticket.rnd, | 1925 | rnd_label = GNUNET_STRINGS_data_to_string_alloc (&ch->ticket.rnd, |
1926 | sizeof (uint64_t)); | 1926 | sizeof (uint64_t)); |
1927 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1927 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1967,7 +1967,7 @@ attr_store_cont (void *cls, | |||
1967 | struct AttributeStoreHandle *as_handle = cls; | 1967 | struct AttributeStoreHandle *as_handle = cls; |
1968 | struct GNUNET_MQ_Envelope *env; | 1968 | struct GNUNET_MQ_Envelope *env; |
1969 | struct AttributeStoreResultMessage *acr_msg; | 1969 | struct AttributeStoreResultMessage *acr_msg; |
1970 | 1970 | ||
1971 | as_handle->ns_qe = NULL; | 1971 | as_handle->ns_qe = NULL; |
1972 | GNUNET_CONTAINER_DLL_remove (as_handle->client->store_op_head, | 1972 | GNUNET_CONTAINER_DLL_remove (as_handle->client->store_op_head, |
1973 | as_handle->client->store_op_tail, | 1973 | as_handle->client->store_op_tail, |
@@ -1986,7 +1986,7 @@ attr_store_cont (void *cls, | |||
1986 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1986 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1987 | "Sending ATTRIBUTE_STORE_RESPONSE message\n"); | 1987 | "Sending ATTRIBUTE_STORE_RESPONSE message\n"); |
1988 | env = GNUNET_MQ_msg (acr_msg, | 1988 | env = GNUNET_MQ_msg (acr_msg, |
1989 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE); | 1989 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE); |
1990 | acr_msg->id = htonl (as_handle->r_id); | 1990 | acr_msg->id = htonl (as_handle->r_id); |
1991 | acr_msg->op_result = htonl (GNUNET_OK); | 1991 | acr_msg->op_result = htonl (GNUNET_OK); |
1992 | GNUNET_MQ_send (as_handle->client->mq, | 1992 | GNUNET_MQ_send (as_handle->client->mq, |
@@ -2009,10 +2009,10 @@ attr_store_task (void *cls) | |||
2009 | 2009 | ||
2010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2010 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2011 | "Storing attribute\n"); | 2011 | "Storing attribute\n"); |
2012 | buf_size = GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (as_handle->claim); | 2012 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (as_handle->claim); |
2013 | buf = GNUNET_malloc (buf_size); | 2013 | buf = GNUNET_malloc (buf_size); |
2014 | 2014 | ||
2015 | GNUNET_IDENTITY_ATTRIBUTE_serialize (as_handle->claim, | 2015 | GNUNET_RECLAIM_ATTRIBUTE_serialize (as_handle->claim, |
2016 | buf); | 2016 | buf); |
2017 | 2017 | ||
2018 | GNUNET_asprintf (&policy, | 2018 | GNUNET_asprintf (&policy, |
@@ -2111,7 +2111,7 @@ handle_attribute_store_message (void *cls, | |||
2111 | data_len = ntohs (sam->attr_len); | 2111 | data_len = ntohs (sam->attr_len); |
2112 | 2112 | ||
2113 | as_handle = GNUNET_new (struct AttributeStoreHandle); | 2113 | as_handle = GNUNET_new (struct AttributeStoreHandle); |
2114 | as_handle->claim = GNUNET_IDENTITY_ATTRIBUTE_deserialize ((char*)&sam[1], | 2114 | as_handle->claim = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char*)&sam[1], |
2115 | data_len); | 2115 | data_len); |
2116 | 2116 | ||
2117 | as_handle->r_id = ntohl (sam->id); | 2117 | as_handle->r_id = ntohl (sam->id); |
@@ -2158,7 +2158,7 @@ attr_iter_finished (void *cls) | |||
2158 | struct AttributeResultMessage *arm; | 2158 | struct AttributeResultMessage *arm; |
2159 | 2159 | ||
2160 | env = GNUNET_MQ_msg (arm, | 2160 | env = GNUNET_MQ_msg (arm, |
2161 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT); | 2161 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); |
2162 | arm->id = htonl (ai->request_id); | 2162 | arm->id = htonl (ai->request_id); |
2163 | arm->attr_len = htons (0); | 2163 | arm->attr_len = htons (0); |
2164 | GNUNET_MQ_send (ai->client->mq, env); | 2164 | GNUNET_MQ_send (ai->client->mq, env); |
@@ -2189,14 +2189,14 @@ attr_iter_cb (void *cls, | |||
2189 | if (rd_count != 1) | 2189 | if (rd_count != 1) |
2190 | { | 2190 | { |
2191 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, | 2191 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, |
2192 | 1); | 2192 | 1); |
2193 | return; | 2193 | return; |
2194 | } | 2194 | } |
2195 | 2195 | ||
2196 | if (GNUNET_GNSRECORD_TYPE_ID_ATTR != rd->record_type) | 2196 | if (GNUNET_GNSRECORD_TYPE_ID_ATTR != rd->record_type) |
2197 | { | 2197 | { |
2198 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, | 2198 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, |
2199 | 1); | 2199 | 1); |
2200 | return; | 2200 | return; |
2201 | } | 2201 | } |
2202 | attr_ver = ntohl(*((uint32_t*)rd->data)); | 2202 | attr_ver = ntohl(*((uint32_t*)rd->data)); |
@@ -2213,7 +2213,7 @@ attr_iter_cb (void *cls, | |||
2213 | if (GNUNET_SYSERR == msg_extra_len) | 2213 | if (GNUNET_SYSERR == msg_extra_len) |
2214 | { | 2214 | { |
2215 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, | 2215 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, |
2216 | 1); | 2216 | 1); |
2217 | return; | 2217 | return; |
2218 | } | 2218 | } |
2219 | 2219 | ||
@@ -2224,7 +2224,7 @@ attr_iter_cb (void *cls, | |||
2224 | "Found attribute: %s\n", label); | 2224 | "Found attribute: %s\n", label); |
2225 | env = GNUNET_MQ_msg_extra (arm, | 2225 | env = GNUNET_MQ_msg_extra (arm, |
2226 | msg_extra_len, | 2226 | msg_extra_len, |
2227 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT); | 2227 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT); |
2228 | arm->id = htonl (ai->request_id); | 2228 | arm->id = htonl (ai->request_id); |
2229 | arm->attr_len = htons (msg_extra_len); | 2229 | arm->attr_len = htons (msg_extra_len); |
2230 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, | 2230 | GNUNET_CRYPTO_ecdsa_key_get_public (zone, |
@@ -2264,7 +2264,7 @@ iterate_next_after_abe_bootstrap (void *cls, | |||
2264 | struct AttributeIterator *ai = cls; | 2264 | struct AttributeIterator *ai = cls; |
2265 | ai->abe_key = abe_key; | 2265 | ai->abe_key = abe_key; |
2266 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, | 2266 | GNUNET_NAMESTORE_zone_iterator_next (ai->ns_it, |
2267 | 1); | 2267 | 1); |
2268 | } | 2268 | } |
2269 | 2269 | ||
2270 | 2270 | ||
@@ -2406,8 +2406,8 @@ cleanup_ticket_iter_handle (struct TicketIteration *ti) | |||
2406 | */ | 2406 | */ |
2407 | static void | 2407 | static void |
2408 | ticket_iterate_proc (void *cls, | 2408 | ticket_iterate_proc (void *cls, |
2409 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 2409 | const struct GNUNET_RECLAIM_Ticket *ticket, |
2410 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 2410 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
2411 | { | 2411 | { |
2412 | struct TicketIterationProcResult *proc = cls; | 2412 | struct TicketIterationProcResult *proc = cls; |
2413 | 2413 | ||
@@ -2467,7 +2467,7 @@ run_ticket_iteration_round (struct TicketIteration *ti) | |||
2467 | } | 2467 | } |
2468 | /* send empty response to indicate end of list */ | 2468 | /* send empty response to indicate end of list */ |
2469 | env = GNUNET_MQ_msg (trm, | 2469 | env = GNUNET_MQ_msg (trm, |
2470 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT); | 2470 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT); |
2471 | trm->id = htonl (ti->r_id); | 2471 | trm->id = htonl (ti->r_id); |
2472 | GNUNET_MQ_send (ti->client->mq, | 2472 | GNUNET_MQ_send (ti->client->mq, |
2473 | env); | 2473 | env); |
@@ -2572,7 +2572,7 @@ run (void *cls, | |||
2572 | char *database; | 2572 | char *database; |
2573 | cfg = c; | 2573 | cfg = c; |
2574 | 2574 | ||
2575 | stats = GNUNET_STATISTICS_create ("identity-provider", cfg); | 2575 | stats = GNUNET_STATISTICS_create ("reclaim", cfg); |
2576 | 2576 | ||
2577 | //Connect to identity and namestore services | 2577 | //Connect to identity and namestore services |
2578 | ns_handle = GNUNET_NAMESTORE_connect (cfg); | 2578 | ns_handle = GNUNET_NAMESTORE_connect (cfg); |
@@ -2597,13 +2597,13 @@ run (void *cls, | |||
2597 | /* Loading DB plugin */ | 2597 | /* Loading DB plugin */ |
2598 | if (GNUNET_OK != | 2598 | if (GNUNET_OK != |
2599 | GNUNET_CONFIGURATION_get_value_string (cfg, | 2599 | GNUNET_CONFIGURATION_get_value_string (cfg, |
2600 | "identity-provider", | 2600 | "reclaim", |
2601 | "database", | 2601 | "database", |
2602 | &database)) | 2602 | &database)) |
2603 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2603 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2604 | "No database backend configured\n"); | 2604 | "No database backend configured\n"); |
2605 | GNUNET_asprintf (&db_lib_name, | 2605 | GNUNET_asprintf (&db_lib_name, |
2606 | "libgnunet_plugin_identity_provider_%s", | 2606 | "libgnunet_plugin_reclaim_%s", |
2607 | database); | 2607 | database); |
2608 | TKT_database = GNUNET_PLUGIN_load (db_lib_name, | 2608 | TKT_database = GNUNET_PLUGIN_load (db_lib_name, |
2609 | (void *) cfg); | 2609 | (void *) cfg); |
@@ -2619,7 +2619,7 @@ run (void *cls, | |||
2619 | 2619 | ||
2620 | if (GNUNET_OK == | 2620 | if (GNUNET_OK == |
2621 | GNUNET_CONFIGURATION_get_value_time (cfg, | 2621 | GNUNET_CONFIGURATION_get_value_time (cfg, |
2622 | "identity-provider", | 2622 | "reclaim", |
2623 | "TOKEN_EXPIRATION_INTERVAL", | 2623 | "TOKEN_EXPIRATION_INTERVAL", |
2624 | &token_expiration_interval)) | 2624 | &token_expiration_interval)) |
2625 | { | 2625 | { |
@@ -2736,51 +2736,51 @@ client_connect_cb (void *cls, | |||
2736 | * Define "main" method using service macro. | 2736 | * Define "main" method using service macro. |
2737 | */ | 2737 | */ |
2738 | GNUNET_SERVICE_MAIN | 2738 | GNUNET_SERVICE_MAIN |
2739 | ("identity-provider", | 2739 | ("reclaim", |
2740 | GNUNET_SERVICE_OPTION_NONE, | 2740 | GNUNET_SERVICE_OPTION_NONE, |
2741 | &run, | 2741 | &run, |
2742 | &client_connect_cb, | 2742 | &client_connect_cb, |
2743 | &client_disconnect_cb, | 2743 | &client_disconnect_cb, |
2744 | NULL, | 2744 | NULL, |
2745 | GNUNET_MQ_hd_var_size (attribute_store_message, | 2745 | GNUNET_MQ_hd_var_size (attribute_store_message, |
2746 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE, | 2746 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE, |
2747 | struct AttributeStoreMessage, | 2747 | struct AttributeStoreMessage, |
2748 | NULL), | 2748 | NULL), |
2749 | GNUNET_MQ_hd_fixed_size (iteration_start, | 2749 | GNUNET_MQ_hd_fixed_size (iteration_start, |
2750 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_START, | 2750 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START, |
2751 | struct AttributeIterationStartMessage, | 2751 | struct AttributeIterationStartMessage, |
2752 | NULL), | 2752 | NULL), |
2753 | GNUNET_MQ_hd_fixed_size (iteration_next, | 2753 | GNUNET_MQ_hd_fixed_size (iteration_next, |
2754 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_NEXT, | 2754 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT, |
2755 | struct AttributeIterationNextMessage, | 2755 | struct AttributeIterationNextMessage, |
2756 | NULL), | 2756 | NULL), |
2757 | GNUNET_MQ_hd_fixed_size (iteration_stop, | 2757 | GNUNET_MQ_hd_fixed_size (iteration_stop, |
2758 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_STOP, | 2758 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP, |
2759 | struct AttributeIterationStopMessage, | 2759 | struct AttributeIterationStopMessage, |
2760 | NULL), | 2760 | NULL), |
2761 | GNUNET_MQ_hd_var_size (issue_ticket_message, | 2761 | GNUNET_MQ_hd_var_size (issue_ticket_message, |
2762 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_TICKET, | 2762 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET, |
2763 | struct IssueTicketMessage, | 2763 | struct IssueTicketMessage, |
2764 | NULL), | 2764 | NULL), |
2765 | GNUNET_MQ_hd_var_size (consume_ticket_message, | 2765 | GNUNET_MQ_hd_var_size (consume_ticket_message, |
2766 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET, | 2766 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET, |
2767 | struct ConsumeTicketMessage, | 2767 | struct ConsumeTicketMessage, |
2768 | NULL), | 2768 | NULL), |
2769 | GNUNET_MQ_hd_fixed_size (ticket_iteration_start, | 2769 | GNUNET_MQ_hd_fixed_size (ticket_iteration_start, |
2770 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_START, | 2770 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START, |
2771 | struct TicketIterationStartMessage, | 2771 | struct TicketIterationStartMessage, |
2772 | NULL), | 2772 | NULL), |
2773 | GNUNET_MQ_hd_fixed_size (ticket_iteration_next, | 2773 | GNUNET_MQ_hd_fixed_size (ticket_iteration_next, |
2774 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_NEXT, | 2774 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT, |
2775 | struct TicketIterationNextMessage, | 2775 | struct TicketIterationNextMessage, |
2776 | NULL), | 2776 | NULL), |
2777 | GNUNET_MQ_hd_fixed_size (ticket_iteration_stop, | 2777 | GNUNET_MQ_hd_fixed_size (ticket_iteration_stop, |
2778 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_STOP, | 2778 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP, |
2779 | struct TicketIterationStopMessage, | 2779 | struct TicketIterationStopMessage, |
2780 | NULL), | 2780 | NULL), |
2781 | GNUNET_MQ_hd_var_size (revoke_ticket_message, | 2781 | GNUNET_MQ_hd_var_size (revoke_ticket_message, |
2782 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET, | 2782 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET, |
2783 | struct RevokeTicketMessage, | 2783 | struct RevokeTicketMessage, |
2784 | NULL), | 2784 | NULL), |
2785 | GNUNET_MQ_handler_end()); | 2785 | GNUNET_MQ_handler_end()); |
2786 | /* end of gnunet-service-identity-provider.c */ | 2786 | /* end of gnunet-service-reclaim.c */ |
diff --git a/src/reclaim/jwt.c b/src/reclaim/jwt.c new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/reclaim/jwt.c | |||
@@ -0,0 +1 @@ | |||
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c new file mode 100644 index 000000000..1e9e64fec --- /dev/null +++ b/src/reclaim/oidc_helper.c | |||
@@ -0,0 +1,440 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /** | ||
20 | * @file reclaim/oidc_helper.c | ||
21 | * @brief helper library for OIDC related functions | ||
22 | * @author Martin Schanzenbach | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_util_lib.h" | ||
26 | #include "gnunet_signatures.h" | ||
27 | #include "gnunet_reclaim_service.h" | ||
28 | #include "gnunet_reclaim_attribute_lib.h" | ||
29 | #include <jansson.h> | ||
30 | #include <inttypes.h> | ||
31 | #include "oidc_helper.h" | ||
32 | |||
33 | static char* | ||
34 | create_jwt_header(void) | ||
35 | { | ||
36 | json_t *root; | ||
37 | char *json_str; | ||
38 | |||
39 | root = json_object (); | ||
40 | json_object_set_new (root, JWT_ALG, json_string (JWT_ALG_VALUE)); | ||
41 | json_object_set_new (root, JWT_TYP, json_string (JWT_TYP_VALUE)); | ||
42 | |||
43 | json_str = json_dumps (root, JSON_INDENT(0) | JSON_COMPACT); | ||
44 | json_decref (root); | ||
45 | return json_str; | ||
46 | } | ||
47 | |||
48 | static void | ||
49 | replace_char(char* str, char find, char replace){ | ||
50 | char *current_pos = strchr(str,find); | ||
51 | while (current_pos){ | ||
52 | *current_pos = replace; | ||
53 | current_pos = strchr(current_pos,find); | ||
54 | } | ||
55 | } | ||
56 | |||
57 | //RFC4648 | ||
58 | static void | ||
59 | fix_base64(char* str) { | ||
60 | char *padding; | ||
61 | //First, remove trailing padding '=' | ||
62 | padding = strtok(str, "="); | ||
63 | while (NULL != padding) | ||
64 | padding = strtok(NULL, "="); | ||
65 | |||
66 | //Replace + with - | ||
67 | replace_char (str, '+', '-'); | ||
68 | |||
69 | //Replace / with _ | ||
70 | replace_char (str, '/', '_'); | ||
71 | |||
72 | } | ||
73 | |||
74 | /** | ||
75 | * Create a JWT from attributes | ||
76 | * | ||
77 | * @param aud_key the public of the audience | ||
78 | * @param sub_key the public key of the subject | ||
79 | * @param attrs the attribute list | ||
80 | * @param expiration_time the validity of the token | ||
81 | * @param secret_key the key used to sign the JWT | ||
82 | * @return a new base64-encoded JWT string. | ||
83 | */ | ||
84 | char* | ||
85 | OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, | ||
86 | const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, | ||
87 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | ||
88 | const struct GNUNET_TIME_Relative *expiration_time, | ||
89 | const char *nonce, | ||
90 | const char *secret_key) | ||
91 | { | ||
92 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | ||
93 | struct GNUNET_HashCode signature; | ||
94 | struct GNUNET_TIME_Absolute exp_time; | ||
95 | struct GNUNET_TIME_Absolute time_now; | ||
96 | char* audience; | ||
97 | char* subject; | ||
98 | char* header; | ||
99 | char* body_str; | ||
100 | char* result; | ||
101 | char* header_base64; | ||
102 | char* body_base64; | ||
103 | char* signature_target; | ||
104 | char* signature_base64; | ||
105 | char* attr_val_str; | ||
106 | json_t* body; | ||
107 | |||
108 | //iat REQUIRED time now | ||
109 | time_now = GNUNET_TIME_absolute_get(); | ||
110 | //exp REQUIRED time expired from config | ||
111 | exp_time = GNUNET_TIME_absolute_add (time_now, *expiration_time); | ||
112 | //auth_time only if max_age | ||
113 | //nonce only if nonce | ||
114 | // OPTIONAL acr,amr,azp | ||
115 | subject = GNUNET_STRINGS_data_to_string_alloc (sub_key, | ||
116 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
117 | audience = GNUNET_STRINGS_data_to_string_alloc (aud_key, | ||
118 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
119 | header = create_jwt_header (); | ||
120 | body = json_object (); | ||
121 | |||
122 | //iss REQUIRED case sensitive server uri with https | ||
123 | //The issuer is the local reclaim instance (e.g. https://reclaim.id/api/openid) | ||
124 | json_object_set_new (body, | ||
125 | "iss", json_string (SERVER_ADDRESS)); | ||
126 | //sub REQUIRED public key identity, not exceed 255 ASCII length | ||
127 | json_object_set_new (body, | ||
128 | "sub", json_string (subject)); | ||
129 | //aud REQUIRED public key client_id must be there | ||
130 | json_object_set_new (body, | ||
131 | "aud", json_string (audience)); | ||
132 | //iat | ||
133 | json_object_set_new (body, | ||
134 | "iat", json_integer (time_now.abs_value_us / (1000*1000))); | ||
135 | //exp | ||
136 | json_object_set_new (body, | ||
137 | "exp", json_integer (exp_time.abs_value_us / (1000*1000))); | ||
138 | //nbf | ||
139 | json_object_set_new (body, | ||
140 | "nbf", json_integer (time_now.abs_value_us / (1000*1000))); | ||
141 | //nonce | ||
142 | if (NULL != nonce) | ||
143 | json_object_set_new (body, | ||
144 | "nonce", json_string (nonce)); | ||
145 | |||
146 | for (le = attrs->list_head; NULL != le; le = le->next) | ||
147 | { | ||
148 | attr_val_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (le->claim->type, | ||
149 | le->claim->data, | ||
150 | le->claim->data_size); | ||
151 | json_object_set_new (body, | ||
152 | le->claim->name, | ||
153 | json_string (attr_val_str)); | ||
154 | GNUNET_free (attr_val_str); | ||
155 | } | ||
156 | body_str = json_dumps (body, JSON_INDENT(0) | JSON_COMPACT); | ||
157 | json_decref (body); | ||
158 | |||
159 | GNUNET_STRINGS_base64_encode (header, | ||
160 | strlen (header), | ||
161 | &header_base64); | ||
162 | fix_base64(header_base64); | ||
163 | |||
164 | GNUNET_STRINGS_base64_encode (body_str, | ||
165 | strlen (body_str), | ||
166 | &body_base64); | ||
167 | fix_base64(body_base64); | ||
168 | |||
169 | GNUNET_free (subject); | ||
170 | GNUNET_free (audience); | ||
171 | |||
172 | /** | ||
173 | * Creating the JWT signature. This might not be | ||
174 | * standards compliant, check. | ||
175 | */ | ||
176 | GNUNET_asprintf (&signature_target, "%s.%s", header_base64, body_base64); | ||
177 | GNUNET_CRYPTO_hmac_raw (secret_key, strlen (secret_key), signature_target, strlen (signature_target), &signature); | ||
178 | GNUNET_STRINGS_base64_encode ((const char*)&signature, | ||
179 | sizeof (struct GNUNET_HashCode), | ||
180 | &signature_base64); | ||
181 | fix_base64(signature_base64); | ||
182 | |||
183 | GNUNET_asprintf (&result, "%s.%s.%s", | ||
184 | header_base64, body_base64, signature_base64); | ||
185 | |||
186 | GNUNET_free (signature_target); | ||
187 | GNUNET_free (header); | ||
188 | GNUNET_free (body_str); | ||
189 | GNUNET_free (signature_base64); | ||
190 | GNUNET_free (body_base64); | ||
191 | GNUNET_free (header_base64); | ||
192 | return result; | ||
193 | } | ||
194 | /** | ||
195 | * Builds an OIDC authorization code including | ||
196 | * a reclaim ticket and nonce | ||
197 | * | ||
198 | * @param issuer the issuer of the ticket, used to sign the ticket and nonce | ||
199 | * @param ticket the ticket to include in the code | ||
200 | * @param nonce the nonce to include in the code | ||
201 | * @return a new authorization code (caller must free) | ||
202 | */ | ||
203 | char* | ||
204 | OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, | ||
205 | const struct GNUNET_RECLAIM_Ticket *ticket, | ||
206 | const char* nonce) | ||
207 | { | ||
208 | char *ticket_str; | ||
209 | json_t *code_json; | ||
210 | char *signature_payload; | ||
211 | char *signature_str; | ||
212 | char *authz_code; | ||
213 | size_t signature_payload_len; | ||
214 | struct GNUNET_CRYPTO_EcdsaSignature signature; | ||
215 | struct GNUNET_CRYPTO_EccSignaturePurpose *purpose; | ||
216 | |||
217 | signature_payload_len = sizeof (struct GNUNET_RECLAIM_Ticket); | ||
218 | if (NULL != nonce) | ||
219 | signature_payload_len += strlen (nonce); | ||
220 | |||
221 | signature_payload = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + signature_payload_len); | ||
222 | purpose = (struct GNUNET_CRYPTO_EccSignaturePurpose *)signature_payload; | ||
223 | purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + signature_payload_len); | ||
224 | purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN); | ||
225 | memcpy (&purpose[1], | ||
226 | ticket, | ||
227 | sizeof (struct GNUNET_RECLAIM_Ticket)); | ||
228 | if (NULL != nonce) | ||
229 | memcpy (((char*)&purpose[1]) + sizeof (struct GNUNET_RECLAIM_Ticket), | ||
230 | nonce, | ||
231 | strlen (nonce)); | ||
232 | if (GNUNET_SYSERR == GNUNET_CRYPTO_ecdsa_sign (issuer, | ||
233 | purpose, | ||
234 | &signature)) | ||
235 | { | ||
236 | GNUNET_free (signature_payload); | ||
237 | return NULL; | ||
238 | } | ||
239 | signature_str = GNUNET_STRINGS_data_to_string_alloc (&signature, | ||
240 | sizeof (signature)); | ||
241 | ticket_str = GNUNET_STRINGS_data_to_string_alloc (ticket, | ||
242 | sizeof (struct GNUNET_RECLAIM_Ticket)); | ||
243 | |||
244 | code_json = json_object (); | ||
245 | json_object_set_new (code_json, | ||
246 | "ticket", | ||
247 | json_string (ticket_str)); | ||
248 | if (NULL != nonce) | ||
249 | json_object_set_new (code_json, | ||
250 | "nonce", | ||
251 | json_string (nonce)); | ||
252 | json_object_set_new (code_json, | ||
253 | "signature", | ||
254 | json_string (signature_str)); | ||
255 | authz_code = json_dumps (code_json, | ||
256 | JSON_INDENT(0) | JSON_COMPACT); | ||
257 | GNUNET_free (signature_payload); | ||
258 | GNUNET_free (signature_str); | ||
259 | GNUNET_free (ticket_str); | ||
260 | json_decref (code_json); | ||
261 | return authz_code; | ||
262 | } | ||
263 | |||
264 | |||
265 | |||
266 | |||
267 | /** | ||
268 | * Parse reclaim ticket and nonce from | ||
269 | * authorization code. | ||
270 | * This also verifies the signature in the code. | ||
271 | * | ||
272 | * @param audience the expected audience of the code | ||
273 | * @param code the string representation of the code | ||
274 | * @param ticket where to store the ticket | ||
275 | * @param nonce where to store the nonce | ||
276 | * @return GNUNET_OK if successful, else GNUNET_SYSERR | ||
277 | */ | ||
278 | int | ||
279 | OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | ||
280 | const char* code, | ||
281 | struct GNUNET_RECLAIM_Ticket **ticket, | ||
282 | char **nonce) | ||
283 | { | ||
284 | json_error_t error; | ||
285 | json_t *code_json; | ||
286 | json_t *ticket_json; | ||
287 | json_t *nonce_json; | ||
288 | json_t *signature_json; | ||
289 | const char *ticket_str; | ||
290 | const char *signature_str; | ||
291 | const char *nonce_str; | ||
292 | char *code_output; | ||
293 | struct GNUNET_CRYPTO_EccSignaturePurpose *purpose; | ||
294 | struct GNUNET_CRYPTO_EcdsaSignature signature; | ||
295 | size_t signature_payload_len; | ||
296 | |||
297 | code_output = NULL; | ||
298 | GNUNET_STRINGS_base64_decode (code, | ||
299 | strlen(code), | ||
300 | (void**)&code_output); | ||
301 | code_json = json_loads (code_output, 0 , &error); | ||
302 | GNUNET_free (code_output); | ||
303 | ticket_json = json_object_get (code_json, "ticket"); | ||
304 | nonce_json = json_object_get (code_json, "nonce"); | ||
305 | signature_json = json_object_get (code_json, "signature"); | ||
306 | *ticket = NULL; | ||
307 | *nonce = NULL; | ||
308 | |||
309 | if ((NULL == ticket_json || !json_is_string (ticket_json)) || | ||
310 | (NULL == signature_json || !json_is_string (signature_json))) | ||
311 | { | ||
312 | json_decref (code_json); | ||
313 | return GNUNET_SYSERR; | ||
314 | } | ||
315 | ticket_str = json_string_value (ticket_json); | ||
316 | signature_str = json_string_value (signature_json); | ||
317 | nonce_str = NULL; | ||
318 | if (NULL != nonce_json) | ||
319 | nonce_str = json_string_value (nonce_json); | ||
320 | signature_payload_len = sizeof (struct GNUNET_RECLAIM_Ticket); | ||
321 | if (NULL != nonce_str) | ||
322 | signature_payload_len += strlen (nonce_str); | ||
323 | purpose = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + | ||
324 | signature_payload_len); | ||
325 | purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + signature_payload_len); | ||
326 | purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN); | ||
327 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (ticket_str, | ||
328 | strlen (ticket_str), | ||
329 | &purpose[1], | ||
330 | sizeof (struct GNUNET_RECLAIM_Ticket))) | ||
331 | { | ||
332 | GNUNET_free (purpose); | ||
333 | json_decref (code_json); | ||
334 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
335 | "Cannot parse ticket!\n"); | ||
336 | return GNUNET_SYSERR; | ||
337 | } | ||
338 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (signature_str, | ||
339 | strlen (signature_str), | ||
340 | &signature, | ||
341 | sizeof (struct GNUNET_CRYPTO_EcdsaSignature))) | ||
342 | { | ||
343 | GNUNET_free (purpose); | ||
344 | json_decref (code_json); | ||
345 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
346 | "Cannot parse signature!\n"); | ||
347 | return GNUNET_SYSERR; | ||
348 | } | ||
349 | *ticket = GNUNET_new (struct GNUNET_RECLAIM_Ticket); | ||
350 | memcpy (*ticket, | ||
351 | &purpose[1], | ||
352 | sizeof (struct GNUNET_RECLAIM_Ticket)); | ||
353 | if (0 != memcmp (audience, | ||
354 | &(*ticket)->audience, | ||
355 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
356 | { | ||
357 | GNUNET_free (purpose); | ||
358 | GNUNET_free (*ticket); | ||
359 | json_decref (code_json); | ||
360 | *ticket = NULL; | ||
361 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
362 | "Audience in ticket does not match client!\n"); | ||
363 | return GNUNET_SYSERR; | ||
364 | |||
365 | } | ||
366 | if (NULL != nonce_str) | ||
367 | memcpy (((char*)&purpose[1]) + sizeof (struct GNUNET_RECLAIM_Ticket), | ||
368 | nonce_str, | ||
369 | strlen (nonce_str)); | ||
370 | if (GNUNET_OK != GNUNET_CRYPTO_ecdsa_verify (GNUNET_SIGNATURE_PURPOSE_RECLAIM_CODE_SIGN, | ||
371 | purpose, | ||
372 | &signature, | ||
373 | &(*ticket)->identity)) | ||
374 | { | ||
375 | GNUNET_free (purpose); | ||
376 | GNUNET_free (*ticket); | ||
377 | json_decref (code_json); | ||
378 | *ticket = NULL; | ||
379 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
380 | "Signature of authZ code invalid!\n"); | ||
381 | return GNUNET_SYSERR; | ||
382 | } | ||
383 | *nonce = GNUNET_strdup (nonce_str); | ||
384 | return GNUNET_OK; | ||
385 | } | ||
386 | |||
387 | /** | ||
388 | * Build a token response for a token request | ||
389 | * TODO: Maybe we should add the scope here? | ||
390 | * | ||
391 | * @param access_token the access token to include | ||
392 | * @param id_token the id_token to include | ||
393 | * @param expiration_time the expiration time of the token(s) | ||
394 | * @param token_response where to store the response | ||
395 | */ | ||
396 | void | ||
397 | OIDC_build_token_response (const char *access_token, | ||
398 | const char *id_token, | ||
399 | const struct GNUNET_TIME_Relative *expiration_time, | ||
400 | char **token_response) | ||
401 | { | ||
402 | json_t *root_json; | ||
403 | |||
404 | root_json = json_object (); | ||
405 | |||
406 | GNUNET_assert (NULL != access_token); | ||
407 | GNUNET_assert (NULL != id_token); | ||
408 | GNUNET_assert (NULL != expiration_time); | ||
409 | json_object_set_new (root_json, | ||
410 | "access_token", | ||
411 | json_string (access_token)); | ||
412 | json_object_set_new (root_json, | ||
413 | "token_type", | ||
414 | json_string ("Bearer")); | ||
415 | json_object_set_new (root_json, | ||
416 | "expires_in", | ||
417 | json_integer (expiration_time->rel_value_us / (1000 * 1000))); | ||
418 | json_object_set_new (root_json, | ||
419 | "id_token", | ||
420 | json_string (id_token)); | ||
421 | *token_response = json_dumps (root_json, | ||
422 | JSON_INDENT(0) | JSON_COMPACT); | ||
423 | json_decref (root_json); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * Generate a new access token | ||
428 | */ | ||
429 | char* | ||
430 | OIDC_access_token_new () | ||
431 | { | ||
432 | char* access_token_number; | ||
433 | char* access_token; | ||
434 | uint64_t random_number; | ||
435 | |||
436 | random_number = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_NONCE, UINT64_MAX); | ||
437 | GNUNET_asprintf (&access_token_number, "%" PRIu64, random_number); | ||
438 | GNUNET_STRINGS_base64_encode(access_token_number,strlen(access_token_number),&access_token); | ||
439 | return access_token; | ||
440 | } | ||
diff --git a/src/reclaim/oidc_helper.h b/src/reclaim/oidc_helper.h new file mode 100644 index 000000000..7a0f45bf9 --- /dev/null +++ b/src/reclaim/oidc_helper.h | |||
@@ -0,0 +1,109 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2010-2015 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | /** | ||
20 | * @file reclaim/oidc_helper.h | ||
21 | * @brief helper library for OIDC related functions | ||
22 | * @author Martin Schanzenbach | ||
23 | */ | ||
24 | |||
25 | #ifndef JWT_H | ||
26 | #define JWT_H | ||
27 | |||
28 | #define JWT_ALG "alg" | ||
29 | |||
30 | /* Use 512bit HMAC */ | ||
31 | #define JWT_ALG_VALUE "HS512" | ||
32 | |||
33 | #define JWT_TYP "typ" | ||
34 | |||
35 | #define JWT_TYP_VALUE "jwt" | ||
36 | |||
37 | #define SERVER_ADDRESS "https://reclaim.id" | ||
38 | |||
39 | /** | ||
40 | * Create a JWT from attributes | ||
41 | * | ||
42 | * @param aud_key the public of the audience | ||
43 | * @param sub_key the public key of the subject | ||
44 | * @param attrs the attribute list | ||
45 | * @param expiration_time the validity of the token | ||
46 | * @param secret_key the key used to sign the JWT | ||
47 | * @return a new base64-encoded JWT string. | ||
48 | */ | ||
49 | char* | ||
50 | OIDC_id_token_new (const struct GNUNET_CRYPTO_EcdsaPublicKey *aud_key, | ||
51 | const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key, | ||
52 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, | ||
53 | const struct GNUNET_TIME_Relative *expiration_time, | ||
54 | const char *nonce, | ||
55 | const char *secret_key); | ||
56 | |||
57 | /** | ||
58 | * Builds an OIDC authorization code including | ||
59 | * a reclaim ticket and nonce | ||
60 | * | ||
61 | * @param issuer the issuer of the ticket, used to sign the ticket and nonce | ||
62 | * @param ticket the ticket to include in the code | ||
63 | * @param nonce the nonce to include in the code | ||
64 | * @return a new authorization code (caller must free) | ||
65 | */ | ||
66 | char* | ||
67 | OIDC_build_authz_code (const struct GNUNET_CRYPTO_EcdsaPrivateKey *issuer, | ||
68 | const struct GNUNET_RECLAIM_Ticket *ticket, | ||
69 | const char* nonce); | ||
70 | |||
71 | /** | ||
72 | * Parse reclaim ticket and nonce from | ||
73 | * authorization code. | ||
74 | * This also verifies the signature in the code. | ||
75 | * | ||
76 | * @param audience the expected audience of the code | ||
77 | * @param code the string representation of the code | ||
78 | * @param ticket where to store the ticket | ||
79 | * @param nonce where to store the nonce | ||
80 | * @return GNUNET_OK if successful, else GNUNET_SYSERR | ||
81 | */ | ||
82 | int | ||
83 | OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience, | ||
84 | const char* code, | ||
85 | struct GNUNET_RECLAIM_Ticket **ticket, | ||
86 | char **nonce); | ||
87 | |||
88 | /** | ||
89 | * Build a token response for a token request | ||
90 | * TODO: Maybe we should add the scope here? | ||
91 | * | ||
92 | * @param access_token the access token to include | ||
93 | * @param id_token the id_token to include | ||
94 | * @param expiration_time the expiration time of the token(s) | ||
95 | * @param token_response where to store the response | ||
96 | */ | ||
97 | void | ||
98 | OIDC_build_token_response (const char *access_token, | ||
99 | const char *id_token, | ||
100 | const struct GNUNET_TIME_Relative *expiration_time, | ||
101 | char **token_response); | ||
102 | /** | ||
103 | * Generate a new access token | ||
104 | */ | ||
105 | char* | ||
106 | OIDC_access_token_new (); | ||
107 | |||
108 | |||
109 | #endif | ||
diff --git a/src/identity-provider/plugin_gnsrecord_identity_provider.c b/src/reclaim/plugin_gnsrecord_reclaim.c index f0dc563dc..781b88abc 100644 --- a/src/identity-provider/plugin_gnsrecord_identity_provider.c +++ b/src/reclaim/plugin_gnsrecord_reclaim.c | |||
@@ -17,7 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @file identity-provider/plugin_gnsrecord_identity_provider.c | 20 | * @file reclaim/plugin_gnsrecord_reclaim.c |
21 | * @brief gnsrecord plugin to provide the API for identity records | 21 | * @brief gnsrecord plugin to provide the API for identity records |
22 | * @author Martin Schanzenbach | 22 | * @author Martin Schanzenbach |
23 | */ | 23 | */ |
@@ -54,6 +54,8 @@ value_to_string (void *cls, | |||
54 | case GNUNET_GNSRECORD_TYPE_ID_ATTR: | 54 | case GNUNET_GNSRECORD_TYPE_ID_ATTR: |
55 | return GNUNET_STRINGS_data_to_string_alloc (data, data_size); | 55 | return GNUNET_STRINGS_data_to_string_alloc (data, data_size); |
56 | case GNUNET_GNSRECORD_TYPE_ID_TOKEN: //DEPRECATED | 56 | case GNUNET_GNSRECORD_TYPE_ID_TOKEN: //DEPRECATED |
57 | case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: | ||
58 | case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: | ||
57 | return GNUNET_strndup (data, data_size); | 59 | return GNUNET_strndup (data, data_size); |
58 | case GNUNET_GNSRECORD_TYPE_ABE_KEY: | 60 | case GNUNET_GNSRECORD_TYPE_ABE_KEY: |
59 | case GNUNET_GNSRECORD_TYPE_ABE_MASTER: | 61 | case GNUNET_GNSRECORD_TYPE_ABE_MASTER: |
@@ -113,6 +115,8 @@ string_to_value (void *cls, | |||
113 | *data, | 115 | *data, |
114 | *data_size); | 116 | *data_size); |
115 | case GNUNET_GNSRECORD_TYPE_ID_TOKEN: | 117 | case GNUNET_GNSRECORD_TYPE_ID_TOKEN: |
118 | case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT: | ||
119 | case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT: | ||
116 | *data = GNUNET_strdup (s); | 120 | *data = GNUNET_strdup (s); |
117 | *data_size = strlen (s); | 121 | *data_size = strlen (s); |
118 | return GNUNET_OK; | 122 | return GNUNET_OK; |
@@ -181,6 +185,8 @@ static struct { | |||
181 | { "ABE_KEY", GNUNET_GNSRECORD_TYPE_ABE_KEY }, | 185 | { "ABE_KEY", GNUNET_GNSRECORD_TYPE_ABE_KEY }, |
182 | { "ABE_MASTER", GNUNET_GNSRECORD_TYPE_ABE_MASTER }, | 186 | { "ABE_MASTER", GNUNET_GNSRECORD_TYPE_ABE_MASTER }, |
183 | { "ID_TOKEN_METADATA", GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA }, | 187 | { "ID_TOKEN_METADATA", GNUNET_GNSRECORD_TYPE_ID_TOKEN_METADATA }, |
188 | { "RECLAIM_OIDC_CLIENT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT }, | ||
189 | { "RECLAIM_OIDC_REDIRECT", GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT }, | ||
184 | { NULL, UINT32_MAX } | 190 | { NULL, UINT32_MAX } |
185 | }; | 191 | }; |
186 | 192 | ||
@@ -234,7 +240,7 @@ number_to_typename (void *cls, | |||
234 | * @return the exported block API | 240 | * @return the exported block API |
235 | */ | 241 | */ |
236 | void * | 242 | void * |
237 | libgnunet_plugin_gnsrecord_identity_provider_init (void *cls) | 243 | libgnunet_plugin_gnsrecord_reclaim_init (void *cls) |
238 | { | 244 | { |
239 | struct GNUNET_GNSRECORD_PluginFunctions *api; | 245 | struct GNUNET_GNSRECORD_PluginFunctions *api; |
240 | 246 | ||
@@ -254,7 +260,7 @@ libgnunet_plugin_gnsrecord_identity_provider_init (void *cls) | |||
254 | * @return NULL | 260 | * @return NULL |
255 | */ | 261 | */ |
256 | void * | 262 | void * |
257 | libgnunet_plugin_gnsrecord_identity_provider_done (void *cls) | 263 | libgnunet_plugin_gnsrecord_reclaim_done (void *cls) |
258 | { | 264 | { |
259 | struct GNUNET_GNSRECORD_PluginFunctions *api = cls; | 265 | struct GNUNET_GNSRECORD_PluginFunctions *api = cls; |
260 | 266 | ||
diff --git a/src/identity-provider/plugin_identity_provider_sqlite.c b/src/reclaim/plugin_reclaim_sqlite.c index f2a8b7b54..b545a94e8 100644 --- a/src/identity-provider/plugin_identity_provider_sqlite.c +++ b/src/reclaim/plugin_reclaim_sqlite.c | |||
@@ -17,15 +17,15 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @file identity-provider/plugin_identity_provider_sqlite.c | 20 | * @file reclaim/plugin_reclaim_sqlite.c |
21 | * @brief sqlite-based idp backend | 21 | * @brief sqlite-based idp backend |
22 | * @author Martin Schanzenbach | 22 | * @author Martin Schanzenbach |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_identity_provider_service.h" | 26 | #include "gnunet_reclaim_service.h" |
27 | #include "gnunet_identity_provider_plugin.h" | 27 | #include "gnunet_reclaim_plugin.h" |
28 | #include "gnunet_identity_attribute_lib.h" | 28 | #include "gnunet_reclaim_attribute_lib.h" |
29 | #include "gnunet_sq_lib.h" | 29 | #include "gnunet_sq_lib.h" |
30 | #include <sqlite3.h> | 30 | #include <sqlite3.h> |
31 | 31 | ||
@@ -47,9 +47,9 @@ | |||
47 | * a failure of the command 'cmd' on file 'filename' | 47 | * a failure of the command 'cmd' on file 'filename' |
48 | * with the message given by strerror(errno). | 48 | * with the message given by strerror(errno). |
49 | */ | 49 | */ |
50 | #define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, "identity-provider", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0) | 50 | #define LOG_SQLITE(db, level, cmd) do { GNUNET_log_from (level, "reclaim", _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, sqlite3_errmsg(db->dbh)); } while(0) |
51 | 51 | ||
52 | #define LOG(kind,...) GNUNET_log_from (kind, "identity-provider-sqlite", __VA_ARGS__) | 52 | #define LOG(kind,...) GNUNET_log_from (kind, "reclaim-sqlite", __VA_ARGS__) |
53 | 53 | ||
54 | 54 | ||
55 | /** | 55 | /** |
@@ -180,12 +180,12 @@ database_setup (struct Plugin *plugin) | |||
180 | 180 | ||
181 | if (GNUNET_OK != | 181 | if (GNUNET_OK != |
182 | GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, | 182 | GNUNET_CONFIGURATION_get_value_filename (plugin->cfg, |
183 | "identity-provider-sqlite", | 183 | "reclaim-sqlite", |
184 | "FILENAME", | 184 | "FILENAME", |
185 | &afsdir)) | 185 | &afsdir)) |
186 | { | 186 | { |
187 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 187 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
188 | "identity-provider-sqlite", | 188 | "reclaim-sqlite", |
189 | "FILENAME"); | 189 | "FILENAME"); |
190 | return GNUNET_SYSERR; | 190 | return GNUNET_SYSERR; |
191 | } | 191 | } |
@@ -370,9 +370,9 @@ database_shutdown (struct Plugin *plugin) | |||
370 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 370 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
371 | */ | 371 | */ |
372 | static int | 372 | static int |
373 | identity_provider_sqlite_store_ticket (void *cls, | 373 | reclaim_sqlite_store_ticket (void *cls, |
374 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 374 | const struct GNUNET_RECLAIM_Ticket *ticket, |
375 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs) | 375 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs) |
376 | { | 376 | { |
377 | struct Plugin *plugin = cls; | 377 | struct Plugin *plugin = cls; |
378 | size_t attrs_len; | 378 | size_t attrs_len; |
@@ -401,9 +401,9 @@ identity_provider_sqlite_store_ticket (void *cls, | |||
401 | GNUNET_SQ_reset (plugin->dbh, | 401 | GNUNET_SQ_reset (plugin->dbh, |
402 | plugin->delete_ticket); | 402 | plugin->delete_ticket); |
403 | 403 | ||
404 | attrs_len = GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (attrs); | 404 | attrs_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); |
405 | attrs_ser = GNUNET_malloc (attrs_len); | 405 | attrs_ser = GNUNET_malloc (attrs_len); |
406 | GNUNET_IDENTITY_ATTRIBUTE_list_serialize (attrs, | 406 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, |
407 | attrs_ser); | 407 | attrs_ser); |
408 | struct GNUNET_SQ_QueryParam sparams[] = { | 408 | struct GNUNET_SQ_QueryParam sparams[] = { |
409 | GNUNET_SQ_query_param_auto_from_type (&ticket->identity), | 409 | GNUNET_SQ_query_param_auto_from_type (&ticket->identity), |
@@ -458,8 +458,8 @@ identity_provider_sqlite_store_ticket (void *cls, | |||
458 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 458 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
459 | */ | 459 | */ |
460 | static int | 460 | static int |
461 | identity_provider_sqlite_delete_ticket (void *cls, | 461 | reclaim_sqlite_delete_ticket (void *cls, |
462 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket) | 462 | const struct GNUNET_RECLAIM_Ticket *ticket) |
463 | { | 463 | { |
464 | struct Plugin *plugin = cls; | 464 | struct Plugin *plugin = cls; |
465 | int n; | 465 | int n; |
@@ -521,11 +521,11 @@ identity_provider_sqlite_delete_ticket (void *cls, | |||
521 | static int | 521 | static int |
522 | get_ticket_and_call_iterator (struct Plugin *plugin, | 522 | get_ticket_and_call_iterator (struct Plugin *plugin, |
523 | sqlite3_stmt *stmt, | 523 | sqlite3_stmt *stmt, |
524 | GNUNET_IDENTITY_PROVIDER_TicketIterator iter, | 524 | GNUNET_RECLAIM_TicketIterator iter, |
525 | void *iter_cls) | 525 | void *iter_cls) |
526 | { | 526 | { |
527 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 527 | struct GNUNET_RECLAIM_Ticket ticket; |
528 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs; | 528 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; |
529 | int ret; | 529 | int ret; |
530 | int sret; | 530 | int sret; |
531 | size_t attrs_len; | 531 | size_t attrs_len; |
@@ -552,13 +552,13 @@ get_ticket_and_call_iterator (struct Plugin *plugin, | |||
552 | } | 552 | } |
553 | else | 553 | else |
554 | { | 554 | { |
555 | attrs = GNUNET_IDENTITY_ATTRIBUTE_list_deserialize (attrs_ser, | 555 | attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize (attrs_ser, |
556 | attrs_len); | 556 | attrs_len); |
557 | if (NULL != iter) | 557 | if (NULL != iter) |
558 | iter (iter_cls, | 558 | iter (iter_cls, |
559 | &ticket, | 559 | &ticket, |
560 | attrs); | 560 | attrs); |
561 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (attrs); | 561 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); |
562 | ret = GNUNET_YES; | 562 | ret = GNUNET_YES; |
563 | } | 563 | } |
564 | GNUNET_SQ_cleanup_result (rs); | 564 | GNUNET_SQ_cleanup_result (rs); |
@@ -586,9 +586,9 @@ get_ticket_and_call_iterator (struct Plugin *plugin, | |||
586 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR | 586 | * @return #GNUNET_OK on success, else #GNUNET_SYSERR |
587 | */ | 587 | */ |
588 | static int | 588 | static int |
589 | identity_provider_sqlite_ticket_get_attrs (void *cls, | 589 | reclaim_sqlite_ticket_get_attrs (void *cls, |
590 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 590 | const struct GNUNET_RECLAIM_Ticket *ticket, |
591 | GNUNET_IDENTITY_PROVIDER_TicketIterator iter, | 591 | GNUNET_RECLAIM_TicketIterator iter, |
592 | void *iter_cls) | 592 | void *iter_cls) |
593 | { | 593 | { |
594 | struct Plugin *plugin = cls; | 594 | struct Plugin *plugin = cls; |
@@ -628,11 +628,11 @@ identity_provider_sqlite_ticket_get_attrs (void *cls, | |||
628 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error | 628 | * @return #GNUNET_OK on success, #GNUNET_NO if there were no results, #GNUNET_SYSERR on error |
629 | */ | 629 | */ |
630 | static int | 630 | static int |
631 | identity_provider_sqlite_iterate_tickets (void *cls, | 631 | reclaim_sqlite_iterate_tickets (void *cls, |
632 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 632 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
633 | int audience, | 633 | int audience, |
634 | uint64_t offset, | 634 | uint64_t offset, |
635 | GNUNET_IDENTITY_PROVIDER_TicketIterator iter, | 635 | GNUNET_RECLAIM_TicketIterator iter, |
636 | void *iter_cls) | 636 | void *iter_cls) |
637 | { | 637 | { |
638 | struct Plugin *plugin = cls; | 638 | struct Plugin *plugin = cls; |
@@ -680,15 +680,15 @@ identity_provider_sqlite_iterate_tickets (void *cls, | |||
680 | /** | 680 | /** |
681 | * Entry point for the plugin. | 681 | * Entry point for the plugin. |
682 | * | 682 | * |
683 | * @param cls the "struct GNUNET_IDENTITY_PROVIDER_PluginEnvironment*" | 683 | * @param cls the "struct GNUNET_RECLAIM_PluginEnvironment*" |
684 | * @return NULL on error, otherwise the plugin context | 684 | * @return NULL on error, otherwise the plugin context |
685 | */ | 685 | */ |
686 | void * | 686 | void * |
687 | libgnunet_plugin_identity_provider_sqlite_init (void *cls) | 687 | libgnunet_plugin_reclaim_sqlite_init (void *cls) |
688 | { | 688 | { |
689 | static struct Plugin plugin; | 689 | static struct Plugin plugin; |
690 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 690 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
691 | struct GNUNET_IDENTITY_PROVIDER_PluginFunctions *api; | 691 | struct GNUNET_RECLAIM_PluginFunctions *api; |
692 | 692 | ||
693 | if (NULL != plugin.cfg) | 693 | if (NULL != plugin.cfg) |
694 | return NULL; /* can only initialize once! */ | 694 | return NULL; /* can only initialize once! */ |
@@ -699,12 +699,12 @@ libgnunet_plugin_identity_provider_sqlite_init (void *cls) | |||
699 | database_shutdown (&plugin); | 699 | database_shutdown (&plugin); |
700 | return NULL; | 700 | return NULL; |
701 | } | 701 | } |
702 | api = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_PluginFunctions); | 702 | api = GNUNET_new (struct GNUNET_RECLAIM_PluginFunctions); |
703 | api->cls = &plugin; | 703 | api->cls = &plugin; |
704 | api->store_ticket = &identity_provider_sqlite_store_ticket; | 704 | api->store_ticket = &reclaim_sqlite_store_ticket; |
705 | api->delete_ticket = &identity_provider_sqlite_delete_ticket; | 705 | api->delete_ticket = &reclaim_sqlite_delete_ticket; |
706 | api->iterate_tickets = &identity_provider_sqlite_iterate_tickets; | 706 | api->iterate_tickets = &reclaim_sqlite_iterate_tickets; |
707 | api->get_ticket_attributes = &identity_provider_sqlite_ticket_get_attrs; | 707 | api->get_ticket_attributes = &reclaim_sqlite_ticket_get_attrs; |
708 | LOG (GNUNET_ERROR_TYPE_INFO, | 708 | LOG (GNUNET_ERROR_TYPE_INFO, |
709 | _("Sqlite database running\n")); | 709 | _("Sqlite database running\n")); |
710 | return api; | 710 | return api; |
@@ -718,9 +718,9 @@ libgnunet_plugin_identity_provider_sqlite_init (void *cls) | |||
718 | * @return always NULL | 718 | * @return always NULL |
719 | */ | 719 | */ |
720 | void * | 720 | void * |
721 | libgnunet_plugin_identity_provider_sqlite_done (void *cls) | 721 | libgnunet_plugin_reclaim_sqlite_done (void *cls) |
722 | { | 722 | { |
723 | struct GNUNET_IDENTITY_PROVIDER_PluginFunctions *api = cls; | 723 | struct GNUNET_RECLAIM_PluginFunctions *api = cls; |
724 | struct Plugin *plugin = api->cls; | 724 | struct Plugin *plugin = api->cls; |
725 | 725 | ||
726 | database_shutdown (plugin); | 726 | database_shutdown (plugin); |
@@ -731,4 +731,4 @@ libgnunet_plugin_identity_provider_sqlite_done (void *cls) | |||
731 | return NULL; | 731 | return NULL; |
732 | } | 732 | } |
733 | 733 | ||
734 | /* end of plugin_identity_provider_sqlite.c */ | 734 | /* end of plugin_reclaim_sqlite.c */ |
diff --git a/src/identity-provider/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c index d87a345cf..24673c692 100644 --- a/src/identity-provider/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c | |||
@@ -36,9 +36,9 @@ | |||
36 | #include <jansson.h> | 36 | #include <jansson.h> |
37 | #include <inttypes.h> | 37 | #include <inttypes.h> |
38 | #include "gnunet_signatures.h" | 38 | #include "gnunet_signatures.h" |
39 | #include "gnunet_identity_attribute_lib.h" | 39 | #include "gnunet_reclaim_attribute_lib.h" |
40 | #include "gnunet_identity_provider_service.h" | 40 | #include "gnunet_reclaim_service.h" |
41 | #include "jwt.h" | 41 | #include "oidc_helper.h" |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * REST root namespace | 44 | * REST root namespace |
@@ -68,7 +68,7 @@ | |||
68 | /** | 68 | /** |
69 | * Attribute key | 69 | * Attribute key |
70 | */ | 70 | */ |
71 | #define GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE "attribute" | 71 | #define GNUNET_REST_JSONAPI_RECLAIM_ATTRIBUTE "attribute" |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Ticket key | 74 | * Ticket key |
@@ -79,7 +79,7 @@ | |||
79 | /** | 79 | /** |
80 | * Value key | 80 | * Value key |
81 | */ | 81 | */ |
82 | #define GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE_VALUE "value" | 82 | #define GNUNET_REST_JSONAPI_RECLAIM_ATTRIBUTE_VALUE "value" |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * State while collecting all egos | 85 | * State while collecting all egos |
@@ -168,7 +168,6 @@ static char* OIDC_ignored_parameter_array [] = | |||
168 | { | 168 | { |
169 | "display", | 169 | "display", |
170 | "prompt", | 170 | "prompt", |
171 | "max_age", | ||
172 | "ui_locales", | 171 | "ui_locales", |
173 | "response_mode", | 172 | "response_mode", |
174 | "id_token_hint", | 173 | "id_token_hint", |
@@ -230,12 +229,6 @@ struct OIDC_Variables | |||
230 | char *client_id; | 229 | char *client_id; |
231 | 230 | ||
232 | /** | 231 | /** |
233 | * GNUNET_YES if there is a delegation to | ||
234 | * this RP or if it is a local identity | ||
235 | */ | ||
236 | int is_client_trusted; | ||
237 | |||
238 | /** | ||
239 | * The OIDC redirect uri | 232 | * The OIDC redirect uri |
240 | */ | 233 | */ |
241 | char *redirect_uri; | 234 | char *redirect_uri; |
@@ -347,6 +340,16 @@ struct RequestHandle | |||
347 | struct GNUNET_REST_RequestHandle *rest_handle; | 340 | struct GNUNET_REST_RequestHandle *rest_handle; |
348 | 341 | ||
349 | /** | 342 | /** |
343 | * GNS handle | ||
344 | */ | ||
345 | struct GNUNET_GNS_Handle *gns_handle; | ||
346 | |||
347 | /** | ||
348 | * GNS lookup op | ||
349 | */ | ||
350 | struct GNUNET_GNS_LookupRequest *gns_op; | ||
351 | |||
352 | /** | ||
350 | * Handle to NAMESTORE | 353 | * Handle to NAMESTORE |
351 | */ | 354 | */ |
352 | struct GNUNET_NAMESTORE_Handle *namestore_handle; | 355 | struct GNUNET_NAMESTORE_Handle *namestore_handle; |
@@ -359,7 +362,7 @@ struct RequestHandle | |||
359 | /** | 362 | /** |
360 | * Attribute claim list | 363 | * Attribute claim list |
361 | */ | 364 | */ |
362 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attr_list; | 365 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list; |
363 | 366 | ||
364 | /** | 367 | /** |
365 | * IDENTITY Operation | 368 | * IDENTITY Operation |
@@ -369,27 +372,27 @@ struct RequestHandle | |||
369 | /** | 372 | /** |
370 | * Identity Provider | 373 | * Identity Provider |
371 | */ | 374 | */ |
372 | struct GNUNET_IDENTITY_PROVIDER_Handle *idp; | 375 | struct GNUNET_RECLAIM_Handle *idp; |
373 | 376 | ||
374 | /** | 377 | /** |
375 | * Idp Operation | 378 | * Idp Operation |
376 | */ | 379 | */ |
377 | struct GNUNET_IDENTITY_PROVIDER_Operation *idp_op; | 380 | struct GNUNET_RECLAIM_Operation *idp_op; |
378 | 381 | ||
379 | /** | 382 | /** |
380 | * Attribute iterator | 383 | * Attribute iterator |
381 | */ | 384 | */ |
382 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *attr_it; | 385 | struct GNUNET_RECLAIM_AttributeIterator *attr_it; |
383 | 386 | ||
384 | /** | 387 | /** |
385 | * Ticket iterator | 388 | * Ticket iterator |
386 | */ | 389 | */ |
387 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *ticket_it; | 390 | struct GNUNET_RECLAIM_TicketIterator *ticket_it; |
388 | 391 | ||
389 | /** | 392 | /** |
390 | * A ticket | 393 | * A ticket |
391 | */ | 394 | */ |
392 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 395 | struct GNUNET_RECLAIM_Ticket ticket; |
393 | 396 | ||
394 | /** | 397 | /** |
395 | * Desired timeout for the lookup (default is no timeout). | 398 | * Desired timeout for the lookup (default is no timeout). |
@@ -422,6 +425,16 @@ struct RequestHandle | |||
422 | char *tld; | 425 | char *tld; |
423 | 426 | ||
424 | /** | 427 | /** |
428 | * The redirect prefix | ||
429 | */ | ||
430 | char *redirect_prefix; | ||
431 | |||
432 | /** | ||
433 | * The redirect suffix | ||
434 | */ | ||
435 | char *redirect_suffix; | ||
436 | |||
437 | /** | ||
425 | * Error response message | 438 | * Error response message |
426 | */ | 439 | */ |
427 | char *emsg; | 440 | char *emsg; |
@@ -450,8 +463,8 @@ struct RequestHandle | |||
450 | static void | 463 | static void |
451 | cleanup_handle (struct RequestHandle *handle) | 464 | cleanup_handle (struct RequestHandle *handle) |
452 | { | 465 | { |
453 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *claim_entry; | 466 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry; |
454 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *claim_tmp; | 467 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp; |
455 | struct EgoEntry *ego_entry; | 468 | struct EgoEntry *ego_entry; |
456 | struct EgoEntry *ego_tmp; | 469 | struct EgoEntry *ego_tmp; |
457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 470 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -463,19 +476,28 @@ cleanup_handle (struct RequestHandle *handle) | |||
463 | if (NULL != handle->identity_handle) | 476 | if (NULL != handle->identity_handle) |
464 | GNUNET_IDENTITY_disconnect (handle->identity_handle); | 477 | GNUNET_IDENTITY_disconnect (handle->identity_handle); |
465 | if (NULL != handle->attr_it) | 478 | if (NULL != handle->attr_it) |
466 | GNUNET_IDENTITY_PROVIDER_get_attributes_stop (handle->attr_it); | 479 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); |
467 | if (NULL != handle->ticket_it) | 480 | if (NULL != handle->ticket_it) |
468 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (handle->ticket_it); | 481 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); |
469 | if (NULL != handle->idp) | 482 | if (NULL != handle->idp) |
470 | GNUNET_IDENTITY_PROVIDER_disconnect (handle->idp); | 483 | GNUNET_RECLAIM_disconnect (handle->idp); |
471 | if (NULL != handle->url) | 484 | if (NULL != handle->url) |
472 | GNUNET_free (handle->url); | 485 | GNUNET_free (handle->url); |
473 | if (NULL != handle->tld) | 486 | if (NULL != handle->tld) |
474 | GNUNET_free (handle->tld); | 487 | GNUNET_free (handle->tld); |
488 | if (NULL != handle->redirect_prefix) | ||
489 | GNUNET_free (handle->redirect_prefix); | ||
490 | if (NULL != handle->redirect_suffix) | ||
491 | GNUNET_free (handle->redirect_suffix); | ||
475 | if (NULL != handle->emsg) | 492 | if (NULL != handle->emsg) |
476 | GNUNET_free (handle->emsg); | 493 | GNUNET_free (handle->emsg); |
477 | if (NULL != handle->edesc) | 494 | if (NULL != handle->edesc) |
478 | GNUNET_free (handle->edesc); | 495 | GNUNET_free (handle->edesc); |
496 | if (NULL != handle->gns_op) | ||
497 | GNUNET_GNS_lookup_cancel (handle->gns_op); | ||
498 | if (NULL != handle->gns_handle) | ||
499 | GNUNET_GNS_disconnect (handle->gns_handle); | ||
500 | |||
479 | if (NULL != handle->namestore_handle) | 501 | if (NULL != handle->namestore_handle) |
480 | GNUNET_NAMESTORE_disconnect (handle->namestore_handle); | 502 | GNUNET_NAMESTORE_disconnect (handle->namestore_handle); |
481 | if (NULL != handle->oidc) | 503 | if (NULL != handle->oidc) |
@@ -732,6 +754,8 @@ cookie_identity_interpretation (struct RequestHandle *handle) | |||
732 | { | 754 | { |
733 | handle->oidc->login_identity = strtok(handle->oidc->login_identity, OIDC_COOKIE_HEADER_INFORMATION_KEY); | 755 | handle->oidc->login_identity = strtok(handle->oidc->login_identity, OIDC_COOKIE_HEADER_INFORMATION_KEY); |
734 | handle->oidc->login_identity = GNUNET_strdup(handle->oidc->login_identity); | 756 | handle->oidc->login_identity = GNUNET_strdup(handle->oidc->login_identity); |
757 | } else { | ||
758 | handle->oidc->login_identity = NULL; | ||
735 | } | 759 | } |
736 | } | 760 | } |
737 | else | 761 | else |
@@ -753,7 +777,7 @@ login_redirection(void *cls) | |||
753 | struct RequestHandle *handle = cls; | 777 | struct RequestHandle *handle = cls; |
754 | 778 | ||
755 | if ( GNUNET_OK | 779 | if ( GNUNET_OK |
756 | == GNUNET_CONFIGURATION_get_value_string (cfg, "identity-rest-plugin", | 780 | == GNUNET_CONFIGURATION_get_value_string (cfg, "reclaim-rest-plugin", |
757 | "address", &login_base_url) ) | 781 | "address", &login_base_url) ) |
758 | { | 782 | { |
759 | GNUNET_asprintf (&new_redirect, "%s?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s", | 783 | GNUNET_asprintf (&new_redirect, "%s?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s", |
@@ -799,11 +823,12 @@ oidc_iteration_error (void *cls) | |||
799 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 823 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
800 | } | 824 | } |
801 | 825 | ||
802 | static void get_client_name_result (void *cls, | 826 | static void |
803 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 827 | get_client_name_result (void *cls, |
804 | const char *label, | 828 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
805 | unsigned int rd_count, | 829 | const char *label, |
806 | const struct GNUNET_GNSRECORD_Data *rd) | 830 | unsigned int rd_count, |
831 | const struct GNUNET_GNSRECORD_Data *rd) | ||
807 | { | 832 | { |
808 | struct RequestHandle *handle = cls; | 833 | struct RequestHandle *handle = cls; |
809 | struct MHD_Response *resp; | 834 | struct MHD_Response *resp; |
@@ -811,46 +836,33 @@ static void get_client_name_result (void *cls, | |||
811 | char *redirect_uri; | 836 | char *redirect_uri; |
812 | char *code_json_string; | 837 | char *code_json_string; |
813 | char *code_base64_final_string; | 838 | char *code_base64_final_string; |
814 | char *redirect_path; | 839 | |
815 | char *tmp; | ||
816 | char *tmp_prefix; | ||
817 | char *prefix; | ||
818 | ticket_str = GNUNET_STRINGS_data_to_string_alloc (&handle->ticket, | 840 | ticket_str = GNUNET_STRINGS_data_to_string_alloc (&handle->ticket, |
819 | sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket)); | 841 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
820 | //TODO change if more attributes are needed (see max_age) | 842 | //TODO change if more attributes are needed (see max_age) |
821 | GNUNET_asprintf (&code_json_string, "{\"ticket\":\"%s\"%s%s%s}", | 843 | code_json_string = OIDC_build_authz_code (&handle->priv_key, |
822 | ticket_str, | 844 | &handle->ticket, |
823 | (NULL != handle->oidc->nonce) ? ", \"nonce\":\"" : "", | 845 | handle->oidc->nonce); |
824 | (NULL != handle->oidc->nonce) ? handle->oidc->nonce : "", | ||
825 | (NULL != handle->oidc->nonce) ? "\"" : ""); | ||
826 | code_base64_final_string = base_64_encode(code_json_string); | 846 | code_base64_final_string = base_64_encode(code_json_string); |
827 | tmp = GNUNET_strdup (handle->oidc->redirect_uri); | ||
828 | redirect_path = strtok (tmp, "/"); | ||
829 | redirect_path = strtok (NULL, "/"); | ||
830 | redirect_path = strtok (NULL, "/"); | ||
831 | tmp_prefix = GNUNET_strdup (handle->oidc->redirect_uri); | ||
832 | prefix = strrchr (tmp_prefix, | ||
833 | (unsigned char) '.'); | ||
834 | *prefix = '\0'; | ||
835 | GNUNET_asprintf (&redirect_uri, "%s.%s/%s?%s=%s&state=%s", | 847 | GNUNET_asprintf (&redirect_uri, "%s.%s/%s?%s=%s&state=%s", |
836 | tmp_prefix, | 848 | handle->redirect_prefix, |
837 | handle->tld, | 849 | handle->tld, |
838 | redirect_path, | 850 | handle->redirect_suffix, |
839 | handle->oidc->response_type, | 851 | handle->oidc->response_type, |
840 | code_base64_final_string, handle->oidc->state); | 852 | code_base64_final_string, handle->oidc->state); |
841 | resp = GNUNET_REST_create_response (""); | 853 | resp = GNUNET_REST_create_response (""); |
842 | MHD_add_response_header (resp, "Location", redirect_uri); | 854 | MHD_add_response_header (resp, "Location", redirect_uri); |
843 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 855 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
844 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 856 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); |
845 | GNUNET_free (tmp); | ||
846 | GNUNET_free (tmp_prefix); | ||
847 | GNUNET_free (redirect_uri); | 857 | GNUNET_free (redirect_uri); |
848 | GNUNET_free (ticket_str); | 858 | GNUNET_free (ticket_str); |
849 | GNUNET_free (code_json_string); | 859 | GNUNET_free (code_json_string); |
850 | GNUNET_free (code_base64_final_string); | 860 | GNUNET_free (code_base64_final_string); |
851 | return; | 861 | return; |
862 | |||
852 | } | 863 | } |
853 | 864 | ||
865 | |||
854 | static void | 866 | static void |
855 | get_client_name_error (void *cls) | 867 | get_client_name_error (void *cls) |
856 | { | 868 | { |
@@ -861,32 +873,93 @@ get_client_name_error (void *cls) | |||
861 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | 873 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); |
862 | } | 874 | } |
863 | 875 | ||
864 | /** | 876 | |
865 | * Issues ticket and redirects to relying party with the authorization code as | ||
866 | * parameter. Otherwise redirects with error | ||
867 | */ | ||
868 | static void | 877 | static void |
869 | oidc_ticket_issue_cb (void* cls, | 878 | lookup_redirect_uri_result (void *cls, |
870 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket) | 879 | uint32_t rd_count, |
880 | const struct GNUNET_GNSRECORD_Data *rd) | ||
871 | { | 881 | { |
872 | struct RequestHandle *handle = cls; | 882 | struct RequestHandle *handle = cls; |
873 | handle->idp_op = NULL; | 883 | char *tmp; |
874 | handle->ticket = *ticket; | 884 | char *tmp_key_str; |
875 | if (NULL != ticket) { | 885 | char *pos; |
886 | struct GNUNET_CRYPTO_EcdsaPublicKey redirect_zone; | ||
887 | |||
888 | handle->gns_op = NULL; | ||
889 | if (0 == rd_count) | ||
890 | { | ||
891 | handle->emsg = GNUNET_strdup("server_error"); | ||
892 | handle->edesc = GNUNET_strdup("Server cannot generate ticket, redirect uri not found."); | ||
893 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | ||
894 | return; | ||
895 | } | ||
896 | for (int i = 0; i < rd_count; i++) | ||
897 | { | ||
898 | if (GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT != rd[i].record_type) | ||
899 | continue; | ||
900 | if (0 != strcmp (rd[i].data, | ||
901 | handle->oidc->redirect_uri)) | ||
902 | continue; | ||
903 | tmp = GNUNET_strdup (rd[i].data); | ||
904 | pos = strrchr (tmp, | ||
905 | (unsigned char) '.'); | ||
906 | *pos = '\0'; | ||
907 | handle->redirect_prefix = GNUNET_strdup (tmp); | ||
908 | tmp_key_str = pos + 1; | ||
909 | pos = strchr (tmp_key_str, | ||
910 | (unsigned char) '/'); | ||
911 | *pos = '\0'; | ||
912 | handle->redirect_suffix = GNUNET_strdup (pos + 1); | ||
913 | |||
914 | GNUNET_STRINGS_string_to_data (tmp_key_str, | ||
915 | strlen (tmp_key_str), | ||
916 | &redirect_zone, | ||
917 | sizeof (redirect_zone)); | ||
918 | |||
876 | GNUNET_NAMESTORE_zone_to_name (handle->namestore_handle, | 919 | GNUNET_NAMESTORE_zone_to_name (handle->namestore_handle, |
877 | &handle->priv_key, | 920 | &handle->priv_key, |
878 | &handle->oidc->client_pkey, | 921 | &redirect_zone, |
879 | &get_client_name_error, | 922 | &get_client_name_error, |
880 | handle, | 923 | handle, |
881 | &get_client_name_result, | 924 | &get_client_name_result, |
882 | handle); | 925 | handle); |
926 | GNUNET_free (tmp); | ||
883 | return; | 927 | return; |
884 | } | 928 | } |
885 | handle->emsg = GNUNET_strdup("server_error"); | 929 | handle->emsg = GNUNET_strdup("server_error"); |
886 | handle->edesc = GNUNET_strdup("Server cannot generate ticket."); | 930 | handle->edesc = GNUNET_strdup("Server cannot generate ticket, redirect uri not found."); |
887 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | 931 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); |
888 | } | 932 | } |
889 | 933 | ||
934 | /** | ||
935 | * Issues ticket and redirects to relying party with the authorization code as | ||
936 | * parameter. Otherwise redirects with error | ||
937 | */ | ||
938 | static void | ||
939 | oidc_ticket_issue_cb (void* cls, | ||
940 | const struct GNUNET_RECLAIM_Ticket *ticket) | ||
941 | { | ||
942 | struct RequestHandle *handle = cls; | ||
943 | |||
944 | handle->idp_op = NULL; | ||
945 | handle->ticket = *ticket; | ||
946 | if (NULL == ticket) | ||
947 | { | ||
948 | handle->emsg = GNUNET_strdup("server_error"); | ||
949 | handle->edesc = GNUNET_strdup("Server cannot generate ticket."); | ||
950 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | ||
951 | return; | ||
952 | } | ||
953 | handle->gns_op = GNUNET_GNS_lookup (handle->gns_handle, | ||
954 | "+", | ||
955 | &handle->oidc->client_pkey, | ||
956 | GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT, | ||
957 | GNUNET_GNS_LO_DEFAULT, | ||
958 | &lookup_redirect_uri_result, | ||
959 | handle); | ||
960 | |||
961 | } | ||
962 | |||
890 | static void | 963 | static void |
891 | oidc_collect_finished_cb (void *cls) | 964 | oidc_collect_finished_cb (void *cls) |
892 | { | 965 | { |
@@ -900,12 +973,12 @@ oidc_collect_finished_cb (void *cls) | |||
900 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | 973 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); |
901 | return; | 974 | return; |
902 | } | 975 | } |
903 | handle->idp_op = GNUNET_IDENTITY_PROVIDER_ticket_issue (handle->idp, | 976 | handle->idp_op = GNUNET_RECLAIM_ticket_issue (handle->idp, |
904 | &handle->priv_key, | 977 | &handle->priv_key, |
905 | &handle->oidc->client_pkey, | 978 | &handle->oidc->client_pkey, |
906 | handle->attr_list, | 979 | handle->attr_list, |
907 | &oidc_ticket_issue_cb, | 980 | &oidc_ticket_issue_cb, |
908 | handle); | 981 | handle); |
909 | } | 982 | } |
910 | 983 | ||
911 | 984 | ||
@@ -915,17 +988,17 @@ oidc_collect_finished_cb (void *cls) | |||
915 | static void | 988 | static void |
916 | oidc_attr_collect (void *cls, | 989 | oidc_attr_collect (void *cls, |
917 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 990 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
918 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) | 991 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
919 | { | 992 | { |
920 | struct RequestHandle *handle = cls; | 993 | struct RequestHandle *handle = cls; |
921 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 994 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
922 | char* scope_variables; | 995 | char* scope_variables; |
923 | char* scope_variable; | 996 | char* scope_variable; |
924 | char delimiter[]=" "; | 997 | char delimiter[]=" "; |
925 | 998 | ||
926 | if ( (NULL == attr->name) || (NULL == attr->data) ) | 999 | if ( (NULL == attr->name) || (NULL == attr->data) ) |
927 | { | 1000 | { |
928 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (handle->attr_it); | 1001 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); |
929 | return; | 1002 | return; |
930 | } | 1003 | } |
931 | 1004 | ||
@@ -941,18 +1014,18 @@ oidc_attr_collect (void *cls, | |||
941 | } | 1014 | } |
942 | if ( NULL == scope_variable ) | 1015 | if ( NULL == scope_variable ) |
943 | { | 1016 | { |
944 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (handle->attr_it); | 1017 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); |
945 | GNUNET_free(scope_variables); | 1018 | GNUNET_free(scope_variables); |
946 | return; | 1019 | return; |
947 | } | 1020 | } |
948 | GNUNET_free(scope_variables); | 1021 | GNUNET_free(scope_variables); |
949 | 1022 | ||
950 | le = GNUNET_new(struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry); | 1023 | le = GNUNET_new(struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry); |
951 | le->claim = GNUNET_IDENTITY_ATTRIBUTE_claim_new (attr->name, attr->type, | 1024 | le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, attr->type, |
952 | attr->data, attr->data_size); | 1025 | attr->data, attr->data_size); |
953 | GNUNET_CONTAINER_DLL_insert(handle->attr_list->list_head, | 1026 | GNUNET_CONTAINER_DLL_insert(handle->attr_list->list_head, |
954 | handle->attr_list->list_tail, le); | 1027 | handle->attr_list->list_tail, le); |
955 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (handle->attr_it); | 1028 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); |
956 | } | 1029 | } |
957 | 1030 | ||
958 | 1031 | ||
@@ -1005,88 +1078,33 @@ login_check (void *cls) | |||
1005 | handle->priv_key = *GNUNET_IDENTITY_ego_get_private_key ( | 1078 | handle->priv_key = *GNUNET_IDENTITY_ego_get_private_key ( |
1006 | handle->ego_entry->ego); | 1079 | handle->ego_entry->ego); |
1007 | handle->resp_object = GNUNET_JSONAPI_document_new (); | 1080 | handle->resp_object = GNUNET_JSONAPI_document_new (); |
1008 | handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg); | 1081 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
1009 | handle->attr_list = GNUNET_new( | 1082 | handle->attr_list = GNUNET_new( |
1010 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); | 1083 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
1011 | handle->attr_it = GNUNET_IDENTITY_PROVIDER_get_attributes_start ( | 1084 | handle->attr_it = GNUNET_RECLAIM_get_attributes_start ( |
1012 | handle->idp, &handle->priv_key, &oidc_iteration_error, handle, | 1085 | handle->idp, &handle->priv_key, &oidc_iteration_error, handle, |
1013 | &oidc_attr_collect, handle, &oidc_collect_finished_cb, handle); | 1086 | &oidc_attr_collect, handle, &oidc_collect_finished_cb, handle); |
1014 | return; | 1087 | return; |
1015 | } | 1088 | } |
1016 | } | 1089 | } |
1017 | handle->emsg = GNUNET_strdup("invalid_cookie"); | 1090 | //handle->emsg = GNUNET_strdup("invalid_cookie"); |
1018 | handle->edesc = GNUNET_strdup( | 1091 | //handle->edesc = GNUNET_strdup( |
1019 | "The cookie of the login identity is not valid"); | 1092 | // "The cookie of the login identity is not valid"); |
1020 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | 1093 | //GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); |
1094 | GNUNET_SCHEDULER_add_now (&login_redirection,handle); | ||
1021 | return; | 1095 | return; |
1022 | } | 1096 | } |
1023 | } | 1097 | } |
1024 | } | 1098 | } |
1025 | 1099 | ||
1026 | /** | 1100 | /** |
1027 | * Searches for client_id in namestore. If found trust status stored in handle | ||
1028 | * Else continues to search | ||
1029 | * | ||
1030 | * @param handle the RequestHandle | ||
1031 | */ | ||
1032 | static void | ||
1033 | namestore_iteration_callback ( | ||
1034 | void *cls, const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key, | ||
1035 | const char *rname, unsigned int rd_len, | ||
1036 | const struct GNUNET_GNSRECORD_Data *rd) | ||
1037 | { | ||
1038 | struct RequestHandle *handle = cls; | ||
1039 | struct GNUNET_CRYPTO_EcdsaPublicKey login_identity_pkey; | ||
1040 | struct GNUNET_CRYPTO_EcdsaPublicKey current_zone_pkey; | ||
1041 | int i; | ||
1042 | |||
1043 | for (i = 0; i < rd_len; i++) | ||
1044 | { | ||
1045 | if ( GNUNET_GNSRECORD_TYPE_PKEY != rd[i].record_type ) | ||
1046 | continue; | ||
1047 | |||
1048 | if ( NULL != handle->oidc->login_identity ) | ||
1049 | { | ||
1050 | GNUNET_CRYPTO_ecdsa_public_key_from_string ( | ||
1051 | handle->oidc->login_identity, | ||
1052 | strlen (handle->oidc->login_identity), | ||
1053 | &login_identity_pkey); | ||
1054 | GNUNET_IDENTITY_ego_get_public_key (handle->ego_entry->ego, | ||
1055 | ¤t_zone_pkey); | ||
1056 | |||
1057 | if ( 0 == memcmp (rd[i].data, &handle->oidc->client_pkey, | ||
1058 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) ) | ||
1059 | { | ||
1060 | if ( 0 == memcmp (&login_identity_pkey, ¤t_zone_pkey, | ||
1061 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) ) | ||
1062 | { | ||
1063 | handle->oidc->is_client_trusted = GNUNET_YES; | ||
1064 | } | ||
1065 | } | ||
1066 | } | ||
1067 | else | ||
1068 | { | ||
1069 | if ( 0 == memcmp (rd[i].data, &handle->oidc->client_pkey, | ||
1070 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) ) | ||
1071 | { | ||
1072 | handle->oidc->is_client_trusted = GNUNET_YES; | ||
1073 | } | ||
1074 | } | ||
1075 | } | ||
1076 | |||
1077 | GNUNET_NAMESTORE_zone_iterator_next (handle->namestore_handle_it, | ||
1078 | 1); | ||
1079 | } | ||
1080 | |||
1081 | |||
1082 | /** | ||
1083 | * Iteration over all results finished, build final | 1101 | * Iteration over all results finished, build final |
1084 | * response. | 1102 | * response. |
1085 | * | 1103 | * |
1086 | * @param cls the `struct RequestHandle` | 1104 | * @param cls the `struct RequestHandle` |
1087 | */ | 1105 | */ |
1088 | static void | 1106 | static void |
1089 | namestore_iteration_finished (void *cls) | 1107 | build_authz_response (void *cls) |
1090 | { | 1108 | { |
1091 | struct RequestHandle *handle = cls; | 1109 | struct RequestHandle *handle = cls; |
1092 | struct GNUNET_HashCode cache_key; | 1110 | struct GNUNET_HashCode cache_key; |
@@ -1096,25 +1114,6 @@ namestore_iteration_finished (void *cls) | |||
1096 | int number_of_ignored_parameter, iterator; | 1114 | int number_of_ignored_parameter, iterator; |
1097 | 1115 | ||
1098 | 1116 | ||
1099 | handle->ego_entry = handle->ego_entry->next; | ||
1100 | |||
1101 | if(NULL != handle->ego_entry) | ||
1102 | { | ||
1103 | handle->priv_key = *GNUNET_IDENTITY_ego_get_private_key (handle->ego_entry->ego); | ||
1104 | handle->namestore_handle_it = GNUNET_NAMESTORE_zone_iteration_start (handle->namestore_handle, &handle->priv_key, | ||
1105 | &oidc_iteration_error, handle, &namestore_iteration_callback, handle, | ||
1106 | &namestore_iteration_finished, handle); | ||
1107 | return; | ||
1108 | } | ||
1109 | if (GNUNET_NO == handle->oidc->is_client_trusted) | ||
1110 | { | ||
1111 | handle->emsg = GNUNET_strdup("unauthorized_client"); | ||
1112 | handle->edesc = GNUNET_strdup("The client is not authorized to request an " | ||
1113 | "authorization code using this method."); | ||
1114 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
1115 | return; | ||
1116 | } | ||
1117 | |||
1118 | // REQUIRED value: redirect_uri | 1117 | // REQUIRED value: redirect_uri |
1119 | GNUNET_CRYPTO_hash (OIDC_REDIRECT_URI_KEY, strlen (OIDC_REDIRECT_URI_KEY), | 1118 | GNUNET_CRYPTO_hash (OIDC_REDIRECT_URI_KEY, strlen (OIDC_REDIRECT_URI_KEY), |
1120 | &cache_key); | 1119 | &cache_key); |
@@ -1244,8 +1243,8 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1244 | struct RequestHandle *handle = cls; | 1243 | struct RequestHandle *handle = cls; |
1245 | struct GNUNET_HashCode cache_key; | 1244 | struct GNUNET_HashCode cache_key; |
1246 | struct EgoEntry *tmp_ego; | 1245 | struct EgoEntry *tmp_ego; |
1247 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | ||
1248 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; | 1246 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key; |
1247 | struct GNUNET_CRYPTO_EcdsaPublicKey pkey; | ||
1249 | 1248 | ||
1250 | cookie_identity_interpretation(handle); | 1249 | cookie_identity_interpretation(handle); |
1251 | 1250 | ||
@@ -1299,9 +1298,8 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1299 | 1298 | ||
1300 | handle->ego_entry = handle->ego_head; | 1299 | handle->ego_entry = handle->ego_head; |
1301 | handle->priv_key = *GNUNET_IDENTITY_ego_get_private_key (handle->ego_head->ego); | 1300 | handle->priv_key = *GNUNET_IDENTITY_ego_get_private_key (handle->ego_head->ego); |
1302 | handle->oidc->is_client_trusted = GNUNET_NO; | 1301 | //If we know this identity, translated the corresponding TLD |
1303 | 1302 | //TODO: We might want to have a reverse lookup functionality for TLDs? | |
1304 | //First check if client_id is one of our egos; TODO: handle other TLD cases: Delegation, from config | ||
1305 | for (tmp_ego = handle->ego_head; NULL != tmp_ego; tmp_ego = tmp_ego->next) | 1303 | for (tmp_ego = handle->ego_head; NULL != tmp_ego; tmp_ego = tmp_ego->next) |
1306 | { | 1304 | { |
1307 | priv_key = GNUNET_IDENTITY_ego_get_private_key (tmp_ego->ego); | 1305 | priv_key = GNUNET_IDENTITY_ego_get_private_key (tmp_ego->ego); |
@@ -1311,17 +1309,10 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1311 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) ) | 1309 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) ) |
1312 | { | 1310 | { |
1313 | handle->tld = GNUNET_strdup (tmp_ego->identifier); | 1311 | handle->tld = GNUNET_strdup (tmp_ego->identifier); |
1314 | handle->oidc->is_client_trusted = GNUNET_YES; | ||
1315 | handle->ego_entry = handle->ego_tail; | 1312 | handle->ego_entry = handle->ego_tail; |
1316 | } | 1313 | } |
1317 | } | 1314 | } |
1318 | 1315 | GNUNET_SCHEDULER_add_now (&build_authz_response, handle); | |
1319 | |||
1320 | // Checks if client_id is valid: | ||
1321 | handle->namestore_handle_it = GNUNET_NAMESTORE_zone_iteration_start ( | ||
1322 | handle->namestore_handle, &handle->priv_key, &oidc_iteration_error, | ||
1323 | handle, &namestore_iteration_callback, handle, | ||
1324 | &namestore_iteration_finished, handle); | ||
1325 | } | 1316 | } |
1326 | 1317 | ||
1327 | /** | 1318 | /** |
@@ -1359,8 +1350,8 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1359 | 1350 | ||
1360 | current_time = GNUNET_new(struct GNUNET_TIME_Absolute); | 1351 | current_time = GNUNET_new(struct GNUNET_TIME_Absolute); |
1361 | *current_time = GNUNET_TIME_relative_to_absolute ( | 1352 | *current_time = GNUNET_TIME_relative_to_absolute ( |
1362 | GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_get_minute_ (), | 1353 | GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_get_second_ (), |
1363 | 30)); | 1354 | 5)); |
1364 | last_time = GNUNET_CONTAINER_multihashmap_get(OIDC_identity_login_time, &cache_key); | 1355 | last_time = GNUNET_CONTAINER_multihashmap_get(OIDC_identity_login_time, &cache_key); |
1365 | if (NULL != last_time) | 1356 | if (NULL != last_time) |
1366 | { | 1357 | { |
@@ -1382,37 +1373,19 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1382 | return; | 1373 | return; |
1383 | } | 1374 | } |
1384 | 1375 | ||
1385 | /** | 1376 | static int |
1386 | * Responds to token url-encoded POST request | 1377 | check_authorization (struct RequestHandle *handle, |
1387 | * | 1378 | struct GNUNET_CRYPTO_EcdsaPublicKey *cid) |
1388 | * @param con_handle the connection handle | ||
1389 | * @param url the url | ||
1390 | * @param cls the RequestHandle | ||
1391 | */ | ||
1392 | static void | ||
1393 | token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | ||
1394 | const char* url, | ||
1395 | void *cls) | ||
1396 | { | 1379 | { |
1397 | //TODO static strings | ||
1398 | struct RequestHandle *handle = cls; | ||
1399 | struct GNUNET_HashCode cache_key; | 1380 | struct GNUNET_HashCode cache_key; |
1400 | char *authorization, *credentials; | 1381 | char *authorization; |
1401 | char delimiter[]=" "; | 1382 | char *credentials; |
1402 | char delimiter_user_psw[]=":"; | 1383 | char *basic_authorization; |
1403 | char *grant_type, *code; | 1384 | char *client_id; |
1404 | char *user_psw = NULL, *client_id, *psw; | 1385 | char *pass; |
1405 | char *expected_psw; | 1386 | char *expected_pass; |
1406 | int client_exists = GNUNET_NO; | 1387 | int client_exists = GNUNET_NO; |
1407 | struct MHD_Response *resp; | ||
1408 | char* code_output; | ||
1409 | json_t *root, *ticket_string, *nonce, *max_age; | ||
1410 | json_error_t error; | ||
1411 | char *json_response; | ||
1412 | 1388 | ||
1413 | /* | ||
1414 | * Check Authorization | ||
1415 | */ | ||
1416 | GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, | 1389 | GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, |
1417 | strlen (OIDC_AUTHORIZATION_HEADER_KEY), | 1390 | strlen (OIDC_AUTHORIZATION_HEADER_KEY), |
1418 | &cache_key); | 1391 | &cache_key); |
@@ -1422,80 +1395,75 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1422 | handle->emsg=GNUNET_strdup("invalid_client"); | 1395 | handle->emsg=GNUNET_strdup("invalid_client"); |
1423 | handle->edesc=GNUNET_strdup("missing authorization"); | 1396 | handle->edesc=GNUNET_strdup("missing authorization"); |
1424 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1397 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1425 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1398 | return GNUNET_SYSERR; |
1426 | return; | ||
1427 | } | 1399 | } |
1428 | authorization = GNUNET_CONTAINER_multihashmap_get ( handle->rest_handle->header_param_map, &cache_key); | 1400 | authorization = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->header_param_map, |
1401 | &cache_key); | ||
1429 | 1402 | ||
1430 | //split header in "Basic" and [content] | 1403 | //split header in "Basic" and [content] |
1431 | credentials = strtok (authorization, delimiter); | 1404 | credentials = strtok (authorization, " "); |
1432 | if (0 != strcmp ("Basic",credentials)) | 1405 | if (0 != strcmp ("Basic", credentials)) |
1433 | { | 1406 | { |
1434 | handle->emsg=GNUNET_strdup("invalid_client"); | 1407 | handle->emsg=GNUNET_strdup("invalid_client"); |
1435 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1408 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1436 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1409 | return GNUNET_SYSERR; |
1437 | return; | ||
1438 | } | 1410 | } |
1439 | credentials = strtok(NULL, delimiter); | 1411 | credentials = strtok(NULL, " "); |
1440 | if (NULL == credentials) | 1412 | if (NULL == credentials) |
1441 | { | 1413 | { |
1442 | handle->emsg=GNUNET_strdup("invalid_client"); | 1414 | handle->emsg=GNUNET_strdup("invalid_client"); |
1443 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1415 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1444 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1416 | return GNUNET_SYSERR; |
1445 | return; | ||
1446 | } | 1417 | } |
1447 | GNUNET_STRINGS_base64_decode (credentials, strlen (credentials), &user_psw); | 1418 | GNUNET_STRINGS_base64_decode (credentials, |
1419 | strlen (credentials), | ||
1420 | (void**)&basic_authorization); | ||
1448 | 1421 | ||
1449 | if ( NULL == user_psw ) | 1422 | if ( NULL == basic_authorization ) |
1450 | { | 1423 | { |
1451 | handle->emsg=GNUNET_strdup("invalid_client"); | 1424 | handle->emsg=GNUNET_strdup("invalid_client"); |
1452 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1425 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1453 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1426 | return GNUNET_SYSERR; |
1454 | return; | ||
1455 | } | 1427 | } |
1456 | client_id = strtok (user_psw, delimiter_user_psw); | 1428 | client_id = strtok (basic_authorization, ":"); |
1457 | if ( NULL == client_id ) | 1429 | if ( NULL == client_id ) |
1458 | { | 1430 | { |
1459 | GNUNET_free_non_null(user_psw); | 1431 | GNUNET_free_non_null(basic_authorization); |
1460 | handle->emsg=GNUNET_strdup("invalid_client"); | 1432 | handle->emsg=GNUNET_strdup("invalid_client"); |
1461 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1433 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1462 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1434 | return GNUNET_SYSERR; |
1463 | return; | ||
1464 | } | 1435 | } |
1465 | psw = strtok (NULL, delimiter_user_psw); | 1436 | pass = strtok (NULL, ":"); |
1466 | if (NULL == psw) | 1437 | if (NULL == pass) |
1467 | { | 1438 | { |
1468 | GNUNET_free_non_null(user_psw); | 1439 | GNUNET_free_non_null(basic_authorization); |
1469 | handle->emsg=GNUNET_strdup("invalid_client"); | 1440 | handle->emsg=GNUNET_strdup("invalid_client"); |
1470 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1441 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1471 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1442 | return GNUNET_SYSERR; |
1472 | return; | ||
1473 | } | 1443 | } |
1474 | 1444 | ||
1475 | //check client password | 1445 | //check client password |
1476 | if ( GNUNET_OK | 1446 | if ( GNUNET_OK |
1477 | == GNUNET_CONFIGURATION_get_value_string (cfg, "identity-rest-plugin", | 1447 | == GNUNET_CONFIGURATION_get_value_string (cfg, "reclaim-rest-plugin", |
1478 | "psw", &expected_psw) ) | 1448 | "psw", &expected_pass) ) |
1479 | { | 1449 | { |
1480 | if (0 != strcmp (expected_psw, psw)) | 1450 | if (0 != strcmp (expected_pass, pass)) |
1481 | { | 1451 | { |
1482 | GNUNET_free_non_null(user_psw); | 1452 | GNUNET_free_non_null(basic_authorization); |
1483 | GNUNET_free(expected_psw); | 1453 | GNUNET_free(expected_pass); |
1484 | handle->emsg=GNUNET_strdup("invalid_client"); | 1454 | handle->emsg=GNUNET_strdup("invalid_client"); |
1485 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1455 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1486 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1456 | return GNUNET_SYSERR; |
1487 | return; | ||
1488 | } | 1457 | } |
1489 | GNUNET_free(expected_psw); | 1458 | GNUNET_free(expected_pass); |
1490 | } | 1459 | } |
1491 | else | 1460 | else |
1492 | { | 1461 | { |
1493 | GNUNET_free_non_null(user_psw); | 1462 | GNUNET_free_non_null(basic_authorization); |
1494 | handle->emsg = GNUNET_strdup("server_error"); | 1463 | handle->emsg = GNUNET_strdup("server_error"); |
1495 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); | 1464 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); |
1496 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | 1465 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; |
1497 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1466 | return GNUNET_SYSERR; |
1498 | return; | ||
1499 | } | 1467 | } |
1500 | 1468 | ||
1501 | //check client_id | 1469 | //check client_id |
@@ -1510,9 +1478,107 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1510 | } | 1478 | } |
1511 | if (GNUNET_NO == client_exists) | 1479 | if (GNUNET_NO == client_exists) |
1512 | { | 1480 | { |
1513 | GNUNET_free_non_null(user_psw); | 1481 | GNUNET_free_non_null(basic_authorization); |
1514 | handle->emsg=GNUNET_strdup("invalid_client"); | 1482 | handle->emsg=GNUNET_strdup("invalid_client"); |
1515 | handle->response_code = MHD_HTTP_UNAUTHORIZED; | 1483 | handle->response_code = MHD_HTTP_UNAUTHORIZED; |
1484 | return GNUNET_SYSERR; | ||
1485 | } | ||
1486 | GNUNET_STRINGS_string_to_data (client_id, | ||
1487 | strlen(client_id), | ||
1488 | cid, | ||
1489 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
1490 | |||
1491 | GNUNET_free (basic_authorization); | ||
1492 | return GNUNET_OK; | ||
1493 | } | ||
1494 | |||
1495 | static int | ||
1496 | ego_exists (struct RequestHandle *handle, | ||
1497 | struct GNUNET_CRYPTO_EcdsaPublicKey *test_key) | ||
1498 | { | ||
1499 | struct EgoEntry *ego_entry; | ||
1500 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; | ||
1501 | |||
1502 | for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | ||
1503 | { | ||
1504 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &pub_key); | ||
1505 | if (0 == memcmp (&pub_key, | ||
1506 | test_key, | ||
1507 | sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
1508 | { | ||
1509 | break; | ||
1510 | } | ||
1511 | } | ||
1512 | if (NULL == ego_entry) | ||
1513 | return GNUNET_NO; | ||
1514 | return GNUNET_YES; | ||
1515 | } | ||
1516 | |||
1517 | static void | ||
1518 | store_ticket_reference (const struct RequestHandle *handle, | ||
1519 | const char* access_token, | ||
1520 | const struct GNUNET_RECLAIM_Ticket *ticket, | ||
1521 | const struct GNUNET_CRYPTO_EcdsaPublicKey *cid) | ||
1522 | { | ||
1523 | struct GNUNET_HashCode cache_key; | ||
1524 | char *id_ticket_combination; | ||
1525 | char *ticket_string; | ||
1526 | char *client_id; | ||
1527 | |||
1528 | GNUNET_CRYPTO_hash(access_token, strlen(access_token), &cache_key); | ||
1529 | client_id = GNUNET_STRINGS_data_to_string_alloc (cid, | ||
1530 | sizeof (struct GNUNET_CRYPTO_EcdsaPublicKey)); | ||
1531 | ticket_string = GNUNET_STRINGS_data_to_string_alloc (ticket, | ||
1532 | sizeof (struct GNUNET_RECLAIM_Ticket)); | ||
1533 | GNUNET_asprintf(&id_ticket_combination, | ||
1534 | "%s;%s", | ||
1535 | client_id, | ||
1536 | ticket_string); | ||
1537 | GNUNET_CONTAINER_multihashmap_put(OIDC_interpret_access_token, | ||
1538 | &cache_key, | ||
1539 | id_ticket_combination, | ||
1540 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | ||
1541 | |||
1542 | GNUNET_free (client_id); | ||
1543 | GNUNET_free (ticket_string); | ||
1544 | } | ||
1545 | |||
1546 | /** | ||
1547 | * Responds to token url-encoded POST request | ||
1548 | * | ||
1549 | * @param con_handle the connection handle | ||
1550 | * @param url the url | ||
1551 | * @param cls the RequestHandle | ||
1552 | */ | ||
1553 | static void | ||
1554 | token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | ||
1555 | const char* url, | ||
1556 | void *cls) | ||
1557 | { | ||
1558 | struct RequestHandle *handle = cls; | ||
1559 | struct GNUNET_TIME_Relative expiration_time; | ||
1560 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *cl; | ||
1561 | struct GNUNET_RECLAIM_Ticket *ticket; | ||
1562 | struct GNUNET_CRYPTO_EcdsaPublicKey cid; | ||
1563 | struct GNUNET_HashCode cache_key; | ||
1564 | struct MHD_Response *resp; | ||
1565 | char *grant_type; | ||
1566 | char *code; | ||
1567 | char *json_response; | ||
1568 | char *id_token; | ||
1569 | char *access_token; | ||
1570 | char *jwt_secret; | ||
1571 | char *nonce; | ||
1572 | int i = 1; | ||
1573 | |||
1574 | /* | ||
1575 | * Check Authorization | ||
1576 | */ | ||
1577 | if (GNUNET_SYSERR == check_authorization (handle, | ||
1578 | &cid)) | ||
1579 | { | ||
1580 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
1581 | "OIDC authorization for token endpoint failed\n"); | ||
1516 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1582 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1517 | return; | 1583 | return; |
1518 | } | 1584 | } |
@@ -1524,27 +1590,25 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1524 | //TODO Do not allow multiple equal parameter names | 1590 | //TODO Do not allow multiple equal parameter names |
1525 | //REQUIRED grant_type | 1591 | //REQUIRED grant_type |
1526 | GNUNET_CRYPTO_hash (OIDC_GRANT_TYPE_KEY, strlen (OIDC_GRANT_TYPE_KEY), &cache_key); | 1592 | GNUNET_CRYPTO_hash (OIDC_GRANT_TYPE_KEY, strlen (OIDC_GRANT_TYPE_KEY), &cache_key); |
1527 | if ( GNUNET_NO | 1593 | if (GNUNET_NO == |
1528 | == GNUNET_CONTAINER_multihashmap_contains ( | 1594 | GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle->url_param_map, |
1529 | handle->rest_handle->url_param_map, &cache_key) ) | 1595 | &cache_key)) |
1530 | { | 1596 | { |
1531 | GNUNET_free_non_null(user_psw); | ||
1532 | handle->emsg = GNUNET_strdup("invalid_request"); | 1597 | handle->emsg = GNUNET_strdup("invalid_request"); |
1533 | handle->edesc = GNUNET_strdup("missing parameter grant_type"); | 1598 | handle->edesc = GNUNET_strdup("missing parameter grant_type"); |
1534 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 1599 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
1535 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1600 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1536 | return; | 1601 | return; |
1537 | } | 1602 | } |
1538 | grant_type = GNUNET_CONTAINER_multihashmap_get ( | 1603 | grant_type = GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map, |
1539 | handle->rest_handle->url_param_map, &cache_key); | 1604 | &cache_key); |
1540 | 1605 | ||
1541 | //REQUIRED code | 1606 | //REQUIRED code |
1542 | GNUNET_CRYPTO_hash (OIDC_CODE_KEY, strlen (OIDC_CODE_KEY), &cache_key); | 1607 | GNUNET_CRYPTO_hash (OIDC_CODE_KEY, strlen (OIDC_CODE_KEY), &cache_key); |
1543 | if ( GNUNET_NO | 1608 | if (GNUNET_NO == |
1544 | == GNUNET_CONTAINER_multihashmap_contains ( | 1609 | GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle->url_param_map, |
1545 | handle->rest_handle->url_param_map, &cache_key) ) | 1610 | &cache_key)) |
1546 | { | 1611 | { |
1547 | GNUNET_free_non_null(user_psw); | ||
1548 | handle->emsg = GNUNET_strdup("invalid_request"); | 1612 | handle->emsg = GNUNET_strdup("invalid_request"); |
1549 | handle->edesc = GNUNET_strdup("missing parameter code"); | 1613 | handle->edesc = GNUNET_strdup("missing parameter code"); |
1550 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 1614 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
@@ -1557,11 +1621,10 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1557 | //REQUIRED redirect_uri | 1621 | //REQUIRED redirect_uri |
1558 | GNUNET_CRYPTO_hash (OIDC_REDIRECT_URI_KEY, strlen (OIDC_REDIRECT_URI_KEY), | 1622 | GNUNET_CRYPTO_hash (OIDC_REDIRECT_URI_KEY, strlen (OIDC_REDIRECT_URI_KEY), |
1559 | &cache_key); | 1623 | &cache_key); |
1560 | if ( GNUNET_NO | 1624 | if (GNUNET_NO == |
1561 | == GNUNET_CONTAINER_multihashmap_contains ( | 1625 | GNUNET_CONTAINER_multihashmap_contains (handle->rest_handle->url_param_map, |
1562 | handle->rest_handle->url_param_map, &cache_key) ) | 1626 | &cache_key) ) |
1563 | { | 1627 | { |
1564 | GNUNET_free_non_null(user_psw); | ||
1565 | handle->emsg = GNUNET_strdup("invalid_request"); | 1628 | handle->emsg = GNUNET_strdup("invalid_request"); |
1566 | handle->edesc = GNUNET_strdup("missing parameter redirect_uri"); | 1629 | handle->edesc = GNUNET_strdup("missing parameter redirect_uri"); |
1567 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 1630 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
@@ -1572,21 +1635,18 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1572 | //Check parameter grant_type == "authorization_code" | 1635 | //Check parameter grant_type == "authorization_code" |
1573 | if (0 != strcmp(OIDC_GRANT_TYPE_VALUE, grant_type)) | 1636 | if (0 != strcmp(OIDC_GRANT_TYPE_VALUE, grant_type)) |
1574 | { | 1637 | { |
1575 | GNUNET_free_non_null(user_psw); | ||
1576 | handle->emsg=GNUNET_strdup("unsupported_grant_type"); | 1638 | handle->emsg=GNUNET_strdup("unsupported_grant_type"); |
1577 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 1639 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
1578 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1640 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1579 | return; | 1641 | return; |
1580 | } | 1642 | } |
1581 | GNUNET_CRYPTO_hash (code, strlen (code), &cache_key); | 1643 | GNUNET_CRYPTO_hash (code, strlen (code), &cache_key); |
1582 | int i = 1; | 1644 | if (GNUNET_SYSERR == |
1583 | if ( GNUNET_SYSERR | 1645 | GNUNET_CONTAINER_multihashmap_put (OIDC_ticket_once, |
1584 | == GNUNET_CONTAINER_multihashmap_put (OIDC_ticket_once, | 1646 | &cache_key, |
1585 | &cache_key, | 1647 | &i, |
1586 | &i, | 1648 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) ) |
1587 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY) ) | ||
1588 | { | 1649 | { |
1589 | GNUNET_free_non_null(user_psw); | ||
1590 | handle->emsg = GNUNET_strdup("invalid_request"); | 1650 | handle->emsg = GNUNET_strdup("invalid_request"); |
1591 | handle->edesc = GNUNET_strdup("Cannot use the same code more than once"); | 1651 | handle->edesc = GNUNET_strdup("Cannot use the same code more than once"); |
1592 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 1652 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
@@ -1595,16 +1655,11 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1595 | } | 1655 | } |
1596 | 1656 | ||
1597 | //decode code | 1657 | //decode code |
1598 | GNUNET_STRINGS_base64_decode(code,strlen(code),&code_output); | 1658 | if(GNUNET_OK != OIDC_parse_authz_code (&cid, |
1599 | root = json_loads (code_output, 0, &error); | 1659 | code, |
1600 | GNUNET_free(code_output); | 1660 | &ticket, |
1601 | ticket_string = json_object_get (root, "ticket"); | 1661 | &nonce)) |
1602 | nonce = json_object_get (root, "nonce"); | ||
1603 | max_age = json_object_get (root, "max_age"); | ||
1604 | |||
1605 | if(ticket_string == NULL && !json_is_string(ticket_string)) | ||
1606 | { | 1662 | { |
1607 | GNUNET_free_non_null(user_psw); | ||
1608 | handle->emsg = GNUNET_strdup("invalid_request"); | 1663 | handle->emsg = GNUNET_strdup("invalid_request"); |
1609 | handle->edesc = GNUNET_strdup("invalid code"); | 1664 | handle->edesc = GNUNET_strdup("invalid code"); |
1610 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 1665 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
@@ -1612,42 +1667,13 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1612 | return; | 1667 | return; |
1613 | } | 1668 | } |
1614 | 1669 | ||
1615 | struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket = GNUNET_new(struct GNUNET_IDENTITY_PROVIDER_Ticket); | ||
1616 | if ( GNUNET_OK | ||
1617 | != GNUNET_STRINGS_string_to_data (json_string_value(ticket_string), | ||
1618 | strlen (json_string_value(ticket_string)), | ||
1619 | ticket, | ||
1620 | sizeof(struct GNUNET_IDENTITY_PROVIDER_Ticket))) | ||
1621 | { | ||
1622 | GNUNET_free_non_null(user_psw); | ||
1623 | handle->emsg = GNUNET_strdup("invalid_request"); | ||
1624 | handle->edesc = GNUNET_strdup("invalid code"); | ||
1625 | handle->response_code = MHD_HTTP_BAD_REQUEST; | ||
1626 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
1627 | GNUNET_free(ticket); | ||
1628 | return; | ||
1629 | } | ||
1630 | // this is the current client (relying party) | ||
1631 | struct GNUNET_CRYPTO_EcdsaPublicKey pub_key; | ||
1632 | GNUNET_IDENTITY_ego_get_public_key(handle->ego_entry->ego,&pub_key); | ||
1633 | if (0 != memcmp(&pub_key,&ticket->audience,sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) | ||
1634 | { | ||
1635 | GNUNET_free_non_null(user_psw); | ||
1636 | handle->emsg = GNUNET_strdup("invalid_request"); | ||
1637 | handle->edesc = GNUNET_strdup("invalid code"); | ||
1638 | handle->response_code = MHD_HTTP_BAD_REQUEST; | ||
1639 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
1640 | GNUNET_free(ticket); | ||
1641 | return; | ||
1642 | } | ||
1643 | |||
1644 | //create jwt | 1670 | //create jwt |
1645 | unsigned long long int expiration_time; | 1671 | if (GNUNET_OK != |
1646 | if ( GNUNET_OK | 1672 | GNUNET_CONFIGURATION_get_value_time(cfg, |
1647 | != GNUNET_CONFIGURATION_get_value_number(cfg, "identity-rest-plugin", | 1673 | "reclaim-rest-plugin", |
1648 | "expiration_time", &expiration_time) ) | 1674 | "expiration_time", |
1675 | &expiration_time)) | ||
1649 | { | 1676 | { |
1650 | GNUNET_free_non_null(user_psw); | ||
1651 | handle->emsg = GNUNET_strdup("server_error"); | 1677 | handle->emsg = GNUNET_strdup("server_error"); |
1652 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); | 1678 | handle->edesc = GNUNET_strdup ("gnunet configuration failed"); |
1653 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; | 1679 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; |
@@ -1656,118 +1682,56 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1656 | return; | 1682 | return; |
1657 | } | 1683 | } |
1658 | 1684 | ||
1659 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *cl = GNUNET_new (struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList); | ||
1660 | //aud REQUIRED public key client_id must be there | ||
1661 | GNUNET_IDENTITY_ATTRIBUTE_list_add(cl, | ||
1662 | "aud", | ||
1663 | GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, | ||
1664 | client_id, | ||
1665 | strlen(client_id)); | ||
1666 | //exp REQUIRED time expired from config | ||
1667 | struct GNUNET_TIME_Absolute exp_time = GNUNET_TIME_relative_to_absolute ( | ||
1668 | GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_get_second_ (), | ||
1669 | expiration_time)); | ||
1670 | const char* exp_time_string = GNUNET_STRINGS_absolute_time_to_string(exp_time); | ||
1671 | GNUNET_IDENTITY_ATTRIBUTE_list_add (cl, | ||
1672 | "exp", | ||
1673 | GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, | ||
1674 | exp_time_string, | ||
1675 | strlen(exp_time_string)); | ||
1676 | //iat REQUIRED time now | ||
1677 | struct GNUNET_TIME_Absolute time_now = GNUNET_TIME_absolute_get(); | ||
1678 | const char* time_now_string = GNUNET_STRINGS_absolute_time_to_string(time_now); | ||
1679 | GNUNET_IDENTITY_ATTRIBUTE_list_add (cl, | ||
1680 | "iat", | ||
1681 | GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, | ||
1682 | time_now_string, | ||
1683 | strlen(time_now_string)); | ||
1684 | //nonce only if nonce is provided | ||
1685 | if ( NULL != nonce && json_is_string(nonce) ) | ||
1686 | { | ||
1687 | GNUNET_IDENTITY_ATTRIBUTE_list_add (cl, | ||
1688 | "nonce", | ||
1689 | GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, | ||
1690 | json_string_value(nonce), | ||
1691 | strlen(json_string_value(nonce))); | ||
1692 | } | ||
1693 | //auth_time only if max_age is provided | ||
1694 | if ( NULL != max_age && json_is_string(max_age) ) | ||
1695 | { | ||
1696 | GNUNET_IDENTITY_ATTRIBUTE_list_add (cl, | ||
1697 | "auth_time", | ||
1698 | GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, | ||
1699 | json_string_value(max_age), | ||
1700 | strlen(json_string_value(max_age))); | ||
1701 | } | ||
1702 | //TODO OPTIONAL acr,amr,azp | ||
1703 | 1685 | ||
1704 | struct EgoEntry *ego_entry; | 1686 | //TODO OPTIONAL acr,amr,azp |
1705 | for (ego_entry = handle->ego_head; NULL != ego_entry; ego_entry = ego_entry->next) | 1687 | if (GNUNET_NO == ego_exists (handle, |
1688 | &ticket->audience)) | ||
1706 | { | 1689 | { |
1707 | GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &pub_key); | 1690 | handle->emsg = GNUNET_strdup("invalid_request"); |
1708 | if (0 == memcmp (&pub_key, &ticket->audience, sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey))) | 1691 | handle->edesc = GNUNET_strdup("invalid code..."); |
1709 | { | 1692 | handle->response_code = MHD_HTTP_BAD_REQUEST; |
1710 | break; | 1693 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1711 | } | 1694 | GNUNET_free(ticket); |
1712 | } | 1695 | } |
1713 | if ( NULL == ego_entry ) | 1696 | if ( GNUNET_OK |
1697 | != GNUNET_CONFIGURATION_get_value_string (cfg, "reclaim-rest-plugin", | ||
1698 | "jwt_secret", &jwt_secret) ) | ||
1714 | { | 1699 | { |
1715 | GNUNET_free_non_null(user_psw); | ||
1716 | handle->emsg = GNUNET_strdup("invalid_request"); | 1700 | handle->emsg = GNUNET_strdup("invalid_request"); |
1717 | handle->edesc = GNUNET_strdup("invalid code...."); | 1701 | handle->edesc = GNUNET_strdup("No signing secret configured!"); |
1718 | handle->response_code = MHD_HTTP_BAD_REQUEST; | 1702 | handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; |
1719 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 1703 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
1720 | GNUNET_free(ticket); | 1704 | GNUNET_free(ticket); |
1721 | return; | 1705 | return; |
1722 | } | 1706 | } |
1723 | char *id_token = jwt_create_from_list(&ticket->audience, | 1707 | //TODO We should collect the attributes here. cl always empty |
1724 | cl, | 1708 | cl = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
1725 | GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego)); | 1709 | id_token = OIDC_id_token_new (&ticket->audience, |
1726 | 1710 | &ticket->identity, | |
1727 | //Create random access_token | 1711 | cl, |
1728 | char* access_token_number; | 1712 | &expiration_time, |
1729 | char* access_token; | 1713 | (NULL != nonce) ? nonce : NULL, |
1730 | uint64_t random_number; | 1714 | jwt_secret); |
1731 | random_number = GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_NONCE, UINT64_MAX); | 1715 | access_token = OIDC_access_token_new (); |
1732 | GNUNET_asprintf(&access_token_number, "%" PRIu64, random_number); | 1716 | OIDC_build_token_response (access_token, |
1733 | GNUNET_STRINGS_base64_encode(access_token_number,strlen(access_token_number),&access_token); | 1717 | id_token, |
1734 | 1718 | &expiration_time, | |
1735 | 1719 | &json_response); | |
1736 | 1720 | ||
1737 | //TODO OPTIONAL add refresh_token and scope | 1721 | store_ticket_reference (handle, |
1738 | GNUNET_asprintf (&json_response, | 1722 | access_token, |
1739 | "{ \"access_token\" : \"%s\", " | 1723 | ticket, |
1740 | "\"token_type\" : \"Bearer\", " | 1724 | &cid); |
1741 | "\"expires_in\" : %d, " | ||
1742 | "\"id_token\" : \"%s\"}", | ||
1743 | access_token, | ||
1744 | expiration_time, | ||
1745 | id_token); | ||
1746 | GNUNET_CRYPTO_hash(access_token, strlen(access_token), &cache_key); | ||
1747 | char *id_ticket_combination; | ||
1748 | GNUNET_asprintf(&id_ticket_combination, | ||
1749 | "%s;%s", | ||
1750 | client_id, | ||
1751 | json_string_value(ticket_string)); | ||
1752 | GNUNET_CONTAINER_multihashmap_put(OIDC_interpret_access_token, | ||
1753 | &cache_key, | ||
1754 | id_ticket_combination, | ||
1755 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE); | ||
1756 | |||
1757 | resp = GNUNET_REST_create_response (json_response); | 1725 | resp = GNUNET_REST_create_response (json_response); |
1758 | MHD_add_response_header (resp, "Cache-Control", "no-store"); | 1726 | MHD_add_response_header (resp, "Cache-Control", "no-store"); |
1759 | MHD_add_response_header (resp, "Pragma", "no-cache"); | 1727 | MHD_add_response_header (resp, "Pragma", "no-cache"); |
1760 | MHD_add_response_header (resp, "Content-Type", "application/json"); | 1728 | MHD_add_response_header (resp, "Content-Type", "application/json"); |
1761 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | 1729 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); |
1762 | 1730 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy(cl); | |
1763 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy(cl); | ||
1764 | GNUNET_free(access_token_number); | ||
1765 | GNUNET_free(access_token); | 1731 | GNUNET_free(access_token); |
1766 | GNUNET_free(user_psw); | ||
1767 | GNUNET_free(json_response); | 1732 | GNUNET_free(json_response); |
1768 | GNUNET_free(ticket); | 1733 | GNUNET_free(ticket); |
1769 | GNUNET_free(id_token); | 1734 | GNUNET_free(id_token); |
1770 | json_decref (root); | ||
1771 | GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); | 1735 | GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle); |
1772 | } | 1736 | } |
1773 | 1737 | ||
@@ -1777,7 +1741,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1777 | static void | 1741 | static void |
1778 | consume_ticket (void *cls, | 1742 | consume_ticket (void *cls, |
1779 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 1743 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
1780 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) | 1744 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
1781 | { | 1745 | { |
1782 | struct RequestHandle *handle = cls; | 1746 | struct RequestHandle *handle = cls; |
1783 | char *tmp_value; | 1747 | char *tmp_value; |
@@ -1789,9 +1753,9 @@ consume_ticket (void *cls, | |||
1789 | return; | 1753 | return; |
1790 | } | 1754 | } |
1791 | 1755 | ||
1792 | tmp_value = GNUNET_IDENTITY_ATTRIBUTE_value_to_string (attr->type, | 1756 | tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, |
1793 | attr->data, | 1757 | attr->data, |
1794 | attr->data_size); | 1758 | attr->data_size); |
1795 | 1759 | ||
1796 | value = json_string (tmp_value); | 1760 | value = json_string (tmp_value); |
1797 | 1761 | ||
@@ -1820,7 +1784,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1820 | struct GNUNET_HashCode cache_key; | 1784 | struct GNUNET_HashCode cache_key; |
1821 | char *authorization, *authorization_type, *authorization_access_token; | 1785 | char *authorization, *authorization_type, *authorization_access_token; |
1822 | char *client_ticket, *client, *ticket_str; | 1786 | char *client_ticket, *client, *ticket_str; |
1823 | struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket; | 1787 | struct GNUNET_RECLAIM_Ticket *ticket; |
1824 | 1788 | ||
1825 | GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, | 1789 | GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, |
1826 | strlen (OIDC_AUTHORIZATION_HEADER_KEY), | 1790 | strlen (OIDC_AUTHORIZATION_HEADER_KEY), |
@@ -1918,12 +1882,12 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1918 | GNUNET_free(client_ticket); | 1882 | GNUNET_free(client_ticket); |
1919 | return; | 1883 | return; |
1920 | } | 1884 | } |
1921 | ticket = GNUNET_new(struct GNUNET_IDENTITY_PROVIDER_Ticket); | 1885 | ticket = GNUNET_new(struct GNUNET_RECLAIM_Ticket); |
1922 | if ( GNUNET_OK | 1886 | if ( GNUNET_OK |
1923 | != GNUNET_STRINGS_string_to_data (ticket_str, | 1887 | != GNUNET_STRINGS_string_to_data (ticket_str, |
1924 | strlen (ticket_str), | 1888 | strlen (ticket_str), |
1925 | ticket, | 1889 | ticket, |
1926 | sizeof(struct GNUNET_IDENTITY_PROVIDER_Ticket))) | 1890 | sizeof(struct GNUNET_RECLAIM_Ticket))) |
1927 | { | 1891 | { |
1928 | handle->emsg = GNUNET_strdup("invalid_token"); | 1892 | handle->emsg = GNUNET_strdup("invalid_token"); |
1929 | handle->edesc = GNUNET_strdup("The Access Token expired"); | 1893 | handle->edesc = GNUNET_strdup("The Access Token expired"); |
@@ -1935,15 +1899,15 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
1935 | return; | 1899 | return; |
1936 | } | 1900 | } |
1937 | 1901 | ||
1938 | handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg); | 1902 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
1939 | handle->oidc->response = json_object(); | 1903 | handle->oidc->response = json_object(); |
1940 | json_object_set_new( handle->oidc->response, "sub", json_string( handle->ego_entry->keystring)); | 1904 | json_object_set_new( handle->oidc->response, "sub", json_string( handle->ego_entry->keystring)); |
1941 | handle->idp_op = GNUNET_IDENTITY_PROVIDER_ticket_consume ( | 1905 | handle->idp_op = GNUNET_RECLAIM_ticket_consume ( |
1942 | handle->idp, | 1906 | handle->idp, |
1943 | GNUNET_IDENTITY_ego_get_private_key (handle->ego_entry->ego), | 1907 | GNUNET_IDENTITY_ego_get_private_key (handle->ego_entry->ego), |
1944 | ticket, | 1908 | ticket, |
1945 | consume_ticket, | 1909 | consume_ticket, |
1946 | handle); | 1910 | handle); |
1947 | GNUNET_free(ticket); | 1911 | GNUNET_free(ticket); |
1948 | GNUNET_free(authorization); | 1912 | GNUNET_free(authorization); |
1949 | GNUNET_free(client_ticket); | 1913 | GNUNET_free(client_ticket); |
@@ -2103,6 +2067,7 @@ rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, | |||
2103 | handle->identity_handle = GNUNET_IDENTITY_connect (cfg, | 2067 | handle->identity_handle = GNUNET_IDENTITY_connect (cfg, |
2104 | &list_ego, | 2068 | &list_ego, |
2105 | handle); | 2069 | handle); |
2070 | handle->gns_handle = GNUNET_GNS_connect (cfg); | ||
2106 | handle->namestore_handle = GNUNET_NAMESTORE_connect (cfg); | 2071 | handle->namestore_handle = GNUNET_NAMESTORE_connect (cfg); |
2107 | handle->timeout_task = | 2072 | handle->timeout_task = |
2108 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | 2073 | GNUNET_SCHEDULER_add_delayed (handle->timeout, |
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/reclaim/plugin_rest_reclaim.c index a83163db2..38ffc4ddb 100644 --- a/src/identity-provider/plugin_rest_identity_provider.c +++ b/src/reclaim/plugin_rest_reclaim.c | |||
@@ -18,8 +18,8 @@ | |||
18 | /** | 18 | /** |
19 | * @author Martin Schanzenbach | 19 | * @author Martin Schanzenbach |
20 | * @author Philippe Buschmann | 20 | * @author Philippe Buschmann |
21 | * @file identity/plugin_rest_identity.c | 21 | * @file reclaim/plugin_rest_reclaim.c |
22 | * @brief GNUnet Namestore REST plugin | 22 | * @brief GNUnet reclaim REST plugin |
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
@@ -36,38 +36,38 @@ | |||
36 | #include <jansson.h> | 36 | #include <jansson.h> |
37 | #include <inttypes.h> | 37 | #include <inttypes.h> |
38 | #include "gnunet_signatures.h" | 38 | #include "gnunet_signatures.h" |
39 | #include "gnunet_identity_attribute_lib.h" | 39 | #include "gnunet_reclaim_attribute_lib.h" |
40 | #include "gnunet_identity_provider_service.h" | 40 | #include "gnunet_reclaim_service.h" |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * REST root namespace | 43 | * REST root namespace |
44 | */ | 44 | */ |
45 | #define GNUNET_REST_API_NS_IDENTITY_PROVIDER "/idp" | 45 | #define GNUNET_REST_API_NS_RECLAIM "/reclaim" |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * Attribute namespace | 48 | * Attribute namespace |
49 | */ | 49 | */ |
50 | #define GNUNET_REST_API_NS_IDENTITY_ATTRIBUTES "/idp/attributes" | 50 | #define GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES "/reclaim/attributes" |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * Ticket namespace | 53 | * Ticket namespace |
54 | */ | 54 | */ |
55 | #define GNUNET_REST_API_NS_IDENTITY_TICKETS "/idp/tickets" | 55 | #define GNUNET_REST_API_NS_IDENTITY_TICKETS "/reclaim/tickets" |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Revoke namespace | 58 | * Revoke namespace |
59 | */ | 59 | */ |
60 | #define GNUNET_REST_API_NS_IDENTITY_REVOKE "/idp/revoke" | 60 | #define GNUNET_REST_API_NS_IDENTITY_REVOKE "/reclaim/revoke" |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * Revoke namespace | 63 | * Revoke namespace |
64 | */ | 64 | */ |
65 | #define GNUNET_REST_API_NS_IDENTITY_CONSUME "/idp/consume" | 65 | #define GNUNET_REST_API_NS_IDENTITY_CONSUME "/reclaim/consume" |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Attribute key | 68 | * Attribute key |
69 | */ | 69 | */ |
70 | #define GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE "attribute" | 70 | #define GNUNET_REST_JSONAPI_RECLAIM_ATTRIBUTE "attribute" |
71 | 71 | ||
72 | /** | 72 | /** |
73 | * Ticket key | 73 | * Ticket key |
@@ -78,7 +78,7 @@ | |||
78 | /** | 78 | /** |
79 | * Value key | 79 | * Value key |
80 | */ | 80 | */ |
81 | #define GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE_VALUE "value" | 81 | #define GNUNET_REST_JSONAPI_RECLAIM_ATTRIBUTE_VALUE "value" |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * State while collecting all egos | 84 | * State while collecting all egos |
@@ -190,7 +190,7 @@ struct RequestHandle | |||
190 | /** | 190 | /** |
191 | * Attribute claim list | 191 | * Attribute claim list |
192 | */ | 192 | */ |
193 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attr_list; | 193 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attr_list; |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * IDENTITY Operation | 196 | * IDENTITY Operation |
@@ -200,27 +200,27 @@ struct RequestHandle | |||
200 | /** | 200 | /** |
201 | * Identity Provider | 201 | * Identity Provider |
202 | */ | 202 | */ |
203 | struct GNUNET_IDENTITY_PROVIDER_Handle *idp; | 203 | struct GNUNET_RECLAIM_Handle *idp; |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * Idp Operation | 206 | * Idp Operation |
207 | */ | 207 | */ |
208 | struct GNUNET_IDENTITY_PROVIDER_Operation *idp_op; | 208 | struct GNUNET_RECLAIM_Operation *idp_op; |
209 | 209 | ||
210 | /** | 210 | /** |
211 | * Attribute iterator | 211 | * Attribute iterator |
212 | */ | 212 | */ |
213 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *attr_it; | 213 | struct GNUNET_RECLAIM_AttributeIterator *attr_it; |
214 | 214 | ||
215 | /** | 215 | /** |
216 | * Ticket iterator | 216 | * Ticket iterator |
217 | */ | 217 | */ |
218 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *ticket_it; | 218 | struct GNUNET_RECLAIM_TicketIterator *ticket_it; |
219 | 219 | ||
220 | /** | 220 | /** |
221 | * A ticket | 221 | * A ticket |
222 | */ | 222 | */ |
223 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 223 | struct GNUNET_RECLAIM_Ticket ticket; |
224 | 224 | ||
225 | /** | 225 | /** |
226 | * Desired timeout for the lookup (default is no timeout). | 226 | * Desired timeout for the lookup (default is no timeout). |
@@ -271,8 +271,8 @@ struct RequestHandle | |||
271 | static void | 271 | static void |
272 | cleanup_handle (struct RequestHandle *handle) | 272 | cleanup_handle (struct RequestHandle *handle) |
273 | { | 273 | { |
274 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *claim_entry; | 274 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_entry; |
275 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *claim_tmp; | 275 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *claim_tmp; |
276 | struct EgoEntry *ego_entry; | 276 | struct EgoEntry *ego_entry; |
277 | struct EgoEntry *ego_tmp; | 277 | struct EgoEntry *ego_tmp; |
278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 278 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -284,11 +284,11 @@ cleanup_handle (struct RequestHandle *handle) | |||
284 | if (NULL != handle->identity_handle) | 284 | if (NULL != handle->identity_handle) |
285 | GNUNET_IDENTITY_disconnect (handle->identity_handle); | 285 | GNUNET_IDENTITY_disconnect (handle->identity_handle); |
286 | if (NULL != handle->attr_it) | 286 | if (NULL != handle->attr_it) |
287 | GNUNET_IDENTITY_PROVIDER_get_attributes_stop (handle->attr_it); | 287 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); |
288 | if (NULL != handle->ticket_it) | 288 | if (NULL != handle->ticket_it) |
289 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (handle->ticket_it); | 289 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); |
290 | if (NULL != handle->idp) | 290 | if (NULL != handle->idp) |
291 | GNUNET_IDENTITY_PROVIDER_disconnect (handle->idp); | 291 | GNUNET_RECLAIM_disconnect (handle->idp); |
292 | if (NULL != handle->url) | 292 | if (NULL != handle->url) |
293 | GNUNET_free (handle->url); | 293 | GNUNET_free (handle->url); |
294 | if (NULL != handle->emsg) | 294 | if (NULL != handle->emsg) |
@@ -435,7 +435,7 @@ collect_finished_cb (void *cls) | |||
435 | */ | 435 | */ |
436 | static void | 436 | static void |
437 | ticket_collect (void *cls, | 437 | ticket_collect (void *cls, |
438 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket) | 438 | const struct GNUNET_RECLAIM_Ticket *ticket) |
439 | { | 439 | { |
440 | struct GNUNET_JSONAPI_Resource *json_resource; | 440 | struct GNUNET_JSONAPI_Resource *json_resource; |
441 | struct RequestHandle *handle = cls; | 441 | struct RequestHandle *handle = cls; |
@@ -474,7 +474,7 @@ ticket_collect (void *cls, | |||
474 | value); | 474 | value); |
475 | GNUNET_free (tmp); | 475 | GNUNET_free (tmp); |
476 | json_decref (value); | 476 | json_decref (value); |
477 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_next (handle->ticket_it); | 477 | GNUNET_RECLAIM_ticket_iteration_next (handle->ticket_it); |
478 | } | 478 | } |
479 | 479 | ||
480 | 480 | ||
@@ -523,8 +523,8 @@ list_tickets_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
523 | return; | 523 | return; |
524 | } | 524 | } |
525 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 525 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
526 | handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg); | 526 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
527 | handle->ticket_it = GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (handle->idp, | 527 | handle->ticket_it = GNUNET_RECLAIM_ticket_iteration_start (handle->idp, |
528 | priv_key, | 528 | priv_key, |
529 | &collect_error_cb, | 529 | &collect_error_cb, |
530 | handle, | 530 | handle, |
@@ -549,7 +549,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
549 | struct RequestHandle *handle = cls; | 549 | struct RequestHandle *handle = cls; |
550 | struct EgoEntry *ego_entry; | 550 | struct EgoEntry *ego_entry; |
551 | struct MHD_Response *resp; | 551 | struct MHD_Response *resp; |
552 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attribute; | 552 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attribute; |
553 | struct GNUNET_JSONAPI_Document *json_obj; | 553 | struct GNUNET_JSONAPI_Document *json_obj; |
554 | struct GNUNET_JSONAPI_Resource *json_res; | 554 | struct GNUNET_JSONAPI_Resource *json_res; |
555 | struct GNUNET_TIME_Relative exp; | 555 | struct GNUNET_TIME_Relative exp; |
@@ -565,14 +565,14 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
565 | 565 | ||
566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding an attribute for %s.\n", | 566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding an attribute for %s.\n", |
567 | handle->url); | 567 | handle->url); |
568 | if ( strlen (GNUNET_REST_API_NS_IDENTITY_ATTRIBUTES) >= | 568 | if ( strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= |
569 | strlen (handle->url)) | 569 | strlen (handle->url)) |
570 | { | 570 | { |
571 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 571 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
572 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 572 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
573 | return; | 573 | return; |
574 | } | 574 | } |
575 | identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_ATTRIBUTES) + 1; | 575 | identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; |
576 | 576 | ||
577 | for (ego_entry = handle->ego_head; | 577 | for (ego_entry = handle->ego_head; |
578 | NULL != ego_entry; | 578 | NULL != ego_entry; |
@@ -625,7 +625,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
625 | } | 625 | } |
626 | json_res = GNUNET_JSONAPI_document_get_resource (json_obj, 0); | 626 | json_res = GNUNET_JSONAPI_document_get_resource (json_obj, 0); |
627 | if (GNUNET_NO == GNUNET_JSONAPI_resource_check_type (json_res, | 627 | if (GNUNET_NO == GNUNET_JSONAPI_resource_check_type (json_res, |
628 | GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE)) | 628 | GNUNET_REST_JSONAPI_RECLAIM_ATTRIBUTE)) |
629 | { | 629 | { |
630 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 630 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
631 | "Unsupported JSON data type\n"); | 631 | "Unsupported JSON data type\n"); |
@@ -651,12 +651,12 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
651 | value_json = GNUNET_JSONAPI_resource_read_attr (json_res, | 651 | value_json = GNUNET_JSONAPI_resource_read_attr (json_res, |
652 | "value"); | 652 | "value"); |
653 | value_str = json_string_value (value_json); | 653 | value_str = json_string_value (value_json); |
654 | attribute = GNUNET_IDENTITY_ATTRIBUTE_claim_new (name_str, | 654 | attribute = GNUNET_RECLAIM_ATTRIBUTE_claim_new (name_str, |
655 | GNUNET_IDENTITY_ATTRIBUTE_TYPE_STRING, | 655 | GNUNET_RECLAIM_ATTRIBUTE_TYPE_STRING, |
656 | value_str, | 656 | value_str, |
657 | strlen (value_str) + 1); | 657 | strlen (value_str) + 1); |
658 | handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg); | 658 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
659 | handle->idp_op = GNUNET_IDENTITY_PROVIDER_attribute_store (handle->idp, | 659 | handle->idp_op = GNUNET_RECLAIM_attribute_store (handle->idp, |
660 | identity_priv, | 660 | identity_priv, |
661 | attribute, | 661 | attribute, |
662 | &exp, | 662 | &exp, |
@@ -675,7 +675,7 @@ add_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
675 | static void | 675 | static void |
676 | attr_collect (void *cls, | 676 | attr_collect (void *cls, |
677 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 677 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
678 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) | 678 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
679 | { | 679 | { |
680 | struct GNUNET_JSONAPI_Resource *json_resource; | 680 | struct GNUNET_JSONAPI_Resource *json_resource; |
681 | struct RequestHandle *handle = cls; | 681 | struct RequestHandle *handle = cls; |
@@ -684,17 +684,17 @@ attr_collect (void *cls, | |||
684 | 684 | ||
685 | if ((NULL == attr->name) || (NULL == attr->data)) | 685 | if ((NULL == attr->name) || (NULL == attr->data)) |
686 | { | 686 | { |
687 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (handle->attr_it); | 687 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); |
688 | return; | 688 | return; |
689 | } | 689 | } |
690 | 690 | ||
691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", | 691 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", |
692 | attr->name); | 692 | attr->name); |
693 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE, | 693 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_RECLAIM_ATTRIBUTE, |
694 | attr->name); | 694 | attr->name); |
695 | GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource); | 695 | GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource); |
696 | 696 | ||
697 | tmp_value = GNUNET_IDENTITY_ATTRIBUTE_value_to_string (attr->type, | 697 | tmp_value = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, |
698 | attr->data, | 698 | attr->data, |
699 | attr->data_size); | 699 | attr->data_size); |
700 | 700 | ||
@@ -705,7 +705,7 @@ attr_collect (void *cls, | |||
705 | value); | 705 | value); |
706 | json_decref (value); | 706 | json_decref (value); |
707 | GNUNET_free(tmp_value); | 707 | GNUNET_free(tmp_value); |
708 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (handle->attr_it); | 708 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); |
709 | } | 709 | } |
710 | 710 | ||
711 | 711 | ||
@@ -729,14 +729,14 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
729 | 729 | ||
730 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting attributes for %s.\n", | 730 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Getting attributes for %s.\n", |
731 | handle->url); | 731 | handle->url); |
732 | if ( strlen (GNUNET_REST_API_NS_IDENTITY_ATTRIBUTES) >= | 732 | if ( strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) >= |
733 | strlen (handle->url)) | 733 | strlen (handle->url)) |
734 | { | 734 | { |
735 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); | 735 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No identity given.\n"); |
736 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 736 | GNUNET_SCHEDULER_add_now (&do_error, handle); |
737 | return; | 737 | return; |
738 | } | 738 | } |
739 | identity = handle->url + strlen (GNUNET_REST_API_NS_IDENTITY_ATTRIBUTES) + 1; | 739 | identity = handle->url + strlen (GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES) + 1; |
740 | 740 | ||
741 | for (ego_entry = handle->ego_head; | 741 | for (ego_entry = handle->ego_head; |
742 | NULL != ego_entry; | 742 | NULL != ego_entry; |
@@ -755,8 +755,8 @@ list_attribute_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
755 | return; | 755 | return; |
756 | } | 756 | } |
757 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 757 | priv_key = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
758 | handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg); | 758 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
759 | handle->attr_it = GNUNET_IDENTITY_PROVIDER_get_attributes_start (handle->idp, | 759 | handle->attr_it = GNUNET_RECLAIM_get_attributes_start (handle->idp, |
760 | priv_key, | 760 | priv_key, |
761 | &collect_error_cb, | 761 | &collect_error_cb, |
762 | handle, | 762 | handle, |
@@ -780,7 +780,7 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
780 | struct RequestHandle *handle = cls; | 780 | struct RequestHandle *handle = cls; |
781 | struct EgoEntry *ego_entry; | 781 | struct EgoEntry *ego_entry; |
782 | struct MHD_Response *resp; | 782 | struct MHD_Response *resp; |
783 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 783 | struct GNUNET_RECLAIM_Ticket ticket; |
784 | struct GNUNET_JSONAPI_Document *json_obj; | 784 | struct GNUNET_JSONAPI_Document *json_obj; |
785 | struct GNUNET_JSONAPI_Resource *json_res; | 785 | struct GNUNET_JSONAPI_Resource *json_res; |
786 | struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk; | 786 | struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk; |
@@ -844,7 +844,7 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
844 | rnd_json = GNUNET_JSONAPI_resource_read_attr (json_res, | 844 | rnd_json = GNUNET_JSONAPI_resource_read_attr (json_res, |
845 | "rnd"); | 845 | "rnd"); |
846 | identity_json = GNUNET_JSONAPI_resource_read_attr (json_res, | 846 | identity_json = GNUNET_JSONAPI_resource_read_attr (json_res, |
847 | "identity"); | 847 | "issuer"); |
848 | audience_json = GNUNET_JSONAPI_resource_read_attr (json_res, | 848 | audience_json = GNUNET_JSONAPI_resource_read_attr (json_res, |
849 | "audience"); | 849 | "audience"); |
850 | rnd_str = json_string_value (rnd_json); | 850 | rnd_str = json_string_value (rnd_json); |
@@ -884,8 +884,8 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
884 | } | 884 | } |
885 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 885 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
886 | 886 | ||
887 | handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg); | 887 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
888 | handle->idp_op = GNUNET_IDENTITY_PROVIDER_ticket_revoke (handle->idp, | 888 | handle->idp_op = GNUNET_RECLAIM_ticket_revoke (handle->idp, |
889 | identity_priv, | 889 | identity_priv, |
890 | &ticket, | 890 | &ticket, |
891 | &finished_cont, | 891 | &finished_cont, |
@@ -896,7 +896,7 @@ revoke_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
896 | static void | 896 | static void |
897 | consume_cont (void *cls, | 897 | consume_cont (void *cls, |
898 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 898 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
899 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr) | 899 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
900 | { | 900 | { |
901 | struct RequestHandle *handle = cls; | 901 | struct RequestHandle *handle = cls; |
902 | struct GNUNET_JSONAPI_Resource *json_resource; | 902 | struct GNUNET_JSONAPI_Resource *json_resource; |
@@ -910,7 +910,7 @@ consume_cont (void *cls, | |||
910 | 910 | ||
911 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", | 911 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Adding attribute: %s\n", |
912 | attr->name); | 912 | attr->name); |
913 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE, | 913 | json_resource = GNUNET_JSONAPI_resource_new (GNUNET_REST_JSONAPI_RECLAIM_ATTRIBUTE, |
914 | attr->name); | 914 | attr->name); |
915 | GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource); | 915 | GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource); |
916 | 916 | ||
@@ -934,7 +934,7 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
934 | struct RequestHandle *handle = cls; | 934 | struct RequestHandle *handle = cls; |
935 | struct EgoEntry *ego_entry; | 935 | struct EgoEntry *ego_entry; |
936 | struct MHD_Response *resp; | 936 | struct MHD_Response *resp; |
937 | struct GNUNET_IDENTITY_PROVIDER_Ticket ticket; | 937 | struct GNUNET_RECLAIM_Ticket ticket; |
938 | struct GNUNET_JSONAPI_Document *json_obj; | 938 | struct GNUNET_JSONAPI_Document *json_obj; |
939 | struct GNUNET_JSONAPI_Resource *json_res; | 939 | struct GNUNET_JSONAPI_Resource *json_res; |
940 | struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk; | 940 | struct GNUNET_CRYPTO_EcdsaPublicKey tmp_pk; |
@@ -1038,8 +1038,8 @@ consume_ticket_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1038 | } | 1038 | } |
1039 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); | 1039 | identity_priv = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego); |
1040 | handle->resp_object = GNUNET_JSONAPI_document_new (); | 1040 | handle->resp_object = GNUNET_JSONAPI_document_new (); |
1041 | handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg); | 1041 | handle->idp = GNUNET_RECLAIM_connect (cfg); |
1042 | handle->idp_op = GNUNET_IDENTITY_PROVIDER_ticket_consume (handle->idp, | 1042 | handle->idp_op = GNUNET_RECLAIM_ticket_consume (handle->idp, |
1043 | identity_priv, | 1043 | identity_priv, |
1044 | &ticket, | 1044 | &ticket, |
1045 | &consume_cont, | 1045 | &consume_cont, |
@@ -1084,12 +1084,12 @@ init_cont (struct RequestHandle *handle) | |||
1084 | { | 1084 | { |
1085 | struct GNUNET_REST_RequestHandlerError err; | 1085 | struct GNUNET_REST_RequestHandlerError err; |
1086 | static const struct GNUNET_REST_RequestHandler handlers[] = { | 1086 | static const struct GNUNET_REST_RequestHandler handlers[] = { |
1087 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_ATTRIBUTES, &list_attribute_cont}, | 1087 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &list_attribute_cont}, |
1088 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_ATTRIBUTES, &add_attribute_cont}, | 1088 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_RECLAIM_ATTRIBUTES, &add_attribute_cont}, |
1089 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont}, | 1089 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_TICKETS, &list_tickets_cont}, |
1090 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_REVOKE, &revoke_ticket_cont}, | 1090 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_REVOKE, &revoke_ticket_cont}, |
1091 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_CONSUME, &consume_ticket_cont}, | 1091 | {MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY_CONSUME, &consume_ticket_cont}, |
1092 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY_PROVIDER, | 1092 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_RECLAIM, |
1093 | &options_cont}, | 1093 | &options_cont}, |
1094 | GNUNET_REST_HANDLER_END | 1094 | GNUNET_REST_HANDLER_END |
1095 | }; | 1095 | }; |
@@ -1202,7 +1202,7 @@ rest_identity_process_request(struct GNUNET_REST_RequestHandle *rest_handle, | |||
1202 | * @return NULL on error, otherwise the plugin context | 1202 | * @return NULL on error, otherwise the plugin context |
1203 | */ | 1203 | */ |
1204 | void * | 1204 | void * |
1205 | libgnunet_plugin_rest_identity_provider_init (void *cls) | 1205 | libgnunet_plugin_rest_reclaim_init (void *cls) |
1206 | { | 1206 | { |
1207 | static struct Plugin plugin; | 1207 | static struct Plugin plugin; |
1208 | struct GNUNET_REST_Plugin *api; | 1208 | struct GNUNET_REST_Plugin *api; |
@@ -1214,7 +1214,7 @@ libgnunet_plugin_rest_identity_provider_init (void *cls) | |||
1214 | plugin.cfg = cfg; | 1214 | plugin.cfg = cfg; |
1215 | api = GNUNET_new (struct GNUNET_REST_Plugin); | 1215 | api = GNUNET_new (struct GNUNET_REST_Plugin); |
1216 | api->cls = &plugin; | 1216 | api->cls = &plugin; |
1217 | api->name = GNUNET_REST_API_NS_IDENTITY_PROVIDER; | 1217 | api->name = GNUNET_REST_API_NS_RECLAIM; |
1218 | api->process_request = &rest_identity_process_request; | 1218 | api->process_request = &rest_identity_process_request; |
1219 | GNUNET_asprintf (&allow_methods, | 1219 | GNUNET_asprintf (&allow_methods, |
1220 | "%s, %s, %s, %s, %s", | 1220 | "%s, %s, %s, %s, %s", |
@@ -1237,7 +1237,7 @@ libgnunet_plugin_rest_identity_provider_init (void *cls) | |||
1237 | * @return always NULL | 1237 | * @return always NULL |
1238 | */ | 1238 | */ |
1239 | void * | 1239 | void * |
1240 | libgnunet_plugin_rest_identity_provider_done (void *cls) | 1240 | libgnunet_plugin_rest_reclaim_done (void *cls) |
1241 | { | 1241 | { |
1242 | struct GNUNET_REST_Plugin *api = cls; | 1242 | struct GNUNET_REST_Plugin *api = cls; |
1243 | struct Plugin *plugin = api->cls; | 1243 | struct Plugin *plugin = api->cls; |
@@ -1250,4 +1250,4 @@ libgnunet_plugin_rest_identity_provider_done (void *cls) | |||
1250 | return NULL; | 1250 | return NULL; |
1251 | } | 1251 | } |
1252 | 1252 | ||
1253 | /* end of plugin_rest_identity_provider.c */ | 1253 | /* end of plugin_rest_reclaim.c */ |
diff --git a/src/identity-provider/identity-provider.conf b/src/reclaim/reclaim.conf index cc50152a1..cf0a0dc5e 100644 --- a/src/identity-provider/identity-provider.conf +++ b/src/reclaim/reclaim.conf | |||
@@ -1,22 +1,23 @@ | |||
1 | [identity-provider] | 1 | [reclaim] |
2 | START_ON_DEMAND = NO | 2 | START_ON_DEMAND = NO |
3 | RUN_PER_USER = YES | 3 | RUN_PER_USER = YES |
4 | #PORT = 2108 | 4 | #PORT = 2108 |
5 | HOSTNAME = localhost | 5 | HOSTNAME = localhost |
6 | BINARY = gnunet-service-identity-provider | 6 | BINARY = gnunet-service-reclaim |
7 | ACCEPT_FROM = 127.0.0.1; | 7 | ACCEPT_FROM = 127.0.0.1; |
8 | ACCEPT_FROM6 = ::1; | 8 | ACCEPT_FROM6 = ::1; |
9 | UNIXPATH = $GNUNET_USER_RUNTIME_DIR/gnunet-service-identity-provider.sock | 9 | UNIXPATH = $GNUNET_USER_RUNTIME_DIR/gnunet-service-reclaim.sock |
10 | UNIX_MATCH_UID = NO | 10 | UNIX_MATCH_UID = NO |
11 | UNIX_MATCH_GID = YES | 11 | UNIX_MATCH_GID = YES |
12 | TOKEN_EXPIRATION_INTERVAL = 30 m | 12 | TOKEN_EXPIRATION_INTERVAL = 30 m |
13 | DATABASE = sqlite | 13 | DATABASE = sqlite |
14 | 14 | ||
15 | [identity-rest-plugin] | 15 | [reclaim-rest-plugin] |
16 | #ADDRESS = https://identity.gnu:8000#/login | 16 | #ADDRESS = https://identity.gnu:8000#/login |
17 | ADDRESS = https://reclaim.ui/#/login | 17 | ADDRESS = https://reclaim.ui/#/login |
18 | PSW = secret | 18 | PSW = secret |
19 | EXPIRATION_TIME = 3600 | 19 | JWT_SECRET = secret |
20 | EXPIRATION_TIME = 1d | ||
20 | 21 | ||
21 | [identity-provider-sqlite] | 22 | [reclaim-sqlite] |
22 | FILENAME = $GNUNET_DATA_HOME/identity-provider/sqlite.db | 23 | FILENAME = $GNUNET_DATA_HOME/reclaim/sqlite.db |
diff --git a/src/identity-provider/identity_provider.h b/src/reclaim/reclaim.h index 6a4b7769f..d2c84686d 100644 --- a/src/identity-provider/identity_provider.h +++ b/src/reclaim/reclaim.h | |||
@@ -18,13 +18,13 @@ | |||
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @author Martin Schanzenbach | 20 | * @author Martin Schanzenbach |
21 | * @file identity-provider/identity_provider.h | 21 | * @file reclaim/reclaim.h |
22 | * | 22 | * |
23 | * @brief Common type definitions for the identity provider | 23 | * @brief Common type definitions for the identity provider |
24 | * service and API. | 24 | * service and API. |
25 | */ | 25 | */ |
26 | #ifndef IDENTITY_PROVIDER_H | 26 | #ifndef RECLAIM_H |
27 | #define IDENTITY_PROVIDER_H | 27 | #define RECLAIM_H |
28 | 28 | ||
29 | #include "gnunet_common.h" | 29 | #include "gnunet_common.h" |
30 | 30 | ||
@@ -152,7 +152,7 @@ struct AttributeIterationStartMessage | |||
152 | struct AttributeIterationNextMessage | 152 | struct AttributeIterationNextMessage |
153 | { | 153 | { |
154 | /** | 154 | /** |
155 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_NEXT | 155 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT |
156 | */ | 156 | */ |
157 | struct GNUNET_MessageHeader header; | 157 | struct GNUNET_MessageHeader header; |
158 | 158 | ||
@@ -170,7 +170,7 @@ struct AttributeIterationNextMessage | |||
170 | struct AttributeIterationStopMessage | 170 | struct AttributeIterationStopMessage |
171 | { | 171 | { |
172 | /** | 172 | /** |
173 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_STOP | 173 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP |
174 | */ | 174 | */ |
175 | struct GNUNET_MessageHeader header; | 175 | struct GNUNET_MessageHeader header; |
176 | 176 | ||
@@ -214,7 +214,7 @@ struct TicketIterationStartMessage | |||
214 | struct TicketIterationNextMessage | 214 | struct TicketIterationNextMessage |
215 | { | 215 | { |
216 | /** | 216 | /** |
217 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_NEXT | 217 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT |
218 | */ | 218 | */ |
219 | struct GNUNET_MessageHeader header; | 219 | struct GNUNET_MessageHeader header; |
220 | 220 | ||
@@ -232,7 +232,7 @@ struct TicketIterationNextMessage | |||
232 | struct TicketIterationStopMessage | 232 | struct TicketIterationStopMessage |
233 | { | 233 | { |
234 | /** | 234 | /** |
235 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_STOP | 235 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP |
236 | */ | 236 | */ |
237 | struct GNUNET_MessageHeader header; | 237 | struct GNUNET_MessageHeader header; |
238 | 238 | ||
@@ -251,7 +251,7 @@ struct TicketIterationStopMessage | |||
251 | struct IssueTicketMessage | 251 | struct IssueTicketMessage |
252 | { | 252 | { |
253 | /** | 253 | /** |
254 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_TICKET | 254 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET |
255 | */ | 255 | */ |
256 | struct GNUNET_MessageHeader header; | 256 | struct GNUNET_MessageHeader header; |
257 | 257 | ||
@@ -284,7 +284,7 @@ struct IssueTicketMessage | |||
284 | struct RevokeTicketMessage | 284 | struct RevokeTicketMessage |
285 | { | 285 | { |
286 | /** | 286 | /** |
287 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET | 287 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET |
288 | */ | 288 | */ |
289 | struct GNUNET_MessageHeader header; | 289 | struct GNUNET_MessageHeader header; |
290 | 290 | ||
@@ -312,7 +312,7 @@ struct RevokeTicketMessage | |||
312 | struct RevokeTicketResultMessage | 312 | struct RevokeTicketResultMessage |
313 | { | 313 | { |
314 | /** | 314 | /** |
315 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT | 315 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT |
316 | */ | 316 | */ |
317 | struct GNUNET_MessageHeader header; | 317 | struct GNUNET_MessageHeader header; |
318 | 318 | ||
@@ -334,7 +334,7 @@ struct RevokeTicketResultMessage | |||
334 | struct TicketResultMessage | 334 | struct TicketResultMessage |
335 | { | 335 | { |
336 | /** | 336 | /** |
337 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT | 337 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT |
338 | */ | 338 | */ |
339 | struct GNUNET_MessageHeader header; | 339 | struct GNUNET_MessageHeader header; |
340 | 340 | ||
@@ -351,7 +351,7 @@ struct TicketResultMessage | |||
351 | struct ConsumeTicketMessage | 351 | struct ConsumeTicketMessage |
352 | { | 352 | { |
353 | /** | 353 | /** |
354 | * Type will be #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET | 354 | * Type will be #GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET |
355 | */ | 355 | */ |
356 | struct GNUNET_MessageHeader header; | 356 | struct GNUNET_MessageHeader header; |
357 | 357 | ||
diff --git a/src/identity-provider/identity_provider_api.c b/src/reclaim/reclaim_api.c index 772b4a244..3f1584ccd 100644 --- a/src/identity-provider/identity_provider_api.c +++ b/src/reclaim/reclaim_api.c | |||
@@ -17,8 +17,8 @@ | |||
17 | */ | 17 | */ |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * @file identity-provider/identity_provider_api.c | 20 | * @file reclaim/reclaim_api.c |
21 | * @brief api to interact with the identity provider service | 21 | * @brief api to interact with the reclaim service |
22 | * @author Martin Schanzenbach | 22 | * @author Martin Schanzenbach |
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
@@ -26,33 +26,33 @@ | |||
26 | #include "gnunet_constants.h" | 26 | #include "gnunet_constants.h" |
27 | #include "gnunet_protocols.h" | 27 | #include "gnunet_protocols.h" |
28 | #include "gnunet_mq_lib.h" | 28 | #include "gnunet_mq_lib.h" |
29 | #include "gnunet_identity_provider_service.h" | 29 | #include "gnunet_reclaim_service.h" |
30 | #include "gnunet_identity_attribute_lib.h" | 30 | #include "gnunet_reclaim_attribute_lib.h" |
31 | #include "identity_provider.h" | 31 | #include "reclaim.h" |
32 | 32 | ||
33 | #define LOG(kind,...) GNUNET_log_from (kind, "identity-api",__VA_ARGS__) | 33 | #define LOG(kind,...) GNUNET_log_from (kind, "reclaim-api",__VA_ARGS__) |
34 | 34 | ||
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Handle for an operation with the service. | 37 | * Handle for an operation with the service. |
38 | */ | 38 | */ |
39 | struct GNUNET_IDENTITY_PROVIDER_Operation | 39 | struct GNUNET_RECLAIM_Operation |
40 | { | 40 | { |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Main handle. | 43 | * Main handle. |
44 | */ | 44 | */ |
45 | struct GNUNET_IDENTITY_PROVIDER_Handle *h; | 45 | struct GNUNET_RECLAIM_Handle *h; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * We keep operations in a DLL. | 48 | * We keep operations in a DLL. |
49 | */ | 49 | */ |
50 | struct GNUNET_IDENTITY_PROVIDER_Operation *next; | 50 | struct GNUNET_RECLAIM_Operation *next; |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * We keep operations in a DLL. | 53 | * We keep operations in a DLL. |
54 | */ | 54 | */ |
55 | struct GNUNET_IDENTITY_PROVIDER_Operation *prev; | 55 | struct GNUNET_RECLAIM_Operation *prev; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Message to send to the service. | 58 | * Message to send to the service. |
@@ -63,22 +63,22 @@ struct GNUNET_IDENTITY_PROVIDER_Operation | |||
63 | /** | 63 | /** |
64 | * Continuation to invoke after attribute store call | 64 | * Continuation to invoke after attribute store call |
65 | */ | 65 | */ |
66 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus as_cb; | 66 | GNUNET_RECLAIM_ContinuationWithStatus as_cb; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Attribute result callback | 69 | * Attribute result callback |
70 | */ | 70 | */ |
71 | GNUNET_IDENTITY_PROVIDER_AttributeResult ar_cb; | 71 | GNUNET_RECLAIM_AttributeResult ar_cb; |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Revocation result callback | 74 | * Revocation result callback |
75 | */ | 75 | */ |
76 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus rvk_cb; | 76 | GNUNET_RECLAIM_ContinuationWithStatus rvk_cb; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Ticket result callback | 79 | * Ticket result callback |
80 | */ | 80 | */ |
81 | GNUNET_IDENTITY_PROVIDER_TicketCallback tr_cb; | 81 | GNUNET_RECLAIM_TicketCallback tr_cb; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Envelope with the message for this queue entry. | 84 | * Envelope with the message for this queue entry. |
@@ -100,23 +100,23 @@ struct GNUNET_IDENTITY_PROVIDER_Operation | |||
100 | /** | 100 | /** |
101 | * Handle for a ticket iterator operation | 101 | * Handle for a ticket iterator operation |
102 | */ | 102 | */ |
103 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator | 103 | struct GNUNET_RECLAIM_TicketIterator |
104 | { | 104 | { |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * Kept in a DLL. | 107 | * Kept in a DLL. |
108 | */ | 108 | */ |
109 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *next; | 109 | struct GNUNET_RECLAIM_TicketIterator *next; |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Kept in a DLL. | 112 | * Kept in a DLL. |
113 | */ | 113 | */ |
114 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *prev; | 114 | struct GNUNET_RECLAIM_TicketIterator *prev; |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * Main handle to access the idp. | 117 | * Main handle to access the idp. |
118 | */ | 118 | */ |
119 | struct GNUNET_IDENTITY_PROVIDER_Handle *h; | 119 | struct GNUNET_RECLAIM_Handle *h; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Function to call on completion. | 122 | * Function to call on completion. |
@@ -131,7 +131,7 @@ struct GNUNET_IDENTITY_PROVIDER_TicketIterator | |||
131 | /** | 131 | /** |
132 | * The continuation to call with the results | 132 | * The continuation to call with the results |
133 | */ | 133 | */ |
134 | GNUNET_IDENTITY_PROVIDER_TicketCallback tr_cb; | 134 | GNUNET_RECLAIM_TicketCallback tr_cb; |
135 | 135 | ||
136 | /** | 136 | /** |
137 | * Closure for @e tr_cb. | 137 | * Closure for @e tr_cb. |
@@ -165,23 +165,23 @@ struct GNUNET_IDENTITY_PROVIDER_TicketIterator | |||
165 | /** | 165 | /** |
166 | * Handle for a attribute iterator operation | 166 | * Handle for a attribute iterator operation |
167 | */ | 167 | */ |
168 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator | 168 | struct GNUNET_RECLAIM_AttributeIterator |
169 | { | 169 | { |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * Kept in a DLL. | 172 | * Kept in a DLL. |
173 | */ | 173 | */ |
174 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *next; | 174 | struct GNUNET_RECLAIM_AttributeIterator *next; |
175 | 175 | ||
176 | /** | 176 | /** |
177 | * Kept in a DLL. | 177 | * Kept in a DLL. |
178 | */ | 178 | */ |
179 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *prev; | 179 | struct GNUNET_RECLAIM_AttributeIterator *prev; |
180 | 180 | ||
181 | /** | 181 | /** |
182 | * Main handle to access the idp. | 182 | * Main handle to access the idp. |
183 | */ | 183 | */ |
184 | struct GNUNET_IDENTITY_PROVIDER_Handle *h; | 184 | struct GNUNET_RECLAIM_Handle *h; |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * Function to call on completion. | 187 | * Function to call on completion. |
@@ -196,7 +196,7 @@ struct GNUNET_IDENTITY_PROVIDER_AttributeIterator | |||
196 | /** | 196 | /** |
197 | * The continuation to call with the results | 197 | * The continuation to call with the results |
198 | */ | 198 | */ |
199 | GNUNET_IDENTITY_PROVIDER_AttributeResult proc; | 199 | GNUNET_RECLAIM_AttributeResult proc; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | * Closure for @e proc. | 202 | * Closure for @e proc. |
@@ -235,7 +235,7 @@ struct GNUNET_IDENTITY_PROVIDER_AttributeIterator | |||
235 | /** | 235 | /** |
236 | * Handle for the service. | 236 | * Handle for the service. |
237 | */ | 237 | */ |
238 | struct GNUNET_IDENTITY_PROVIDER_Handle | 238 | struct GNUNET_RECLAIM_Handle |
239 | { | 239 | { |
240 | /** | 240 | /** |
241 | * Configuration to use. | 241 | * Configuration to use. |
@@ -255,32 +255,32 @@ struct GNUNET_IDENTITY_PROVIDER_Handle | |||
255 | /** | 255 | /** |
256 | * Head of active operations. | 256 | * Head of active operations. |
257 | */ | 257 | */ |
258 | struct GNUNET_IDENTITY_PROVIDER_Operation *op_head; | 258 | struct GNUNET_RECLAIM_Operation *op_head; |
259 | 259 | ||
260 | /** | 260 | /** |
261 | * Tail of active operations. | 261 | * Tail of active operations. |
262 | */ | 262 | */ |
263 | struct GNUNET_IDENTITY_PROVIDER_Operation *op_tail; | 263 | struct GNUNET_RECLAIM_Operation *op_tail; |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * Head of active iterations | 266 | * Head of active iterations |
267 | */ | 267 | */ |
268 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it_head; | 268 | struct GNUNET_RECLAIM_AttributeIterator *it_head; |
269 | 269 | ||
270 | /** | 270 | /** |
271 | * Tail of active iterations | 271 | * Tail of active iterations |
272 | */ | 272 | */ |
273 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it_tail; | 273 | struct GNUNET_RECLAIM_AttributeIterator *it_tail; |
274 | 274 | ||
275 | /** | 275 | /** |
276 | * Head of active iterations | 276 | * Head of active iterations |
277 | */ | 277 | */ |
278 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *ticket_it_head; | 278 | struct GNUNET_RECLAIM_TicketIterator *ticket_it_head; |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Tail of active iterations | 281 | * Tail of active iterations |
282 | */ | 282 | */ |
283 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *ticket_it_tail; | 283 | struct GNUNET_RECLAIM_TicketIterator *ticket_it_tail; |
284 | 284 | ||
285 | 285 | ||
286 | /** | 286 | /** |
@@ -318,10 +318,10 @@ struct GNUNET_IDENTITY_PROVIDER_Handle | |||
318 | /** | 318 | /** |
319 | * Try again to connect to the service. | 319 | * Try again to connect to the service. |
320 | * | 320 | * |
321 | * @param h handle to the identity provider service. | 321 | * @param h handle to the reclaim service. |
322 | */ | 322 | */ |
323 | static void | 323 | static void |
324 | reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h); | 324 | reconnect (struct GNUNET_RECLAIM_Handle *h); |
325 | 325 | ||
326 | /** | 326 | /** |
327 | * Reconnect | 327 | * Reconnect |
@@ -331,7 +331,7 @@ reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h); | |||
331 | static void | 331 | static void |
332 | reconnect_task (void *cls) | 332 | reconnect_task (void *cls) |
333 | { | 333 | { |
334 | struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; | 334 | struct GNUNET_RECLAIM_Handle *handle = cls; |
335 | 335 | ||
336 | handle->reconnect_task = NULL; | 336 | handle->reconnect_task = NULL; |
337 | reconnect (handle); | 337 | reconnect (handle); |
@@ -344,7 +344,7 @@ reconnect_task (void *cls) | |||
344 | * @param handle our service | 344 | * @param handle our service |
345 | */ | 345 | */ |
346 | static void | 346 | static void |
347 | force_reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *handle) | 347 | force_reconnect (struct GNUNET_RECLAIM_Handle *handle) |
348 | { | 348 | { |
349 | GNUNET_MQ_destroy (handle->mq); | 349 | GNUNET_MQ_destroy (handle->mq); |
350 | handle->mq = NULL; | 350 | handle->mq = NULL; |
@@ -362,9 +362,9 @@ force_reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *handle) | |||
362 | * @param it entry to free | 362 | * @param it entry to free |
363 | */ | 363 | */ |
364 | static void | 364 | static void |
365 | free_it (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it) | 365 | free_it (struct GNUNET_RECLAIM_AttributeIterator *it) |
366 | { | 366 | { |
367 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = it->h; | 367 | struct GNUNET_RECLAIM_Handle *h = it->h; |
368 | 368 | ||
369 | GNUNET_CONTAINER_DLL_remove (h->it_head, | 369 | GNUNET_CONTAINER_DLL_remove (h->it_head, |
370 | h->it_tail, | 370 | h->it_tail, |
@@ -375,7 +375,7 @@ free_it (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it) | |||
375 | } | 375 | } |
376 | 376 | ||
377 | static void | 377 | static void |
378 | free_op (struct GNUNET_IDENTITY_PROVIDER_Operation* op) | 378 | free_op (struct GNUNET_RECLAIM_Operation* op) |
379 | { | 379 | { |
380 | if (NULL == op) | 380 | if (NULL == op) |
381 | return; | 381 | return; |
@@ -397,7 +397,7 @@ static void | |||
397 | mq_error_handler (void *cls, | 397 | mq_error_handler (void *cls, |
398 | enum GNUNET_MQ_Error error) | 398 | enum GNUNET_MQ_Error error) |
399 | { | 399 | { |
400 | struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; | 400 | struct GNUNET_RECLAIM_Handle *handle = cls; |
401 | force_reconnect (handle); | 401 | force_reconnect (handle); |
402 | } | 402 | } |
403 | 403 | ||
@@ -412,8 +412,8 @@ static void | |||
412 | handle_attribute_store_response (void *cls, | 412 | handle_attribute_store_response (void *cls, |
413 | const struct AttributeStoreResultMessage *msg) | 413 | const struct AttributeStoreResultMessage *msg) |
414 | { | 414 | { |
415 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls; | 415 | struct GNUNET_RECLAIM_Handle *h = cls; |
416 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 416 | struct GNUNET_RECLAIM_Operation *op; |
417 | uint32_t r_id = ntohl (msg->id); | 417 | uint32_t r_id = ntohl (msg->id); |
418 | int res; | 418 | int res; |
419 | const char *emsg; | 419 | const char *emsg; |
@@ -448,7 +448,7 @@ handle_attribute_store_response (void *cls, | |||
448 | 448 | ||
449 | /** | 449 | /** |
450 | * Handle an incoming message of type | 450 | * Handle an incoming message of type |
451 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT | 451 | * #GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT |
452 | * | 452 | * |
453 | * @param cls | 453 | * @param cls |
454 | * @param msg the message we received | 454 | * @param msg the message we received |
@@ -474,7 +474,7 @@ check_consume_ticket_result (void *cls, | |||
474 | 474 | ||
475 | /** | 475 | /** |
476 | * Handle an incoming message of type | 476 | * Handle an incoming message of type |
477 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT | 477 | * #GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT |
478 | * | 478 | * |
479 | * @param cls | 479 | * @param cls |
480 | * @param msg the message we received | 480 | * @param msg the message we received |
@@ -483,8 +483,8 @@ static void | |||
483 | handle_consume_ticket_result (void *cls, | 483 | handle_consume_ticket_result (void *cls, |
484 | const struct ConsumeTicketResultMessage *msg) | 484 | const struct ConsumeTicketResultMessage *msg) |
485 | { | 485 | { |
486 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls; | 486 | struct GNUNET_RECLAIM_Handle *h = cls; |
487 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 487 | struct GNUNET_RECLAIM_Operation *op; |
488 | size_t attrs_len; | 488 | size_t attrs_len; |
489 | uint32_t r_id = ntohl (msg->id); | 489 | uint32_t r_id = ntohl (msg->id); |
490 | 490 | ||
@@ -500,9 +500,9 @@ handle_consume_ticket_result (void *cls, | |||
500 | return; | 500 | return; |
501 | 501 | ||
502 | { | 502 | { |
503 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs; | 503 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs; |
504 | struct GNUNET_IDENTITY_ATTRIBUTE_ClaimListEntry *le; | 504 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
505 | attrs = GNUNET_IDENTITY_ATTRIBUTE_list_deserialize ((char*)&msg[1], | 505 | attrs = GNUNET_RECLAIM_ATTRIBUTE_list_deserialize ((char*)&msg[1], |
506 | attrs_len); | 506 | attrs_len); |
507 | if (NULL != op->ar_cb) | 507 | if (NULL != op->ar_cb) |
508 | { | 508 | { |
@@ -518,7 +518,7 @@ handle_consume_ticket_result (void *cls, | |||
518 | op->ar_cb (op->cls, | 518 | op->ar_cb (op->cls, |
519 | &msg->identity, | 519 | &msg->identity, |
520 | le->claim); | 520 | le->claim); |
521 | GNUNET_IDENTITY_ATTRIBUTE_list_destroy (attrs); | 521 | GNUNET_RECLAIM_ATTRIBUTE_list_destroy (attrs); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | if (NULL != op) | 524 | if (NULL != op) |
@@ -539,7 +539,7 @@ handle_consume_ticket_result (void *cls, | |||
539 | 539 | ||
540 | /** | 540 | /** |
541 | * Handle an incoming message of type | 541 | * Handle an incoming message of type |
542 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT | 542 | * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT |
543 | * | 543 | * |
544 | * @param cls | 544 | * @param cls |
545 | * @param msg the message we received | 545 | * @param msg the message we received |
@@ -565,7 +565,7 @@ check_attribute_result (void *cls, | |||
565 | 565 | ||
566 | /** | 566 | /** |
567 | * Handle an incoming message of type | 567 | * Handle an incoming message of type |
568 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT | 568 | * #GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT |
569 | * | 569 | * |
570 | * @param cls | 570 | * @param cls |
571 | * @param msg the message we received | 571 | * @param msg the message we received |
@@ -575,9 +575,9 @@ handle_attribute_result (void *cls, | |||
575 | const struct AttributeResultMessage *msg) | 575 | const struct AttributeResultMessage *msg) |
576 | { | 576 | { |
577 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; | 577 | static struct GNUNET_CRYPTO_EcdsaPrivateKey identity_dummy; |
578 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls; | 578 | struct GNUNET_RECLAIM_Handle *h = cls; |
579 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it; | 579 | struct GNUNET_RECLAIM_AttributeIterator *it; |
580 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 580 | struct GNUNET_RECLAIM_Operation *op; |
581 | size_t attr_len; | 581 | size_t attr_len; |
582 | uint32_t r_id = ntohl (msg->id); | 582 | uint32_t r_id = ntohl (msg->id); |
583 | 583 | ||
@@ -627,8 +627,8 @@ handle_attribute_result (void *cls, | |||
627 | } | 627 | } |
628 | 628 | ||
629 | { | 629 | { |
630 | struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr; | 630 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; |
631 | attr = GNUNET_IDENTITY_ATTRIBUTE_deserialize ((char*)&msg[1], | 631 | attr = GNUNET_RECLAIM_ATTRIBUTE_deserialize ((char*)&msg[1], |
632 | attr_len); | 632 | attr_len); |
633 | if (NULL != it) | 633 | if (NULL != it) |
634 | { | 634 | { |
@@ -652,7 +652,7 @@ handle_attribute_result (void *cls, | |||
652 | 652 | ||
653 | /** | 653 | /** |
654 | * Handle an incoming message of type | 654 | * Handle an incoming message of type |
655 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT | 655 | * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT |
656 | * | 656 | * |
657 | * @param cls | 657 | * @param cls |
658 | * @param msg the message we received | 658 | * @param msg the message we received |
@@ -677,7 +677,7 @@ check_ticket_result (void *cls, | |||
677 | 677 | ||
678 | /** | 678 | /** |
679 | * Handle an incoming message of type | 679 | * Handle an incoming message of type |
680 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT | 680 | * #GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT |
681 | * | 681 | * |
682 | * @param cls | 682 | * @param cls |
683 | * @param msg the message we received | 683 | * @param msg the message we received |
@@ -686,10 +686,10 @@ static void | |||
686 | handle_ticket_result (void *cls, | 686 | handle_ticket_result (void *cls, |
687 | const struct TicketResultMessage *msg) | 687 | const struct TicketResultMessage *msg) |
688 | { | 688 | { |
689 | struct GNUNET_IDENTITY_PROVIDER_Handle *handle = cls; | 689 | struct GNUNET_RECLAIM_Handle *handle = cls; |
690 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 690 | struct GNUNET_RECLAIM_Operation *op; |
691 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it; | 691 | struct GNUNET_RECLAIM_TicketIterator *it; |
692 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket; | 692 | const struct GNUNET_RECLAIM_Ticket *ticket; |
693 | uint32_t r_id = ntohl (msg->id); | 693 | uint32_t r_id = ntohl (msg->id); |
694 | size_t msg_len; | 694 | size_t msg_len; |
695 | 695 | ||
@@ -712,7 +712,7 @@ handle_ticket_result (void *cls, | |||
712 | if (NULL != op->tr_cb) | 712 | if (NULL != op->tr_cb) |
713 | op->tr_cb (op->cls, NULL); | 713 | op->tr_cb (op->cls, NULL); |
714 | } else { | 714 | } else { |
715 | ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket *)&msg[1]; | 715 | ticket = (struct GNUNET_RECLAIM_Ticket *)&msg[1]; |
716 | if (NULL != op->tr_cb) | 716 | if (NULL != op->tr_cb) |
717 | op->tr_cb (op->cls, ticket); | 717 | op->tr_cb (op->cls, ticket); |
718 | } | 718 | } |
@@ -728,7 +728,7 @@ handle_ticket_result (void *cls, | |||
728 | it->finish_cb (it->finish_cb_cls); | 728 | it->finish_cb (it->finish_cb_cls); |
729 | GNUNET_free (it); | 729 | GNUNET_free (it); |
730 | } else { | 730 | } else { |
731 | ticket = (struct GNUNET_IDENTITY_PROVIDER_Ticket *)&msg[1]; | 731 | ticket = (struct GNUNET_RECLAIM_Ticket *)&msg[1]; |
732 | if (NULL != it->tr_cb) | 732 | if (NULL != it->tr_cb) |
733 | it->tr_cb (it->cls, ticket); | 733 | it->tr_cb (it->cls, ticket); |
734 | } | 734 | } |
@@ -740,7 +740,7 @@ handle_ticket_result (void *cls, | |||
740 | 740 | ||
741 | /** | 741 | /** |
742 | * Handle an incoming message of type | 742 | * Handle an incoming message of type |
743 | * #GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT | 743 | * #GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT |
744 | * | 744 | * |
745 | * @param cls | 745 | * @param cls |
746 | * @param msg the message we received | 746 | * @param msg the message we received |
@@ -749,8 +749,8 @@ static void | |||
749 | handle_revoke_ticket_result (void *cls, | 749 | handle_revoke_ticket_result (void *cls, |
750 | const struct RevokeTicketResultMessage *msg) | 750 | const struct RevokeTicketResultMessage *msg) |
751 | { | 751 | { |
752 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = cls; | 752 | struct GNUNET_RECLAIM_Handle *h = cls; |
753 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 753 | struct GNUNET_RECLAIM_Operation *op; |
754 | uint32_t r_id = ntohl (msg->id); | 754 | uint32_t r_id = ntohl (msg->id); |
755 | int32_t success; | 755 | int32_t success; |
756 | 756 | ||
@@ -785,42 +785,42 @@ handle_revoke_ticket_result (void *cls, | |||
785 | /** | 785 | /** |
786 | * Try again to connect to the service. | 786 | * Try again to connect to the service. |
787 | * | 787 | * |
788 | * @param h handle to the identity provider service. | 788 | * @param h handle to the reclaim service. |
789 | */ | 789 | */ |
790 | static void | 790 | static void |
791 | reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) | 791 | reconnect (struct GNUNET_RECLAIM_Handle *h) |
792 | { | 792 | { |
793 | struct GNUNET_MQ_MessageHandler handlers[] = { | 793 | struct GNUNET_MQ_MessageHandler handlers[] = { |
794 | GNUNET_MQ_hd_fixed_size (attribute_store_response, | 794 | GNUNET_MQ_hd_fixed_size (attribute_store_response, |
795 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE_RESPONSE, | 795 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE_RESPONSE, |
796 | struct AttributeStoreResultMessage, | 796 | struct AttributeStoreResultMessage, |
797 | h), | 797 | h), |
798 | GNUNET_MQ_hd_var_size (attribute_result, | 798 | GNUNET_MQ_hd_var_size (attribute_result, |
799 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_RESULT, | 799 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_RESULT, |
800 | struct AttributeResultMessage, | 800 | struct AttributeResultMessage, |
801 | h), | 801 | h), |
802 | GNUNET_MQ_hd_var_size (ticket_result, | 802 | GNUNET_MQ_hd_var_size (ticket_result, |
803 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_RESULT, | 803 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_RESULT, |
804 | struct TicketResultMessage, | 804 | struct TicketResultMessage, |
805 | h), | 805 | h), |
806 | GNUNET_MQ_hd_var_size (consume_ticket_result, | 806 | GNUNET_MQ_hd_var_size (consume_ticket_result, |
807 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET_RESULT, | 807 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET_RESULT, |
808 | struct ConsumeTicketResultMessage, | 808 | struct ConsumeTicketResultMessage, |
809 | h), | 809 | h), |
810 | GNUNET_MQ_hd_fixed_size (revoke_ticket_result, | 810 | GNUNET_MQ_hd_fixed_size (revoke_ticket_result, |
811 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET_RESULT, | 811 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET_RESULT, |
812 | struct RevokeTicketResultMessage, | 812 | struct RevokeTicketResultMessage, |
813 | h), | 813 | h), |
814 | GNUNET_MQ_handler_end () | 814 | GNUNET_MQ_handler_end () |
815 | }; | 815 | }; |
816 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 816 | struct GNUNET_RECLAIM_Operation *op; |
817 | 817 | ||
818 | GNUNET_assert (NULL == h->mq); | 818 | GNUNET_assert (NULL == h->mq); |
819 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 819 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
820 | "Connecting to identity provider service.\n"); | 820 | "Connecting to reclaim service.\n"); |
821 | 821 | ||
822 | h->mq = GNUNET_CLIENT_connect (h->cfg, | 822 | h->mq = GNUNET_CLIENT_connect (h->cfg, |
823 | "identity-provider", | 823 | "reclaim", |
824 | handlers, | 824 | handlers, |
825 | &mq_error_handler, | 825 | &mq_error_handler, |
826 | h); | 826 | h); |
@@ -833,17 +833,17 @@ reconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) | |||
833 | 833 | ||
834 | 834 | ||
835 | /** | 835 | /** |
836 | * Connect to the identity provider service. | 836 | * Connect to the reclaim service. |
837 | * | 837 | * |
838 | * @param cfg the configuration to use | 838 | * @param cfg the configuration to use |
839 | * @return handle to use | 839 | * @return handle to use |
840 | */ | 840 | */ |
841 | struct GNUNET_IDENTITY_PROVIDER_Handle * | 841 | struct GNUNET_RECLAIM_Handle * |
842 | GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | 842 | GNUNET_RECLAIM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) |
843 | { | 843 | { |
844 | struct GNUNET_IDENTITY_PROVIDER_Handle *h; | 844 | struct GNUNET_RECLAIM_Handle *h; |
845 | 845 | ||
846 | h = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Handle); | 846 | h = GNUNET_new (struct GNUNET_RECLAIM_Handle); |
847 | h->cfg = cfg; | 847 | h->cfg = cfg; |
848 | reconnect (h); | 848 | reconnect (h); |
849 | if (NULL == h->mq) | 849 | if (NULL == h->mq) |
@@ -864,9 +864,9 @@ GNUNET_IDENTITY_PROVIDER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
864 | * @param op operation to cancel | 864 | * @param op operation to cancel |
865 | */ | 865 | */ |
866 | void | 866 | void |
867 | GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op) | 867 | GNUNET_RECLAIM_cancel (struct GNUNET_RECLAIM_Operation *op) |
868 | { | 868 | { |
869 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = op->h; | 869 | struct GNUNET_RECLAIM_Handle *h = op->h; |
870 | 870 | ||
871 | GNUNET_CONTAINER_DLL_remove (h->op_head, | 871 | GNUNET_CONTAINER_DLL_remove (h->op_head, |
872 | h->op_tail, | 872 | h->op_tail, |
@@ -881,7 +881,7 @@ GNUNET_IDENTITY_PROVIDER_cancel (struct GNUNET_IDENTITY_PROVIDER_Operation *op) | |||
881 | * @param h handle to destroy | 881 | * @param h handle to destroy |
882 | */ | 882 | */ |
883 | void | 883 | void |
884 | GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) | 884 | GNUNET_RECLAIM_disconnect (struct GNUNET_RECLAIM_Handle *h) |
885 | { | 885 | { |
886 | GNUNET_assert (NULL != h); | 886 | GNUNET_assert (NULL != h); |
887 | if (NULL != h->mq) | 887 | if (NULL != h->mq) |
@@ -902,7 +902,7 @@ GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) | |||
902 | * Store an attribute. If the attribute is already present, | 902 | * Store an attribute. If the attribute is already present, |
903 | * it is replaced with the new attribute. | 903 | * it is replaced with the new attribute. |
904 | * | 904 | * |
905 | * @param h handle to the identity provider | 905 | * @param h handle to the reclaim |
906 | * @param pkey private key of the identity | 906 | * @param pkey private key of the identity |
907 | * @param attr the attribute value | 907 | * @param attr the attribute value |
908 | * @param exp_interval the relative expiration interval for the attribute | 908 | * @param exp_interval the relative expiration interval for the attribute |
@@ -910,19 +910,19 @@ GNUNET_IDENTITY_PROVIDER_disconnect (struct GNUNET_IDENTITY_PROVIDER_Handle *h) | |||
910 | * @param cont_cls closure for @a cont | 910 | * @param cont_cls closure for @a cont |
911 | * @return handle to abort the request | 911 | * @return handle to abort the request |
912 | */ | 912 | */ |
913 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 913 | struct GNUNET_RECLAIM_Operation * |
914 | GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 914 | GNUNET_RECLAIM_attribute_store (struct GNUNET_RECLAIM_Handle *h, |
915 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 915 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
916 | const struct GNUNET_IDENTITY_ATTRIBUTE_Claim *attr, | 916 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr, |
917 | const struct GNUNET_TIME_Relative *exp_interval, | 917 | const struct GNUNET_TIME_Relative *exp_interval, |
918 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cont, | 918 | GNUNET_RECLAIM_ContinuationWithStatus cont, |
919 | void *cont_cls) | 919 | void *cont_cls) |
920 | { | 920 | { |
921 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 921 | struct GNUNET_RECLAIM_Operation *op; |
922 | struct AttributeStoreMessage *sam; | 922 | struct AttributeStoreMessage *sam; |
923 | size_t attr_len; | 923 | size_t attr_len; |
924 | 924 | ||
925 | op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation); | 925 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
926 | op->h = h; | 926 | op->h = h; |
927 | op->as_cb = cont; | 927 | op->as_cb = cont; |
928 | op->cls = cont_cls; | 928 | op->cls = cont_cls; |
@@ -930,15 +930,15 @@ GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
930 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, | 930 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, |
931 | h->op_tail, | 931 | h->op_tail, |
932 | op); | 932 | op); |
933 | attr_len = GNUNET_IDENTITY_ATTRIBUTE_serialize_get_size (attr); | 933 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (attr); |
934 | op->env = GNUNET_MQ_msg_extra (sam, | 934 | op->env = GNUNET_MQ_msg_extra (sam, |
935 | attr_len, | 935 | attr_len, |
936 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_STORE); | 936 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_STORE); |
937 | sam->identity = *pkey; | 937 | sam->identity = *pkey; |
938 | sam->id = htonl (op->r_id); | 938 | sam->id = htonl (op->r_id); |
939 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); | 939 | sam->exp = GNUNET_htonll (exp_interval->rel_value_us); |
940 | 940 | ||
941 | GNUNET_IDENTITY_ATTRIBUTE_serialize (attr, | 941 | GNUNET_RECLAIM_ATTRIBUTE_serialize (attr, |
942 | (char*)&sam[1]); | 942 | (char*)&sam[1]); |
943 | 943 | ||
944 | sam->attr_len = htons (attr_len); | 944 | sam->attr_len = htons (attr_len); |
@@ -952,11 +952,11 @@ GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
952 | 952 | ||
953 | /** | 953 | /** |
954 | * List all attributes for a local identity. | 954 | * List all attributes for a local identity. |
955 | * This MUST lock the `struct GNUNET_IDENTITY_PROVIDER_Handle` | 955 | * This MUST lock the `struct GNUNET_RECLAIM_Handle` |
956 | * for any other calls than #GNUNET_IDENTITY_PROVIDER_get_attributes_next() and | 956 | * for any other calls than #GNUNET_RECLAIM_get_attributes_next() and |
957 | * #GNUNET_IDENTITY_PROVIDER_get_attributes_stop. @a proc will be called once | 957 | * #GNUNET_RECLAIM_get_attributes_stop. @a proc will be called once |
958 | * immediately, and then again after | 958 | * immediately, and then again after |
959 | * #GNUNET_IDENTITY_PROVIDER_get_attributes_next() is invoked. | 959 | * #GNUNET_RECLAIM_get_attributes_next() is invoked. |
960 | * | 960 | * |
961 | * On error (disconnect), @a error_cb will be invoked. | 961 | * On error (disconnect), @a error_cb will be invoked. |
962 | * On normal completion, @a finish_cb proc will be | 962 | * On normal completion, @a finish_cb proc will be |
@@ -975,23 +975,23 @@ GNUNET_IDENTITY_PROVIDER_attribute_store (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
975 | * @param finish_cb_cls closure for @a finish_cb | 975 | * @param finish_cb_cls closure for @a finish_cb |
976 | * @return an iterator handle to use for iteration | 976 | * @return an iterator handle to use for iteration |
977 | */ | 977 | */ |
978 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator * | 978 | struct GNUNET_RECLAIM_AttributeIterator * |
979 | GNUNET_IDENTITY_PROVIDER_get_attributes_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 979 | GNUNET_RECLAIM_get_attributes_start (struct GNUNET_RECLAIM_Handle *h, |
980 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 980 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
981 | GNUNET_SCHEDULER_TaskCallback error_cb, | 981 | GNUNET_SCHEDULER_TaskCallback error_cb, |
982 | void *error_cb_cls, | 982 | void *error_cb_cls, |
983 | GNUNET_IDENTITY_PROVIDER_AttributeResult proc, | 983 | GNUNET_RECLAIM_AttributeResult proc, |
984 | void *proc_cls, | 984 | void *proc_cls, |
985 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 985 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
986 | void *finish_cb_cls) | 986 | void *finish_cb_cls) |
987 | { | 987 | { |
988 | struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it; | 988 | struct GNUNET_RECLAIM_AttributeIterator *it; |
989 | struct GNUNET_MQ_Envelope *env; | 989 | struct GNUNET_MQ_Envelope *env; |
990 | struct AttributeIterationStartMessage *msg; | 990 | struct AttributeIterationStartMessage *msg; |
991 | uint32_t rid; | 991 | uint32_t rid; |
992 | 992 | ||
993 | rid = h->r_id_gen++; | 993 | rid = h->r_id_gen++; |
994 | it = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator); | 994 | it = GNUNET_new (struct GNUNET_RECLAIM_AttributeIterator); |
995 | it->h = h; | 995 | it->h = h; |
996 | it->error_cb = error_cb; | 996 | it->error_cb = error_cb; |
997 | it->error_cb_cls = error_cb_cls; | 997 | it->error_cb_cls = error_cb_cls; |
@@ -1005,7 +1005,7 @@ GNUNET_IDENTITY_PROVIDER_get_attributes_start (struct GNUNET_IDENTITY_PROVIDER_H | |||
1005 | h->it_tail, | 1005 | h->it_tail, |
1006 | it); | 1006 | it); |
1007 | env = GNUNET_MQ_msg (msg, | 1007 | env = GNUNET_MQ_msg (msg, |
1008 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_START); | 1008 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_START); |
1009 | msg->id = htonl (rid); | 1009 | msg->id = htonl (rid); |
1010 | msg->identity = *identity; | 1010 | msg->identity = *identity; |
1011 | if (NULL == h->mq) | 1011 | if (NULL == h->mq) |
@@ -1018,20 +1018,20 @@ GNUNET_IDENTITY_PROVIDER_get_attributes_start (struct GNUNET_IDENTITY_PROVIDER_H | |||
1018 | 1018 | ||
1019 | 1019 | ||
1020 | /** | 1020 | /** |
1021 | * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_get_attributes_start | 1021 | * Calls the record processor specified in #GNUNET_RECLAIM_get_attributes_start |
1022 | * for the next record. | 1022 | * for the next record. |
1023 | * | 1023 | * |
1024 | * @param it the iterator | 1024 | * @param it the iterator |
1025 | */ | 1025 | */ |
1026 | void | 1026 | void |
1027 | GNUNET_IDENTITY_PROVIDER_get_attributes_next (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it) | 1027 | GNUNET_RECLAIM_get_attributes_next (struct GNUNET_RECLAIM_AttributeIterator *it) |
1028 | { | 1028 | { |
1029 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = it->h; | 1029 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1030 | struct AttributeIterationNextMessage *msg; | 1030 | struct AttributeIterationNextMessage *msg; |
1031 | struct GNUNET_MQ_Envelope *env; | 1031 | struct GNUNET_MQ_Envelope *env; |
1032 | 1032 | ||
1033 | env = GNUNET_MQ_msg (msg, | 1033 | env = GNUNET_MQ_msg (msg, |
1034 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_NEXT); | 1034 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_NEXT); |
1035 | msg->id = htonl (it->r_id); | 1035 | msg->id = htonl (it->r_id); |
1036 | GNUNET_MQ_send (h->mq, | 1036 | GNUNET_MQ_send (h->mq, |
1037 | env); | 1037 | env); |
@@ -1041,21 +1041,21 @@ GNUNET_IDENTITY_PROVIDER_get_attributes_next (struct GNUNET_IDENTITY_PROVIDER_At | |||
1041 | /** | 1041 | /** |
1042 | * Stops iteration and releases the idp handle for further calls. Must | 1042 | * Stops iteration and releases the idp handle for further calls. Must |
1043 | * be called on any iteration that has not yet completed prior to calling | 1043 | * be called on any iteration that has not yet completed prior to calling |
1044 | * #GNUNET_IDENTITY_PROVIDER_disconnect. | 1044 | * #GNUNET_RECLAIM_disconnect. |
1045 | * | 1045 | * |
1046 | * @param it the iterator | 1046 | * @param it the iterator |
1047 | */ | 1047 | */ |
1048 | void | 1048 | void |
1049 | GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_AttributeIterator *it) | 1049 | GNUNET_RECLAIM_get_attributes_stop (struct GNUNET_RECLAIM_AttributeIterator *it) |
1050 | { | 1050 | { |
1051 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = it->h; | 1051 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1052 | struct GNUNET_MQ_Envelope *env; | 1052 | struct GNUNET_MQ_Envelope *env; |
1053 | struct AttributeIterationStopMessage *msg; | 1053 | struct AttributeIterationStopMessage *msg; |
1054 | 1054 | ||
1055 | if (NULL != h->mq) | 1055 | if (NULL != h->mq) |
1056 | { | 1056 | { |
1057 | env = GNUNET_MQ_msg (msg, | 1057 | env = GNUNET_MQ_msg (msg, |
1058 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ATTRIBUTE_ITERATION_STOP); | 1058 | GNUNET_MESSAGE_TYPE_RECLAIM_ATTRIBUTE_ITERATION_STOP); |
1059 | msg->id = htonl (it->r_id); | 1059 | msg->id = htonl (it->r_id); |
1060 | GNUNET_MQ_send (h->mq, | 1060 | GNUNET_MQ_send (h->mq, |
1061 | env); | 1061 | env); |
@@ -1066,10 +1066,10 @@ GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_At | |||
1066 | 1066 | ||
1067 | /** TODO | 1067 | /** TODO |
1068 | * Issues a ticket to another identity. The identity may use | 1068 | * Issues a ticket to another identity. The identity may use |
1069 | * @GNUNET_IDENTITY_PROVIDER_authorization_ticket_consume to consume the ticket | 1069 | * @GNUNET_RECLAIM_authorization_ticket_consume to consume the ticket |
1070 | * and retrieve the attributes specified in the AttributeList. | 1070 | * and retrieve the attributes specified in the AttributeList. |
1071 | * | 1071 | * |
1072 | * @param h the identity provider to use | 1072 | * @param h the reclaim to use |
1073 | * @param iss the issuing identity | 1073 | * @param iss the issuing identity |
1074 | * @param rp the subject of the ticket (the relying party) | 1074 | * @param rp the subject of the ticket (the relying party) |
1075 | * @param attrs the attributes that the relying party is given access to | 1075 | * @param attrs the attributes that the relying party is given access to |
@@ -1077,19 +1077,19 @@ GNUNET_IDENTITY_PROVIDER_get_attributes_stop (struct GNUNET_IDENTITY_PROVIDER_At | |||
1077 | * @param cb_cls the callback closure | 1077 | * @param cb_cls the callback closure |
1078 | * @return handle to abort the operation | 1078 | * @return handle to abort the operation |
1079 | */ | 1079 | */ |
1080 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 1080 | struct GNUNET_RECLAIM_Operation * |
1081 | GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 1081 | GNUNET_RECLAIM_ticket_issue (struct GNUNET_RECLAIM_Handle *h, |
1082 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, | 1082 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *iss, |
1083 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, | 1083 | const struct GNUNET_CRYPTO_EcdsaPublicKey *rp, |
1084 | const struct GNUNET_IDENTITY_ATTRIBUTE_ClaimList *attrs, | 1084 | const struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList *attrs, |
1085 | GNUNET_IDENTITY_PROVIDER_TicketCallback cb, | 1085 | GNUNET_RECLAIM_TicketCallback cb, |
1086 | void *cb_cls) | 1086 | void *cb_cls) |
1087 | { | 1087 | { |
1088 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 1088 | struct GNUNET_RECLAIM_Operation *op; |
1089 | struct IssueTicketMessage *tim; | 1089 | struct IssueTicketMessage *tim; |
1090 | size_t attr_len; | 1090 | size_t attr_len; |
1091 | 1091 | ||
1092 | op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation); | 1092 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1093 | op->h = h; | 1093 | op->h = h; |
1094 | op->tr_cb = cb; | 1094 | op->tr_cb = cb; |
1095 | op->cls = cb_cls; | 1095 | op->cls = cb_cls; |
@@ -1097,15 +1097,15 @@ GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h | |||
1097 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, | 1097 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, |
1098 | h->op_tail, | 1098 | h->op_tail, |
1099 | op); | 1099 | op); |
1100 | attr_len = GNUNET_IDENTITY_ATTRIBUTE_list_serialize_get_size (attrs); | 1100 | attr_len = GNUNET_RECLAIM_ATTRIBUTE_list_serialize_get_size (attrs); |
1101 | op->env = GNUNET_MQ_msg_extra (tim, | 1101 | op->env = GNUNET_MQ_msg_extra (tim, |
1102 | attr_len, | 1102 | attr_len, |
1103 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_ISSUE_TICKET); | 1103 | GNUNET_MESSAGE_TYPE_RECLAIM_ISSUE_TICKET); |
1104 | tim->identity = *iss; | 1104 | tim->identity = *iss; |
1105 | tim->rp = *rp; | 1105 | tim->rp = *rp; |
1106 | tim->id = htonl (op->r_id); | 1106 | tim->id = htonl (op->r_id); |
1107 | 1107 | ||
1108 | GNUNET_IDENTITY_ATTRIBUTE_list_serialize (attrs, | 1108 | GNUNET_RECLAIM_ATTRIBUTE_list_serialize (attrs, |
1109 | (char*)&tim[1]); | 1109 | (char*)&tim[1]); |
1110 | 1110 | ||
1111 | tim->attr_len = htons (attr_len); | 1111 | tim->attr_len = htons (attr_len); |
@@ -1119,24 +1119,24 @@ GNUNET_IDENTITY_PROVIDER_ticket_issue (struct GNUNET_IDENTITY_PROVIDER_Handle *h | |||
1119 | * Consumes an issued ticket. The ticket is persisted | 1119 | * Consumes an issued ticket. The ticket is persisted |
1120 | * and used to retrieve identity information from the issuer | 1120 | * and used to retrieve identity information from the issuer |
1121 | * | 1121 | * |
1122 | * @param h the identity provider to use | 1122 | * @param h the reclaim to use |
1123 | * @param identity the identity that is the subject of the issued ticket (the relying party) | 1123 | * @param identity the identity that is the subject of the issued ticket (the relying party) |
1124 | * @param ticket the issued ticket to consume | 1124 | * @param ticket the issued ticket to consume |
1125 | * @param cb the callback to call | 1125 | * @param cb the callback to call |
1126 | * @param cb_cls the callback closure | 1126 | * @param cb_cls the callback closure |
1127 | * @return handle to abort the operation | 1127 | * @return handle to abort the operation |
1128 | */ | 1128 | */ |
1129 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 1129 | struct GNUNET_RECLAIM_Operation * |
1130 | GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 1130 | GNUNET_RECLAIM_ticket_consume (struct GNUNET_RECLAIM_Handle *h, |
1131 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1131 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1132 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 1132 | const struct GNUNET_RECLAIM_Ticket *ticket, |
1133 | GNUNET_IDENTITY_PROVIDER_AttributeResult cb, | 1133 | GNUNET_RECLAIM_AttributeResult cb, |
1134 | void *cb_cls) | 1134 | void *cb_cls) |
1135 | { | 1135 | { |
1136 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 1136 | struct GNUNET_RECLAIM_Operation *op; |
1137 | struct ConsumeTicketMessage *ctm; | 1137 | struct ConsumeTicketMessage *ctm; |
1138 | 1138 | ||
1139 | op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation); | 1139 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1140 | op->h = h; | 1140 | op->h = h; |
1141 | op->ar_cb = cb; | 1141 | op->ar_cb = cb; |
1142 | op->cls = cb_cls; | 1142 | op->cls = cb_cls; |
@@ -1145,14 +1145,14 @@ GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
1145 | h->op_tail, | 1145 | h->op_tail, |
1146 | op); | 1146 | op); |
1147 | op->env = GNUNET_MQ_msg_extra (ctm, | 1147 | op->env = GNUNET_MQ_msg_extra (ctm, |
1148 | sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket), | 1148 | sizeof (const struct GNUNET_RECLAIM_Ticket), |
1149 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_CONSUME_TICKET); | 1149 | GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET); |
1150 | ctm->identity = *identity; | 1150 | ctm->identity = *identity; |
1151 | ctm->id = htonl (op->r_id); | 1151 | ctm->id = htonl (op->r_id); |
1152 | 1152 | ||
1153 | GNUNET_memcpy ((char*)&ctm[1], | 1153 | GNUNET_memcpy ((char*)&ctm[1], |
1154 | ticket, | 1154 | ticket, |
1155 | sizeof (const struct GNUNET_IDENTITY_PROVIDER_Ticket)); | 1155 | sizeof (const struct GNUNET_RECLAIM_Ticket)); |
1156 | 1156 | ||
1157 | if (NULL != h->mq) | 1157 | if (NULL != h->mq) |
1158 | GNUNET_MQ_send_copy (h->mq, | 1158 | GNUNET_MQ_send_copy (h->mq, |
@@ -1166,7 +1166,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
1166 | * Lists all tickets that have been issued to remote | 1166 | * Lists all tickets that have been issued to remote |
1167 | * identites (relying parties) | 1167 | * identites (relying parties) |
1168 | * | 1168 | * |
1169 | * @param h the identity provider to use | 1169 | * @param h the reclaim to use |
1170 | * @param identity the issuing identity | 1170 | * @param identity the issuing identity |
1171 | * @param error_cb function to call on error (i.e. disconnect), | 1171 | * @param error_cb function to call on error (i.e. disconnect), |
1172 | * the handle is afterwards invalid | 1172 | * the handle is afterwards invalid |
@@ -1179,17 +1179,17 @@ GNUNET_IDENTITY_PROVIDER_ticket_consume (struct GNUNET_IDENTITY_PROVIDER_Handle | |||
1179 | * @param finish_cb_cls closure for @a finish_cb | 1179 | * @param finish_cb_cls closure for @a finish_cb |
1180 | * @return an iterator handle to use for iteration | 1180 | * @return an iterator handle to use for iteration |
1181 | */ | 1181 | */ |
1182 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator * | 1182 | struct GNUNET_RECLAIM_TicketIterator * |
1183 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 1183 | GNUNET_RECLAIM_ticket_iteration_start (struct GNUNET_RECLAIM_Handle *h, |
1184 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1184 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1185 | GNUNET_SCHEDULER_TaskCallback error_cb, | 1185 | GNUNET_SCHEDULER_TaskCallback error_cb, |
1186 | void *error_cb_cls, | 1186 | void *error_cb_cls, |
1187 | GNUNET_IDENTITY_PROVIDER_TicketCallback proc, | 1187 | GNUNET_RECLAIM_TicketCallback proc, |
1188 | void *proc_cls, | 1188 | void *proc_cls, |
1189 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 1189 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
1190 | void *finish_cb_cls) | 1190 | void *finish_cb_cls) |
1191 | { | 1191 | { |
1192 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it; | 1192 | struct GNUNET_RECLAIM_TicketIterator *it; |
1193 | struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub; | 1193 | struct GNUNET_CRYPTO_EcdsaPublicKey identity_pub; |
1194 | struct GNUNET_MQ_Envelope *env; | 1194 | struct GNUNET_MQ_Envelope *env; |
1195 | struct TicketIterationStartMessage *msg; | 1195 | struct TicketIterationStartMessage *msg; |
@@ -1198,7 +1198,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER | |||
1198 | GNUNET_CRYPTO_ecdsa_key_get_public (identity, | 1198 | GNUNET_CRYPTO_ecdsa_key_get_public (identity, |
1199 | &identity_pub); | 1199 | &identity_pub); |
1200 | rid = h->r_id_gen++; | 1200 | rid = h->r_id_gen++; |
1201 | it = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_TicketIterator); | 1201 | it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator); |
1202 | it->h = h; | 1202 | it->h = h; |
1203 | it->error_cb = error_cb; | 1203 | it->error_cb = error_cb; |
1204 | it->error_cb_cls = error_cb_cls; | 1204 | it->error_cb_cls = error_cb_cls; |
@@ -1211,7 +1211,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER | |||
1211 | h->ticket_it_tail, | 1211 | h->ticket_it_tail, |
1212 | it); | 1212 | it); |
1213 | env = GNUNET_MQ_msg (msg, | 1213 | env = GNUNET_MQ_msg (msg, |
1214 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_START); | 1214 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); |
1215 | msg->id = htonl (rid); | 1215 | msg->id = htonl (rid); |
1216 | msg->identity = identity_pub; | 1216 | msg->identity = identity_pub; |
1217 | msg->is_audience = htonl (GNUNET_NO); | 1217 | msg->is_audience = htonl (GNUNET_NO); |
@@ -1229,7 +1229,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER | |||
1229 | * Lists all tickets that have been issued to remote | 1229 | * Lists all tickets that have been issued to remote |
1230 | * identites (relying parties) | 1230 | * identites (relying parties) |
1231 | * | 1231 | * |
1232 | * @param h the identity provider to use | 1232 | * @param h the reclaim to use |
1233 | * @param identity the issuing identity | 1233 | * @param identity the issuing identity |
1234 | * @param error_cb function to call on error (i.e. disconnect), | 1234 | * @param error_cb function to call on error (i.e. disconnect), |
1235 | * the handle is afterwards invalid | 1235 | * the handle is afterwards invalid |
@@ -1242,23 +1242,23 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_start (struct GNUNET_IDENTITY_PROVIDER | |||
1242 | * @param finish_cb_cls closure for @a finish_cb | 1242 | * @param finish_cb_cls closure for @a finish_cb |
1243 | * @return an iterator handle to use for iteration | 1243 | * @return an iterator handle to use for iteration |
1244 | */ | 1244 | */ |
1245 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator * | 1245 | struct GNUNET_RECLAIM_TicketIterator * |
1246 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_start_rp (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 1246 | GNUNET_RECLAIM_ticket_iteration_start_rp (struct GNUNET_RECLAIM_Handle *h, |
1247 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 1247 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
1248 | GNUNET_SCHEDULER_TaskCallback error_cb, | 1248 | GNUNET_SCHEDULER_TaskCallback error_cb, |
1249 | void *error_cb_cls, | 1249 | void *error_cb_cls, |
1250 | GNUNET_IDENTITY_PROVIDER_TicketCallback proc, | 1250 | GNUNET_RECLAIM_TicketCallback proc, |
1251 | void *proc_cls, | 1251 | void *proc_cls, |
1252 | GNUNET_SCHEDULER_TaskCallback finish_cb, | 1252 | GNUNET_SCHEDULER_TaskCallback finish_cb, |
1253 | void *finish_cb_cls) | 1253 | void *finish_cb_cls) |
1254 | { | 1254 | { |
1255 | struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it; | 1255 | struct GNUNET_RECLAIM_TicketIterator *it; |
1256 | struct GNUNET_MQ_Envelope *env; | 1256 | struct GNUNET_MQ_Envelope *env; |
1257 | struct TicketIterationStartMessage *msg; | 1257 | struct TicketIterationStartMessage *msg; |
1258 | uint32_t rid; | 1258 | uint32_t rid; |
1259 | 1259 | ||
1260 | rid = h->r_id_gen++; | 1260 | rid = h->r_id_gen++; |
1261 | it = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_TicketIterator); | 1261 | it = GNUNET_new (struct GNUNET_RECLAIM_TicketIterator); |
1262 | it->h = h; | 1262 | it->h = h; |
1263 | it->error_cb = error_cb; | 1263 | it->error_cb = error_cb; |
1264 | it->error_cb_cls = error_cb_cls; | 1264 | it->error_cb_cls = error_cb_cls; |
@@ -1271,7 +1271,7 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_start_rp (struct GNUNET_IDENTITY_PROVI | |||
1271 | h->ticket_it_tail, | 1271 | h->ticket_it_tail, |
1272 | it); | 1272 | it); |
1273 | env = GNUNET_MQ_msg (msg, | 1273 | env = GNUNET_MQ_msg (msg, |
1274 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_START); | 1274 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_START); |
1275 | msg->id = htonl (rid); | 1275 | msg->id = htonl (rid); |
1276 | msg->identity = *identity; | 1276 | msg->identity = *identity; |
1277 | msg->is_audience = htonl (GNUNET_YES); | 1277 | msg->is_audience = htonl (GNUNET_YES); |
@@ -1286,20 +1286,20 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_start_rp (struct GNUNET_IDENTITY_PROVI | |||
1286 | } | 1286 | } |
1287 | 1287 | ||
1288 | /** | 1288 | /** |
1289 | * Calls the record processor specified in #GNUNET_IDENTITY_PROVIDER_ticket_iteration_start | 1289 | * Calls the record processor specified in #GNUNET_RECLAIM_ticket_iteration_start |
1290 | * for the next record. | 1290 | * for the next record. |
1291 | * | 1291 | * |
1292 | * @param it the iterator | 1292 | * @param it the iterator |
1293 | */ | 1293 | */ |
1294 | void | 1294 | void |
1295 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_next (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it) | 1295 | GNUNET_RECLAIM_ticket_iteration_next (struct GNUNET_RECLAIM_TicketIterator *it) |
1296 | { | 1296 | { |
1297 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = it->h; | 1297 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1298 | struct TicketIterationNextMessage *msg; | 1298 | struct TicketIterationNextMessage *msg; |
1299 | struct GNUNET_MQ_Envelope *env; | 1299 | struct GNUNET_MQ_Envelope *env; |
1300 | 1300 | ||
1301 | env = GNUNET_MQ_msg (msg, | 1301 | env = GNUNET_MQ_msg (msg, |
1302 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_NEXT); | 1302 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_NEXT); |
1303 | msg->id = htonl (it->r_id); | 1303 | msg->id = htonl (it->r_id); |
1304 | GNUNET_MQ_send (h->mq, | 1304 | GNUNET_MQ_send (h->mq, |
1305 | env); | 1305 | env); |
@@ -1309,21 +1309,21 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_next (struct GNUNET_IDENTITY_PROVIDER_ | |||
1309 | /** | 1309 | /** |
1310 | * Stops iteration and releases the idp handle for further calls. Must | 1310 | * Stops iteration and releases the idp handle for further calls. Must |
1311 | * be called on any iteration that has not yet completed prior to calling | 1311 | * be called on any iteration that has not yet completed prior to calling |
1312 | * #GNUNET_IDENTITY_PROVIDER_disconnect. | 1312 | * #GNUNET_RECLAIM_disconnect. |
1313 | * | 1313 | * |
1314 | * @param it the iterator | 1314 | * @param it the iterator |
1315 | */ | 1315 | */ |
1316 | void | 1316 | void |
1317 | GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (struct GNUNET_IDENTITY_PROVIDER_TicketIterator *it) | 1317 | GNUNET_RECLAIM_ticket_iteration_stop (struct GNUNET_RECLAIM_TicketIterator *it) |
1318 | { | 1318 | { |
1319 | struct GNUNET_IDENTITY_PROVIDER_Handle *h = it->h; | 1319 | struct GNUNET_RECLAIM_Handle *h = it->h; |
1320 | struct GNUNET_MQ_Envelope *env; | 1320 | struct GNUNET_MQ_Envelope *env; |
1321 | struct TicketIterationStopMessage *msg; | 1321 | struct TicketIterationStopMessage *msg; |
1322 | 1322 | ||
1323 | if (NULL != h->mq) | 1323 | if (NULL != h->mq) |
1324 | { | 1324 | { |
1325 | env = GNUNET_MQ_msg (msg, | 1325 | env = GNUNET_MQ_msg (msg, |
1326 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_TICKET_ITERATION_STOP); | 1326 | GNUNET_MESSAGE_TYPE_RECLAIM_TICKET_ITERATION_STOP); |
1327 | msg->id = htonl (it->r_id); | 1327 | msg->id = htonl (it->r_id); |
1328 | GNUNET_MQ_send (h->mq, | 1328 | GNUNET_MQ_send (h->mq, |
1329 | env); | 1329 | env); |
@@ -1335,27 +1335,26 @@ GNUNET_IDENTITY_PROVIDER_ticket_iteration_stop (struct GNUNET_IDENTITY_PROVIDER_ | |||
1335 | * Revoked an issued ticket. The relying party will be unable to retrieve | 1335 | * Revoked an issued ticket. The relying party will be unable to retrieve |
1336 | * updated attributes. | 1336 | * updated attributes. |
1337 | * | 1337 | * |
1338 | * @param h the identity provider to use | 1338 | * @param h the reclaim to use |
1339 | * @param identity the issuing identity | 1339 | * @param identity the issuing identity |
1340 | * @param ticket the ticket to revoke | 1340 | * @param ticket the ticket to revoke |
1341 | * @param cb the callback | 1341 | * @param cb the callback |
1342 | * @param cb_cls the callback closure | 1342 | * @param cb_cls the callback closure |
1343 | * @return handle to abort the operation | 1343 | * @return handle to abort the operation |
1344 | */ | 1344 | */ |
1345 | struct GNUNET_IDENTITY_PROVIDER_Operation * | 1345 | struct GNUNET_RECLAIM_Operation * |
1346 | GNUNET_IDENTITY_PROVIDER_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Handle *h, | 1346 | GNUNET_RECLAIM_ticket_revoke (struct GNUNET_RECLAIM_Handle *h, |
1347 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, | 1347 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *identity, |
1348 | const struct GNUNET_IDENTITY_PROVIDER_Ticket *ticket, | 1348 | const struct GNUNET_RECLAIM_Ticket *ticket, |
1349 | GNUNET_IDENTITY_PROVIDER_ContinuationWithStatus cb, | 1349 | GNUNET_RECLAIM_ContinuationWithStatus cb, |
1350 | void *cb_cls) | 1350 | void *cb_cls) |
1351 | { | 1351 | { |
1352 | struct GNUNET_IDENTITY_PROVIDER_Operation *op; | 1352 | struct GNUNET_RECLAIM_Operation *op; |
1353 | struct GNUNET_MQ_Envelope *env; | ||
1354 | struct RevokeTicketMessage *msg; | 1353 | struct RevokeTicketMessage *msg; |
1355 | uint32_t rid; | 1354 | uint32_t rid; |
1356 | 1355 | ||
1357 | rid = h->r_id_gen++; | 1356 | rid = h->r_id_gen++; |
1358 | op = GNUNET_new (struct GNUNET_IDENTITY_PROVIDER_Operation); | 1357 | op = GNUNET_new (struct GNUNET_RECLAIM_Operation); |
1359 | op->h = h; | 1358 | op->h = h; |
1360 | op->rvk_cb = cb; | 1359 | op->rvk_cb = cb; |
1361 | op->cls = cb_cls; | 1360 | op->cls = cb_cls; |
@@ -1363,22 +1362,22 @@ GNUNET_IDENTITY_PROVIDER_ticket_revoke (struct GNUNET_IDENTITY_PROVIDER_Handle * | |||
1363 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, | 1362 | GNUNET_CONTAINER_DLL_insert_tail (h->op_head, |
1364 | h->op_tail, | 1363 | h->op_tail, |
1365 | op); | 1364 | op); |
1366 | env = GNUNET_MQ_msg_extra (msg, | 1365 | op->env = GNUNET_MQ_msg_extra (msg, |
1367 | sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket), | 1366 | sizeof (struct GNUNET_RECLAIM_Ticket), |
1368 | GNUNET_MESSAGE_TYPE_IDENTITY_PROVIDER_REVOKE_TICKET); | 1367 | GNUNET_MESSAGE_TYPE_RECLAIM_REVOKE_TICKET); |
1369 | msg->id = htonl (rid); | 1368 | msg->id = htonl (rid); |
1370 | msg->identity = *identity; | 1369 | msg->identity = *identity; |
1371 | GNUNET_memcpy (&msg[1], | 1370 | GNUNET_memcpy (&msg[1], |
1372 | ticket, | 1371 | ticket, |
1373 | sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket)); | 1372 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
1374 | if (NULL == h->mq) | 1373 | if (NULL != h->mq) { |
1375 | op->env = env; | ||
1376 | else | ||
1377 | GNUNET_MQ_send (h->mq, | 1374 | GNUNET_MQ_send (h->mq, |
1378 | env); | 1375 | op->env); |
1376 | op->env = NULL; | ||
1377 | } | ||
1379 | return op; | 1378 | return op; |
1380 | } | 1379 | } |
1381 | 1380 | ||
1382 | 1381 | ||
1383 | 1382 | ||
1384 | /* end of identity_provider_api.c */ | 1383 | /* end of reclaim_api.c */ |
diff --git a/src/reclaim/test_reclaim.sh b/src/reclaim/test_reclaim.sh new file mode 100755 index 000000000..311f5382a --- /dev/null +++ b/src/reclaim/test_reclaim.sh | |||
@@ -0,0 +1,31 @@ | |||
1 | #!/bin/bash | ||
2 | #trap "gnunet-arm -e -c test_reclaim_lookup.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_reclaim.conf | ||
27 | gnunet-identity -C testego -c test_reclaim.conf | ||
28 | valgrind gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf | ||
29 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf | ||
30 | gnunet-reclaim -e testego -D -c test_reclaim.conf | ||
31 | gnunet-arm -e -c test_reclaim.conf | ||
diff --git a/src/reclaim/test_reclaim_attribute.sh b/src/reclaim/test_reclaim_attribute.sh new file mode 100755 index 000000000..39bd715b7 --- /dev/null +++ b/src/reclaim/test_reclaim_attribute.sh | |||
@@ -0,0 +1,40 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_reclaim.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_reclaim.conf | ||
27 | #gnunet-arm -i rest -c test_reclaim.conf | ||
28 | gnunet-identity -C testego -c test_reclaim.conf | ||
29 | gnunet-identity -C rpego -c test_reclaim.conf | ||
30 | TEST_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep testego | awk '{print $3}') | ||
31 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf | ||
32 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf > /dev/null 2>&1 | ||
33 | if test $? != 0 | ||
34 | then | ||
35 | echo "Failed." | ||
36 | exit 1 | ||
37 | fi | ||
38 | |||
39 | #curl localhost:7776/reclaim/attributes/testego | ||
40 | gnunet-arm -e -c test_reclaim.conf | ||
diff --git a/src/reclaim/test_reclaim_consume.sh b/src/reclaim/test_reclaim_consume.sh new file mode 100755 index 000000000..36c8052d0 --- /dev/null +++ b/src/reclaim/test_reclaim_consume.sh | |||
@@ -0,0 +1,43 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_reclaim.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_reclaim.conf | ||
27 | #gnunet-arm -i rest -c test_reclaim.conf | ||
28 | gnunet-identity -C testego -c test_reclaim.conf | ||
29 | gnunet-identity -C rpego -c test_reclaim.conf | ||
30 | SUBJECT_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep rpego | awk '{print $3}') | ||
31 | TEST_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep testego | awk '{print $3}') | ||
32 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf | ||
33 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf | ||
34 | TICKET=$(gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf | awk '{print $1}') | ||
35 | gnunet-reclaim -e rpego -C $TICKET -c test_reclaim.conf > /dev/null 2>&1 | ||
36 | |||
37 | if test $? != 0 | ||
38 | then | ||
39 | "Failed." | ||
40 | exit 1 | ||
41 | fi | ||
42 | #curl http://localhost:7776/reclaim/tickets/testego | ||
43 | gnunet-arm -e -c test_reclaim.conf | ||
diff --git a/src/identity-provider/test_idp_defaults.conf b/src/reclaim/test_reclaim_defaults.conf index a9a197dea..a9a197dea 100644 --- a/src/identity-provider/test_idp_defaults.conf +++ b/src/reclaim/test_reclaim_defaults.conf | |||
diff --git a/src/reclaim/test_reclaim_issue.sh b/src/reclaim/test_reclaim_issue.sh new file mode 100755 index 000000000..6a71470e1 --- /dev/null +++ b/src/reclaim/test_reclaim_issue.sh | |||
@@ -0,0 +1,42 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_reclaim.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_reclaim.conf | ||
27 | #gnunet-arm -i rest -c test_reclaim.conf | ||
28 | gnunet-identity -C testego -c test_reclaim.conf | ||
29 | gnunet-identity -C rpego -c test_reclaim.conf | ||
30 | SUBJECT_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep rpego | awk '{print $3}') | ||
31 | TEST_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep testego | awk '{print $3}') | ||
32 | gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf > /dev/null 2>&1 | ||
33 | gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf > /dev/null 2>&1 | ||
34 | #gnunet-reclaim -e testego -D -c test_reclaim.conf | ||
35 | gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf > /dev/null 2>&1 | ||
36 | if test $? != 0 | ||
37 | then | ||
38 | echo "Failed." | ||
39 | exit 1 | ||
40 | fi | ||
41 | #curl http://localhost:7776/reclaim/attributes/testego | ||
42 | gnunet-arm -e -c test_reclaim.conf | ||
diff --git a/src/reclaim/test_reclaim_revoke.sh b/src/reclaim/test_reclaim_revoke.sh new file mode 100755 index 000000000..595752fd8 --- /dev/null +++ b/src/reclaim/test_reclaim_revoke.sh | |||
@@ -0,0 +1,65 @@ | |||
1 | #!/bin/bash | ||
2 | trap "gnunet-arm -e -c test_reclaim.conf" SIGINT | ||
3 | |||
4 | LOCATION=$(which gnunet-config) | ||
5 | if [ -z $LOCATION ] | ||
6 | then | ||
7 | LOCATION="gnunet-config" | ||
8 | fi | ||
9 | $LOCATION --version 1> /dev/null | ||
10 | if test $? != 0 | ||
11 | then | ||
12 | echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX" | ||
13 | exit 77 | ||
14 | fi | ||
15 | |||
16 | rm -rf `gnunet-config -c test_reclaim.conf -s PATHS -o GNUNET_HOME -f` | ||
17 | |||
18 | # (1) PKEY1.user -> PKEY2.resu.user | ||
19 | # (2) PKEY2.resu -> PKEY3 | ||
20 | # (3) PKEY3.user -> PKEY4 | ||
21 | |||
22 | |||
23 | which timeout &> /dev/null && DO_TIMEOUT="timeout 30" | ||
24 | |||
25 | TEST_ATTR="test" | ||
26 | gnunet-arm -s -c test_reclaim.conf 2&>1 > /dev/null | ||
27 | gnunet-identity -C alice -c test_reclaim.conf | ||
28 | gnunet-identity -C bob -c test_reclaim.conf | ||
29 | gnunet-identity -C eve -c test_reclaim.conf | ||
30 | ALICE_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep alice | awk '{print $3}') | ||
31 | BOB_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep bob | awk '{print $3}') | ||
32 | EVE_KEY=$(gnunet-identity -d -c test_reclaim.conf | grep eve | awk '{print $3}') | ||
33 | |||
34 | gnunet-reclaim -e alice -E 15s -a email -V john@doe.gnu -c test_reclaim.conf | ||
35 | gnunet-reclaim -e alice -E 15s -a name -V John -c test_reclaim.conf | ||
36 | TICKET_BOB=$(gnunet-reclaim -e alice -i "email,name" -r $BOB_KEY -c test_reclaim.conf | awk '{print $1}') | ||
37 | #gnunet-reclaim -e bob -C $TICKET_BOB -c test_reclaim.conf | ||
38 | TICKET_EVE=$(gnunet-reclaim -e alice -i "email" -r $EVE_KEY -c test_reclaim.conf | awk '{print $1}') | ||
39 | |||
40 | #echo "Consuming $TICKET" | ||
41 | #gnunet-reclaim -e eve -C $TICKET_EVE -c test_reclaim.conf | ||
42 | gnunet-reclaim -e alice -R $TICKET_EVE -c test_reclaim.conf | ||
43 | |||
44 | #sleep 6 | ||
45 | |||
46 | gnunet-reclaim -e eve -C $TICKET_EVE -c test_reclaim.conf 2&>1 >/dev/null | ||
47 | if test $? == 0 | ||
48 | then | ||
49 | echo "Eve can still resolve attributes..." | ||
50 | gnunet-arm -e -c test_reclaim.conf | ||
51 | exit 1 | ||
52 | fi | ||
53 | |||
54 | gnunet-arm -e -c test_reclaim.conf | ||
55 | gnunet-arm -s -c test_reclaim.conf 2&>1 > /dev/null | ||
56 | |||
57 | gnunet-reclaim -e bob -C $TICKET_BOB -c test_reclaim.conf 2&>1 >/dev/null | ||
58 | if test $? != 0 | ||
59 | then | ||
60 | echo "Bob cannot resolve attributes..." | ||
61 | gnunet-arm -e -c test_reclaim.conf | ||
62 | exit 1 | ||
63 | fi | ||
64 | |||
65 | gnunet-arm -e -c test_reclaim.conf | ||
diff --git a/src/rest/Makefile.am b/src/rest/Makefile.am index ebfb98024..ce0454d53 100644 --- a/src/rest/Makefile.am +++ b/src/rest/Makefile.am | |||
@@ -29,6 +29,18 @@ libexec_PROGRAMS = \ | |||
29 | EXTRA_DIST = \ | 29 | EXTRA_DIST = \ |
30 | rest.conf | 30 | rest.conf |
31 | 31 | ||
32 | plugin_LTLIBRARIES = libgnunet_plugin_rest_copying.la | ||
33 | |||
34 | libgnunet_plugin_rest_copying_la_SOURCES = \ | ||
35 | plugin_rest_copying.c | ||
36 | libgnunet_plugin_rest_copying_la_LIBADD = \ | ||
37 | $(top_builddir)/src/rest/libgnunetrest.la \ | ||
38 | $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \ | ||
39 | $(LTLIBINTL) -lmicrohttpd | ||
40 | libgnunet_plugin_rest_copying_la_LDFLAGS = \ | ||
41 | $(GN_PLUGIN_LDFLAGS) | ||
42 | |||
43 | |||
32 | gnunet_rest_server_SOURCES = \ | 44 | gnunet_rest_server_SOURCES = \ |
33 | gnunet-rest-server.c | 45 | gnunet-rest-server.c |
34 | 46 | ||
diff --git a/src/rest/plugin_rest_copying.c b/src/rest/plugin_rest_copying.c new file mode 100644 index 000000000..668dc5d38 --- /dev/null +++ b/src/rest/plugin_rest_copying.c | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2012-2018 GNUnet e.V. | ||
4 | |||
5 | GNUnet is free software: you can redistribute it and/or modify it | ||
6 | under the terms of the GNU Affero General Public License as published | ||
7 | by the Free Software Foundation, either version 3 of the License, | ||
8 | or (at your option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Affero General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Affero General Public License | ||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | /** | ||
19 | * @author Martin Schanzenbach | ||
20 | * @file gns/plugin_rest_copying.c | ||
21 | * @brief REST plugin that serves licensing information. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include "platform.h" | ||
26 | #include "gnunet_rest_plugin.h" | ||
27 | #include <gnunet_rest_lib.h> | ||
28 | |||
29 | #define GNUNET_REST_API_NS_COPYING "/copying" | ||
30 | |||
31 | #define GNUNET_REST_COPYING_TEXT "GNU Affero General Public License version 3 or later. See also: <http://www.gnu.org/licenses/>" | ||
32 | |||
33 | /** | ||
34 | * @brief struct returned by the initialization function of the plugin | ||
35 | */ | ||
36 | struct Plugin | ||
37 | { | ||
38 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
39 | }; | ||
40 | |||
41 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
42 | |||
43 | struct RequestHandle | ||
44 | { | ||
45 | /** | ||
46 | * Handle to rest request | ||
47 | */ | ||
48 | struct GNUNET_REST_RequestHandle *rest_handle; | ||
49 | |||
50 | /** | ||
51 | * The plugin result processor | ||
52 | */ | ||
53 | GNUNET_REST_ResultProcessor proc; | ||
54 | |||
55 | /** | ||
56 | * The closure of the result processor | ||
57 | */ | ||
58 | void *proc_cls; | ||
59 | |||
60 | /** | ||
61 | * HTTP response code | ||
62 | */ | ||
63 | int response_code; | ||
64 | |||
65 | }; | ||
66 | |||
67 | |||
68 | /** | ||
69 | * Cleanup request handle. | ||
70 | * | ||
71 | * @param handle Handle to clean up | ||
72 | */ | ||
73 | static void | ||
74 | cleanup_handle (struct RequestHandle *handle) | ||
75 | { | ||
76 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
77 | "Cleaning up\n"); | ||
78 | GNUNET_free (handle); | ||
79 | } | ||
80 | |||
81 | |||
82 | /** | ||
83 | * Task run on shutdown. Cleans up everything. | ||
84 | * | ||
85 | * @param cls unused | ||
86 | * @param tc scheduler context | ||
87 | */ | ||
88 | static void | ||
89 | do_error (void *cls) | ||
90 | { | ||
91 | struct RequestHandle *handle = cls; | ||
92 | struct MHD_Response *resp; | ||
93 | |||
94 | resp = GNUNET_REST_create_response (NULL); | ||
95 | handle->proc (handle->proc_cls, resp, handle->response_code); | ||
96 | cleanup_handle (handle); | ||
97 | } | ||
98 | |||
99 | |||
100 | /** | ||
101 | * Handle rest request | ||
102 | * | ||
103 | * @param handle the lookup handle | ||
104 | */ | ||
105 | static void | ||
106 | get_cont (struct GNUNET_REST_RequestHandle *con_handle, | ||
107 | const char* url, | ||
108 | void *cls) | ||
109 | { | ||
110 | struct MHD_Response *resp; | ||
111 | struct RequestHandle *handle = cls; | ||
112 | |||
113 | resp = GNUNET_REST_create_response (GNUNET_REST_COPYING_TEXT); | ||
114 | handle->proc (handle->proc_cls, | ||
115 | resp, | ||
116 | MHD_HTTP_OK); | ||
117 | cleanup_handle (handle); | ||
118 | } | ||
119 | |||
120 | |||
121 | |||
122 | /** | ||
123 | * Handle rest request | ||
124 | * | ||
125 | * @param handle the lookup handle | ||
126 | */ | ||
127 | static void | ||
128 | options_cont (struct GNUNET_REST_RequestHandle *con_handle, | ||
129 | const char* url, | ||
130 | void *cls) | ||
131 | { | ||
132 | struct MHD_Response *resp; | ||
133 | struct RequestHandle *handle = cls; | ||
134 | |||
135 | resp = GNUNET_REST_create_response (NULL); | ||
136 | MHD_add_response_header (resp, | ||
137 | "Access-Control-Allow-Methods", | ||
138 | MHD_HTTP_METHOD_GET); | ||
139 | handle->proc (handle->proc_cls, | ||
140 | resp, | ||
141 | MHD_HTTP_OK); | ||
142 | cleanup_handle (handle); | ||
143 | } | ||
144 | |||
145 | |||
146 | /** | ||
147 | * Function processing the REST call | ||
148 | * | ||
149 | * @param method HTTP method | ||
150 | * @param url URL of the HTTP request | ||
151 | * @param data body of the HTTP request (optional) | ||
152 | * @param data_size length of the body | ||
153 | * @param proc callback function for the result | ||
154 | * @param proc_cls closure for @a proc | ||
155 | * @return #GNUNET_OK if request accepted | ||
156 | */ | ||
157 | static void | ||
158 | rest_copying_process_request (struct GNUNET_REST_RequestHandle *conndata_handle, | ||
159 | GNUNET_REST_ResultProcessor proc, | ||
160 | void *proc_cls) | ||
161 | { | ||
162 | static const struct GNUNET_REST_RequestHandler handlers[] = { | ||
163 | {MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_COPYING, &get_cont}, | ||
164 | {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_COPYING, &options_cont}, | ||
165 | GNUNET_REST_HANDLER_END | ||
166 | }; | ||
167 | struct RequestHandle *handle = GNUNET_new (struct RequestHandle); | ||
168 | struct GNUNET_REST_RequestHandlerError err; | ||
169 | |||
170 | handle->proc_cls = proc_cls; | ||
171 | handle->proc = proc; | ||
172 | handle->rest_handle = conndata_handle; | ||
173 | |||
174 | if (GNUNET_NO == GNUNET_REST_handle_request (conndata_handle, | ||
175 | handlers, | ||
176 | &err, | ||
177 | handle)) | ||
178 | { | ||
179 | handle->response_code = err.error_code; | ||
180 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | |||
185 | /** | ||
186 | * Entry point for the plugin. | ||
187 | * | ||
188 | * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*" | ||
189 | * @return NULL on error, otherwise the plugin context | ||
190 | */ | ||
191 | void * | ||
192 | libgnunet_plugin_rest_copying_init (void *cls) | ||
193 | { | ||
194 | static struct Plugin plugin; | ||
195 | cfg = cls; | ||
196 | struct GNUNET_REST_Plugin *api; | ||
197 | |||
198 | if (NULL != plugin.cfg) | ||
199 | return NULL; /* can only initialize once! */ | ||
200 | memset (&plugin, 0, sizeof (struct Plugin)); | ||
201 | plugin.cfg = cfg; | ||
202 | api = GNUNET_new (struct GNUNET_REST_Plugin); | ||
203 | api->cls = &plugin; | ||
204 | api->name = GNUNET_REST_API_NS_COPYING; | ||
205 | api->process_request = &rest_copying_process_request; | ||
206 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
207 | _("COPYING REST API initialized\n")); | ||
208 | return api; | ||
209 | } | ||
210 | |||
211 | |||
212 | /** | ||
213 | * Exit point from the plugin. | ||
214 | * | ||
215 | * @param cls the plugin context (as returned by "init") | ||
216 | * @return always NULL | ||
217 | */ | ||
218 | void * | ||
219 | libgnunet_plugin_rest_copying_done (void *cls) | ||
220 | { | ||
221 | struct GNUNET_REST_Plugin *api = cls; | ||
222 | struct Plugin *plugin = api->cls; | ||
223 | |||
224 | plugin->cfg = NULL; | ||
225 | GNUNET_free (api); | ||
226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
227 | "COPYING REST plugin is finished\n"); | ||
228 | return NULL; | ||
229 | } | ||
230 | |||
231 | /* end of plugin_rest_copying.c */ | ||
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index 16f23e86c..49714872f 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c | |||
@@ -49,7 +49,11 @@ static unsigned bits_needed; | |||
49 | /** | 49 | /** |
50 | * How long do we run the test? | 50 | * How long do we run the test? |
51 | */ | 51 | */ |
52 | //#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) | 52 | static struct GNUNET_TIME_Relative duration; |
53 | |||
54 | /** | ||
55 | * When do we do a hard shutdown? | ||
56 | */ | ||
53 | static struct GNUNET_TIME_Relative timeout; | 57 | static struct GNUNET_TIME_Relative timeout; |
54 | 58 | ||
55 | 59 | ||
@@ -446,6 +450,10 @@ struct RPSPeer | |||
446 | * @brief statistics values | 450 | * @brief statistics values |
447 | */ | 451 | */ |
448 | uint64_t stats[STAT_TYPE_MAX]; | 452 | uint64_t stats[STAT_TYPE_MAX]; |
453 | /** | ||
454 | * @brief Handle for the statistics get request | ||
455 | */ | ||
456 | struct GNUNET_STATISTICS_GetHandle *h_stat_get[STAT_TYPE_MAX]; | ||
449 | }; | 457 | }; |
450 | 458 | ||
451 | /** | 459 | /** |
@@ -489,15 +497,16 @@ static unsigned int view_sizes; | |||
489 | static int ok; | 497 | static int ok; |
490 | 498 | ||
491 | /** | 499 | /** |
492 | * Identifier for the churn task that runs periodically | 500 | * Identifier for the task that runs after the test to collect results |
493 | */ | 501 | */ |
494 | static struct GNUNET_SCHEDULER_Task *post_test_task; | 502 | static struct GNUNET_SCHEDULER_Task *post_test_task; |
495 | 503 | ||
496 | /** | 504 | /** |
497 | * Identifier for the churn task that runs periodically | 505 | * Identifier for the shutdown task |
498 | */ | 506 | */ |
499 | static struct GNUNET_SCHEDULER_Task *shutdown_task; | 507 | static struct GNUNET_SCHEDULER_Task *shutdown_task; |
500 | 508 | ||
509 | |||
501 | /** | 510 | /** |
502 | * Identifier for the churn task that runs periodically | 511 | * Identifier for the churn task that runs periodically |
503 | */ | 512 | */ |
@@ -874,6 +883,75 @@ static int check_statistics_collect_completed () | |||
874 | return GNUNET_YES; | 883 | return GNUNET_YES; |
875 | } | 884 | } |
876 | 885 | ||
886 | static void | ||
887 | rps_disconnect_adapter (void *cls, | ||
888 | void *op_result); | ||
889 | |||
890 | static void | ||
891 | cancel_pending_req (struct PendingRequest *pending_req) | ||
892 | { | ||
893 | struct RPSPeer *rps_peer; | ||
894 | |||
895 | rps_peer = pending_req->rps_peer; | ||
896 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, | ||
897 | rps_peer->pending_req_tail, | ||
898 | pending_req); | ||
899 | rps_peer->num_pending_reqs--; | ||
900 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
901 | "Cancelling pending rps get request\n"); | ||
902 | GNUNET_SCHEDULER_cancel (pending_req->request_task); | ||
903 | GNUNET_free (pending_req); | ||
904 | } | ||
905 | |||
906 | static void | ||
907 | cancel_request (struct PendingReply *pending_rep) | ||
908 | { | ||
909 | struct RPSPeer *rps_peer; | ||
910 | |||
911 | rps_peer = pending_rep->rps_peer; | ||
912 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head, | ||
913 | rps_peer->pending_rep_tail, | ||
914 | pending_rep); | ||
915 | rps_peer->num_pending_reps--; | ||
916 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
917 | "Cancelling rps get reply\n"); | ||
918 | GNUNET_RPS_request_cancel (pending_rep->req_handle); | ||
919 | GNUNET_free (pending_rep); | ||
920 | } | ||
921 | |||
922 | void | ||
923 | clean_peer (unsigned peer_index) | ||
924 | { | ||
925 | struct PendingRequest *pending_req; | ||
926 | |||
927 | while (NULL != (pending_req = rps_peers[peer_index].pending_req_head)) | ||
928 | { | ||
929 | cancel_pending_req (pending_req); | ||
930 | } | ||
931 | pending_req = rps_peers[peer_index].pending_req_head; | ||
932 | rps_disconnect_adapter (&rps_peers[peer_index], | ||
933 | &rps_peers[peer_index].rps_handle); | ||
934 | for (unsigned stat_type = STAT_TYPE_ROUNDS; | ||
935 | stat_type < STAT_TYPE_MAX; | ||
936 | stat_type++) | ||
937 | { | ||
938 | if (NULL != rps_peers[peer_index].h_stat_get[stat_type]) | ||
939 | { | ||
940 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
941 | "(%u) did not yet receive stat value for `%s'\n", | ||
942 | rps_peers[peer_index].index, | ||
943 | stat_type_2_str (stat_type)); | ||
944 | GNUNET_STATISTICS_get_cancel ( | ||
945 | rps_peers[peer_index].h_stat_get[stat_type]); | ||
946 | } | ||
947 | } | ||
948 | if (NULL != rps_peers[peer_index].op) | ||
949 | { | ||
950 | GNUNET_TESTBED_operation_done (rps_peers[peer_index].op); | ||
951 | rps_peers[peer_index].op = NULL; | ||
952 | } | ||
953 | } | ||
954 | |||
877 | /** | 955 | /** |
878 | * Task run on timeout to shut everything down. | 956 | * Task run on timeout to shut everything down. |
879 | */ | 957 | */ |
@@ -881,35 +959,55 @@ static void | |||
881 | shutdown_op (void *cls) | 959 | shutdown_op (void *cls) |
882 | { | 960 | { |
883 | unsigned int i; | 961 | unsigned int i; |
962 | struct OpListEntry *entry; | ||
884 | 963 | ||
885 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 964 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
886 | "Shutdown task scheduled, going down.\n"); | 965 | "Shutdown task scheduled, going down.\n"); |
887 | in_shutdown = GNUNET_YES; | 966 | in_shutdown = GNUNET_YES; |
967 | |||
968 | if (NULL != shutdown_task) | ||
969 | { | ||
970 | GNUNET_SCHEDULER_cancel (shutdown_task); | ||
971 | shutdown_task = NULL; | ||
972 | } | ||
888 | if (NULL != post_test_task) | 973 | if (NULL != post_test_task) |
889 | { | 974 | { |
890 | GNUNET_SCHEDULER_cancel (post_test_task); | 975 | GNUNET_SCHEDULER_cancel (post_test_task); |
976 | post_test_task = NULL; | ||
891 | } | 977 | } |
892 | if (NULL != churn_task) | 978 | if (NULL != churn_task) |
893 | { | 979 | { |
894 | GNUNET_SCHEDULER_cancel (churn_task); | 980 | GNUNET_SCHEDULER_cancel (churn_task); |
895 | churn_task = NULL; | 981 | churn_task = NULL; |
896 | } | 982 | } |
983 | entry = oplist_head; | ||
984 | while (NULL != (entry = oplist_head)) | ||
985 | { | ||
986 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
987 | "Operation still pending on shutdown (%u)\n", | ||
988 | entry->index); | ||
989 | GNUNET_TESTBED_operation_done (entry->op); | ||
990 | GNUNET_CONTAINER_DLL_remove (oplist_head, oplist_tail, entry); | ||
991 | GNUNET_free (entry); | ||
992 | } | ||
897 | for (i = 0; i < num_peers; i++) | 993 | for (i = 0; i < num_peers; i++) |
898 | { | 994 | { |
899 | if (NULL != rps_peers[i].rps_handle) | 995 | clean_peer (i); |
900 | { | ||
901 | GNUNET_RPS_disconnect (rps_peers[i].rps_handle); | ||
902 | } | ||
903 | if (NULL != rps_peers[i].op) | ||
904 | { | ||
905 | GNUNET_TESTBED_operation_done (rps_peers[i].op); | ||
906 | } | ||
907 | } | 996 | } |
908 | } | 997 | } |
909 | 998 | ||
999 | static void | ||
1000 | trigger_shutdown (void *cls) | ||
1001 | { | ||
1002 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1003 | "Shutdown was triggerd by timeout, going down.\n"); | ||
1004 | shutdown_task = NULL; | ||
1005 | GNUNET_SCHEDULER_shutdown (); | ||
1006 | } | ||
1007 | |||
910 | 1008 | ||
911 | /** | 1009 | /** |
912 | * Task run on timeout to collect statistics and potentially shut down. | 1010 | * Task run after #duration to collect statistics and potentially shut down. |
913 | */ | 1011 | */ |
914 | static void | 1012 | static void |
915 | post_test_op (void *cls) | 1013 | post_test_op (void *cls) |
@@ -919,7 +1017,7 @@ post_test_op (void *cls) | |||
919 | post_test_task = NULL; | 1017 | post_test_task = NULL; |
920 | post_test = GNUNET_YES; | 1018 | post_test = GNUNET_YES; |
921 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1019 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
922 | "Post test task scheduled, going down.\n"); | 1020 | "Post test task scheduled.\n"); |
923 | if (NULL != churn_task) | 1021 | if (NULL != churn_task) |
924 | { | 1022 | { |
925 | GNUNET_SCHEDULER_cancel (churn_task); | 1023 | GNUNET_SCHEDULER_cancel (churn_task); |
@@ -943,7 +1041,7 @@ post_test_op (void *cls) | |||
943 | GNUNET_YES == check_statistics_collect_completed()) | 1041 | GNUNET_YES == check_statistics_collect_completed()) |
944 | { | 1042 | { |
945 | GNUNET_SCHEDULER_cancel (shutdown_task); | 1043 | GNUNET_SCHEDULER_cancel (shutdown_task); |
946 | shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL); | 1044 | shutdown_task = NULL; |
947 | GNUNET_SCHEDULER_shutdown (); | 1045 | GNUNET_SCHEDULER_shutdown (); |
948 | } | 1046 | } |
949 | } | 1047 | } |
@@ -1030,9 +1128,9 @@ info_cb (void *cb_cls, | |||
1030 | */ | 1128 | */ |
1031 | static void | 1129 | static void |
1032 | rps_connect_complete_cb (void *cls, | 1130 | rps_connect_complete_cb (void *cls, |
1033 | struct GNUNET_TESTBED_Operation *op, | 1131 | struct GNUNET_TESTBED_Operation *op, |
1034 | void *ca_result, | 1132 | void *ca_result, |
1035 | const char *emsg) | 1133 | const char *emsg) |
1036 | { | 1134 | { |
1037 | struct RPSPeer *rps_peer = cls; | 1135 | struct RPSPeer *rps_peer = cls; |
1038 | struct GNUNET_RPS_Handle *rps = ca_result; | 1136 | struct GNUNET_RPS_Handle *rps = ca_result; |
@@ -1057,7 +1155,9 @@ rps_connect_complete_cb (void *cls, | |||
1057 | return; | 1155 | return; |
1058 | } | 1156 | } |
1059 | 1157 | ||
1060 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started client successfully\n"); | 1158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1159 | "Started client successfully (%u)\n", | ||
1160 | rps_peer->index); | ||
1061 | 1161 | ||
1062 | cur_test_run.main_test (rps_peer); | 1162 | cur_test_run.main_test (rps_peer); |
1063 | } | 1163 | } |
@@ -1075,7 +1175,7 @@ rps_connect_complete_cb (void *cls, | |||
1075 | */ | 1175 | */ |
1076 | static void * | 1176 | static void * |
1077 | rps_connect_adapter (void *cls, | 1177 | rps_connect_adapter (void *cls, |
1078 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1178 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1079 | { | 1179 | { |
1080 | struct GNUNET_RPS_Handle *h; | 1180 | struct GNUNET_RPS_Handle *h; |
1081 | 1181 | ||
@@ -1167,15 +1267,26 @@ stat_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
1167 | */ | 1267 | */ |
1168 | static void | 1268 | static void |
1169 | rps_disconnect_adapter (void *cls, | 1269 | rps_disconnect_adapter (void *cls, |
1170 | void *op_result) | 1270 | void *op_result) |
1171 | { | 1271 | { |
1172 | struct RPSPeer *peer = cls; | 1272 | struct RPSPeer *peer = cls; |
1173 | struct GNUNET_RPS_Handle *h = op_result; | 1273 | struct GNUNET_RPS_Handle *h = op_result; |
1274 | struct PendingReply *pending_rep; | ||
1174 | 1275 | ||
1175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "disconnect_adapter()\n"); | 1276 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1277 | "disconnect_adapter (%u)\n", | ||
1278 | peer->index); | ||
1176 | GNUNET_assert (NULL != peer); | 1279 | GNUNET_assert (NULL != peer); |
1177 | GNUNET_RPS_disconnect (h); | 1280 | if (NULL != peer->rps_handle) |
1178 | peer->rps_handle = NULL; | 1281 | { |
1282 | while (NULL != (pending_rep = peer->pending_rep_head)) | ||
1283 | { | ||
1284 | cancel_request (pending_rep); | ||
1285 | } | ||
1286 | GNUNET_assert (h == peer->rps_handle); | ||
1287 | GNUNET_RPS_disconnect (h); | ||
1288 | peer->rps_handle = NULL; | ||
1289 | } | ||
1179 | } | 1290 | } |
1180 | 1291 | ||
1181 | 1292 | ||
@@ -1219,13 +1330,15 @@ default_reply_handle (void *cls, | |||
1219 | rps_peer->num_recv_ids++; | 1330 | rps_peer->num_recv_ids++; |
1220 | } | 1331 | } |
1221 | 1332 | ||
1222 | if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit) | 1333 | if (GNUNET_YES != post_test) return; |
1334 | if (HAVE_QUICK_QUIT != cur_test_run.have_quick_quit) return; | ||
1335 | if (0 == evaluate()) | ||
1223 | { | 1336 | { |
1224 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); | 1337 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1225 | GNUNET_assert (NULL != post_test_task); | 1338 | "Test succeeded before end of duration\n"); |
1226 | GNUNET_SCHEDULER_cancel (post_test_task); | 1339 | if (NULL != post_test_task) GNUNET_SCHEDULER_cancel (post_test_task); |
1227 | post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); | 1340 | post_test_task = GNUNET_SCHEDULER_add_now (&post_test_op, NULL); |
1228 | GNUNET_assert (NULL!= post_test_task); | 1341 | GNUNET_assert (NULL != post_test_task); |
1229 | } | 1342 | } |
1230 | } | 1343 | } |
1231 | 1344 | ||
@@ -1239,13 +1352,13 @@ request_peers (void *cls) | |||
1239 | struct RPSPeer *rps_peer; | 1352 | struct RPSPeer *rps_peer; |
1240 | struct PendingReply *pending_rep; | 1353 | struct PendingReply *pending_rep; |
1241 | 1354 | ||
1242 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) | ||
1243 | return; | ||
1244 | rps_peer = pending_req->rps_peer; | 1355 | rps_peer = pending_req->rps_peer; |
1245 | GNUNET_assert (1 <= rps_peer->num_pending_reqs); | 1356 | GNUNET_assert (1 <= rps_peer->num_pending_reqs); |
1246 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, | 1357 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, |
1247 | rps_peer->pending_req_tail, | 1358 | rps_peer->pending_req_tail, |
1248 | pending_req); | 1359 | pending_req); |
1360 | rps_peer->num_pending_reqs--; | ||
1361 | if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) return; | ||
1249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1362 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1250 | "Requesting one peer\n"); | 1363 | "Requesting one peer\n"); |
1251 | pending_rep = GNUNET_new (struct PendingReply); | 1364 | pending_rep = GNUNET_new (struct PendingReply); |
@@ -1258,39 +1371,6 @@ request_peers (void *cls) | |||
1258 | rps_peer->pending_rep_tail, | 1371 | rps_peer->pending_rep_tail, |
1259 | pending_rep); | 1372 | pending_rep); |
1260 | rps_peer->num_pending_reps++; | 1373 | rps_peer->num_pending_reps++; |
1261 | rps_peer->num_pending_reqs--; | ||
1262 | } | ||
1263 | |||
1264 | static void | ||
1265 | cancel_pending_req (struct PendingRequest *pending_req) | ||
1266 | { | ||
1267 | struct RPSPeer *rps_peer; | ||
1268 | |||
1269 | rps_peer = pending_req->rps_peer; | ||
1270 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_req_head, | ||
1271 | rps_peer->pending_req_tail, | ||
1272 | pending_req); | ||
1273 | rps_peer->num_pending_reqs--; | ||
1274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1275 | "Cancelling pending request\n"); | ||
1276 | GNUNET_SCHEDULER_cancel (pending_req->request_task); | ||
1277 | GNUNET_free (pending_req); | ||
1278 | } | ||
1279 | |||
1280 | static void | ||
1281 | cancel_request (struct PendingReply *pending_rep) | ||
1282 | { | ||
1283 | struct RPSPeer *rps_peer; | ||
1284 | |||
1285 | rps_peer = pending_rep->rps_peer; | ||
1286 | GNUNET_CONTAINER_DLL_remove (rps_peer->pending_rep_head, | ||
1287 | rps_peer->pending_rep_tail, | ||
1288 | pending_rep); | ||
1289 | rps_peer->num_pending_reps--; | ||
1290 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1291 | "Cancelling request\n"); | ||
1292 | GNUNET_RPS_request_cancel (pending_rep->req_handle); | ||
1293 | GNUNET_free (pending_rep); | ||
1294 | } | 1374 | } |
1295 | 1375 | ||
1296 | 1376 | ||
@@ -2261,12 +2341,6 @@ void write_final_stats (void){ | |||
2261 | stat_type < STAT_TYPE_MAX; | 2341 | stat_type < STAT_TYPE_MAX; |
2262 | stat_type++) | 2342 | stat_type++) |
2263 | { | 2343 | { |
2264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2265 | "Add to sum (%" PRIu64 ") %" PRIu64 " of stat type %u - %s\n", | ||
2266 | sums[stat_type], | ||
2267 | rps_peers[i].stats[stat_type], | ||
2268 | stat_type, | ||
2269 | stat_type_2_str (stat_type)); | ||
2270 | sums[stat_type] += rps_peers[i].stats[stat_type]; | 2344 | sums[stat_type] += rps_peers[i].stats[stat_type]; |
2271 | } | 2345 | } |
2272 | } | 2346 | } |
@@ -2312,6 +2386,8 @@ post_test_shutdown_ready_cb (void *cls, | |||
2312 | { | 2386 | { |
2313 | struct STATcls *stat_cls = (struct STATcls *) cls; | 2387 | struct STATcls *stat_cls = (struct STATcls *) cls; |
2314 | struct RPSPeer *rps_peer = stat_cls->rps_peer; | 2388 | struct RPSPeer *rps_peer = stat_cls->rps_peer; |
2389 | |||
2390 | rps_peer->h_stat_get[stat_cls->stat_type] = NULL; | ||
2315 | if (GNUNET_OK == success) | 2391 | if (GNUNET_OK == success) |
2316 | { | 2392 | { |
2317 | /* set flag that we we got the value */ | 2393 | /* set flag that we we got the value */ |
@@ -2363,6 +2439,7 @@ stat_iterator (void *cls, | |||
2363 | { | 2439 | { |
2364 | const struct STATcls *stat_cls = (const struct STATcls *) cls; | 2440 | const struct STATcls *stat_cls = (const struct STATcls *) cls; |
2365 | struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer; | 2441 | struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer; |
2442 | |||
2366 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", | 2443 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", |
2367 | //stat_type_2_str (stat_cls->stat_type), | 2444 | //stat_type_2_str (stat_cls->stat_type), |
2368 | name, | 2445 | name, |
@@ -2455,12 +2532,13 @@ void post_profiler (struct RPSPeer *rps_peer) | |||
2455 | stat_cls->stat_type = stat_type; | 2532 | stat_cls->stat_type = stat_type; |
2456 | rps_peer->file_name_stats = | 2533 | rps_peer->file_name_stats = |
2457 | store_prefix_file_name (rps_peer->peer_id, "stats"); | 2534 | store_prefix_file_name (rps_peer->peer_id, "stats"); |
2458 | GNUNET_STATISTICS_get (rps_peer->stats_h, | 2535 | rps_peer->h_stat_get[stat_type] = GNUNET_STATISTICS_get ( |
2459 | "rps", | 2536 | rps_peer->stats_h, |
2460 | stat_type_2_str (stat_type), | 2537 | "rps", |
2461 | post_test_shutdown_ready_cb, | 2538 | stat_type_2_str (stat_type), |
2462 | stat_iterator, | 2539 | post_test_shutdown_ready_cb, |
2463 | (struct STATcls *) stat_cls); | 2540 | stat_iterator, |
2541 | (struct STATcls *) stat_cls); | ||
2464 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2542 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2465 | "Requested statistics for %s (peer %" PRIu32 ")\n", | 2543 | "Requested statistics for %s (peer %" PRIu32 ")\n", |
2466 | stat_type_2_str (stat_type), | 2544 | stat_type_2_str (stat_type), |
@@ -2555,6 +2633,8 @@ test_run (void *cls, | |||
2555 | /* Connect all peers to statistics service */ | 2633 | /* Connect all peers to statistics service */ |
2556 | if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics) | 2634 | if (COLLECT_STATISTICS == cur_test_run.have_collect_statistics) |
2557 | { | 2635 | { |
2636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2637 | "Connecting to statistics service\n"); | ||
2558 | rps_peers[i].stat_op = | 2638 | rps_peers[i].stat_op = |
2559 | GNUNET_TESTBED_service_connect (NULL, | 2639 | GNUNET_TESTBED_service_connect (NULL, |
2560 | peers[i], | 2640 | peers[i], |
@@ -2569,11 +2649,12 @@ test_run (void *cls, | |||
2569 | 2649 | ||
2570 | if (NULL != churn_task) | 2650 | if (NULL != churn_task) |
2571 | GNUNET_SCHEDULER_cancel (churn_task); | 2651 | GNUNET_SCHEDULER_cancel (churn_task); |
2572 | post_test_task = GNUNET_SCHEDULER_add_delayed (timeout, &post_test_op, NULL); | 2652 | post_test_task = GNUNET_SCHEDULER_add_delayed (duration, &post_test_op, NULL); |
2573 | timeout = GNUNET_TIME_relative_multiply (timeout, 1 + (0.1 * num_peers)); | 2653 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "timeout for shutdown is %lu\n", timeout.rel_value_us/1000000); |
2574 | shutdown_task = GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL); | 2654 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, |
2575 | shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL); | 2655 | &trigger_shutdown, |
2576 | 2656 | NULL); | |
2657 | GNUNET_SCHEDULER_add_shutdown (shutdown_op, NULL); | ||
2577 | } | 2658 | } |
2578 | 2659 | ||
2579 | 2660 | ||
@@ -2609,7 +2690,7 @@ run (void *cls, | |||
2609 | if (0 == cur_test_run.num_requests) cur_test_run.num_requests = 5; | 2690 | if (0 == cur_test_run.num_requests) cur_test_run.num_requests = 5; |
2610 | //cur_test_run.have_churn = HAVE_CHURN; | 2691 | //cur_test_run.have_churn = HAVE_CHURN; |
2611 | cur_test_run.have_churn = HAVE_NO_CHURN; | 2692 | cur_test_run.have_churn = HAVE_NO_CHURN; |
2612 | cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; | 2693 | cur_test_run.have_quick_quit = HAVE_QUICK_QUIT; |
2613 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; | 2694 | cur_test_run.have_collect_statistics = COLLECT_STATISTICS; |
2614 | cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) | | 2695 | cur_test_run.stat_collect_flags = BIT(STAT_TYPE_ROUNDS) | |
2615 | BIT(STAT_TYPE_BLOCKS) | | 2696 | BIT(STAT_TYPE_BLOCKS) | |
@@ -2632,10 +2713,38 @@ run (void *cls, | |||
2632 | /* 'Clean' directory */ | 2713 | /* 'Clean' directory */ |
2633 | (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); | 2714 | (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); |
2634 | GNUNET_DISK_directory_create ("/tmp/rps/"); | 2715 | GNUNET_DISK_directory_create ("/tmp/rps/"); |
2635 | if (0 == timeout.rel_value_us) | 2716 | if (0 == duration.rel_value_us) |
2636 | { | 2717 | { |
2637 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); | 2718 | if (0 == timeout.rel_value_us) |
2719 | { | ||
2720 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); | ||
2721 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
2722 | (90 * 1.2) + | ||
2723 | (0.01 * num_peers)); | ||
2724 | } | ||
2725 | else | ||
2726 | { | ||
2727 | duration = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
2728 | (timeout.rel_value_us/1000000) | ||
2729 | * 0.75); | ||
2730 | } | ||
2638 | } | 2731 | } |
2732 | else | ||
2733 | { | ||
2734 | if (0 == timeout.rel_value_us) | ||
2735 | { | ||
2736 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
2737 | ((duration.rel_value_us/1000000) | ||
2738 | * 1.2) + (0.01 * num_peers)); | ||
2739 | } | ||
2740 | } | ||
2741 | GNUNET_assert (duration.rel_value_us < timeout.rel_value_us); | ||
2742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2743 | "duration is %lus\n", | ||
2744 | duration.rel_value_us/1000000); | ||
2745 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2746 | "timeout is %lus\n", | ||
2747 | timeout.rel_value_us/1000000); | ||
2639 | 2748 | ||
2640 | /* Compute number of bits for representing largest peer id */ | 2749 | /* Compute number of bits for representing largest peer id */ |
2641 | for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++) | 2750 | for (bits_needed = 1; (1 << bits_needed) < num_peers; bits_needed++) |
@@ -2685,6 +2794,12 @@ main (int argc, char *argv[]) | |||
2685 | gettext_noop ("number of peers to start"), | 2794 | gettext_noop ("number of peers to start"), |
2686 | &num_peers), | 2795 | &num_peers), |
2687 | 2796 | ||
2797 | GNUNET_GETOPT_option_relative_time ('d', | ||
2798 | "duration", | ||
2799 | "DURATION", | ||
2800 | gettext_noop ("duration of the profiling"), | ||
2801 | &duration), | ||
2802 | |||
2688 | GNUNET_GETOPT_option_relative_time ('t', | 2803 | GNUNET_GETOPT_option_relative_time ('t', |
2689 | "timeout", | 2804 | "timeout", |
2690 | "TIMEOUT", | 2805 | "TIMEOUT", |
@@ -2732,7 +2847,6 @@ main (int argc, char *argv[]) | |||
2732 | GNUNET_free (rps_peers); | 2847 | GNUNET_free (rps_peers); |
2733 | GNUNET_free (rps_peer_ids); | 2848 | GNUNET_free (rps_peer_ids); |
2734 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); | 2849 | GNUNET_CONTAINER_multipeermap_destroy (peer_map); |
2735 | printf ("test -1\n"); | ||
2736 | return ret_value; | 2850 | return ret_value; |
2737 | } | 2851 | } |
2738 | 2852 | ||
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 5a75ac55a..21963ee42 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -68,6 +68,7 @@ static struct GNUNET_STATISTICS_Handle *stats; | |||
68 | */ | 68 | */ |
69 | static struct GNUNET_PeerIdentity own_identity; | 69 | static struct GNUNET_PeerIdentity own_identity; |
70 | 70 | ||
71 | static int in_shutdown = GNUNET_NO; | ||
71 | 72 | ||
72 | /** | 73 | /** |
73 | * @brief Port used for cadet. | 74 | * @brief Port used for cadet. |
@@ -97,11 +98,6 @@ static struct GNUNET_HashCode port; | |||
97 | #define unset_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask)) | 98 | #define unset_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask)) |
98 | 99 | ||
99 | /** | 100 | /** |
100 | * Set a channel flag of given channel context. | ||
101 | */ | ||
102 | #define set_channel_flag(channel_flags, mask) ((*channel_flags) |= (mask)) | ||
103 | |||
104 | /** | ||
105 | * Get channel flag of given channel context. | 101 | * Get channel flag of given channel context. |
106 | */ | 102 | */ |
107 | #define check_channel_flag_set(channel_flags, mask)\ | 103 | #define check_channel_flag_set(channel_flags, mask)\ |
@@ -164,6 +160,11 @@ struct PendingMessage | |||
164 | }; | 160 | }; |
165 | 161 | ||
166 | /** | 162 | /** |
163 | * @brief Context for a channel | ||
164 | */ | ||
165 | struct ChannelCtx; | ||
166 | |||
167 | /** | ||
167 | * Struct used to keep track of other peer's status | 168 | * Struct used to keep track of other peer's status |
168 | * | 169 | * |
169 | * This is stored in a multipeermap. | 170 | * This is stored in a multipeermap. |
@@ -181,22 +182,12 @@ struct PeerContext | |||
181 | /** | 182 | /** |
182 | * Channel open to client. | 183 | * Channel open to client. |
183 | */ | 184 | */ |
184 | struct GNUNET_CADET_Channel *send_channel; | 185 | struct ChannelCtx *send_channel_ctx; |
185 | |||
186 | /** | ||
187 | * Flags to the sending channel | ||
188 | */ | ||
189 | uint32_t *send_channel_flags; | ||
190 | 186 | ||
191 | /** | 187 | /** |
192 | * Channel open from client. | 188 | * Channel open from client. |
193 | */ | 189 | */ |
194 | struct GNUNET_CADET_Channel *recv_channel; // unneeded? | 190 | struct ChannelCtx *recv_channel_ctx; |
195 | |||
196 | /** | ||
197 | * Flags to the receiving channel | ||
198 | */ | ||
199 | uint32_t *recv_channel_flags; | ||
200 | 191 | ||
201 | /** | 192 | /** |
202 | * Array of pending operations on this peer. | 193 | * Array of pending operations on this peer. |
@@ -242,6 +233,11 @@ struct PeerContext | |||
242 | struct PendingMessage *pending_messages_tail; | 233 | struct PendingMessage *pending_messages_tail; |
243 | 234 | ||
244 | /** | 235 | /** |
236 | * @brief Task to destroy this context. | ||
237 | */ | ||
238 | struct GNUNET_SCHEDULER_Task *destruction_task; | ||
239 | |||
240 | /** | ||
245 | * This is pobably followed by 'statistical' data (when we first saw | 241 | * This is pobably followed by 'statistical' data (when we first saw |
246 | * it, how did we get its ID, how many pushes (in a timeinterval), | 242 | * it, how did we get its ID, how many pushes (in a timeinterval), |
247 | * ...) | 243 | * ...) |
@@ -265,6 +261,33 @@ struct PeersIteratorCls | |||
265 | }; | 261 | }; |
266 | 262 | ||
267 | /** | 263 | /** |
264 | * @brief Context for a channel | ||
265 | */ | ||
266 | struct ChannelCtx | ||
267 | { | ||
268 | /** | ||
269 | * @brief Meant to be used in a DLL | ||
270 | */ | ||
271 | struct ChannelCtx *next; | ||
272 | struct ChannelCtx *prev; | ||
273 | |||
274 | /** | ||
275 | * @brief The channel itself | ||
276 | */ | ||
277 | struct GNUNET_CADET_Channel *channel; | ||
278 | |||
279 | /** | ||
280 | * @brief The peer context associated with the channel | ||
281 | */ | ||
282 | struct PeerContext *peer_ctx; | ||
283 | |||
284 | /** | ||
285 | * @brief Scheduled task that will destroy this context | ||
286 | */ | ||
287 | struct GNUNET_SCHEDULER_Task *destruction_task; | ||
288 | }; | ||
289 | |||
290 | /** | ||
268 | * @brief Hashmap of valid peers. | 291 | * @brief Hashmap of valid peers. |
269 | */ | 292 | */ |
270 | static struct GNUNET_CONTAINER_MultiPeerMap *valid_peers; | 293 | static struct GNUNET_CONTAINER_MultiPeerMap *valid_peers; |
@@ -332,8 +355,6 @@ create_peer_ctx (const struct GNUNET_PeerIdentity *peer) | |||
332 | 355 | ||
333 | ctx = GNUNET_new (struct PeerContext); | 356 | ctx = GNUNET_new (struct PeerContext); |
334 | ctx->peer_id = *peer; | 357 | ctx->peer_id = *peer; |
335 | ctx->send_channel_flags = GNUNET_new (uint32_t); | ||
336 | ctx->recv_channel_flags = GNUNET_new (uint32_t); | ||
337 | ret = GNUNET_CONTAINER_multipeermap_put (peer_map, peer, ctx, | 358 | ret = GNUNET_CONTAINER_multipeermap_put (peer_map, peer, ctx, |
338 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 359 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
339 | GNUNET_assert (GNUNET_OK == ret); | 360 | GNUNET_assert (GNUNET_OK == ret); |
@@ -387,8 +408,8 @@ Peers_check_connected (const struct GNUNET_PeerIdentity *peer) | |||
387 | /* Get the context */ | 408 | /* Get the context */ |
388 | peer_ctx = get_peer_ctx (peer); | 409 | peer_ctx = get_peer_ctx (peer); |
389 | /* If we have no channel to this peer we don't know whether it's online */ | 410 | /* If we have no channel to this peer we don't know whether it's online */ |
390 | if ( (NULL == peer_ctx->send_channel) && | 411 | if ( (NULL == peer_ctx->send_channel_ctx) && |
391 | (NULL == peer_ctx->recv_channel) ) | 412 | (NULL == peer_ctx->recv_channel_ctx) ) |
392 | { | 413 | { |
393 | Peers_unset_peer_flag (peer, Peers_ONLINE); | 414 | Peers_unset_peer_flag (peer, Peers_ONLINE); |
394 | return GNUNET_NO; | 415 | return GNUNET_NO; |
@@ -575,6 +596,24 @@ handle_peer_pull_reply (void *cls, | |||
575 | 596 | ||
576 | /* End declaration of handlers */ | 597 | /* End declaration of handlers */ |
577 | 598 | ||
599 | /** | ||
600 | * @brief Allocate memory for a new channel context and insert it into DLL | ||
601 | * | ||
602 | * @param peer_ctx context of the according peer | ||
603 | * | ||
604 | * @return The channel context | ||
605 | */ | ||
606 | static struct ChannelCtx * | ||
607 | add_channel_ctx (struct PeerContext *peer_ctx); | ||
608 | |||
609 | /** | ||
610 | * @brief Remove the channel context from the DLL and free the memory. | ||
611 | * | ||
612 | * @param channel_ctx The channel context. | ||
613 | */ | ||
614 | static void | ||
615 | remove_channel_ctx (struct ChannelCtx *channel_ctx); | ||
616 | |||
578 | 617 | ||
579 | /** | 618 | /** |
580 | * @brief Get the channel of a peer. If not existing, create. | 619 | * @brief Get the channel of a peer. If not existing, create. |
@@ -610,16 +649,17 @@ get_channel (const struct GNUNET_PeerIdentity *peer) | |||
610 | 649 | ||
611 | 650 | ||
612 | peer_ctx = get_peer_ctx (peer); | 651 | peer_ctx = get_peer_ctx (peer); |
613 | if (NULL == peer_ctx->send_channel) | 652 | if (NULL == peer_ctx->send_channel_ctx) |
614 | { | 653 | { |
615 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 654 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
616 | "Trying to establish channel to peer %s\n", | 655 | "Trying to establish channel to peer %s\n", |
617 | GNUNET_i2s (peer)); | 656 | GNUNET_i2s (peer)); |
618 | ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity); | 657 | ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity); |
619 | *ctx_peer = *peer; | 658 | *ctx_peer = *peer; |
620 | peer_ctx->send_channel = | 659 | peer_ctx->send_channel_ctx = add_channel_ctx (peer_ctx); |
660 | peer_ctx->send_channel_ctx->channel = | ||
621 | GNUNET_CADET_channel_create (cadet_handle, | 661 | GNUNET_CADET_channel_create (cadet_handle, |
622 | (struct GNUNET_PeerIdentity *) ctx_peer, /* context */ | 662 | peer_ctx->send_channel_ctx, /* context */ |
623 | peer, | 663 | peer, |
624 | &port, | 664 | &port, |
625 | GNUNET_CADET_OPTION_RELIABLE, | 665 | GNUNET_CADET_OPTION_RELIABLE, |
@@ -627,8 +667,9 @@ get_channel (const struct GNUNET_PeerIdentity *peer) | |||
627 | cleanup_destroyed_channel, /* Disconnect handler */ | 667 | cleanup_destroyed_channel, /* Disconnect handler */ |
628 | cadet_handlers); | 668 | cadet_handlers); |
629 | } | 669 | } |
630 | GNUNET_assert (NULL != peer_ctx->send_channel); | 670 | GNUNET_assert (NULL != peer_ctx->send_channel_ctx); |
631 | return peer_ctx->send_channel; | 671 | GNUNET_assert (NULL != peer_ctx->send_channel_ctx->channel); |
672 | return peer_ctx->send_channel_ctx->channel; | ||
632 | } | 673 | } |
633 | 674 | ||
634 | 675 | ||
@@ -1045,12 +1086,10 @@ restore_valid_peers () | |||
1045 | */ | 1086 | */ |
1046 | void | 1087 | void |
1047 | Peers_initialise (char* fn_valid_peers, | 1088 | Peers_initialise (char* fn_valid_peers, |
1048 | struct GNUNET_CADET_Handle *cadet_h, | 1089 | struct GNUNET_CADET_Handle *cadet_h) |
1049 | const struct GNUNET_PeerIdentity *own_id) | ||
1050 | { | 1090 | { |
1051 | filename_valid_peers = GNUNET_strdup (fn_valid_peers); | 1091 | filename_valid_peers = GNUNET_strdup (fn_valid_peers); |
1052 | cadet_handle = cadet_h; | 1092 | cadet_handle = cadet_h; |
1053 | own_identity = *own_id; | ||
1054 | peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); | 1093 | peer_map = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); |
1055 | valid_peers = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); | 1094 | valid_peers = GNUNET_CONTAINER_multipeermap_create (4, GNUNET_NO); |
1056 | restore_valid_peers (); | 1095 | restore_valid_peers (); |
@@ -1136,14 +1175,12 @@ Peers_get_valid_peers (PeersIterator iterator, | |||
1136 | * @param peer the new #GNUNET_PeerIdentity | 1175 | * @param peer the new #GNUNET_PeerIdentity |
1137 | * | 1176 | * |
1138 | * @return #GNUNET_YES if peer was inserted | 1177 | * @return #GNUNET_YES if peer was inserted |
1139 | * #GNUNET_NO otherwise (if peer was already known or | 1178 | * #GNUNET_NO otherwise |
1140 | * peer was #own_identity) | ||
1141 | */ | 1179 | */ |
1142 | int | 1180 | int |
1143 | Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) | 1181 | Peers_insert_peer (const struct GNUNET_PeerIdentity *peer) |
1144 | { | 1182 | { |
1145 | if ( (GNUNET_YES == Peers_check_peer_known (peer)) || | 1183 | if (GNUNET_YES == Peers_check_peer_known (peer)) |
1146 | (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, &own_identity)) ) | ||
1147 | { | 1184 | { |
1148 | return GNUNET_NO; /* We already know this peer - nothing to do */ | 1185 | return GNUNET_NO; /* We already know this peer - nothing to do */ |
1149 | } | 1186 | } |
@@ -1161,8 +1198,7 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl | |||
1161 | * | 1198 | * |
1162 | * @param peer the peer whose liveliness is to be checked | 1199 | * @param peer the peer whose liveliness is to be checked |
1163 | * @return #GNUNET_YES if peer had to be inserted | 1200 | * @return #GNUNET_YES if peer had to be inserted |
1164 | * #GNUNET_NO otherwise (if peer was already known or | 1201 | * #GNUNET_NO otherwise |
1165 | * peer was #own_identity) | ||
1166 | */ | 1202 | */ |
1167 | int | 1203 | int |
1168 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) | 1204 | Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) |
@@ -1170,13 +1206,10 @@ Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer) | |||
1170 | struct PeerContext *peer_ctx; | 1206 | struct PeerContext *peer_ctx; |
1171 | int ret; | 1207 | int ret; |
1172 | 1208 | ||
1173 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, &own_identity)) | ||
1174 | { | ||
1175 | return GNUNET_NO; | ||
1176 | } | ||
1177 | ret = Peers_insert_peer (peer); | 1209 | ret = Peers_insert_peer (peer); |
1178 | peer_ctx = get_peer_ctx (peer); | 1210 | peer_ctx = get_peer_ctx (peer); |
1179 | if (GNUNET_NO == Peers_check_peer_flag (peer, Peers_ONLINE)) | 1211 | if ( (GNUNET_NO == Peers_check_peer_flag (peer, Peers_ONLINE)) && |
1212 | (NULL == peer_ctx->liveliness_check_pending) ) | ||
1180 | { | 1213 | { |
1181 | check_peer_live (peer_ctx); | 1214 | check_peer_live (peer_ctx); |
1182 | } | 1215 | } |
@@ -1208,7 +1241,7 @@ Peers_check_removable (const struct GNUNET_PeerIdentity *peer) | |||
1208 | } | 1241 | } |
1209 | 1242 | ||
1210 | peer_ctx = get_peer_ctx (peer); | 1243 | peer_ctx = get_peer_ctx (peer); |
1211 | if ( (NULL != peer_ctx->recv_channel) || | 1244 | if ( (NULL != peer_ctx->recv_channel_ctx) || |
1212 | (NULL != peer_ctx->pending_messages_head) || | 1245 | (NULL != peer_ctx->pending_messages_head) || |
1213 | (GNUNET_NO == check_peer_flag_set (peer_ctx, Peers_PULL_REPLY_PENDING)) ) | 1246 | (GNUNET_NO == check_peer_flag_set (peer_ctx, Peers_PULL_REPLY_PENDING)) ) |
1214 | { | 1247 | { |
@@ -1224,6 +1257,46 @@ Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer, | |||
1224 | int | 1257 | int |
1225 | Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags); | 1258 | Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags); |
1226 | 1259 | ||
1260 | static void | ||
1261 | destroy_peer (void *cls) | ||
1262 | { | ||
1263 | struct PeerContext *peer_ctx = cls; | ||
1264 | |||
1265 | GNUNET_assert (NULL != peer_ctx); | ||
1266 | peer_ctx->destruction_task = NULL; | ||
1267 | Peers_remove_peer (&peer_ctx->peer_id); | ||
1268 | } | ||
1269 | |||
1270 | static void | ||
1271 | destroy_channel (void *cls); | ||
1272 | |||
1273 | |||
1274 | static void | ||
1275 | schedule_channel_destruction (struct ChannelCtx *channel_ctx) | ||
1276 | { | ||
1277 | GNUNET_assert (NULL != channel_ctx); | ||
1278 | if (NULL != channel_ctx->destruction_task && | ||
1279 | GNUNET_NO == in_shutdown) | ||
1280 | { | ||
1281 | channel_ctx->destruction_task = | ||
1282 | GNUNET_SCHEDULER_add_now (destroy_channel, channel_ctx); | ||
1283 | } | ||
1284 | } | ||
1285 | |||
1286 | |||
1287 | static void | ||
1288 | schedule_peer_destruction (struct PeerContext *peer_ctx) | ||
1289 | { | ||
1290 | GNUNET_assert (NULL != peer_ctx); | ||
1291 | if (NULL != peer_ctx->destruction_task && | ||
1292 | GNUNET_NO == in_shutdown) | ||
1293 | { | ||
1294 | peer_ctx->destruction_task = | ||
1295 | GNUNET_SCHEDULER_add_now (destroy_peer, peer_ctx); | ||
1296 | } | ||
1297 | } | ||
1298 | |||
1299 | |||
1227 | /** | 1300 | /** |
1228 | * @brief Remove peer | 1301 | * @brief Remove peer |
1229 | * | 1302 | * |
@@ -1235,7 +1308,8 @@ int | |||
1235 | Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | 1308 | Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) |
1236 | { | 1309 | { |
1237 | struct PeerContext *peer_ctx; | 1310 | struct PeerContext *peer_ctx; |
1238 | uint32_t *channel_flag; | 1311 | |
1312 | GNUNET_assert (NULL != peer_map); | ||
1239 | 1313 | ||
1240 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) | 1314 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) |
1241 | { | 1315 | { |
@@ -1249,7 +1323,12 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1249 | GNUNET_i2s (&peer_ctx->peer_id)); | 1323 | GNUNET_i2s (&peer_ctx->peer_id)); |
1250 | Peers_unset_peer_flag (peer, Peers_ONLINE); | 1324 | Peers_unset_peer_flag (peer, Peers_ONLINE); |
1251 | 1325 | ||
1326 | /* Clear list of pending operations */ | ||
1327 | // TODO this probably leaks memory | ||
1328 | // ('only' the cls to the function. Not sure what to do with it) | ||
1252 | GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0); | 1329 | GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0); |
1330 | |||
1331 | /* Remove all pending messages */ | ||
1253 | while (NULL != peer_ctx->pending_messages_head) | 1332 | while (NULL != peer_ctx->pending_messages_head) |
1254 | { | 1333 | { |
1255 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1334 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1261,10 +1340,12 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1261 | peer_ctx->liveliness_check_pending, | 1340 | peer_ctx->liveliness_check_pending, |
1262 | sizeof (struct PendingMessage))) ) | 1341 | sizeof (struct PendingMessage))) ) |
1263 | { | 1342 | { |
1343 | // TODO this may leak memory | ||
1264 | peer_ctx->liveliness_check_pending = NULL; | 1344 | peer_ctx->liveliness_check_pending = NULL; |
1265 | } | 1345 | } |
1266 | remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES); | 1346 | remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES); |
1267 | } | 1347 | } |
1348 | |||
1268 | /* If we are still waiting for notification whether this peer is live | 1349 | /* If we are still waiting for notification whether this peer is live |
1269 | * cancel the according task */ | 1350 | * cancel the according task */ |
1270 | if (NULL != peer_ctx->liveliness_check_pending) | 1351 | if (NULL != peer_ctx->liveliness_check_pending) |
@@ -1277,28 +1358,40 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1277 | remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); | 1358 | remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); |
1278 | peer_ctx->liveliness_check_pending = NULL; | 1359 | peer_ctx->liveliness_check_pending = NULL; |
1279 | } | 1360 | } |
1280 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_SENDING); | 1361 | |
1281 | if (NULL != peer_ctx->send_channel && | 1362 | |
1282 | GNUNET_YES != Peers_check_channel_flag (channel_flag, Peers_CHANNEL_DESTROING)) | 1363 | /* Do we still have to wait for destruction of channels |
1364 | * or issue the destruction? */ | ||
1365 | if (NULL != peer_ctx->send_channel_ctx && | ||
1366 | NULL != peer_ctx->send_channel_ctx->destruction_task | ||
1367 | ) | ||
1283 | { | 1368 | { |
1284 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1369 | schedule_peer_destruction (peer_ctx); |
1285 | "Destroying send channel\n"); | 1370 | return GNUNET_NO; |
1286 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | ||
1287 | peer_ctx->send_channel = NULL; | ||
1288 | peer_ctx->mq = NULL; | ||
1289 | } | 1371 | } |
1290 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_RECEIVING); | 1372 | if (NULL != peer_ctx->recv_channel_ctx && |
1291 | if (NULL != peer_ctx->recv_channel && | 1373 | NULL != peer_ctx->recv_channel_ctx->destruction_task) |
1292 | GNUNET_YES != Peers_check_channel_flag (channel_flag, Peers_CHANNEL_DESTROING)) | ||
1293 | { | 1374 | { |
1294 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1375 | schedule_peer_destruction (peer_ctx); |
1295 | "Destroying recv channel\n"); | 1376 | return GNUNET_NO; |
1296 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); | 1377 | } |
1297 | peer_ctx->recv_channel = NULL; | 1378 | if (NULL != peer_ctx->recv_channel_ctx) |
1379 | { | ||
1380 | schedule_channel_destruction (peer_ctx->recv_channel_ctx); | ||
1381 | schedule_peer_destruction (peer_ctx); | ||
1382 | return GNUNET_NO; | ||
1383 | } | ||
1384 | if (NULL != peer_ctx->send_channel_ctx) | ||
1385 | { | ||
1386 | schedule_channel_destruction (peer_ctx->send_channel_ctx); | ||
1387 | schedule_peer_destruction (peer_ctx); | ||
1388 | return GNUNET_NO; | ||
1298 | } | 1389 | } |
1299 | 1390 | ||
1300 | GNUNET_free (peer_ctx->send_channel_flags); | 1391 | if (NULL != peer_ctx->destruction_task) |
1301 | GNUNET_free (peer_ctx->recv_channel_flags); | 1392 | { |
1393 | GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task); | ||
1394 | } | ||
1302 | 1395 | ||
1303 | if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, &peer_ctx->peer_id)) | 1396 | if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, &peer_ctx->peer_id)) |
1304 | { | 1397 | { |
@@ -1308,7 +1401,6 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1308 | return GNUNET_YES; | 1401 | return GNUNET_YES; |
1309 | } | 1402 | } |
1310 | 1403 | ||
1311 | |||
1312 | /** | 1404 | /** |
1313 | * @brief set flags on a given peer. | 1405 | * @brief set flags on a given peer. |
1314 | * | 1406 | * |
@@ -1364,77 +1456,6 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl | |||
1364 | return check_peer_flag_set (peer_ctx, flags); | 1456 | return check_peer_flag_set (peer_ctx, flags); |
1365 | } | 1457 | } |
1366 | 1458 | ||
1367 | |||
1368 | /** | ||
1369 | * @brief set flags on a given channel. | ||
1370 | * | ||
1371 | * @param channel the channel to set flags on | ||
1372 | * @param flags the flags | ||
1373 | */ | ||
1374 | void | ||
1375 | Peers_set_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags) | ||
1376 | { | ||
1377 | set_channel_flag (channel_flags, flags); | ||
1378 | } | ||
1379 | |||
1380 | |||
1381 | /** | ||
1382 | * @brief unset flags on a given channel. | ||
1383 | * | ||
1384 | * @param channel the channel to unset flags on | ||
1385 | * @param flags the flags | ||
1386 | */ | ||
1387 | void | ||
1388 | Peers_unset_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags) | ||
1389 | { | ||
1390 | unset_channel_flag (channel_flags, flags); | ||
1391 | } | ||
1392 | |||
1393 | |||
1394 | /** | ||
1395 | * @brief Check whether flags on a channel are set. | ||
1396 | * | ||
1397 | * @param channel the channel to check the flag of | ||
1398 | * @param flags the flags to check | ||
1399 | * | ||
1400 | * @return #GNUNET_YES if all given flags are set | ||
1401 | * #GNUNET_NO otherwise | ||
1402 | */ | ||
1403 | int | ||
1404 | Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags) | ||
1405 | { | ||
1406 | return check_channel_flag_set (channel_flags, flags); | ||
1407 | } | ||
1408 | |||
1409 | /** | ||
1410 | * @brief Get the flags for the channel in @a role for @a peer. | ||
1411 | * | ||
1412 | * @param peer Peer to get the channel flags for. | ||
1413 | * @param role Role of channel to get flags for | ||
1414 | * | ||
1415 | * @return The flags. | ||
1416 | */ | ||
1417 | uint32_t * | ||
1418 | Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer, | ||
1419 | enum Peers_ChannelRole role) | ||
1420 | { | ||
1421 | const struct PeerContext *peer_ctx; | ||
1422 | |||
1423 | peer_ctx = get_peer_ctx (peer); | ||
1424 | if (Peers_CHANNEL_ROLE_SENDING == role) | ||
1425 | { | ||
1426 | return peer_ctx->send_channel_flags; | ||
1427 | } | ||
1428 | else if (Peers_CHANNEL_ROLE_RECEIVING == role) | ||
1429 | { | ||
1430 | return peer_ctx->recv_channel_flags; | ||
1431 | } | ||
1432 | else | ||
1433 | { | ||
1434 | GNUNET_assert (0); | ||
1435 | } | ||
1436 | } | ||
1437 | |||
1438 | /** | 1459 | /** |
1439 | * @brief Check whether we have information about the given peer. | 1460 | * @brief Check whether we have information about the given peer. |
1440 | * | 1461 | * |
@@ -1505,7 +1526,7 @@ Peers_check_peer_send_intention (const struct GNUNET_PeerIdentity *peer) | |||
1505 | const struct PeerContext *peer_ctx; | 1526 | const struct PeerContext *peer_ctx; |
1506 | 1527 | ||
1507 | peer_ctx = get_peer_ctx (peer); | 1528 | peer_ctx = get_peer_ctx (peer); |
1508 | if (NULL != peer_ctx->recv_channel) | 1529 | if (NULL != peer_ctx->recv_channel_ctx) |
1509 | { | 1530 | { |
1510 | return GNUNET_YES; | 1531 | return GNUNET_YES; |
1511 | } | 1532 | } |
@@ -1530,6 +1551,7 @@ Peers_handle_inbound_channel (void *cls, | |||
1530 | { | 1551 | { |
1531 | struct PeerContext *peer_ctx; | 1552 | struct PeerContext *peer_ctx; |
1532 | struct GNUNET_PeerIdentity *ctx_peer; | 1553 | struct GNUNET_PeerIdentity *ctx_peer; |
1554 | struct ChannelCtx *channel_ctx; | ||
1533 | 1555 | ||
1534 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1556 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1535 | "New channel was established to us (Peer %s).\n", | 1557 | "New channel was established to us (Peer %s).\n", |
@@ -1540,19 +1562,22 @@ Peers_handle_inbound_channel (void *cls, | |||
1540 | set_peer_live (peer_ctx); | 1562 | set_peer_live (peer_ctx); |
1541 | ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity); | 1563 | ctx_peer = GNUNET_new (struct GNUNET_PeerIdentity); |
1542 | *ctx_peer = *initiator; | 1564 | *ctx_peer = *initiator; |
1565 | channel_ctx = add_channel_ctx (peer_ctx); | ||
1566 | channel_ctx->channel = channel; | ||
1543 | /* We only accept one incoming channel per peer */ | 1567 | /* We only accept one incoming channel per peer */ |
1544 | if (GNUNET_YES == Peers_check_peer_send_intention (initiator)) | 1568 | if (GNUNET_YES == Peers_check_peer_send_intention (initiator)) |
1545 | { | 1569 | { |
1546 | set_channel_flag (peer_ctx->recv_channel_flags, | 1570 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1547 | Peers_CHANNEL_ESTABLISHED_TWICE); | 1571 | "Already got one receive channel. Destroying old one.\n"); |
1548 | //GNUNET_CADET_channel_destroy (channel); | 1572 | GNUNET_break_op (0); |
1549 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); | 1573 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel_ctx->channel); |
1550 | peer_ctx->recv_channel = channel; | 1574 | remove_channel_ctx (peer_ctx->recv_channel_ctx); |
1575 | peer_ctx->recv_channel_ctx = channel_ctx; | ||
1551 | /* return the channel context */ | 1576 | /* return the channel context */ |
1552 | return ctx_peer; | 1577 | return channel_ctx; |
1553 | } | 1578 | } |
1554 | peer_ctx->recv_channel = channel; | 1579 | peer_ctx->recv_channel_ctx = channel_ctx; |
1555 | return ctx_peer; | 1580 | return channel_ctx; |
1556 | } | 1581 | } |
1557 | 1582 | ||
1558 | 1583 | ||
@@ -1574,7 +1599,7 @@ Peers_check_sending_channel_exists (const struct GNUNET_PeerIdentity *peer) | |||
1574 | return GNUNET_NO; | 1599 | return GNUNET_NO; |
1575 | } | 1600 | } |
1576 | peer_ctx = get_peer_ctx (peer); | 1601 | peer_ctx = get_peer_ctx (peer); |
1577 | if (NULL == peer_ctx->send_channel) | 1602 | if (NULL == peer_ctx->send_channel_ctx) |
1578 | { | 1603 | { |
1579 | return GNUNET_NO; | 1604 | return GNUNET_NO; |
1580 | } | 1605 | } |
@@ -1607,12 +1632,14 @@ Peers_check_channel_role (const struct GNUNET_PeerIdentity *peer, | |||
1607 | } | 1632 | } |
1608 | peer_ctx = get_peer_ctx (peer); | 1633 | peer_ctx = get_peer_ctx (peer); |
1609 | if ( (Peers_CHANNEL_ROLE_SENDING == role) && | 1634 | if ( (Peers_CHANNEL_ROLE_SENDING == role) && |
1610 | (channel == peer_ctx->send_channel) ) | 1635 | (NULL != peer_ctx->send_channel_ctx) && |
1636 | (channel == peer_ctx->send_channel_ctx->channel) ) | ||
1611 | { | 1637 | { |
1612 | return GNUNET_YES; | 1638 | return GNUNET_YES; |
1613 | } | 1639 | } |
1614 | if ( (Peers_CHANNEL_ROLE_RECEIVING == role) && | 1640 | if ( (Peers_CHANNEL_ROLE_RECEIVING == role) && |
1615 | (channel == peer_ctx->recv_channel) ) | 1641 | (NULL != peer_ctx->recv_channel_ctx) && |
1642 | (channel == peer_ctx->recv_channel_ctx->channel) ) | ||
1616 | { | 1643 | { |
1617 | return GNUNET_YES; | 1644 | return GNUNET_YES; |
1618 | } | 1645 | } |
@@ -1642,18 +1669,29 @@ Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer) | |||
1642 | return GNUNET_NO; | 1669 | return GNUNET_NO; |
1643 | } | 1670 | } |
1644 | peer_ctx = get_peer_ctx (peer); | 1671 | peer_ctx = get_peer_ctx (peer); |
1645 | if (NULL != peer_ctx->send_channel) | 1672 | if (NULL != peer_ctx->send_channel_ctx) |
1646 | { | 1673 | { |
1647 | set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_CLEAN); | 1674 | schedule_channel_destruction (peer_ctx->send_channel_ctx); |
1648 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | ||
1649 | peer_ctx->send_channel = NULL; | ||
1650 | peer_ctx->mq = NULL; | ||
1651 | (void) Peers_check_connected (peer); | 1675 | (void) Peers_check_connected (peer); |
1652 | return GNUNET_YES; | 1676 | return GNUNET_YES; |
1653 | } | 1677 | } |
1654 | return GNUNET_NO; | 1678 | return GNUNET_NO; |
1655 | } | 1679 | } |
1656 | 1680 | ||
1681 | static void | ||
1682 | destroy_channel (void *cls) | ||
1683 | { | ||
1684 | struct ChannelCtx *channel_ctx = cls; | ||
1685 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; | ||
1686 | |||
1687 | GNUNET_assert (channel_ctx == peer_ctx->send_channel_ctx || | ||
1688 | channel_ctx == peer_ctx->recv_channel_ctx); | ||
1689 | |||
1690 | channel_ctx->destruction_task = NULL; | ||
1691 | GNUNET_CADET_channel_destroy (channel_ctx->channel); | ||
1692 | remove_channel_ctx (peer_ctx->send_channel_ctx); | ||
1693 | } | ||
1694 | |||
1657 | /** | 1695 | /** |
1658 | * This is called when a channel is destroyed. | 1696 | * This is called when a channel is destroyed. |
1659 | * | 1697 | * |
@@ -1664,9 +1702,9 @@ void | |||
1664 | Peers_cleanup_destroyed_channel (void *cls, | 1702 | Peers_cleanup_destroyed_channel (void *cls, |
1665 | const struct GNUNET_CADET_Channel *channel) | 1703 | const struct GNUNET_CADET_Channel *channel) |
1666 | { | 1704 | { |
1667 | struct GNUNET_PeerIdentity *peer = cls; | 1705 | struct ChannelCtx *channel_ctx = cls; |
1668 | struct PeerContext *peer_ctx; | 1706 | const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; |
1669 | uint32_t *channel_flag; | 1707 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; |
1670 | 1708 | ||
1671 | if (GNUNET_NO == Peers_check_peer_known (peer)) | 1709 | if (GNUNET_NO == Peers_check_peer_known (peer)) |
1672 | {/* We don't want to implicitly create a context that we're about to kill */ | 1710 | {/* We don't want to implicitly create a context that we're about to kill */ |
@@ -1675,71 +1713,34 @@ Peers_cleanup_destroyed_channel (void *cls, | |||
1675 | GNUNET_i2s (peer)); | 1713 | GNUNET_i2s (peer)); |
1676 | return; | 1714 | return; |
1677 | } | 1715 | } |
1678 | peer_ctx = get_peer_ctx (peer); | ||
1679 | 1716 | ||
1680 | /* If our peer issued the destruction of the channel, the #Peers_TO_DESTROY | 1717 | /* If our peer issued the destruction of the channel, the #Peers_TO_DESTROY |
1681 | * flag will be set. In this case simply make sure that the channels are | 1718 | * flag will be set. In this case simply make sure that the channels are |
1682 | * cleaned. */ | 1719 | * cleaned. */ |
1683 | /* FIXME This distinction seems to be redundant */ | 1720 | /* The distinction seems to be redundant */ |
1684 | if (Peers_check_peer_flag (peer, Peers_TO_DESTROY)) | 1721 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1685 | {/* We initiatad the destruction of this particular peer */ | 1722 | "Peer is NOT in the process of being destroyed\n"); |
1723 | if ( (NULL != peer_ctx->send_channel_ctx) && | ||
1724 | (channel == peer_ctx->send_channel_ctx->channel) ) | ||
1725 | { /* Something (but us) killd the channel - clean up peer */ | ||
1686 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1726 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1687 | "Peer is in the process of being destroyed\n"); | 1727 | "send channel (%s) was destroyed - cleaning up\n", |
1688 | if (channel == peer_ctx->send_channel) | 1728 | GNUNET_i2s (peer)); |
1689 | { | 1729 | remove_channel_ctx (peer_ctx->send_channel_ctx); |
1690 | peer_ctx->send_channel = NULL; | ||
1691 | peer_ctx->mq = NULL; | ||
1692 | } | ||
1693 | else if (channel == peer_ctx->recv_channel) | ||
1694 | { | ||
1695 | peer_ctx->recv_channel = NULL; | ||
1696 | } | ||
1697 | |||
1698 | if (NULL != peer_ctx->send_channel) | ||
1699 | { | ||
1700 | GNUNET_CADET_channel_destroy (peer_ctx->send_channel); | ||
1701 | channel_flag = Peers_get_channel_flag (&peer_ctx->peer_id, Peers_CHANNEL_ROLE_SENDING); | ||
1702 | Peers_set_channel_flag (channel_flag, Peers_CHANNEL_DESTROING); | ||
1703 | peer_ctx->send_channel = NULL; | ||
1704 | peer_ctx->mq = NULL; | ||
1705 | } | ||
1706 | if (NULL != peer_ctx->recv_channel) | ||
1707 | { | ||
1708 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel); | ||
1709 | channel_flag = Peers_get_channel_flag (&peer_ctx->peer_id, Peers_CHANNEL_ROLE_RECEIVING); | ||
1710 | Peers_set_channel_flag (channel_flag, Peers_CHANNEL_DESTROING); | ||
1711 | peer_ctx->recv_channel = NULL; | ||
1712 | } | ||
1713 | /* Set the #Peers_ONLINE flag accordingly */ | ||
1714 | (void) Peers_check_connected (peer); | ||
1715 | return; | ||
1716 | } | 1730 | } |
1717 | 1731 | else if ( (NULL != peer_ctx->recv_channel_ctx) && | |
1718 | else | 1732 | (channel == peer_ctx->recv_channel_ctx->channel) ) |
1719 | { /* We did not initiate the destruction of this peer */ | 1733 | { /* Other peer doesn't want to send us messages anymore */ |
1720 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1734 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1721 | "Peer is NOT in the process of being destroyed\n"); | 1735 | "Peer %s destroyed recv channel - cleaning up channel\n", |
1722 | if (channel == peer_ctx->send_channel) | 1736 | GNUNET_i2s (peer)); |
1723 | { /* Something (but us) killd the channel - clean up peer */ | 1737 | remove_channel_ctx (peer_ctx->send_channel_ctx); |
1724 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1738 | } |
1725 | "send channel (%s) was destroyed - cleaning up\n", | 1739 | else |
1726 | GNUNET_i2s (peer)); | 1740 | { |
1727 | peer_ctx->send_channel = NULL; | 1741 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1728 | peer_ctx->mq = NULL; | 1742 | "unknown channel (%s) was destroyed\n", |
1729 | } | 1743 | GNUNET_i2s (peer)); |
1730 | else if (channel == peer_ctx->recv_channel) | ||
1731 | { /* Other peer doesn't want to send us messages anymore */ | ||
1732 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1733 | "Peer %s destroyed recv channel - cleaning up channel\n", | ||
1734 | GNUNET_i2s (peer)); | ||
1735 | peer_ctx->recv_channel = NULL; | ||
1736 | } | ||
1737 | else | ||
1738 | { | ||
1739 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1740 | "unknown channel (%s) was destroyed\n", | ||
1741 | GNUNET_i2s (peer)); | ||
1742 | } | ||
1743 | } | 1744 | } |
1744 | (void) Peers_check_connected (peer); | 1745 | (void) Peers_check_connected (peer); |
1745 | } | 1746 | } |
@@ -1791,10 +1792,6 @@ Peers_schedule_operation (const struct GNUNET_PeerIdentity *peer, | |||
1791 | struct PeerPendingOp pending_op; | 1792 | struct PeerPendingOp pending_op; |
1792 | struct PeerContext *peer_ctx; | 1793 | struct PeerContext *peer_ctx; |
1793 | 1794 | ||
1794 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (peer, &own_identity)) | ||
1795 | { | ||
1796 | return GNUNET_NO; | ||
1797 | } | ||
1798 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); | 1795 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); |
1799 | 1796 | ||
1800 | //TODO if LIVE/ONLINE execute immediately | 1797 | //TODO if LIVE/ONLINE execute immediately |
@@ -1828,7 +1825,7 @@ Peers_get_recv_channel (const struct GNUNET_PeerIdentity *peer) | |||
1828 | 1825 | ||
1829 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); | 1826 | GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer)); |
1830 | peer_ctx = get_peer_ctx (peer); | 1827 | peer_ctx = get_peer_ctx (peer); |
1831 | return peer_ctx->recv_channel; | 1828 | return peer_ctx->recv_channel_ctx->channel; |
1832 | } | 1829 | } |
1833 | /*********************************************************************** | 1830 | /*********************************************************************** |
1834 | * /Old gnunet-service-rps_peers.c | 1831 | * /Old gnunet-service-rps_peers.c |
@@ -2489,6 +2486,9 @@ send_pull_reply (const struct GNUNET_PeerIdentity *peer_id, | |||
2489 | 2486 | ||
2490 | Peers_send_message (peer_id, ev, "PULL REPLY"); | 2487 | Peers_send_message (peer_id, ev, "PULL REPLY"); |
2491 | GNUNET_STATISTICS_update(stats, "# pull reply send issued", 1, GNUNET_NO); | 2488 | GNUNET_STATISTICS_update(stats, "# pull reply send issued", 1, GNUNET_NO); |
2489 | // TODO check with send intention: as send_channel is used/opened we indicate | ||
2490 | // a sending intention without intending it. | ||
2491 | // -> clean peer afterwards? | ||
2492 | } | 2492 | } |
2493 | 2493 | ||
2494 | 2494 | ||
@@ -2621,7 +2621,7 @@ remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
2621 | CustomPeerMap_remove_peer (push_map, peer); | 2621 | CustomPeerMap_remove_peer (push_map, peer); |
2622 | RPS_sampler_reinitialise_by_value (prot_sampler, peer); | 2622 | RPS_sampler_reinitialise_by_value (prot_sampler, peer); |
2623 | RPS_sampler_reinitialise_by_value (client_sampler, peer); | 2623 | RPS_sampler_reinitialise_by_value (client_sampler, peer); |
2624 | Peers_remove_peer (peer); | 2624 | schedule_peer_destruction (get_peer_ctx (peer)); |
2625 | } | 2625 | } |
2626 | 2626 | ||
2627 | 2627 | ||
@@ -2665,6 +2665,58 @@ clean_peer (const struct GNUNET_PeerIdentity *peer) | |||
2665 | } | 2665 | } |
2666 | 2666 | ||
2667 | /** | 2667 | /** |
2668 | * @brief Allocate memory for a new channel context and insert it into DLL | ||
2669 | * | ||
2670 | * @param peer_ctx context of the according peer | ||
2671 | * | ||
2672 | * @return The channel context | ||
2673 | */ | ||
2674 | static struct ChannelCtx * | ||
2675 | add_channel_ctx (struct PeerContext *peer_ctx) | ||
2676 | { | ||
2677 | struct ChannelCtx *channel_ctx; | ||
2678 | channel_ctx = GNUNET_new (struct ChannelCtx); | ||
2679 | channel_ctx->peer_ctx = peer_ctx; | ||
2680 | return channel_ctx; | ||
2681 | } | ||
2682 | |||
2683 | /** | ||
2684 | * @brief Remove the channel context from the DLL and free the memory. | ||
2685 | * | ||
2686 | * @param channel_ctx The channel context. | ||
2687 | */ | ||
2688 | static void | ||
2689 | remove_channel_ctx (struct ChannelCtx *channel_ctx) | ||
2690 | { | ||
2691 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; | ||
2692 | if (NULL != channel_ctx->destruction_task) | ||
2693 | { | ||
2694 | GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task); | ||
2695 | } | ||
2696 | GNUNET_free (channel_ctx); | ||
2697 | |||
2698 | if (channel_ctx == peer_ctx->send_channel_ctx) | ||
2699 | { | ||
2700 | peer_ctx->send_channel_ctx = NULL; | ||
2701 | peer_ctx->mq = NULL; | ||
2702 | } | ||
2703 | else if (channel_ctx == peer_ctx->recv_channel_ctx) | ||
2704 | { | ||
2705 | peer_ctx->recv_channel_ctx = NULL; | ||
2706 | } | ||
2707 | else | ||
2708 | { | ||
2709 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2710 | "Trying to remove channel_ctx that is not associated with a peer\n"); | ||
2711 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2712 | "\trecv: %p\n", peer_ctx->recv_channel_ctx); | ||
2713 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2714 | "\tsend: %p\n", peer_ctx->send_channel_ctx); | ||
2715 | GNUNET_assert (0); | ||
2716 | } | ||
2717 | } | ||
2718 | |||
2719 | /** | ||
2668 | * @brief This is called when a channel is destroyed. | 2720 | * @brief This is called when a channel is destroyed. |
2669 | * | 2721 | * |
2670 | * Removes peer completely from our knowledge if the send_channel was destroyed | 2722 | * Removes peer completely from our knowledge if the send_channel was destroyed |
@@ -2680,8 +2732,8 @@ static void | |||
2680 | cleanup_destroyed_channel (void *cls, | 2732 | cleanup_destroyed_channel (void *cls, |
2681 | const struct GNUNET_CADET_Channel *channel) | 2733 | const struct GNUNET_CADET_Channel *channel) |
2682 | { | 2734 | { |
2683 | struct GNUNET_PeerIdentity *peer = cls; | 2735 | struct ChannelCtx *channel_ctx = cls; |
2684 | uint32_t *channel_flag; | 2736 | struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; |
2685 | struct PeerContext *peer_ctx; | 2737 | struct PeerContext *peer_ctx; |
2686 | 2738 | ||
2687 | GNUNET_assert (NULL != peer); | 2739 | GNUNET_assert (NULL != peer); |
@@ -2691,94 +2743,26 @@ cleanup_destroyed_channel (void *cls, | |||
2691 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2743 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2692 | "channel (%s) without associated context was destroyed\n", | 2744 | "channel (%s) without associated context was destroyed\n", |
2693 | GNUNET_i2s (peer)); | 2745 | GNUNET_i2s (peer)); |
2694 | GNUNET_free (peer); | 2746 | remove_channel_ctx (channel_ctx); |
2695 | return; | 2747 | return; |
2696 | } | 2748 | } |
2697 | 2749 | ||
2698 | peer_ctx = get_peer_ctx (peer); | 2750 | peer_ctx = get_peer_ctx (peer); |
2699 | if (GNUNET_YES == Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_RECEIVING)) | ||
2700 | { | ||
2701 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2702 | "Callback on destruction of recv-channel was called (%s)\n", | ||
2703 | GNUNET_i2s (peer)); | ||
2704 | set_channel_flag (peer_ctx->recv_channel_flags, Peers_CHANNEL_DESTROING); | ||
2705 | } else if (GNUNET_YES == Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_SENDING)) | ||
2706 | { | ||
2707 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
2708 | "Callback on destruction of send-channel was called (%s)\n", | ||
2709 | GNUNET_i2s (peer)); | ||
2710 | set_channel_flag (peer_ctx->send_channel_flags, Peers_CHANNEL_DESTROING); | ||
2711 | } else { | ||
2712 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2713 | "Channel to be destroyed has is neither sending nor receiving role\n"); | ||
2714 | } | ||
2715 | 2751 | ||
2716 | if (GNUNET_YES == Peers_check_peer_flag (peer, Peers_TO_DESTROY)) | 2752 | // What should be done here: |
2717 | { /* We are in the middle of removing that peer from our knowledge. In this | 2753 | // * cleanup everything related to the channel |
2718 | case simply make sure that the channels are cleaned. */ | 2754 | // * memory |
2719 | Peers_cleanup_destroyed_channel (cls, channel); | 2755 | // * remove peer if necessary |
2720 | to_file (file_name_view_log, | ||
2721 | "-%s\t(cleanup channel, ourself)", | ||
2722 | GNUNET_i2s_full (peer)); | ||
2723 | GNUNET_free (peer); | ||
2724 | return; | ||
2725 | } | ||
2726 | 2756 | ||
2727 | if (GNUNET_YES == | 2757 | if (peer_ctx->recv_channel_ctx == channel_ctx) |
2728 | Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_SENDING)) | 2758 | { |
2729 | { /* Channel used for sending was destroyed */ | 2759 | remove_channel_ctx (channel_ctx); |
2730 | /* Possible causes of channel destruction: | ||
2731 | * - ourselves -> cleaning send channel -> clean context | ||
2732 | * - other peer -> peer probably went down -> remove | ||
2733 | */ | ||
2734 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_SENDING); | ||
2735 | if (GNUNET_YES == Peers_check_channel_flag (channel_flag, Peers_CHANNEL_CLEAN)) | ||
2736 | { /* We are about to clean the sending channel. Clean the respective | ||
2737 | * context */ | ||
2738 | Peers_cleanup_destroyed_channel (cls, channel); | ||
2739 | GNUNET_free (peer); | ||
2740 | return; | ||
2741 | } | ||
2742 | else | ||
2743 | { /* Other peer destroyed our sending channel that it is supposed to keep | ||
2744 | * open. It probably went down. Remove it from our knowledge. */ | ||
2745 | Peers_cleanup_destroyed_channel (cls, channel); | ||
2746 | remove_peer (peer); | ||
2747 | GNUNET_free (peer); | ||
2748 | return; | ||
2749 | } | ||
2750 | } | ||
2751 | else if (GNUNET_YES == | ||
2752 | Peers_check_channel_role (peer, channel, Peers_CHANNEL_ROLE_RECEIVING)) | ||
2753 | { /* Channel used for receiving was destroyed */ | ||
2754 | /* Possible causes of channel destruction: | ||
2755 | * - ourselves -> peer tried to establish channel twice -> clean context | ||
2756 | * - other peer -> peer doesn't want to send us data -> clean | ||
2757 | */ | ||
2758 | channel_flag = Peers_get_channel_flag (peer, Peers_CHANNEL_ROLE_RECEIVING); | ||
2759 | if (GNUNET_YES == | ||
2760 | Peers_check_channel_flag (channel_flag, Peers_CHANNEL_ESTABLISHED_TWICE)) | ||
2761 | { /* Other peer tried to establish a channel to us twice. We do not accept | ||
2762 | * that. Clean the context. */ | ||
2763 | Peers_cleanup_destroyed_channel (cls, channel); | ||
2764 | GNUNET_free (peer); | ||
2765 | return; | ||
2766 | } | ||
2767 | else | ||
2768 | { /* Other peer doesn't want to send us data anymore. We are free to clean | ||
2769 | * it. */ | ||
2770 | Peers_cleanup_destroyed_channel (cls, channel); | ||
2771 | clean_peer (peer); | ||
2772 | GNUNET_free (peer); | ||
2773 | return; | ||
2774 | } | ||
2775 | } | 2760 | } |
2776 | else | 2761 | else if (peer_ctx->send_channel_ctx == channel_ctx) |
2777 | { | 2762 | { |
2778 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2763 | remove_channel_ctx (channel_ctx); |
2779 | "Destroyed channel is neither sending nor receiving channel\n"); | 2764 | remove_peer (&peer_ctx->peer_id); |
2780 | } | 2765 | } |
2781 | GNUNET_free (peer); | ||
2782 | } | 2766 | } |
2783 | 2767 | ||
2784 | /*********************************************************************** | 2768 | /*********************************************************************** |
@@ -3037,8 +3021,6 @@ handle_client_seed (void *cls, | |||
3037 | 3021 | ||
3038 | num_peers = ntohl (msg->num_peers); | 3022 | num_peers = ntohl (msg->num_peers); |
3039 | peers = (struct GNUNET_PeerIdentity *) &msg[1]; | 3023 | peers = (struct GNUNET_PeerIdentity *) &msg[1]; |
3040 | //peers = GNUNET_new_array (num_peers, struct GNUNET_PeerIdentity); | ||
3041 | //GNUNET_memcpy (peers, &msg[1], num_peers * sizeof (struct GNUNET_PeerIdentity)); | ||
3042 | 3024 | ||
3043 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3025 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3044 | "Client seeded peers:\n"); | 3026 | "Client seeded peers:\n"); |
@@ -3053,9 +3035,6 @@ handle_client_seed (void *cls, | |||
3053 | 3035 | ||
3054 | got_peer (&peers[i]); | 3036 | got_peer (&peers[i]); |
3055 | } | 3037 | } |
3056 | |||
3057 | ////GNUNET_free (peers); | ||
3058 | |||
3059 | GNUNET_SERVICE_client_continue (cli_ctx->client); | 3038 | GNUNET_SERVICE_client_continue (cli_ctx->client); |
3060 | } | 3039 | } |
3061 | 3040 | ||
@@ -3173,11 +3152,12 @@ static void | |||
3173 | handle_peer_check (void *cls, | 3152 | handle_peer_check (void *cls, |
3174 | const struct GNUNET_MessageHeader *msg) | 3153 | const struct GNUNET_MessageHeader *msg) |
3175 | { | 3154 | { |
3176 | const struct GNUNET_PeerIdentity *peer = cls; | 3155 | const struct ChannelCtx *channel_ctx = cls; |
3156 | const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; | ||
3177 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3157 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3178 | "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer)); | 3158 | "Received CHECK_LIVE (%s)\n", GNUNET_i2s (peer)); |
3179 | 3159 | ||
3180 | GNUNET_CADET_receive_done (Peers_get_recv_channel (peer)); | 3160 | GNUNET_CADET_receive_done (channel_ctx->channel); |
3181 | } | 3161 | } |
3182 | 3162 | ||
3183 | /** | 3163 | /** |
@@ -3193,7 +3173,8 @@ static void | |||
3193 | handle_peer_push (void *cls, | 3173 | handle_peer_push (void *cls, |
3194 | const struct GNUNET_MessageHeader *msg) | 3174 | const struct GNUNET_MessageHeader *msg) |
3195 | { | 3175 | { |
3196 | const struct GNUNET_PeerIdentity *peer = cls; | 3176 | const struct ChannelCtx *channel_ctx = cls; |
3177 | const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; | ||
3197 | 3178 | ||
3198 | // (check the proof of work (?)) | 3179 | // (check the proof of work (?)) |
3199 | 3180 | ||
@@ -3238,7 +3219,7 @@ handle_peer_push (void *cls, | |||
3238 | CustomPeerMap_put (push_map, peer); | 3219 | CustomPeerMap_put (push_map, peer); |
3239 | 3220 | ||
3240 | GNUNET_break_op (Peers_check_peer_known (peer)); | 3221 | GNUNET_break_op (Peers_check_peer_known (peer)); |
3241 | GNUNET_CADET_receive_done (Peers_get_recv_channel (peer)); | 3222 | GNUNET_CADET_receive_done (channel_ctx->channel); |
3242 | } | 3223 | } |
3243 | 3224 | ||
3244 | 3225 | ||
@@ -3254,7 +3235,8 @@ static void | |||
3254 | handle_peer_pull_request (void *cls, | 3235 | handle_peer_pull_request (void *cls, |
3255 | const struct GNUNET_MessageHeader *msg) | 3236 | const struct GNUNET_MessageHeader *msg) |
3256 | { | 3237 | { |
3257 | struct GNUNET_PeerIdentity *peer = cls; | 3238 | const struct ChannelCtx *channel_ctx = cls; |
3239 | const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; | ||
3258 | const struct GNUNET_PeerIdentity *view_array; | 3240 | const struct GNUNET_PeerIdentity *view_array; |
3259 | 3241 | ||
3260 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s (peer)); | 3242 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Received PULL REQUEST (%s)\n", GNUNET_i2s (peer)); |
@@ -3277,7 +3259,7 @@ handle_peer_pull_request (void *cls, | |||
3277 | #endif /* ENABLE_MALICIOUS */ | 3259 | #endif /* ENABLE_MALICIOUS */ |
3278 | 3260 | ||
3279 | GNUNET_break_op (Peers_check_peer_known (peer)); | 3261 | GNUNET_break_op (Peers_check_peer_known (peer)); |
3280 | GNUNET_CADET_receive_done (Peers_get_recv_channel (peer)); | 3262 | GNUNET_CADET_receive_done (channel_ctx->channel); |
3281 | view_array = View_get_as_array (); | 3263 | view_array = View_get_as_array (); |
3282 | send_pull_reply (peer, view_array, View_size ()); | 3264 | send_pull_reply (peer, view_array, View_size ()); |
3283 | } | 3265 | } |
@@ -3317,7 +3299,8 @@ check_peer_pull_reply (void *cls, | |||
3317 | if (GNUNET_YES != Peers_check_peer_flag (sender, Peers_PULL_REPLY_PENDING)) | 3299 | if (GNUNET_YES != Peers_check_peer_flag (sender, Peers_PULL_REPLY_PENDING)) |
3318 | { | 3300 | { |
3319 | LOG (GNUNET_ERROR_TYPE_WARNING, | 3301 | LOG (GNUNET_ERROR_TYPE_WARNING, |
3320 | "Received a pull reply from a peer we didn't request one from!\n"); | 3302 | "Received a pull reply from a peer (%s) we didn't request one from!\n", |
3303 | GNUNET_i2s (sender)); | ||
3321 | GNUNET_break_op (0); | 3304 | GNUNET_break_op (0); |
3322 | return GNUNET_SYSERR; | 3305 | return GNUNET_SYSERR; |
3323 | } | 3306 | } |
@@ -3334,8 +3317,9 @@ static void | |||
3334 | handle_peer_pull_reply (void *cls, | 3317 | handle_peer_pull_reply (void *cls, |
3335 | const struct GNUNET_RPS_P2P_PullReplyMessage *msg) | 3318 | const struct GNUNET_RPS_P2P_PullReplyMessage *msg) |
3336 | { | 3319 | { |
3320 | const struct ChannelCtx *channel_ctx = cls; | ||
3321 | const struct GNUNET_PeerIdentity *sender = &channel_ctx->peer_ctx->peer_id; | ||
3337 | const struct GNUNET_PeerIdentity *peers; | 3322 | const struct GNUNET_PeerIdentity *peers; |
3338 | struct GNUNET_PeerIdentity *sender = cls; | ||
3339 | uint32_t i; | 3323 | uint32_t i; |
3340 | #ifdef ENABLE_MALICIOUS | 3324 | #ifdef ENABLE_MALICIOUS |
3341 | struct AttackedPeer *tmp_att_peer; | 3325 | struct AttackedPeer *tmp_att_peer; |
@@ -3373,9 +3357,7 @@ handle_peer_pull_reply (void *cls, | |||
3373 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set, | 3357 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (att_peer_set, |
3374 | &peers[i]) | 3358 | &peers[i]) |
3375 | && GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set, | 3359 | && GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (mal_peer_set, |
3376 | &peers[i]) | 3360 | &peers[i])) |
3377 | && 0 != GNUNET_CRYPTO_cmp_peer_identity (&peers[i], | ||
3378 | &own_identity)) | ||
3379 | { | 3361 | { |
3380 | tmp_att_peer = GNUNET_new (struct AttackedPeer); | 3362 | tmp_att_peer = GNUNET_new (struct AttackedPeer); |
3381 | tmp_att_peer->peer_id = peers[i]; | 3363 | tmp_att_peer->peer_id = peers[i]; |
@@ -3387,21 +3369,17 @@ handle_peer_pull_reply (void *cls, | |||
3387 | continue; | 3369 | continue; |
3388 | } | 3370 | } |
3389 | #endif /* ENABLE_MALICIOUS */ | 3371 | #endif /* ENABLE_MALICIOUS */ |
3390 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, | 3372 | /* Make sure we 'know' about this peer */ |
3391 | &peers[i])) | 3373 | (void) Peers_insert_peer (&peers[i]); |
3392 | { | ||
3393 | /* Make sure we 'know' about this peer */ | ||
3394 | (void) Peers_insert_peer (&peers[i]); | ||
3395 | 3374 | ||
3396 | if (GNUNET_YES == Peers_check_peer_valid (&peers[i])) | 3375 | if (GNUNET_YES == Peers_check_peer_valid (&peers[i])) |
3397 | { | 3376 | { |
3398 | CustomPeerMap_put (pull_map, &peers[i]); | 3377 | CustomPeerMap_put (pull_map, &peers[i]); |
3399 | } | 3378 | } |
3400 | else | 3379 | else |
3401 | { | 3380 | { |
3402 | Peers_schedule_operation (&peers[i], insert_in_pull_map); | 3381 | Peers_schedule_operation (&peers[i], insert_in_pull_map); |
3403 | (void) Peers_issue_peer_liveliness_check (&peers[i]); | 3382 | (void) Peers_issue_peer_liveliness_check (&peers[i]); |
3404 | } | ||
3405 | } | 3383 | } |
3406 | } | 3384 | } |
3407 | 3385 | ||
@@ -3409,7 +3387,7 @@ handle_peer_pull_reply (void *cls, | |||
3409 | clean_peer (sender); | 3387 | clean_peer (sender); |
3410 | 3388 | ||
3411 | GNUNET_break_op (Peers_check_peer_known (sender)); | 3389 | GNUNET_break_op (Peers_check_peer_known (sender)); |
3412 | GNUNET_CADET_receive_done (Peers_get_recv_channel (sender)); | 3390 | GNUNET_CADET_receive_done (channel_ctx->channel); |
3413 | } | 3391 | } |
3414 | 3392 | ||
3415 | 3393 | ||
@@ -3836,10 +3814,8 @@ do_round (void *cls) | |||
3836 | for (i = 0; i < a_peers; i++) | 3814 | for (i = 0; i < a_peers; i++) |
3837 | { | 3815 | { |
3838 | peer = view_array[permut[i]]; | 3816 | peer = view_array[permut[i]]; |
3839 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peer)) // TODO | 3817 | // FIXME if this fails schedule/loop this for later |
3840 | { // FIXME if this fails schedule/loop this for later | 3818 | send_push (&peer); |
3841 | send_push (&peer); | ||
3842 | } | ||
3843 | } | 3819 | } |
3844 | 3820 | ||
3845 | /* Send PULL requests */ | 3821 | /* Send PULL requests */ |
@@ -3857,8 +3833,7 @@ do_round (void *cls) | |||
3857 | for (i = first_border; i < second_border; i++) | 3833 | for (i = first_border; i < second_border; i++) |
3858 | { | 3834 | { |
3859 | peer = view_array[permut[i]]; | 3835 | peer = view_array[permut[i]]; |
3860 | if (0 != GNUNET_CRYPTO_cmp_peer_identity (&own_identity, &peer) && | 3836 | if ( GNUNET_NO == Peers_check_peer_flag (&peer, Peers_PULL_REPLY_PENDING)) |
3861 | GNUNET_NO == Peers_check_peer_flag (&peer, Peers_PULL_REPLY_PENDING)) // TODO | ||
3862 | { // FIXME if this fails schedule/loop this for later | 3837 | { // FIXME if this fails schedule/loop this for later |
3863 | send_pull_request (&peer); | 3838 | send_pull_request (&peer); |
3864 | } | 3839 | } |
@@ -3955,7 +3930,6 @@ do_round (void *cls) | |||
3955 | "-%s", | 3930 | "-%s", |
3956 | GNUNET_i2s_full (&peers_to_clean[i])); | 3931 | GNUNET_i2s_full (&peers_to_clean[i])); |
3957 | clean_peer (&peers_to_clean[i]); | 3932 | clean_peer (&peers_to_clean[i]); |
3958 | //peer_destroy_channel_send (sender); | ||
3959 | } | 3933 | } |
3960 | 3934 | ||
3961 | GNUNET_array_grow (peers_to_clean, peers_to_clean_size, 0); | 3935 | GNUNET_array_grow (peers_to_clean, peers_to_clean_size, 0); |
@@ -4011,7 +3985,6 @@ do_round (void *cls) | |||
4011 | GNUNET_i2s (update_peer)); | 3985 | GNUNET_i2s (update_peer)); |
4012 | insert_in_sampler (NULL, update_peer); | 3986 | insert_in_sampler (NULL, update_peer); |
4013 | clean_peer (update_peer); /* This cleans only if it is not in the view */ | 3987 | clean_peer (update_peer); /* This cleans only if it is not in the view */ |
4014 | //peer_destroy_channel_send (sender); | ||
4015 | } | 3988 | } |
4016 | 3989 | ||
4017 | for (i = 0; i < CustomPeerMap_size (pull_map); i++) | 3990 | for (i = 0; i < CustomPeerMap_size (pull_map); i++) |
@@ -4022,7 +3995,6 @@ do_round (void *cls) | |||
4022 | insert_in_sampler (NULL, CustomPeerMap_get_peer_by_index (pull_map, i)); | 3995 | insert_in_sampler (NULL, CustomPeerMap_get_peer_by_index (pull_map, i)); |
4023 | /* This cleans only if it is not in the view */ | 3996 | /* This cleans only if it is not in the view */ |
4024 | clean_peer (CustomPeerMap_get_peer_by_index (pull_map, i)); | 3997 | clean_peer (CustomPeerMap_get_peer_by_index (pull_map, i)); |
4025 | //peer_destroy_channel_send (sender); | ||
4026 | } | 3998 | } |
4027 | 3999 | ||
4028 | 4000 | ||
@@ -4125,6 +4097,8 @@ shutdown_task (void *cls) | |||
4125 | struct ClientContext *client_ctx; | 4097 | struct ClientContext *client_ctx; |
4126 | struct ReplyCls *reply_cls; | 4098 | struct ReplyCls *reply_cls; |
4127 | 4099 | ||
4100 | in_shutdown = GNUNET_YES; | ||
4101 | |||
4128 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 4102 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
4129 | "RPS is going down\n"); | 4103 | "RPS is going down\n"); |
4130 | 4104 | ||
@@ -4369,10 +4343,17 @@ run (void *cls, | |||
4369 | NULL, /* WindowSize handler */ | 4343 | NULL, /* WindowSize handler */ |
4370 | cleanup_destroyed_channel, /* Disconnect handler */ | 4344 | cleanup_destroyed_channel, /* Disconnect handler */ |
4371 | cadet_handlers); | 4345 | cadet_handlers); |
4346 | if (NULL == cadet_port) | ||
4347 | { | ||
4348 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
4349 | "Cadet port `%s' is already in use.\n", | ||
4350 | GNUNET_APPLICATION_PORT_RPS); | ||
4351 | GNUNET_assert (0); | ||
4352 | } | ||
4372 | 4353 | ||
4373 | 4354 | ||
4374 | peerinfo_handle = GNUNET_PEERINFO_connect (cfg); | 4355 | peerinfo_handle = GNUNET_PEERINFO_connect (cfg); |
4375 | Peers_initialise (fn_valid_peers, cadet_handle, &own_identity); | 4356 | Peers_initialise (fn_valid_peers, cadet_handle); |
4376 | GNUNET_free (fn_valid_peers); | 4357 | GNUNET_free (fn_valid_peers); |
4377 | 4358 | ||
4378 | /* Initialise sampler */ | 4359 | /* Initialise sampler */ |
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c index 42507655b..9e003eb39 100644 --- a/src/rps/gnunet-service-rps_custommap.c +++ b/src/rps/gnunet-service-rps_custommap.c | |||
@@ -213,7 +213,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map, | |||
213 | GNUNET_assert (NULL != last_index); | 213 | GNUNET_assert (NULL != last_index); |
214 | GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index); | 214 | GNUNET_assert (CustomPeerMap_size (c_peer_map) == *last_index); |
215 | GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, last_p, | 215 | GNUNET_CONTAINER_multihashmap32_put (c_peer_map->hash_map, *index, last_p, |
216 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 216 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
217 | GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *last_index); | 217 | GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *last_index); |
218 | *last_index = *index; | 218 | *last_index = *index; |
219 | } | 219 | } |
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index d47e4952f..08fe96097 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c | |||
@@ -31,6 +31,17 @@ | |||
31 | 31 | ||
32 | #define LOG(kind, ...) GNUNET_log_from(kind,"rps-test_util",__VA_ARGS__) | 32 | #define LOG(kind, ...) GNUNET_log_from(kind,"rps-test_util",__VA_ARGS__) |
33 | 33 | ||
34 | #define B2B_PAT "%c%c%c%c%c%c%c%c" | ||
35 | #define B2B(byte) \ | ||
36 | (byte & 0x80 ? '1' : '0'), \ | ||
37 | (byte & 0x40 ? '1' : '0'), \ | ||
38 | (byte & 0x20 ? '1' : '0'), \ | ||
39 | (byte & 0x10 ? '1' : '0'), \ | ||
40 | (byte & 0x08 ? '1' : '0'), \ | ||
41 | (byte & 0x04 ? '1' : '0'), \ | ||
42 | (byte & 0x02 ? '1' : '0'), \ | ||
43 | (byte & 0x01 ? '1' : '0') | ||
44 | |||
34 | #ifndef TO_FILE | 45 | #ifndef TO_FILE |
35 | #define TO_FILE | 46 | #define TO_FILE |
36 | #endif /* TO_FILE */ | 47 | #endif /* TO_FILE */ |
@@ -155,6 +166,9 @@ to_file_raw (const char *file_name, const char *buf, size_t size_buf) | |||
155 | 166 | ||
156 | return; | 167 | return; |
157 | } | 168 | } |
169 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
170 | "Wrote %u bytes raw.\n", | ||
171 | size_written); | ||
158 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) | 172 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) |
159 | LOG (GNUNET_ERROR_TYPE_WARNING, | 173 | LOG (GNUNET_ERROR_TYPE_WARNING, |
160 | "Unable to close file\n"); | 174 | "Unable to close file\n"); |
@@ -180,6 +194,8 @@ to_file_raw_unaligned (const char *file_name, | |||
180 | // num_bits_buf_unaligned = bits_needed % 8; | 194 | // num_bits_buf_unaligned = bits_needed % 8; |
181 | // return; | 195 | // return; |
182 | //} | 196 | //} |
197 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
198 | "Was asked to write %u bits\n", bits_needed); | ||
183 | 199 | ||
184 | char buf_write[size_buf + 1]; | 200 | char buf_write[size_buf + 1]; |
185 | const unsigned bytes_iter = (0 != bits_needed % 8? | 201 | const unsigned bytes_iter = (0 != bits_needed % 8? |
@@ -187,6 +203,14 @@ to_file_raw_unaligned (const char *file_name, | |||
187 | bits_needed/8); | 203 | bits_needed/8); |
188 | // TODO what if no iteration happens? | 204 | // TODO what if no iteration happens? |
189 | unsigned size_buf_write = 0; | 205 | unsigned size_buf_write = 0; |
206 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
207 | "num_bits_buf_unaligned: %u\n", | ||
208 | num_bits_buf_unaligned); | ||
209 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
210 | "ua args: size_buf: %u, bits_needed: %u -> iter: %u\n", | ||
211 | size_buf, | ||
212 | bits_needed, | ||
213 | bytes_iter); | ||
190 | buf_write[0] = buf_unaligned; | 214 | buf_write[0] = buf_unaligned; |
191 | /* Iterate over input bytes */ | 215 | /* Iterate over input bytes */ |
192 | for (unsigned i = 0; i < bytes_iter; i++) | 216 | for (unsigned i = 0; i < bytes_iter; i++) |
@@ -227,17 +251,57 @@ to_file_raw_unaligned (const char *file_name, | |||
227 | { | 251 | { |
228 | num_bits_needed_iter = 8; | 252 | num_bits_needed_iter = 8; |
229 | } | 253 | } |
254 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
255 | "number of bits needed in this iteration: %u\n", | ||
256 | num_bits_needed_iter); | ||
230 | mask_bits_needed_iter = ((char) 1 << num_bits_needed_iter) - 1; | 257 | mask_bits_needed_iter = ((char) 1 << num_bits_needed_iter) - 1; |
258 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
259 | "mask needed bits (current iter): "B2B_PAT"\n", | ||
260 | B2B(mask_bits_needed_iter)); | ||
261 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
262 | "Unaligned byte: "B2B_PAT" (%u bits)\n", | ||
263 | B2B(buf_unaligned), | ||
264 | num_bits_buf_unaligned); | ||
231 | byte_input = buf[i]; | 265 | byte_input = buf[i]; |
266 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
267 | "next whole input byte: "B2B_PAT"\n", | ||
268 | B2B(byte_input)); | ||
232 | byte_input &= mask_bits_needed_iter; | 269 | byte_input &= mask_bits_needed_iter; |
233 | num_bits_to_align = 8 - num_bits_buf_unaligned; | 270 | num_bits_to_align = 8 - num_bits_buf_unaligned; |
271 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
272 | "input byte, needed bits: "B2B_PAT"\n", | ||
273 | B2B(byte_input)); | ||
274 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
275 | "number of bits needed to align unaligned bit: %u\n", | ||
276 | num_bits_to_align); | ||
234 | num_bits_to_move = min (num_bits_to_align, num_bits_needed_iter); | 277 | num_bits_to_move = min (num_bits_to_align, num_bits_needed_iter); |
278 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
279 | "number of bits of new byte to move: %u\n", | ||
280 | num_bits_to_move); | ||
235 | mask_input_to_move = ((char) 1 << num_bits_to_move) - 1; | 281 | mask_input_to_move = ((char) 1 << num_bits_to_move) - 1; |
282 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
283 | "mask of bits of new byte to take for moving: "B2B_PAT"\n", | ||
284 | B2B(mask_input_to_move)); | ||
236 | bits_to_move = byte_input & mask_input_to_move; | 285 | bits_to_move = byte_input & mask_input_to_move; |
286 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
287 | "masked bits of new byte to take for moving: "B2B_PAT"\n", | ||
288 | B2B(bits_to_move)); | ||
237 | distance_shift_bits = num_bits_buf_unaligned; | 289 | distance_shift_bits = num_bits_buf_unaligned; |
290 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
291 | "distance needed to shift bits to their correct spot: %u\n", | ||
292 | distance_shift_bits); | ||
238 | bits_moving = bits_to_move << distance_shift_bits; | 293 | bits_moving = bits_to_move << distance_shift_bits; |
294 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
295 | "shifted, masked bits of new byte being moved: "B2B_PAT"\n", | ||
296 | B2B(bits_moving)); | ||
239 | byte_to_fill = buf_unaligned | bits_moving; | 297 | byte_to_fill = buf_unaligned | bits_moving; |
240 | if (num_bits_buf_unaligned + num_bits_needed_iter > 8) | 298 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
299 | "byte being filled: "B2B_PAT"\n", | ||
300 | B2B(byte_to_fill)); | ||
301 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
302 | "pending bytes: %u\n", | ||
303 | num_bits_buf_unaligned + num_bits_needed_iter); | ||
304 | if (num_bits_buf_unaligned + num_bits_needed_iter >= 8) | ||
241 | { | 305 | { |
242 | /* buf_unaligned was aligned by filling | 306 | /* buf_unaligned was aligned by filling |
243 | * -> can be written to storage */ | 307 | * -> can be written to storage */ |
@@ -246,10 +310,22 @@ to_file_raw_unaligned (const char *file_name, | |||
246 | 310 | ||
247 | /* store the leftover, unaligned bits in buffer */ | 311 | /* store the leftover, unaligned bits in buffer */ |
248 | mask_input_leftover = mask_bits_needed_iter & (~ mask_input_to_move); | 312 | mask_input_leftover = mask_bits_needed_iter & (~ mask_input_to_move); |
313 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
314 | "mask of leftover bits of new byte: "B2B_PAT"\n", | ||
315 | B2B(mask_input_leftover)); | ||
249 | byte_input_leftover = byte_input & mask_input_leftover; | 316 | byte_input_leftover = byte_input & mask_input_leftover; |
317 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
318 | "masked, leftover bits of new byte: "B2B_PAT"\n", | ||
319 | B2B(byte_input_leftover)); | ||
250 | num_bits_leftover = num_bits_needed_iter - num_bits_to_move; | 320 | num_bits_leftover = num_bits_needed_iter - num_bits_to_move; |
251 | num_bits_discard = 8 - num_bits_needed_iter; | 321 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
322 | "number of unaligned bits left: %u\n", | ||
323 | num_bits_leftover); | ||
324 | //num_bits_discard = 8 - num_bits_needed_iter; | ||
252 | byte_unaligned_new = byte_input_leftover >> num_bits_to_move; | 325 | byte_unaligned_new = byte_input_leftover >> num_bits_to_move; |
326 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
327 | "new unaligned byte: "B2B_PAT"\n", | ||
328 | B2B(byte_unaligned_new)); | ||
253 | buf_unaligned = byte_unaligned_new; | 329 | buf_unaligned = byte_unaligned_new; |
254 | num_bits_buf_unaligned = num_bits_leftover % 8; | 330 | num_bits_buf_unaligned = num_bits_leftover % 8; |
255 | } | 331 | } |
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c index 0ef3c864a..cd93ff855 100644 --- a/src/transport/test_quota_compliance.c +++ b/src/transport/test_quota_compliance.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -65,6 +65,8 @@ report () | |||
65 | unsigned long long datarate; | 65 | unsigned long long datarate; |
66 | 66 | ||
67 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; | 67 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; |
68 | if (0 == delta) | ||
69 | delta = 1; | ||
68 | datarate = (total_bytes_recv * 1000 * 1000) / delta; | 70 | datarate = (total_bytes_recv * 1000 * 1000) / delta; |
69 | 71 | ||
70 | FPRINTF (stderr, | 72 | FPRINTF (stderr, |
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c index 86e2a7e9d..c6e77bae0 100644 --- a/src/transport/test_transport_api_reliability.c +++ b/src/transport/test_transport_api_reliability.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -174,6 +174,8 @@ custom_shutdown (void *cls) | |||
174 | 174 | ||
175 | /* Calculcate statistics */ | 175 | /* Calculcate statistics */ |
176 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; | 176 | delta = GNUNET_TIME_absolute_get_duration (start_time).rel_value_us; |
177 | if (0 == delta) | ||
178 | delta = 1; | ||
177 | rate = (1000LL* 1000ll * total_bytes) / (1024 * delta); | 179 | rate = (1000LL* 1000ll * total_bytes) / (1024 * delta); |
178 | FPRINTF (stderr, | 180 | FPRINTF (stderr, |
179 | "\nThroughput was %llu KiBytes/s\n", | 181 | "\nThroughput was %llu KiBytes/s\n", |
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index 8410b7835..fe1f58df7 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -365,14 +365,17 @@ GNUNET_CRYPTO_hmac_derive_key_v (struct GNUNET_CRYPTO_AuthKey *key, | |||
365 | 365 | ||
366 | /** | 366 | /** |
367 | * Calculate HMAC of a message (RFC 2104) | 367 | * Calculate HMAC of a message (RFC 2104) |
368 | * TODO: Shouldn' this be the standard hmac function and | ||
369 | * the above be renamed? | ||
368 | * | 370 | * |
369 | * @param key secret key | 371 | * @param key secret key |
372 | * @param key_len secret key length | ||
370 | * @param plaintext input plaintext | 373 | * @param plaintext input plaintext |
371 | * @param plaintext_len length of @a plaintext | 374 | * @param plaintext_len length of @a plaintext |
372 | * @param hmac where to store the hmac | 375 | * @param hmac where to store the hmac |
373 | */ | 376 | */ |
374 | void | 377 | void |
375 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | 378 | GNUNET_CRYPTO_hmac_raw (const void *key, size_t key_len, |
376 | const void *plaintext, size_t plaintext_len, | 379 | const void *plaintext, size_t plaintext_len, |
377 | struct GNUNET_HashCode *hmac) | 380 | struct GNUNET_HashCode *hmac) |
378 | { | 381 | { |
@@ -390,7 +393,7 @@ GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | |||
390 | { | 393 | { |
391 | gcry_md_reset (md); | 394 | gcry_md_reset (md); |
392 | } | 395 | } |
393 | gcry_md_setkey (md, key->key, sizeof (key->key)); | 396 | gcry_md_setkey (md, key, key_len); |
394 | gcry_md_write (md, plaintext, plaintext_len); | 397 | gcry_md_write (md, plaintext, plaintext_len); |
395 | mc = gcry_md_read (md, GCRY_MD_SHA512); | 398 | mc = gcry_md_read (md, GCRY_MD_SHA512); |
396 | GNUNET_assert (NULL != mc); | 399 | GNUNET_assert (NULL != mc); |
@@ -399,6 +402,25 @@ GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | |||
399 | 402 | ||
400 | 403 | ||
401 | /** | 404 | /** |
405 | * Calculate HMAC of a message (RFC 2104) | ||
406 | * | ||
407 | * @param key secret key | ||
408 | * @param plaintext input plaintext | ||
409 | * @param plaintext_len length of @a plaintext | ||
410 | * @param hmac where to store the hmac | ||
411 | */ | ||
412 | void | ||
413 | GNUNET_CRYPTO_hmac (const struct GNUNET_CRYPTO_AuthKey *key, | ||
414 | const void *plaintext, size_t plaintext_len, | ||
415 | struct GNUNET_HashCode *hmac) | ||
416 | { | ||
417 | GNUNET_CRYPTO_hmac_raw ((void*) key->key, sizeof (key->key), | ||
418 | plaintext, plaintext_len, | ||
419 | hmac); | ||
420 | } | ||
421 | |||
422 | |||
423 | /** | ||
402 | * Context for cummulative hashing. | 424 | * Context for cummulative hashing. |
403 | */ | 425 | */ |
404 | struct GNUNET_HashContext | 426 | struct GNUNET_HashContext |
diff --git a/src/util/dnsparser.c b/src/util/dnsparser.c index 6fb6d657f..24f1b18cf 100644 --- a/src/util/dnsparser.c +++ b/src/util/dnsparser.c | |||
@@ -959,7 +959,7 @@ GNUNET_DNSPARSER_builder_add_name (char *dst, | |||
959 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 959 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
960 | "Invalid DNS name `%s': label with %u characters encountered\n", | 960 | "Invalid DNS name `%s': label with %u characters encountered\n", |
961 | name, | 961 | name, |
962 | len); | 962 | (unsigned int) len); |
963 | goto fail; /* label too long or empty */ | 963 | goto fail; /* label too long or empty */ |
964 | } | 964 | } |
965 | dst[pos++] = (char) (uint8_t) len; | 965 | dst[pos++] = (char) (uint8_t) len; |
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 93d133d1b..5d3836639 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -965,8 +965,6 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task) | |||
965 | 965 | ||
966 | /* scheduler must be running */ | 966 | /* scheduler must be running */ |
967 | GNUNET_assert (NULL != scheduler_driver); | 967 | GNUNET_assert (NULL != scheduler_driver); |
968 | GNUNET_assert ( (NULL != active_task) || | ||
969 | (GNUNET_NO == task->lifeness) ); | ||
970 | is_fd_task = (NULL != task->fds); | 968 | is_fd_task = (NULL != task->fds); |
971 | if (is_fd_task) | 969 | if (is_fd_task) |
972 | { | 970 | { |
@@ -1056,9 +1054,9 @@ GNUNET_SCHEDULER_add_with_reason_and_priority (GNUNET_SCHEDULER_TaskCallback tas | |||
1056 | { | 1054 | { |
1057 | struct GNUNET_SCHEDULER_Task *t; | 1055 | struct GNUNET_SCHEDULER_Task *t; |
1058 | 1056 | ||
1057 | /* scheduler must be running */ | ||
1058 | GNUNET_assert (NULL != scheduler_driver); | ||
1059 | GNUNET_assert (NULL != task); | 1059 | GNUNET_assert (NULL != task); |
1060 | GNUNET_assert ((NULL != active_task) || | ||
1061 | (GNUNET_SCHEDULER_REASON_STARTUP == reason)); | ||
1062 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1060 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1063 | t->read_fd = -1; | 1061 | t->read_fd = -1; |
1064 | t->write_fd = -1; | 1062 | t->write_fd = -1; |
@@ -1099,7 +1097,8 @@ GNUNET_SCHEDULER_add_at_with_priority (struct GNUNET_TIME_Absolute at, | |||
1099 | struct GNUNET_SCHEDULER_Task *pos; | 1097 | struct GNUNET_SCHEDULER_Task *pos; |
1100 | struct GNUNET_SCHEDULER_Task *prev; | 1098 | struct GNUNET_SCHEDULER_Task *prev; |
1101 | 1099 | ||
1102 | GNUNET_assert (NULL != active_task); | 1100 | /* scheduler must be running */ |
1101 | GNUNET_assert (NULL != scheduler_driver); | ||
1103 | GNUNET_assert (NULL != task); | 1102 | GNUNET_assert (NULL != task); |
1104 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1103 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1105 | t->callback = task; | 1104 | t->callback = task; |
@@ -1286,7 +1285,8 @@ GNUNET_SCHEDULER_add_shutdown (GNUNET_SCHEDULER_TaskCallback task, | |||
1286 | { | 1285 | { |
1287 | struct GNUNET_SCHEDULER_Task *t; | 1286 | struct GNUNET_SCHEDULER_Task *t; |
1288 | 1287 | ||
1289 | GNUNET_assert (NULL != active_task); | 1288 | /* scheduler must be running */ |
1289 | GNUNET_assert (NULL != scheduler_driver); | ||
1290 | GNUNET_assert (NULL != task); | 1290 | GNUNET_assert (NULL != task); |
1291 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1291 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1292 | t->callback = task; | 1292 | t->callback = task; |
@@ -1403,7 +1403,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay, | |||
1403 | { | 1403 | { |
1404 | struct GNUNET_SCHEDULER_Task *t; | 1404 | struct GNUNET_SCHEDULER_Task *t; |
1405 | 1405 | ||
1406 | GNUNET_assert (NULL != active_task); | 1406 | /* scheduler must be running */ |
1407 | GNUNET_assert (NULL != scheduler_driver); | ||
1407 | GNUNET_assert (NULL != task); | 1408 | GNUNET_assert (NULL != task); |
1408 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); | 1409 | t = GNUNET_new (struct GNUNET_SCHEDULER_Task); |
1409 | init_fd_info (t, | 1410 | init_fd_info (t, |
@@ -1832,7 +1833,6 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, | |||
1832 | 1833 | ||
1833 | /* scheduler must be running */ | 1834 | /* scheduler must be running */ |
1834 | GNUNET_assert (NULL != scheduler_driver); | 1835 | GNUNET_assert (NULL != scheduler_driver); |
1835 | GNUNET_assert (NULL != active_task); | ||
1836 | GNUNET_assert (NULL != task); | 1836 | GNUNET_assert (NULL != task); |
1837 | int no_rs = (NULL == rs); | 1837 | int no_rs = (NULL == rs); |
1838 | int no_ws = (NULL == ws); | 1838 | int no_ws = (NULL == ws); |
@@ -2022,99 +2022,109 @@ GNUNET_SCHEDULER_do_work (struct GNUNET_SCHEDULER_Handle *sh) | |||
2022 | if (timeout.abs_value_us > now.abs_value_us) | 2022 | if (timeout.abs_value_us > now.abs_value_us) |
2023 | { | 2023 | { |
2024 | /** | 2024 | /** |
2025 | * The driver called this function before the current timeout was | 2025 | * The event loop called this function before the current timeout was |
2026 | * reached (and no FD tasks are ready). This can happen in the | 2026 | * reached (and no FD tasks are ready). This is acceptable if |
2027 | * rare case when the system time is changed while the driver is | 2027 | * |
2028 | * waiting for the timeout, so we handle this gracefully. It might | 2028 | * - the system time was changed while the driver was waiting for |
2029 | * also be a programming error in the driver though. | 2029 | * the timeout |
2030 | * - an external event loop called GNUnet API functions outside of | ||
2031 | * the callbacks called in GNUNET_SCHEDULER_do_work and thus | ||
2032 | * wasn't notified about the new timeout | ||
2033 | * | ||
2034 | * It might also mean we are busy-waiting because of a programming | ||
2035 | * error in the external event loop. | ||
2030 | */ | 2036 | */ |
2031 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2037 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2032 | "GNUNET_SCHEDULER_do_work did not find any ready " | 2038 | "GNUNET_SCHEDULER_do_work did not find any ready " |
2033 | "tasks and timeout has not been reached yet.\n"); | 2039 | "tasks and timeout has not been reached yet.\n"); |
2034 | return GNUNET_NO; | ||
2035 | } | 2040 | } |
2036 | /** | 2041 | else |
2037 | * the current timeout was reached but no ready tasks were found, | 2042 | { |
2038 | * internal scheduler error! | 2043 | /** |
2039 | */ | 2044 | * the current timeout was reached but no ready tasks were found, |
2040 | GNUNET_assert (0); | 2045 | * internal scheduler error! |
2041 | } | 2046 | */ |
2042 | 2047 | GNUNET_assert (0); | |
2043 | /* find out which task priority level we are going to | 2048 | } |
2044 | process this time */ | ||
2045 | max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; | ||
2046 | GNUNET_assert (NULL == ready_head[GNUNET_SCHEDULER_PRIORITY_KEEP]); | ||
2047 | /* yes, p>0 is correct, 0 is "KEEP" which should | ||
2048 | * always be an empty queue (see assertion)! */ | ||
2049 | for (p = GNUNET_SCHEDULER_PRIORITY_COUNT - 1; p > 0; p--) | ||
2050 | { | ||
2051 | pos = ready_head[p]; | ||
2052 | if (NULL != pos) | ||
2053 | break; | ||
2054 | } | 2049 | } |
2055 | GNUNET_assert (NULL != pos); /* ready_count wrong? */ | 2050 | else |
2056 | |||
2057 | /* process all tasks at this priority level, then yield */ | ||
2058 | while (NULL != (pos = ready_head[p])) | ||
2059 | { | 2051 | { |
2060 | GNUNET_CONTAINER_DLL_remove (ready_head[p], | 2052 | /* find out which task priority level we are going to |
2061 | ready_tail[p], | 2053 | process this time */ |
2062 | pos); | 2054 | max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; |
2063 | ready_count--; | 2055 | GNUNET_assert (NULL == ready_head[GNUNET_SCHEDULER_PRIORITY_KEEP]); |
2064 | current_priority = pos->priority; | 2056 | /* yes, p>0 is correct, 0 is "KEEP" which should |
2065 | current_lifeness = pos->lifeness; | 2057 | * always be an empty queue (see assertion)! */ |
2066 | active_task = pos; | 2058 | for (p = GNUNET_SCHEDULER_PRIORITY_COUNT - 1; p > 0; p--) |
2067 | #if PROFILE_DELAYS | ||
2068 | if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value_us > | ||
2069 | DELAY_THRESHOLD.rel_value_us) | ||
2070 | { | 2059 | { |
2071 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2060 | pos = ready_head[p]; |
2072 | "Task %p took %s to be scheduled\n", | 2061 | if (NULL != pos) |
2073 | pos, | 2062 | break; |
2074 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (pos->start_time), | ||
2075 | GNUNET_YES)); | ||
2076 | } | 2063 | } |
2077 | #endif | 2064 | GNUNET_assert (NULL != pos); /* ready_count wrong? */ |
2078 | tc.reason = pos->reason; | 2065 | |
2079 | GNUNET_NETWORK_fdset_zero (sh->rs); | 2066 | /* process all tasks at this priority level, then yield */ |
2080 | GNUNET_NETWORK_fdset_zero (sh->ws); | 2067 | while (NULL != (pos = ready_head[p])) |
2081 | // FIXME: do we have to remove FdInfos from fds if they are not ready? | ||
2082 | tc.fds_len = pos->fds_len; | ||
2083 | tc.fds = pos->fds; | ||
2084 | for (unsigned int i = 0; i != pos->fds_len; ++i) | ||
2085 | { | 2068 | { |
2086 | struct GNUNET_SCHEDULER_FdInfo *fdi = &pos->fds[i]; | 2069 | GNUNET_CONTAINER_DLL_remove (ready_head[p], |
2087 | if (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et)) | 2070 | ready_tail[p], |
2071 | pos); | ||
2072 | ready_count--; | ||
2073 | current_priority = pos->priority; | ||
2074 | current_lifeness = pos->lifeness; | ||
2075 | active_task = pos; | ||
2076 | #if PROFILE_DELAYS | ||
2077 | if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value_us > | ||
2078 | DELAY_THRESHOLD.rel_value_us) | ||
2088 | { | 2079 | { |
2089 | GNUNET_NETWORK_fdset_set_native (sh->rs, | 2080 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2090 | fdi->sock); | 2081 | "Task %p took %s to be scheduled\n", |
2082 | pos, | ||
2083 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (pos->start_time), | ||
2084 | GNUNET_YES)); | ||
2091 | } | 2085 | } |
2092 | if (0 != (GNUNET_SCHEDULER_ET_OUT & fdi->et)) | 2086 | #endif |
2087 | tc.reason = pos->reason; | ||
2088 | GNUNET_NETWORK_fdset_zero (sh->rs); | ||
2089 | GNUNET_NETWORK_fdset_zero (sh->ws); | ||
2090 | // FIXME: do we have to remove FdInfos from fds if they are not ready? | ||
2091 | tc.fds_len = pos->fds_len; | ||
2092 | tc.fds = pos->fds; | ||
2093 | for (unsigned int i = 0; i != pos->fds_len; ++i) | ||
2093 | { | 2094 | { |
2094 | GNUNET_NETWORK_fdset_set_native (sh->ws, | 2095 | struct GNUNET_SCHEDULER_FdInfo *fdi = &pos->fds[i]; |
2095 | fdi->sock); | 2096 | if (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et)) |
2097 | { | ||
2098 | GNUNET_NETWORK_fdset_set_native (sh->rs, | ||
2099 | fdi->sock); | ||
2100 | } | ||
2101 | if (0 != (GNUNET_SCHEDULER_ET_OUT & fdi->et)) | ||
2102 | { | ||
2103 | GNUNET_NETWORK_fdset_set_native (sh->ws, | ||
2104 | fdi->sock); | ||
2105 | } | ||
2096 | } | 2106 | } |
2097 | } | 2107 | tc.read_ready = sh->rs; |
2098 | tc.read_ready = sh->rs; | 2108 | tc.write_ready = sh->ws; |
2099 | tc.write_ready = sh->ws; | 2109 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2100 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2110 | "Running task %p\n", |
2101 | "Running task %p\n", | 2111 | pos); |
2102 | pos); | 2112 | GNUNET_assert (NULL != pos->callback); |
2103 | GNUNET_assert (NULL != pos->callback); | 2113 | pos->callback (pos->callback_cls); |
2104 | pos->callback (pos->callback_cls); | 2114 | if (NULL != pos->fds) |
2105 | if (NULL != pos->fds) | ||
2106 | { | ||
2107 | int del_result = scheduler_driver->del (scheduler_driver->cls, pos); | ||
2108 | if (GNUNET_OK != del_result) | ||
2109 | { | 2115 | { |
2110 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2116 | int del_result = scheduler_driver->del (scheduler_driver->cls, pos); |
2111 | "driver could not delete task %p\n", pos); | 2117 | if (GNUNET_OK != del_result) |
2112 | GNUNET_assert (0); | 2118 | { |
2119 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2120 | "driver could not delete task %p\n", pos); | ||
2121 | GNUNET_assert (0); | ||
2122 | } | ||
2113 | } | 2123 | } |
2124 | active_task = NULL; | ||
2125 | dump_backtrace (pos); | ||
2126 | destroy_task (pos); | ||
2114 | } | 2127 | } |
2115 | active_task = NULL; | ||
2116 | dump_backtrace (pos); | ||
2117 | destroy_task (pos); | ||
2118 | } | 2128 | } |
2119 | shutdown_if_no_lifeness (); | 2129 | shutdown_if_no_lifeness (); |
2120 | if (0 == ready_count) | 2130 | if (0 == ready_count) |
@@ -2164,12 +2174,12 @@ struct GNUNET_SCHEDULER_Handle * | |||
2164 | GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver) | 2174 | GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver) |
2165 | { | 2175 | { |
2166 | struct GNUNET_SCHEDULER_Handle *sh; | 2176 | struct GNUNET_SCHEDULER_Handle *sh; |
2167 | struct GNUNET_SCHEDULER_Task tsk; | ||
2168 | const struct GNUNET_DISK_FileHandle *pr; | 2177 | const struct GNUNET_DISK_FileHandle *pr; |
2169 | 2178 | ||
2170 | /* general set-up */ | 2179 | /* scheduler must not be running */ |
2171 | GNUNET_assert (NULL == active_task); | 2180 | GNUNET_assert (NULL == scheduler_driver); |
2172 | GNUNET_assert (NULL == shutdown_pipe_handle); | 2181 | GNUNET_assert (NULL == shutdown_pipe_handle); |
2182 | /* general set-up */ | ||
2173 | sh = GNUNET_new (struct GNUNET_SCHEDULER_Handle); | 2183 | sh = GNUNET_new (struct GNUNET_SCHEDULER_Handle); |
2174 | shutdown_pipe_handle = GNUNET_DISK_pipe (GNUNET_NO, | 2184 | shutdown_pipe_handle = GNUNET_DISK_pipe (GNUNET_NO, |
2175 | GNUNET_NO, | 2185 | GNUNET_NO, |
@@ -2204,10 +2214,6 @@ GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver) | |||
2204 | /* Setup initial tasks */ | 2214 | /* Setup initial tasks */ |
2205 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; | 2215 | current_priority = GNUNET_SCHEDULER_PRIORITY_DEFAULT; |
2206 | current_lifeness = GNUNET_NO; | 2216 | current_lifeness = GNUNET_NO; |
2207 | memset (&tsk, | ||
2208 | 0, | ||
2209 | sizeof (tsk)); | ||
2210 | active_task = &tsk; | ||
2211 | install_parent_control_task = | 2217 | install_parent_control_task = |
2212 | GNUNET_SCHEDULER_add_now (&install_parent_control_handler, | 2218 | GNUNET_SCHEDULER_add_now (&install_parent_control_handler, |
2213 | NULL); | 2219 | NULL); |
@@ -2217,7 +2223,6 @@ GNUNET_SCHEDULER_driver_init (const struct GNUNET_SCHEDULER_Driver *driver) | |||
2217 | &shutdown_pipe_cb, | 2223 | &shutdown_pipe_cb, |
2218 | NULL); | 2224 | NULL); |
2219 | current_lifeness = GNUNET_YES; | 2225 | current_lifeness = GNUNET_YES; |
2220 | active_task = NULL; | ||
2221 | scheduler_driver->set_wakeup (scheduler_driver->cls, | 2226 | scheduler_driver->set_wakeup (scheduler_driver->cls, |
2222 | get_timeout ()); | 2227 | get_timeout ()); |
2223 | /* begin main event loop */ | 2228 | /* begin main event loop */ |