-fix xquery
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 28 Feb 2012 09:27:53 +0000 (09:27 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Tue, 28 Feb 2012 09:27:53 +0000 (09:27 +0000)
src/gns/gnunet-service-gns.c
src/gns/plugin_block_gns.c

index e236716ea0d698c49ffa6ce76a5d8ff65079ef22..b5649f35c64387c6d40f467b05ac8924f409e0c7 100644 (file)
@@ -323,8 +323,8 @@ resolve_authority_dht(struct GNUNET_GNS_ResolverHandle *rh)
                        &lookup_key,
                        5, //Replication level FIXME
                        GNUNET_DHT_RO_NONE,
-                       &xquery, //xquery FIXME is this bad?
-                       0, // for test bp sizeof(GNUNET_GNS_RECORD_PKEY),
+                       &xquery,
+                       sizeof(xquery),
                        &process_authority_dht_result,
                        rh);
 
@@ -470,7 +470,7 @@ resolve_name_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name)
                        5, //Replication level FIXME
                        GNUNET_DHT_RO_NONE,
                        &xquery, //xquery FIXME is this bad?
-                       0, //for test bp sizeof(rh->query->type),
+                       sizeof(xquery),
                        &process_name_dht_result,
                        rh);
 
index 8a2cb07277849b10b83f32fe99c3a6ed3414b45d..a4d6ad9c8bfd66f19ae5c779f94173f4db3a66e0 100644 (file)
@@ -86,27 +86,17 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
   GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
 
   GNUNET_CRYPTO_hash_xor(&pkey_hash, &name_hash, &query_key);
-  struct GNUNET_CRYPTO_HashAsciiEncoded hstr;
-  GNUNET_CRYPTO_hash_to_enc (query, &hstr);
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Query key: %s\n", (char*)&hstr);
-  GNUNET_CRYPTO_hash_to_enc (&pkey_hash, &hstr);
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Pub key: %s\n", (char*)&hstr);
-  GNUNET_CRYPTO_hash_to_enc (&name_hash, &hstr);
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Name: %s\n", (char*)&hstr);
-  GNUNET_CRYPTO_hash_to_enc (&query_key, &hstr);
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "XOR: %s\n", (char*)&hstr);
   
-  
-  //Check query key against public key
+  /* Check query key against public key */
   if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key))
     return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
   
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Checking payload\n");
   rd_count = ntohl(nrb->rd_count);
 
   struct GNUNET_NAMESTORE_RecordData rd[rd_count];
   int i = 0;
   int record_match = 0;
+  uint32_t record_xquery = ntohl(*((uint32_t*)xquery));
   rb = (struct GNSRecordBlock*)(&name[strlen(name) + 1]);
 
   for (i=0; i<rd_count; i++)
@@ -118,10 +108,15 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
     rd[i].flags = ntohl(rb->flags);
     rd[i].data = (char*)&rb[1];
     rb = (struct GNSRecordBlock *)((char*)&rb[1] + rd[i].data_size);
-    if (xquery_size > 0 && (rd[i].record_type == *((uint32_t*)xquery)))
+    
+    if (xquery_size == 0)
+     continue;
+    
+    if (rd[i].record_type == record_xquery)
+    {
       record_match++;
+    }
   }
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "done\n");
   
 
   /*if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key,
@@ -133,10 +128,11 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
     GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Signature invalid\n");
     return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
   }*/
-  GNUNET_log(GNUNET_ERROR_TYPE_INFO, "done\n");
+  
   //No record matches query
   if ((xquery_size > 0) && (record_match == 0))
-    return GNUNET_BLOCK_EVALUATION_OK_MORE;
+    return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
+
   GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Records match\n");
   //FIXME do bf check before or after crypto??
   if (NULL != bf)