[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20001 - gnunet/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20001 - gnunet/src/gns |
Date: |
Fri, 24 Feb 2012 11:51:42 +0100 |
Author: schanzen
Date: 2012-02-24 11:51:42 +0100 (Fri, 24 Feb 2012)
New Revision: 20001
Modified:
gnunet/src/gns/gnunet-service-gns.c
gnunet/src/gns/namestore_stub_api.c
Log:
-fixes, implemented new stub
Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-02-24 09:59:13 UTC (rev 20000)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-02-24 10:51:42 UTC (rev 20001)
@@ -141,7 +141,8 @@
struct GNUNET_TIME_Relative dht_update_interval;
-void reply_to_dns(struct GNUNET_GNS_PendingQuery *answer);
+void reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd);
void resolve_name(struct GNUNET_GNS_PendingQuery *query,
GNUNET_HashCode *zone);
@@ -440,7 +441,7 @@
//FIXME: add records to query handle, but on stack!
//do we need records in query handle? can't we just
//pass them to reply_to_dns?
- reply_to_dns(query);
+ reply_to_dns(query, num_records, rd);
}
/**
@@ -562,11 +563,11 @@
* @param answer the pending query used in the lookup
*/
void
-reply_to_dns(struct GNUNET_GNS_PendingQuery *answer)
+reply_to_dns(struct GNUNET_GNS_PendingQuery *answer, uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
- struct GNUNET_GNS_QueryRecordList *i;
struct GNUNET_DNSPARSER_Flags dnsflags;
- int j;
+ int i;
size_t len;
int ret;
char *buf;
@@ -575,19 +576,17 @@
packet.answers = answer_records;
len = sizeof(struct GNUNET_DNSPARSER_Record*);
- j = 0;
- for (i=answer->records_head; i != NULL; i=i->next)
+ for (i=0; i < rd_count; i++)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
- "Adding type %d to DNS response\n", i->record->record_type);
- answer_records[j].name = answer->original_name; //FIXME yes?
- answer_records[j].type = i->record->record_type;
- answer_records[j].data.raw.data_len = i->record->data_size;
- answer_records[j].data.raw.data = (char*)i->record->data;
- answer_records[j].expiration_time = i->record->expiration;
- answer_records[j].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
+ "Adding type %d to DNS response\n", rd[i].record_type);
+ answer_records[i].name = answer->original_name; //FIXME yes?
+ answer_records[i].type = rd[i].record_type;
+ answer_records[i].data.raw.data_len = rd[i].data_size;
+ answer_records[i].data.raw.data = (char*)rd[i].data;
+ answer_records[i].expiration_time = rd[i].expiration;
+ answer_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
//GNUNET_free(i->record); DO this later!
- j++;
}
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "after memcpy\n");
/* FIXME how to handle auth, additional etc */
@@ -695,7 +694,7 @@
* FIXME modify query to say NX
*/
GNUNET_assert(query->answered == 0);
- reply_to_dns(query); //answered should be 0
+ reply_to_dns(query, 0, NULL); //answered should be 0
return;
}
@@ -747,7 +746,7 @@
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Found answer to query!\n");
query->answered = 1;
- reply_to_dns(query);
+ reply_to_dns(query, rd_count, rd);
}
}
Modified: gnunet/src/gns/namestore_stub_api.c
===================================================================
--- gnunet/src/gns/namestore_stub_api.c 2012-02-24 09:59:13 UTC (rev 20000)
+++ gnunet/src/gns/namestore_stub_api.c 2012-02-24 10:51:42 UTC (rev 20001)
@@ -67,11 +67,19 @@
struct GNUNET_NAMESTORE_SimpleRecord * records_head;
struct GNUNET_NAMESTORE_SimpleRecord * records_tail;
+ uint32_t locked;
+
};
struct GNUNET_NAMESTORE_ZoneIterator
{
struct GNUNET_NAMESTORE_Handle *handle;
+ GNUNET_NAMESTORE_RecordProcessor proc;
+ void* proc_cls;
+ const GNUNET_HashCode * zone;
+ uint32_t no_flags;
+ uint32_t flags;
+ struct GNUNET_NAMESTORE_Handle *h;
};
struct GNUNET_NAMESTORE_SimpleRecord
@@ -88,13 +96,12 @@
const char *name;
const GNUNET_HashCode *zone;
- uint32_t record_type;
- struct GNUNET_TIME_Absolute expiration;
- enum GNUNET_NAMESTORE_RecordFlags flags;
- size_t data_size;
- const void *data;
+ const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key;
+ uint32_t rd_count;
+ struct GNUNET_NAMESTORE_RecordData rd[100];
};
+
/**
* Initialize the connection with the NAMESTORE service.
*
@@ -111,7 +118,6 @@
return handle;
}
-
/**
* Shutdown connection with the NAMESTORE service.
*
@@ -179,7 +185,34 @@
{
struct GNUNET_NAMESTORE_QueueEntry *qe;
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
- //FIXME
+ struct GNUNET_NAMESTORE_SimpleRecord* sr;
+
+ sr = h->records_head;
+ for (; sr != NULL; sr = sr->next)
+ {
+ if (strcmp(sr->name, name) && (sr->zone == NULL))
+ {
+ memcpy (&(sr->rd[sr->rd_count]), rd,
+ sizeof(struct GNUNET_NAMESTORE_RecordData));
+
+ sr->rd_count++;
+ return qe;
+ }
+ }
+
+ sr = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_SimpleRecord*));
+
+ sr->rd_count = 0;
+ sr->name = GNUNET_malloc(strlen(name));
+ sr->zone = NULL;
+ sr->zone_key = NULL;
+ strcpy((char*)sr->name, name);
+
+ memcpy (&(sr->rd), rd,
+ sizeof(struct GNUNET_NAMESTORE_RecordData));
+
+ GNUNET_CONTAINER_DLL_insert(h->records_head, h->records_tail, sr);
+
return qe;
}
@@ -237,7 +270,21 @@
{
struct GNUNET_NAMESTORE_QueueEntry *qe;
qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
-
+ struct GNUNET_NAMESTORE_SimpleRecord *sr;
+
+ sr = h->records_head;
+ for (; sr != NULL; sr = sr->next)
+ {
+ if (strcmp(sr->name, name) &&
+ (GNUNET_CRYPTO_hash_cmp(sr->zone, zone)))
+ {
+ //Simply always return all records
+ proc(proc_cls, sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS, //FIXME
+ name, sr->rd_count, sr->rd, NULL);
+ return qe;
+ }
+ }
+ proc(proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, name, 0, NULL, NULL);
//FIXME
return qe;
}
@@ -251,18 +298,45 @@
void *proc_cls)
{
struct GNUNET_NAMESTORE_ZoneIterator *it;
+ h->locked = 1;
it = GNUNET_malloc(sizeof(struct GNUNET_NAMESTORE_ZoneIterator));
+ it->h = h;
+ it->proc = proc;
+ it->proc_cls = proc_cls;
+ it->zone = zone;
+ it->no_flags = must_not_have_flags;
+ it->flags = must_have_flags;
+ GNUNET_NAMESTORE_zone_iterator_next(it);
return it;
}
void
GNUNET_NAMESTORE_zone_iterator_next(struct GNUNET_NAMESTORE_ZoneIterator *it)
{
+ struct GNUNET_NAMESTORE_SimpleRecord *sr;
+
+ if (it->h->locked == 0)
+ return;
+
+ sr = it->h->records_head;
+ for (; sr != NULL; sr = sr->next)
+ {
+ if (GNUNET_CRYPTO_hash_cmp(sr->zone, it->zone))
+ {
+ //Simply always return all records
+ //check flags
+ it->proc(it->proc_cls, sr->zone_key, GNUNET_TIME_UNIT_FOREVER_ABS,
//FIXME
+ sr->name, sr->rd_count, sr->rd, NULL);
+ }
+ }
+ it->proc(it->proc_cls, NULL, GNUNET_TIME_UNIT_ZERO_ABS, NULL, 0, NULL, NULL);
}
void
GNUNET_NAMESTORE_zone_iteration_stop(struct GNUNET_NAMESTORE_ZoneIterator *it)
{
+ it->h->locked = 0;
+ GNUNET_free(it);
}
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20001 - gnunet/src/gns,
gnunet <=