diff options
-rw-r--r-- | src/gns/Makefile.am | 16 | ||||
-rw-r--r-- | src/gns/gns.h | 5 | ||||
-rw-r--r-- | src/gns/gns_api.c | 56 | ||||
-rw-r--r-- | src/gns/gnunet-gns-add.c | 5 | ||||
-rw-r--r-- | src/gns/gnunet-gns-lookup.c | 34 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns.c | 181 | ||||
-rw-r--r-- | src/include/gnunet_dht_service.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_gns_service.h | 2 |
8 files changed, 187 insertions, 114 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index aab5d5fba..1dbce3b66 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am | |||
@@ -12,14 +12,14 @@ pkgcfgdir= $(pkgdatadir)/config.d/ | |||
12 | 12 | ||
13 | plugindir = $(libdir)/gnunet | 13 | plugindir = $(libdir)/gnunet |
14 | 14 | ||
15 | pkgcfg_DATA = \ | 15 | #pkgcfg_DATA = \ |
16 | dns.conf | 16 | # dns.conf |
17 | 17 | ||
18 | lib_LTLIBRARIES = \ | 18 | lib_LTLIBRARIES = \ |
19 | libgnunetgns.la | 19 | libgnunetgns.la |
20 | 20 | ||
21 | bin_PROGRAMS = \ | 21 | bin_PROGRAMS = \ |
22 | gnunet-service-gns $(HIJACKBIN) | 22 | gnunet-service-gns |
23 | 23 | ||
24 | noinst_PROGRAMS = \ | 24 | noinst_PROGRAMS = \ |
25 | gnunet-gns-lookup gnunet-gns-add | 25 | gnunet-gns-lookup gnunet-gns-add |
@@ -37,6 +37,15 @@ gnunet_gns_add_LDADD = \ | |||
37 | gnunet_dns_add_DEPENDENCIES = \ | 37 | gnunet_dns_add_DEPENDENCIES = \ |
38 | libgnunetgns.la | 38 | libgnunetgns.la |
39 | 39 | ||
40 | gnunet_gns_lookup_SOURCES = \ | ||
41 | gnunet-gns-lookup.c | ||
42 | gnunet_gns_lookup_LDADD = \ | ||
43 | $(top_builddir)/src/gns/libgnunetgns.la \ | ||
44 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
45 | $(GN_LIBINTL) | ||
46 | gnunet_dns_lookup_DEPENDENCIES = \ | ||
47 | libgnunetgns.la | ||
48 | |||
40 | gnunet_service_gns_SOURCES = \ | 49 | gnunet_service_gns_SOURCES = \ |
41 | gnunet-service-gns.c | 50 | gnunet-service-gns.c |
42 | gnunet_service_gns_LDADD = \ | 51 | gnunet_service_gns_LDADD = \ |
@@ -45,6 +54,7 @@ gnunet_service_gns_LDADD = \ | |||
45 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | 54 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ |
46 | $(top_builddir)/src/util/libgnunetutil.la \ | 55 | $(top_builddir)/src/util/libgnunetutil.la \ |
47 | $(top_builddir)/src/dns/libgnunetdns.la \ | 56 | $(top_builddir)/src/dns/libgnunetdns.la \ |
57 | $(top_builddir)/src/dns/libgnunetdnsparser.la \ | ||
48 | $(GN_LIBINTL) | 58 | $(GN_LIBINTL) |
49 | 59 | ||
50 | libgnunetgns_la_SOURCES = \ | 60 | libgnunetgns_la_SOURCES = \ |
diff --git a/src/gns/gns.h b/src/gns/gns.h index 695722b78..b7f0f306a 100644 --- a/src/gns/gns.h +++ b/src/gns/gns.h | |||
@@ -40,6 +40,11 @@ struct GNUNET_GNS_ClientLookupMessage | |||
40 | struct GNUNET_MessageHeader header; | 40 | struct GNUNET_MessageHeader header; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * A key. TODO some uid | ||
44 | */ | ||
45 | GNUNET_HashCode key; | ||
46 | |||
47 | /** | ||
43 | * Unique identifier for this request (for key collisions). | 48 | * Unique identifier for this request (for key collisions). |
44 | */ | 49 | */ |
45 | // FIXME: unaligned | 50 | // FIXME: unaligned |
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index ed0b447a7..14c1220c9 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -231,6 +231,35 @@ try_connect (struct GNUNET_GNS_Handle *handle) | |||
231 | } | 231 | } |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * Add the request corresponding to the given handle | ||
235 | * to the pending queue (if it is not already in there). | ||
236 | * | ||
237 | * @param cls the 'struct GNUNET_GNS_Handle*' | ||
238 | * @param key key for the request (not used) | ||
239 | * @param value the 'struct GNUNET_GNS_LookupHandle*' | ||
240 | * @return GNUNET_YES (always) | ||
241 | */ | ||
242 | static int | ||
243 | add_request_to_pending (void *cls, const GNUNET_HashCode * key, void *value) | ||
244 | { | ||
245 | struct GNUNET_GNS_Handle *handle = cls; | ||
246 | struct GNUNET_GNS_LookupHandle *rh = value; | ||
247 | |||
248 | if (GNUNET_NO == rh->message->in_pending_queue) | ||
249 | { | ||
250 | #if DEBUG_DHT | ||
251 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
252 | "Retransmitting request related to %s to GNS %p\n", GNUNET_h2s(key), | ||
253 | handle); | ||
254 | #endif | ||
255 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, | ||
256 | rh->message); | ||
257 | rh->message->in_pending_queue = GNUNET_YES; | ||
258 | } | ||
259 | return GNUNET_YES; | ||
260 | } | ||
261 | |||
262 | /** | ||
234 | * Try reconnecting to the GNS service. | 263 | * Try reconnecting to the GNS service. |
235 | * | 264 | * |
236 | * @param cls GNUNET_GNS_Handle | 265 | * @param cls GNUNET_GNS_Handle |
@@ -349,10 +378,8 @@ transmit_pending (void *cls, size_t size, void *buf) | |||
349 | handle->th = NULL; | 378 | handle->th = NULL; |
350 | if (buf == NULL) | 379 | if (buf == NULL) |
351 | { | 380 | { |
352 | #if DEBUG_GNS | 381 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
353 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
354 | "Transmission to GNS service failed! Reconnecting!\n"); | 382 | "Transmission to GNS service failed! Reconnecting!\n"); |
355 | #endif | ||
356 | do_disconnect (handle); | 383 | do_disconnect (handle); |
357 | return 0; | 384 | return 0; |
358 | } | 385 | } |
@@ -562,6 +589,7 @@ GNUNET_GNS_add_record (struct GNUNET_GNS_Handle *handle, | |||
562 | 589 | ||
563 | /** | 590 | /** |
564 | * Perform an asynchronous Lookup operation on the GNS. | 591 | * Perform an asynchronous Lookup operation on the GNS. |
592 | * TODO: Still not sure what we query for... "names" it is for now | ||
565 | * | 593 | * |
566 | * @param handle handle to the GNS service | 594 | * @param handle handle to the GNS service |
567 | * @param timeout how long to wait for transmission of this request to the service | 595 | * @param timeout how long to wait for transmission of this request to the service |
@@ -572,18 +600,26 @@ GNUNET_GNS_add_record (struct GNUNET_GNS_Handle *handle, | |||
572 | */ | 600 | */ |
573 | struct GNUNET_GNS_LookupHandle * | 601 | struct GNUNET_GNS_LookupHandle * |
574 | GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle, | 602 | GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle, |
575 | struct GNUNET_TIME_Relative timeout, | 603 | struct GNUNET_TIME_Relative timeout, |
576 | const char * name, | 604 | const char * name, |
577 | enum GNUNET_GNS_RecordType type, | 605 | enum GNUNET_GNS_RecordType type, |
578 | GNUNET_GNS_LookupIterator iter, | 606 | GNUNET_GNS_LookupIterator iter, |
579 | void *iter_cls) | 607 | void *iter_cls) |
580 | { | 608 | { |
581 | /* IPC to look for local entries, start dht lookup, return lookup_handle */ | 609 | /* IPC to look for local entries, start dht lookup, return lookup_handle */ |
582 | struct GNUNET_GNS_ClientLookupMessage *lookup_msg; | 610 | struct GNUNET_GNS_ClientLookupMessage *lookup_msg; |
583 | struct GNUNET_GNS_LookupHandle *lookup_handle; | 611 | struct GNUNET_GNS_LookupHandle *lookup_handle; |
612 | GNUNET_HashCode key; | ||
584 | size_t msize; | 613 | size_t msize; |
585 | struct PendingMessage *pending; | 614 | struct PendingMessage *pending; |
586 | 615 | ||
616 | if (NULL == name) | ||
617 | { | ||
618 | return NULL; | ||
619 | } | ||
620 | |||
621 | GNUNET_CRYPTO_hash (name, strlen(name), &key); | ||
622 | |||
587 | msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) + strlen(name); | 623 | msize = sizeof (struct GNUNET_GNS_ClientLookupMessage) + strlen(name); |
588 | #if DEBUG_GNS | 624 | #if DEBUG_GNS |
589 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting lookup for %s in GNS %p\n", | 625 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting lookup for %s in GNS %p\n", |
@@ -597,6 +633,7 @@ GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle, | |||
597 | lookup_msg->header.size = htons (msize); | 633 | lookup_msg->header.size = htons (msize); |
598 | lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP); | 634 | lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP); |
599 | lookup_msg->namelen = strlen(name); | 635 | lookup_msg->namelen = strlen(name); |
636 | lookup_msg->key = key; | ||
600 | memcpy(&lookup_msg[1], name, strlen(name)); | 637 | memcpy(&lookup_msg[1], name, strlen(name)); |
601 | handle->uid_gen++; | 638 | handle->uid_gen++; |
602 | lookup_msg->unique_id = handle->uid_gen; | 639 | lookup_msg->unique_id = handle->uid_gen; |
@@ -608,7 +645,8 @@ GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle, | |||
608 | lookup_handle->iter_cls = iter_cls; | 645 | lookup_handle->iter_cls = iter_cls; |
609 | lookup_handle->message = pending; | 646 | lookup_handle->message = pending; |
610 | lookup_handle->unique_id = lookup_msg->unique_id; | 647 | lookup_handle->unique_id = lookup_msg->unique_id; |
611 | GNUNET_CONTAINER_multihashmap_put (handle->active_requests, key, lookup_handle, | 648 | GNUNET_CONTAINER_multihashmap_put (handle->active_requests, &lookup_msg->key, |
649 | lookup_handle, | ||
612 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 650 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
613 | process_pending_messages (handle); | 651 | process_pending_messages (handle); |
614 | return lookup_handle; | 652 | return lookup_handle; |
diff --git a/src/gns/gnunet-gns-add.c b/src/gns/gnunet-gns-add.c index bb1d7e1f4..a1beebca3 100644 --- a/src/gns/gnunet-gns-add.c +++ b/src/gns/gnunet-gns-add.c | |||
@@ -144,8 +144,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
144 | if (verbose) | 144 | if (verbose) |
145 | FPRINTF (stderr, _("Issuing add request for `%s' with data `%s'!\n"), | 145 | FPRINTF (stderr, _("Issuing add request for `%s' with data `%s'!\n"), |
146 | record_key, data); | 146 | record_key, data); |
147 | GNUNET_GNS_add_record (gns_handle, &record_key, record_type, | 147 | GNUNET_GNS_add_record (gns_handle, record_key, |
148 | strlen (data), data, expiration, timeout); | 148 | 0/*RecordType*/, |
149 | strlen (data), data, expiration, timeout); | ||
149 | 150 | ||
150 | } | 151 | } |
151 | 152 | ||
diff --git a/src/gns/gnunet-gns-lookup.c b/src/gns/gnunet-gns-lookup.c index 2d4f7cb02..f305baf0f 100644 --- a/src/gns/gnunet-gns-lookup.c +++ b/src/gns/gnunet-gns-lookup.c | |||
@@ -120,17 +120,12 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
120 | * @param data pointer to the result data | 120 | * @param data pointer to the result data |
121 | */ | 121 | */ |
122 | static void | 122 | static void |
123 | get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, | 123 | lookup_result_iterator (void *cls, |
124 | const GNUNET_HashCode * key, | 124 | const GNUNET_HashCode * key, |
125 | const struct GNUNET_PeerIdentity *get_path, | 125 | const struct GNUNET_GNS_Record *record, |
126 | unsigned int get_path_length, | 126 | unsigned int num_records) |
127 | const struct GNUNET_PeerIdentity *put_path, | ||
128 | unsigned int put_path_length, enum GNUNET_BLOCK_Type type, | ||
129 | size_t size, const void *data) | ||
130 | { | 127 | { |
131 | FPRINTF (stdout, "Result %d, type %d:\n%.*s\n", result_count, type, | 128 | FPRINTF (stdout, "Results %d\n", num_records); |
132 | (unsigned int) size, (char *) data); | ||
133 | result_count++; | ||
134 | } | 129 | } |
135 | 130 | ||
136 | 131 | ||
@@ -147,7 +142,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
147 | const struct GNUNET_CONFIGURATION_Handle *c) | 142 | const struct GNUNET_CONFIGURATION_Handle *c) |
148 | { | 143 | { |
149 | struct GNUNET_TIME_Relative timeout; | 144 | struct GNUNET_TIME_Relative timeout; |
150 | GNUNET_HashCode key; | ||
151 | 145 | ||
152 | cfg = c; | 146 | cfg = c; |
153 | 147 | ||
@@ -159,9 +153,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
159 | return; | 153 | return; |
160 | } | 154 | } |
161 | 155 | ||
162 | lookup_handle = GNUNET_GNS_connect (cfg, 1); | 156 | gns_handle = GNUNET_GNS_connect (cfg, 1); |
163 | 157 | ||
164 | if (lookup_handle == NULL) | 158 | if (gns_handle == NULL) |
165 | { | 159 | { |
166 | if (verbose) | 160 | if (verbose) |
167 | FPRINTF (stderr, "%s", "Couldn't connect to GNS service!\n"); | 161 | FPRINTF (stderr, "%s", "Couldn't connect to GNS service!\n"); |
@@ -171,11 +165,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
171 | else if (verbose) | 165 | else if (verbose) |
172 | FPRINTF (stderr, "%s", "Connected to GNS service!\n"); | 166 | FPRINTF (stderr, "%s", "Connected to GNS service!\n"); |
173 | 167 | ||
174 | if (query_type == GNUNET_BLOCK_TYPE_ANY) /* Type of data not set */ | ||
175 | query_type = GNUNET_BLOCK_TYPE_TEST; | ||
176 | |||
177 | GNUNET_CRYPTO_hash (query_key, strlen (query_key), &key); | ||
178 | |||
179 | timeout = | 168 | timeout = |
180 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_request); | 169 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, timeout_request); |
181 | absolute_timeout = GNUNET_TIME_relative_to_absolute (timeout); | 170 | absolute_timeout = GNUNET_TIME_relative_to_absolute (timeout); |
@@ -184,10 +173,11 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
184 | FPRINTF (stderr, "Issuing lookup request for %s!\n", query_key); | 173 | FPRINTF (stderr, "Issuing lookup request for %s!\n", query_key); |
185 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 174 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
186 | (absolute_timeout), &cleanup_task, NULL); | 175 | (absolute_timeout), &cleanup_task, NULL); |
187 | get_handle = | 176 | lookup_handle = |
188 | GNUNET_GNS_lookup_start (lookup_handle, timeout, query_type, &key, replication, | 177 | GNUNET_GNS_lookup_start (gns_handle, timeout, query_key, |
189 | GNUNET_DHT_RO_NONE, NULL, 0, &get_result_iterator, | 178 | 0/*GNS_RecordType*/, |
190 | NULL); | 179 | &lookup_result_iterator, |
180 | NULL); | ||
191 | 181 | ||
192 | } | 182 | } |
193 | 183 | ||
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 25e066d00..ca732c78e 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -27,14 +27,19 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_transport_service.h" | 28 | #include "gnunet_transport_service.h" |
29 | #include "gnunet_dns_service.h" | 29 | #include "gnunet_dns_service.h" |
30 | #include "gnunet_dnsparser_lib.h" | ||
30 | #include "gnunet_gns_service.h" | 31 | #include "gnunet_gns_service.h" |
31 | #include "gnunet-service-gns.h" | 32 | #include "gns.h" |
32 | 33 | ||
33 | 34 | ||
35 | /* TODO into gnunet_protocols */ | ||
36 | #define GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP 23 | ||
37 | #define GNUNET_MESSAGE_TYPE_GNS_CLIENT_RESULT 24 | ||
38 | |||
34 | /** | 39 | /** |
35 | * Our handle to the DNS handler library | 40 | * Our handle to the DNS handler library |
36 | */ | 41 | */ |
37 | struct GNUNET_DNS_Handle *dns_handler; | 42 | struct GNUNET_DNS_Handle *dns_handle; |
38 | 43 | ||
39 | /** | 44 | /** |
40 | * The configuration the GNS service is running with | 45 | * The configuration the GNS service is running with |
@@ -42,6 +47,11 @@ struct GNUNET_DNS_Handle *dns_handler; | |||
42 | const struct GNUNET_CONFIGURATION_Handle *GNS_cfg; | 47 | const struct GNUNET_CONFIGURATION_Handle *GNS_cfg; |
43 | 48 | ||
44 | /** | 49 | /** |
50 | * Our notification context. | ||
51 | */ | ||
52 | static struct GNUNET_SERVER_NotificationContext *nc; | ||
53 | |||
54 | /** | ||
45 | * Task run during shutdown. | 55 | * Task run during shutdown. |
46 | * | 56 | * |
47 | * @param cls unused | 57 | * @param cls unused |
@@ -50,7 +60,7 @@ const struct GNUNET_CONFIGURATION_Handle *GNS_cfg; | |||
50 | static void | 60 | static void |
51 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 61 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
52 | { | 62 | { |
53 | GNUNET_DNS_disconnect(dns_handle); | 63 | GNUNET_DNS_disconnect(dns_handle); |
54 | } | 64 | } |
55 | 65 | ||
56 | /** | 66 | /** |
@@ -63,55 +73,74 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
63 | */ | 73 | */ |
64 | void | 74 | void |
65 | handle_dns_request(void *cls, | 75 | handle_dns_request(void *cls, |
66 | struct GNUNET_DNS_RequestHandle *rh, | 76 | struct GNUNET_DNS_RequestHandle *rh, |
67 | size_t request_length, | 77 | size_t request_length, |
68 | const char *request) | 78 | const char *request) |
69 | { | 79 | { |
70 | /** | 80 | /** |
71 | * TODO: parse request for tld | 81 | * TODO: parse request for tld |
72 | * Queue rh and gns handle (or use cls) | 82 | * Queue rh and gns handle (or use cls) |
73 | * How should lookup behave: | 83 | * How should lookup behave: |
74 | * - sync and return result or "NX" | 84 | * - sync and return result or "NX" |
75 | * - async like dht with iter | 85 | * - async like dht with iter |
76 | * Maybe provide both, useful for cli app | 86 | * Maybe provide both, useful for cli app |
77 | **/ | 87 | **/ |
78 | struct GNUNET_DNSPARSER_Packet *p; | 88 | struct GNUNET_DNSPARSER_Packet *p; |
79 | int namelen; | 89 | int namelen; |
80 | 90 | int i; | |
81 | p = GNUNET_DNSPARSER_parse (request, request_length); | 91 | char *tail; |
82 | if (NULL == p) | 92 | |
83 | { | 93 | p = GNUNET_DNSPARSER_parse (request, request_length); |
84 | fprintf (stderr, "Received malformed DNS packet, leaving it untouched\n"); | 94 | if (NULL == p) |
85 | GNUNET_DNS_request_forward (rh); | 95 | { |
86 | return; | 96 | fprintf (stderr, "Received malformed DNS packet, leaving it untouched\n"); |
87 | } | 97 | GNUNET_DNS_request_forward (rh); |
88 | /** | 98 | return; |
89 | * TODO factor out | 99 | } |
90 | * Check tld and decide if we or | 100 | /** |
91 | * legacy dns is responsible | 101 | * TODO factor out |
92 | **/ | 102 | * Check tld and decide if we or |
93 | for (i=0;i<p->num_queries;i++) | 103 | * legacy dns is responsible |
94 | { | 104 | **/ |
95 | namelen = strlen(&p->queries[i]->name); | 105 | for (i=0;i<p->num_queries;i++) |
96 | if (namelen >= 7) | 106 | { |
97 | { | 107 | namelen = strlen(p->queries[i].name); |
98 | /** | 108 | if (namelen >= 7) |
99 | * TODO off by 1? | 109 | { |
100 | * Move our tld/root to config file | 110 | /** |
101 | * Generate fake DNS reply that replaces .gnunet with .org | 111 | * TODO off by 1? |
102 | **/ | 112 | * Move our tld/root to config file |
103 | if (0 == strcmp((&p->queries[i]->name)+(namelen-7), ".gnunet")) | 113 | * Generate fake DNS reply that replaces .gnunet with .org |
104 | { | 114 | **/ |
105 | GNUNET_DNS_request_answer(rh, 0 /*length*/, NULL/*reply*/); | 115 | tail = p->queries[i].name+(namelen-7); |
106 | } | 116 | if (0 == strcmp(tail, ".gnunet")) |
107 | else | 117 | { |
108 | { | 118 | /* Do db lookup here. Make dht lookup if necessary */ |
109 | GNUNET_DNS_request_forward (rh); | 119 | GNUNET_DNS_request_answer(rh, 0 /*length*/, NULL/*reply*/); |
110 | } | 120 | } |
111 | } | 121 | else |
112 | } | 122 | { |
123 | GNUNET_DNS_request_forward (rh); | ||
124 | } | ||
125 | } | ||
126 | } | ||
113 | } | 127 | } |
114 | 128 | ||
129 | /*TODO*/ | ||
130 | static void | ||
131 | handle_client_record_lookup(void *cls, | ||
132 | struct GNUNET_SERVER_Client *client, | ||
133 | const struct GNUNET_MessageHeader *message) | ||
134 | { | ||
135 | } | ||
136 | |||
137 | /*TODO*/ | ||
138 | static void | ||
139 | handle_client_record_add(void *cls, | ||
140 | struct GNUNET_SERVER_Client *client, | ||
141 | const struct GNUNET_MessageHeader *message) | ||
142 | { | ||
143 | } | ||
115 | 144 | ||
116 | /** | 145 | /** |
117 | * Process GNS requests. | 146 | * Process GNS requests. |
@@ -124,35 +153,35 @@ static void | |||
124 | run (void *cls, struct GNUNET_SERVER_Handle *server, | 153 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
125 | const struct GNUNET_CONFIGURATION_Handle *c) | 154 | const struct GNUNET_CONFIGURATION_Handle *c) |
126 | { | 155 | { |
127 | /* The IPC message types */ | 156 | /* The IPC message types */ |
128 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 157 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
129 | /* callback, cls, type, size */ | 158 | /* callback, cls, type, size */ |
130 | {&handle_client_record_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_RECORD_LOOKUP, | 159 | {&handle_client_record_lookup, NULL, GNUNET_MESSAGE_TYPE_GNS_CLIENT_LOOKUP, |
131 | sizeof (struct GNUNET_GNS_Lookup)}, | 160 | 0}, |
132 | {&handle_client_record_add, NULL, GNUNET_MESSAGE_TYPE_GNS_RECORD_ADD, | 161 | /*{&handle_client_record_add, NULL, GNUNET_MESSAGE_TYPE_GNS_CLIENT_ADD, |
133 | sizeof (struct GNUNET_GNS_Record)}, | 162 | 0},*/ |
134 | {NULL, NULL, 0, 0} | 163 | {NULL, NULL, 0, 0} |
135 | }; | 164 | }; |
136 | 165 | ||
137 | nc = GNUNET_SERVER_notification_context_create (server, 1); | 166 | nc = GNUNET_SERVER_notification_context_create (server, 1); |
138 | 167 | ||
139 | /* TODO do some config parsing */ | 168 | /* TODO do some config parsing */ |
140 | 169 | ||
141 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 170 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
142 | NULL); | 171 | NULL); |
143 | /** | 172 | /** |
144 | * Do gnunet dns init here | 173 | * Do gnunet dns init here |
145 | * */ | 174 | * */ |
146 | dns_handle = GNUNET_DNS_connect(c, | 175 | dns_handle = GNUNET_DNS_connect(c, |
147 | GNUNET_DNS_FLAG_PRE_RESOLUTION, | 176 | GNUNET_DNS_FLAG_PRE_RESOLUTION, |
148 | &handle_dns_request, /* rh */ | 177 | &handle_dns_request, /* rh */ |
149 | NULL); /* Closure */ | 178 | NULL); /* Closure */ |
150 | GNUNET_SERVER_add_handlers (server, handlers); | 179 | GNUNET_SERVER_add_handlers (server, handlers); |
151 | /** | 180 | /** |
152 | * Esp the lookup would require to keep track of the clients' context | 181 | * Esp the lookup would require to keep track of the clients' context |
153 | * See dht. | 182 | * See dht. |
154 | * GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); | 183 | * GNUNET_SERVER_disconnect_notify (server, &client_disconnect, NULL); |
155 | **/ | 184 | **/ |
156 | } | 185 | } |
157 | 186 | ||
158 | 187 | ||
diff --git a/src/include/gnunet_dht_service.h b/src/include/gnunet_dht_service.h index fd89642c6..e533ef279 100644 --- a/src/include/gnunet_dht_service.h +++ b/src/include/gnunet_dht_service.h | |||
@@ -272,7 +272,7 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, | |||
272 | * | 272 | * |
273 | * @param handle The handle to the monitor request returned by monitor_start. | 273 | * @param handle The handle to the monitor request returned by monitor_start. |
274 | * | 274 | * |
275 | * On return get_handle will no longer be valid, caller must not use again!!! | 275 | * On return handle will no longer be valid, caller must not use again!!! |
276 | */ | 276 | */ |
277 | void | 277 | void |
278 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); | 278 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle); |
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h index 780ddbcca..322a1c9bf 100644 --- a/src/include/gnunet_gns_service.h +++ b/src/include/gnunet_gns_service.h | |||
@@ -80,7 +80,7 @@ enum GNUNET_GNS_RecordType | |||
80 | * @return NULL on error | 80 | * @return NULL on error |
81 | */ | 81 | */ |
82 | struct GNUNET_GNS_Handle * | 82 | struct GNUNET_GNS_Handle * |
83 | GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg | 83 | GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
84 | unsigned int ht_len); | 84 | unsigned int ht_len); |
85 | 85 | ||
86 | 86 | ||