[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20142 - in gnunet/src: include namestore
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20142 - in gnunet/src: include namestore |
Date: |
Wed, 29 Feb 2012 12:11:10 +0100 |
Author: wachs
Date: 2012-02-29 12:11:10 +0100 (Wed, 29 Feb 2012)
New Revision: 20142
Modified:
gnunet/src/include/gnunet_namestore_plugin.h
gnunet/src/include/gnunet_namestore_service.h
gnunet/src/namestore/gnunet-service-namestore.c
gnunet/src/namestore/namestore_api.c
gnunet/src/namestore/plugin_namestore_sqlite.c
gnunet/src/namestore/test_namestore_api_lookup.c
Log:
nametore api change
Modified: gnunet/src/include/gnunet_namestore_plugin.h
===================================================================
--- gnunet/src/include/gnunet_namestore_plugin.h 2012-02-29 09:59:50 UTC
(rev 20141)
+++ gnunet/src/include/gnunet_namestore_plugin.h 2012-02-29 11:11:10 UTC
(rev 20142)
@@ -56,7 +56,7 @@
const struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
struct GNUNET_TIME_Absolute
expire,
const char *name,
- unsigned int rd_count,
+ unsigned int rd_len,
const struct
GNUNET_NAMESTORE_RecordData *rd,
const struct
GNUNET_CRYPTO_RsaSignature *signature);
@@ -85,13 +85,13 @@
* @param rd array of records with data to store
* @param signature signature of the record block, NULL if signature is
unavailable (i.e.
* because the user queried for a particular record type only)
- * @return GNUNET_OK on success
+ * @return GNUNET_OK on success, else GNUNET_SYSERR
*/
int (*put_records) (void *cls,
const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
*zone_key,
struct GNUNET_TIME_Absolute expire,
const char *name,
- unsigned int rd_count,
+ unsigned int rd_len,
const struct GNUNET_NAMESTORE_RecordData *rd,
const struct GNUNET_CRYPTO_RsaSignature *signature);
@@ -115,7 +115,7 @@
*
* @param cls closure (internal context for the plugin)
* @param zone hash of public key of the zone, NULL to iterate over all zones
- * @param name_hash hash of name, NULL to iterate over all records of the
zone
+ * @param name name as '\0' terminated string, NULL to iterate over all
records of the zone
* @param offset offset in the list of all matching records
* @param iter function to call with the result
* @param iter_cls closure for iter
@@ -123,7 +123,7 @@
*/
int (*iterate_records) (void *cls,
const GNUNET_HashCode *zone,
- const GNUNET_HashCode *name_hash,
+ const char *name,
uint64_t offset,
GNUNET_NAMESTORE_RecordIterator iter, void *iter_cls);
Modified: gnunet/src/include/gnunet_namestore_service.h
===================================================================
--- gnunet/src/include/gnunet_namestore_service.h 2012-02-29 09:59:50 UTC
(rev 20141)
+++ gnunet/src/include/gnunet_namestore_service.h 2012-02-29 11:11:10 UTC
(rev 20142)
@@ -274,7 +274,7 @@
const struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
struct GNUNET_TIME_Absolute
expire,
const char *name,
- unsigned int rd_count,
+ unsigned int rd_len,
const struct
GNUNET_NAMESTORE_RecordData *rd,
const struct
GNUNET_CRYPTO_RsaSignature *signature);
Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c 2012-02-29 09:59:50 UTC
(rev 20141)
+++ gnunet/src/namestore/gnunet-service-namestore.c 2012-02-29 11:11:10 UTC
(rev 20142)
@@ -253,8 +253,6 @@
copied_elements = rd_count;
rd_selected = (struct GNUNET_NAMESTORE_RecordData *) rd;
}
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "NAMESTORE_LOOKUP_NAME_RESPONSE: %p
%u\n", rd_selected, copied_elements);
rd_ser_len = GNUNET_NAMESTORE_records_serialize(&rd_ser, copied_elements,
rd_selected);
}
else
@@ -319,13 +317,12 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
"NAMESTORE_LOOKUP_NAME");
struct LookupNameContext lnc;
struct GNUNET_NAMESTORE_Client *nc;
- GNUNET_HashCode name_hash;
size_t name_len;
char * name;
uint32_t id = 0;
uint32_t type = 0;
+ int res;
-
if (ntohs (message->size) < sizeof (struct LookupNameMessage))
{
GNUNET_break_op (0);
@@ -353,18 +350,24 @@
return;
}
- name = GNUNET_malloc (name_len);
- memcpy (name, &ln_msg[1], name_len);
+ name = (char *) &ln_msg[1];
+ if (name[name_len -1] != '\0')
+ {
+ GNUNET_break_op (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+ return;
+ }
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up record for name `%s'\n",
name);
- GNUNET_CRYPTO_hash(name, name_len-1, &name_hash);
- GNUNET_free (name);
/* do the actual lookup */
lnc.id = id;
lnc.nc = nc;
lnc.record_type = type;
- GSN_database->iterate_records(GSN_database->cls, &ln_msg->zone,
&ln_msg->zone, 0, &handle_lookup_name_it, &lnc);
+ res = GSN_database->iterate_records(GSN_database->cls, &ln_msg->zone, name,
0, &handle_lookup_name_it, &lnc);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ITERATE RESULTS: %u\n" , res);
+
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c 2012-02-29 09:59:50 UTC (rev
20141)
+++ gnunet/src/namestore/namestore_api.c 2012-02-29 11:11:10 UTC (rev
20142)
@@ -205,24 +205,29 @@
struct GNUNET_CRYPTO_RsaSignature *signature = NULL;
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded dummy;
struct GNUNET_TIME_Absolute expire;
+ size_t exp_msg_len;
size_t msg_len = 0;
size_t name_len = 0;
size_t rd_len = 0;
int contains_sig = GNUNET_NO;
int rd_count = 0;
- rd_len = ntohs (msg->rd_len);
+ rd_len = ntohl (msg->rd_len);
msg_len = ntohs (msg->header.size);
name_len = ntohs (msg->name_len);
contains_sig = ntohs (msg->contains_sig);
expire = GNUNET_TIME_absolute_ntoh(msg->expire);
- if (msg_len != sizeof (struct LookupNameResponseMessage) +
+ exp_msg_len = sizeof (struct LookupNameResponseMessage) +
sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) +
name_len +
rd_len +
- contains_sig * sizeof (struct GNUNET_CRYPTO_RsaSignature))
+ contains_sig * sizeof (struct GNUNET_CRYPTO_RsaSignature);
+
+ if (msg_len != exp_msg_len)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Message size describes with `%u'
bytes but calculated size is %u bytes \n",
+ msg_len, exp_msg_len);
GNUNET_break_op (0);
return;
}
Modified: gnunet/src/namestore/plugin_namestore_sqlite.c
===================================================================
--- gnunet/src/namestore/plugin_namestore_sqlite.c 2012-02-29 09:59:50 UTC
(rev 20141)
+++ gnunet/src/namestore/plugin_namestore_sqlite.c 2012-02-29 11:11:10 UTC
(rev 20142)
@@ -490,6 +490,7 @@
(void) namestore_sqlite_remove_records (plugin, &zone, name);
name_len = strlen (name);
GNUNET_CRYPTO_hash (name, name_len, &nh);
+
rvalue = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
data_size = rd_count * sizeof (struct DbRecord);
for (i=0;i<rd_count;i++)
@@ -564,7 +565,7 @@
*
* @param cls closure (internal context for the plugin)
* @param zone hash of public key of the zone, NULL to iterate over all zones
- * @param name_hash hash of name, NULL to iterate over all records of the zone
+ * @param name name as string, NULL to iterate over all records of the zone
* @param offset offset in the list of all matching records
* @param iter function to call with the result
* @param iter_cls closure for iter
@@ -573,26 +574,33 @@
static int
namestore_sqlite_iterate_records (void *cls,
const GNUNET_HashCode *zone,
- const GNUNET_HashCode *name_hash,
+ const char *name,
uint64_t offset,
GNUNET_NAMESTORE_RecordIterator iter, void
*iter_cls)
{
struct Plugin *plugin = cls;
sqlite3_stmt *stmt;
+ GNUNET_HashCode name_hase;
unsigned int boff;
int ret;
int sret;
if (NULL == zone)
- if (NULL == name_hash)
+ if (NULL == name)
stmt = plugin->iterate_all;
else
+ {
+ GNUNET_CRYPTO_hash (name, strlen(name), &name_hase);
stmt = plugin->iterate_by_name;
+ }
else
- if (NULL == name_hash)
+ if (NULL == name)
stmt = plugin->iterate_by_zone;
else
+ {
+ GNUNET_CRYPTO_hash (name, strlen(name), &name_hase);
stmt = plugin->iterate_records;
+ }
boff = 0;
if ( (NULL != zone) &&
@@ -608,11 +616,12 @@
"sqlite3_reset");
return GNUNET_SYSERR;
}
- if ( (NULL != name_hash) &&
+ if ( (NULL != name) &&
(SQLITE_OK != sqlite3_bind_blob (stmt, ++boff,
- name_hash, sizeof (GNUNET_HashCode),
+ &name_hase, sizeof (GNUNET_HashCode),
SQLITE_STATIC)) )
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "ITERATE NAME HASH: `%s'",
GNUNET_h2s_full(&name_hase));
LOG_SQLITE (plugin, GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
"sqlite3_bind_XXXX");
if (SQLITE_OK != sqlite3_reset (stmt))
Modified: gnunet/src/namestore/test_namestore_api_lookup.c
===================================================================
--- gnunet/src/namestore/test_namestore_api_lookup.c 2012-02-29 09:59:50 UTC
(rev 20141)
+++ gnunet/src/namestore/test_namestore_api_lookup.c 2012-02-29 11:11:10 UTC
(rev 20142)
@@ -141,7 +141,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name
`%s'\n", name);
res = 1;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup done for name %s'\n", name);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Lookup done for name %s'\n", name);
}
GNUNET_SCHEDULER_add_now(&end, NULL);
@@ -198,7 +198,7 @@
GNUNET_CRYPTO_rsa_key_get_public(privkey, &pubkey);
/* create random zone hash */
- GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &zone);
+ GNUNET_CRYPTO_hash (&pubkey, sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &zone);
struct GNUNET_CRYPTO_RsaSignature signature;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20142 - in gnunet/src: include namestore,
gnunet <=