diff options
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-namestore.c | 33 | ||||
-rw-r--r-- | src/namestore/namestore_api.c | 37 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_lookup_nick.c | 22 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_nick.c | 40 |
4 files changed, 67 insertions, 65 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 3514f4fd9..94fcb8952 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -1038,6 +1038,24 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1038 | GNUNET_free (rd); | 1038 | GNUNET_free (rd); |
1039 | return; | 1039 | return; |
1040 | } | 1040 | } |
1041 | if (NULL != nickstring) | ||
1042 | { | ||
1043 | if (0 == strlen (nickstring)) | ||
1044 | { | ||
1045 | fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring); | ||
1046 | GNUNET_SCHEDULER_shutdown (); | ||
1047 | ret = 1; | ||
1048 | return; | ||
1049 | } | ||
1050 | add = 1; | ||
1051 | typestring = GNUNET_strdup (GNUNET_GNSRECORD_number_to_typename (GNUNET_GNSRECORD_TYPE_NICK)); | ||
1052 | name = GNUNET_strdup (GNUNET_GNS_EMPTY_LABEL_AT); | ||
1053 | value = GNUNET_strdup (nickstring); | ||
1054 | is_public = 0; | ||
1055 | expirationstring = GNUNET_strdup ("never"); | ||
1056 | GNUNET_free (nickstring); | ||
1057 | nickstring = NULL; | ||
1058 | } | ||
1041 | 1059 | ||
1042 | if (add) | 1060 | if (add) |
1043 | { | 1061 | { |
@@ -1227,21 +1245,6 @@ run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1227 | &add_continuation, | 1245 | &add_continuation, |
1228 | &add_qe_uri); | 1246 | &add_qe_uri); |
1229 | } | 1247 | } |
1230 | if (NULL != nickstring) | ||
1231 | { | ||
1232 | if (0 == strlen (nickstring)) | ||
1233 | { | ||
1234 | fprintf (stderr, _ ("Invalid nick `%s'\n"), nickstring); | ||
1235 | GNUNET_SCHEDULER_shutdown (); | ||
1236 | ret = 1; | ||
1237 | return; | ||
1238 | } | ||
1239 | add_qe_uri = GNUNET_NAMESTORE_set_nick (ns, | ||
1240 | &zone_pkey, | ||
1241 | nickstring, | ||
1242 | &add_continuation, | ||
1243 | &add_qe_uri); | ||
1244 | } | ||
1245 | if (monitor) | 1248 | if (monitor) |
1246 | { | 1249 | { |
1247 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, | 1250 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, |
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 156c115d2..2a085cf04 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -1064,43 +1064,6 @@ GNUNET_NAMESTORE_records_store ( | |||
1064 | 1064 | ||
1065 | 1065 | ||
1066 | /** | 1066 | /** |
1067 | * Set the desired nick name for a zone | ||
1068 | * | ||
1069 | * @param h handle to the namestore | ||
1070 | * @param pkey private key of the zone | ||
1071 | * @param nick the nick name to set | ||
1072 | * @param cont continuation to call when done | ||
1073 | * @param cont_cls closure for @a cont | ||
1074 | * @return handle to abort the request | ||
1075 | */ | ||
1076 | struct GNUNET_NAMESTORE_QueueEntry * | ||
1077 | GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h, | ||
1078 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | ||
1079 | const char *nick, | ||
1080 | GNUNET_NAMESTORE_ContinuationWithStatus cont, | ||
1081 | void *cont_cls) | ||
1082 | { | ||
1083 | struct GNUNET_GNSRECORD_Data rd; | ||
1084 | |||
1085 | if (NULL == h->mq) | ||
1086 | return NULL; | ||
1087 | memset (&rd, 0, sizeof(rd)); | ||
1088 | rd.data = nick; | ||
1089 | rd.data_size = strlen (nick) + 1; | ||
1090 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; | ||
1091 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | ||
1092 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | ||
1093 | return GNUNET_NAMESTORE_records_store (h, | ||
1094 | pkey, | ||
1095 | GNUNET_GNS_EMPTY_LABEL_AT, | ||
1096 | 1, | ||
1097 | &rd, | ||
1098 | cont, | ||
1099 | cont_cls); | ||
1100 | } | ||
1101 | |||
1102 | |||
1103 | /** | ||
1104 | * Lookup an item in the namestore. | 1067 | * Lookup an item in the namestore. |
1105 | * | 1068 | * |
1106 | * @param h handle to the namestore | 1069 | * @param h handle to the namestore |
diff --git a/src/namestore/test_namestore_api_lookup_nick.c b/src/namestore/test_namestore_api_lookup_nick.c index 145a3e885..628e76254 100644 --- a/src/namestore/test_namestore_api_lookup_nick.c +++ b/src/namestore/test_namestore_api_lookup_nick.c | |||
@@ -23,6 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_namestore_service.h" | 25 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_gns_service.h" | ||
26 | #include "gnunet_testing_lib.h" | 27 | #include "gnunet_testing_lib.h" |
27 | #include "gnunet_dnsparser_lib.h" | 28 | #include "gnunet_dnsparser_lib.h" |
28 | 29 | ||
@@ -280,6 +281,8 @@ run (void *cls, | |||
280 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 281 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
281 | struct GNUNET_TESTING_Peer *peer) | 282 | struct GNUNET_TESTING_Peer *peer) |
282 | { | 283 | { |
284 | struct GNUNET_GNSRECORD_Data rd; | ||
285 | |||
283 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 286 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
284 | &endbadly, | 287 | &endbadly, |
285 | NULL); | 288 | NULL); |
@@ -290,11 +293,20 @@ run (void *cls, | |||
290 | nsh = GNUNET_NAMESTORE_connect (cfg); | 293 | nsh = GNUNET_NAMESTORE_connect (cfg); |
291 | GNUNET_break (NULL != nsh); | 294 | GNUNET_break (NULL != nsh); |
292 | 295 | ||
293 | nsqe = GNUNET_NAMESTORE_set_nick (nsh, | 296 | memset (&rd, 0, sizeof(rd)); |
294 | &privkey, | 297 | rd.data = TEST_NICK; |
295 | TEST_NICK, | 298 | rd.data_size = strlen (TEST_NICK) + 1; |
296 | &nick_cont, | 299 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; |
297 | (void *) name); | 300 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; |
301 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | ||
302 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | ||
303 | &privkey, | ||
304 | GNUNET_GNS_EMPTY_LABEL_AT, | ||
305 | 1, | ||
306 | &rd, | ||
307 | &nick_cont, | ||
308 | (void *) name); | ||
309 | |||
298 | if (NULL == nsqe) | 310 | if (NULL == nsqe) |
299 | { | 311 | { |
300 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 312 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c index b0c4c8211..1ebdfd073 100644 --- a/src/namestore/test_namestore_api_zone_iteration_nick.c +++ b/src/namestore/test_namestore_api_zone_iteration_nick.c | |||
@@ -23,6 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_namestore_service.h" | 25 | #include "gnunet_namestore_service.h" |
26 | #include "gnunet_gns_service.h" | ||
26 | #include "gnunet_testing_lib.h" | 27 | #include "gnunet_testing_lib.h" |
27 | #include "namestore.h" | 28 | #include "namestore.h" |
28 | #include "gnunet_dnsparser_lib.h" | 29 | #include "gnunet_dnsparser_lib.h" |
@@ -313,10 +314,22 @@ nick_1_cont (void *cls, int32_t success, const char *emsg) | |||
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
314 | "Nick 1 added : %s\n", | 315 | "Nick 1 added : %s\n", |
315 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); | 316 | (success == GNUNET_OK) ? "SUCCESS" : "FAIL"); |
317 | struct GNUNET_GNSRECORD_Data rd; | ||
318 | |||
319 | memset (&rd, 0, sizeof(rd)); | ||
320 | rd.data = ZONE_NICK_2; | ||
321 | rd.data_size = strlen (ZONE_NICK_2) + 1; | ||
322 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; | ||
323 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | ||
324 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | ||
325 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | ||
326 | &privkey2, | ||
327 | GNUNET_GNS_EMPTY_LABEL_AT, | ||
328 | 1, | ||
329 | &rd, | ||
330 | &nick_2_cont, | ||
331 | &privkey2); | ||
316 | 332 | ||
317 | nsqe = GNUNET_NAMESTORE_set_nick (nsh, | ||
318 | &privkey2, ZONE_NICK_2, &nick_2_cont, | ||
319 | &privkey2); | ||
320 | if (NULL == nsqe) | 333 | if (NULL == nsqe) |
321 | { | 334 | { |
322 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 335 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -363,14 +376,25 @@ static void | |||
363 | empty_zone_end (void *cls) | 376 | empty_zone_end (void *cls) |
364 | { | 377 | { |
365 | GNUNET_assert (nsh == cls); | 378 | GNUNET_assert (nsh == cls); |
379 | struct GNUNET_GNSRECORD_Data rd; | ||
380 | |||
366 | zi = NULL; | 381 | zi = NULL; |
367 | GNUNET_CRYPTO_ecdsa_key_create (&privkey); | 382 | GNUNET_CRYPTO_ecdsa_key_create (&privkey); |
368 | GNUNET_CRYPTO_ecdsa_key_create (&privkey2); | 383 | GNUNET_CRYPTO_ecdsa_key_create (&privkey2); |
369 | nsqe = GNUNET_NAMESTORE_set_nick (nsh, | 384 | |
370 | &privkey, | 385 | memset (&rd, 0, sizeof(rd)); |
371 | ZONE_NICK_1, | 386 | rd.data = ZONE_NICK_1; |
372 | &nick_1_cont, | 387 | rd.data_size = strlen (ZONE_NICK_1) + 1; |
373 | NULL); | 388 | rd.record_type = GNUNET_GNSRECORD_TYPE_NICK; |
389 | rd.expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us; | ||
390 | rd.flags |= GNUNET_GNSRECORD_RF_PRIVATE; | ||
391 | nsqe = GNUNET_NAMESTORE_records_store (nsh, | ||
392 | &privkey, | ||
393 | GNUNET_GNS_EMPTY_LABEL_AT, | ||
394 | 1, | ||
395 | &rd, | ||
396 | &nick_1_cont, | ||
397 | NULL); | ||
374 | if (NULL == nsqe) | 398 | if (NULL == nsqe) |
375 | { | 399 | { |
376 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 400 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |