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);
* @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);
*
* @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
*/
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);
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);
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
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))
{
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);
}
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;
}
(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++)
*
* @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
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) &&
"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))
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);
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;