aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-18 10:08:37 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-18 10:08:37 +0000
commit6e55466b0a21f7089a84c119c6c09dce0a38fd60 (patch)
tree4a7010026d1befa5f331112974eab0ebbaa64bdd /src
parentad24ace39ab1da4d3799e1dc73c9d0ccf77616d2 (diff)
downloadgnunet-6e55466b0a21f7089a84c119c6c09dce0a38fd60.tar.gz
gnunet-6e55466b0a21f7089a84c119c6c09dce0a38fd60.zip
-hope springs eternal
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c73
1 files changed, 32 insertions, 41 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index c32aca84f..1a22e624d 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -176,34 +176,36 @@ is_srv (char* name)
176} 176}
177 177
178/** 178/**
179 * Determine if this name is canonical. 179 * Determine if this name is canonical (is a legal name in a zone, without delegation);
180 * i.e. 180 * note that we do not test that the name does not contain illegal characters, we only
181 * test for delegation. Note that service records (i.e. _foo._srv) are canonical names
182 * even though they consist of multiple labels.
183 *
184 * Examples:
181 * a.b.gads = not canonical 185 * a.b.gads = not canonical
182 * a = canonical 186 * a = canonical
187 * _foo._srv = canonical
188 * _f.bar = not canonical
183 * 189 *
184 * @param name the name to test 190 * @param name the name to test
185 * @return GNUNET_YES if canonical 191 * @return GNUNET_YES if canonical
186 */ 192 */
187static int 193static int
188is_canonical (char* name) 194is_canonical (const char* name)
189{ 195{
190 char* ndup; 196 const char *pos;
191 char* tok; 197 const char *dot;
192
193 ndup = GNUNET_strdup (name);
194 strtok (ndup, ".");
195 198
196 for (tok = strtok (NULL, "."); tok != NULL; tok = strtok (NULL, ".")) 199 if (NULL == strchr (name, '.'))
197 { 200 return GNUNET_YES;
198 /* 201 if ('_' != name[0])
199 * probably srv
200 */
201 if (*tok == '_')
202 continue;
203 GNUNET_free (ndup);
204 return GNUNET_NO; 202 return GNUNET_NO;
205 } 203 pos = &name[1];
206 GNUNET_free (ndup); 204 while (NULL != (dot = strchr (pos, '.')))
205 if ('_' != dot[1])
206 return GNUNET_NO;
207 else
208 pos = dot + 1;
207 return GNUNET_YES; 209 return GNUNET_YES;
208} 210}
209 211
@@ -228,7 +230,7 @@ static void
228create_pkey_cont (void* cls, int32_t success, const char* emsg) 230create_pkey_cont (void* cls, int32_t success, const char* emsg)
229{ 231{
230 //FIXME do sth with error 232 //FIXME do sth with error
231 struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; 233 struct GetPseuAuthorityHandle* gph = cls;
232 234
233 gph->namestore_task = NULL; 235 gph->namestore_task = NULL;
234 GNUNET_free (gph->auth); 236 GNUNET_free (gph->auth);
@@ -258,7 +260,7 @@ process_pseu_lookup_ns (void* cls,
258 const struct GNUNET_NAMESTORE_RecordData *rd, 260 const struct GNUNET_NAMESTORE_RecordData *rd,
259 const struct GNUNET_CRYPTO_RsaSignature *signature) 261 const struct GNUNET_CRYPTO_RsaSignature *signature)
260{ 262{
261 struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; 263 struct GetPseuAuthorityHandle* gph = cls;
262 struct GNUNET_NAMESTORE_RecordData new_pkey; 264 struct GNUNET_NAMESTORE_RecordData new_pkey;
263 265
264 gph->namestore_task = NULL; 266 gph->namestore_task = NULL;
@@ -375,7 +377,7 @@ process_auth_discovery_dht_result (void* cls,
375{ 377{
376 struct GetPseuAuthorityHandle* gph = cls; 378 struct GetPseuAuthorityHandle* gph = cls;
377 struct GNSNameRecordBlock *nrb; 379 struct GNSNameRecordBlock *nrb;
378 char* rd_data = (char*)data; 380 const char* rd_data = data;
379 char* name; 381 char* name;
380 int num_records; 382 int num_records;
381 size_t rd_size; 383 size_t rd_size;
@@ -389,7 +391,7 @@ process_auth_discovery_dht_result (void* cls,
389 gph->get_handle = NULL; 391 gph->get_handle = NULL;
390 GNUNET_SCHEDULER_cancel (gph->timeout); 392 GNUNET_SCHEDULER_cancel (gph->timeout);
391 393
392 if (data == NULL) 394 if (NULL == data)
393 { 395 {
394 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 396 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
395 "GNS_GET_AUTH: got dht result null!\n", size); 397 "GNS_GET_AUTH: got dht result null!\n", size);
@@ -583,18 +585,17 @@ shorten_authority_chain (struct GetPseuAuthorityHandle *gph)
583 585
584} 586}
585 587
588
586static void 589static void
587start_shorten (struct AuthorityChain *auth, 590start_shorten (struct AuthorityChain *auth,
588 struct GNUNET_CRYPTO_RsaPrivateKey *key) 591 const struct GNUNET_CRYPTO_RsaPrivateKey *key)
589{ 592{
590 struct GetPseuAuthorityHandle *gph; 593 struct GetPseuAuthorityHandle *gph;
591 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey; 594 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
592 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pb_key; 595 struct GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded *pb_key;
593 596
594 GNUNET_CRYPTO_rsa_key_get_public (key, &pkey); 597 GNUNET_CRYPTO_rsa_key_get_public (key, &pkey);
595 pb_key = GNUNET_CRYPTO_rsa_encode_key (key); 598 if (NULL == (pb_key = GNUNET_CRYPTO_rsa_encode_key (key)))
596
597 if (NULL == pb_key)
598 { 599 {
599 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 600 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
600 "Failed to encode RSA key on shorten\n"); 601 "Failed to encode RSA key on shorten\n");
@@ -602,7 +603,7 @@ start_shorten (struct AuthorityChain *auth,
602 } 603 }
603 604
604 gph = GNUNET_malloc (sizeof (struct GetPseuAuthorityHandle)); 605 gph = GNUNET_malloc (sizeof (struct GetPseuAuthorityHandle));
605 gph->key = GNUNET_CRYPTO_rsa_decode_key ((char*)pb_key, ntohs (pb_key->len)); 606 gph->key = GNUNET_CRYPTO_rsa_decode_key ((const char*) pb_key, ntohs (pb_key->len));
606 607
607 if (NULL == gph->key) 608 if (NULL == gph->key)
608 { 609 {
@@ -640,9 +641,8 @@ gns_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
640 unsigned long long max_bg_queries, 641 unsigned long long max_bg_queries,
641 int ignore_pending) 642 int ignore_pending)
642{ 643{
643 if (NULL == nh) 644 if ( (NULL == nh) ||
644 return GNUNET_SYSERR; 645 (NULL == dh) )
645 if (NULL == dh)
646 return GNUNET_SYSERR; 646 return GNUNET_SYSERR;
647 647
648 cfg = c; 648 cfg = c;
@@ -655,16 +655,7 @@ gns_resolver_init (struct GNUNET_NAMESTORE_Handle *nh,
655 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 655 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
656 max_allowed_background_queries = max_bg_queries; 656 max_allowed_background_queries = max_bg_queries;
657 max_allowed_ns_tasks = GNUNET_GNS_MAX_NS_TASKS; 657 max_allowed_ns_tasks = GNUNET_GNS_MAX_NS_TASKS;
658 ignore_pending_records = ignore_pending; 658 ignore_pending_records = ignore_pending;
659 gph_head = NULL;
660 gph_tail = NULL;
661 rlh_head = NULL;
662 rlh_tail = NULL;
663 nsh_head = NULL;
664 nsh_tail = NULL;
665 nah_head = NULL;
666 nah_tail = NULL;
667
668 GNUNET_RESOLVER_connect (cfg); 659 GNUNET_RESOLVER_connect (cfg);
669 return GNUNET_OK; 660 return GNUNET_OK;
670} 661}