bin_PROGRAMS = \
gnunet-service-gns \
- gnunet-gns-fcfsd
+ gnunet-gns-fcfsd \
+ gnunet-gns
#noinst_PROGRAMS = \
# gnunet-gns-lookup
$(top_builddir)/src/dht/libgnunetdht.la \
$(top_builddir)/src/testing/libgnunettesting.la
-#gnunet_gns_lookup_SOURCES = \
-# gnunet-gns-lookup.c
-#gnunet_gns_lookup_LDADD = \
-# $(top_builddir)/src/gns/libgnunetgns.la \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(GN_LIBINTL)
-#gnunet_dns_lookup_DEPENDENCIES = \
-# libgnunetgns.la
+gnunet_gns_SOURCES = \
+ gnunet-gns.c
+gnunet_gns_LDADD = \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(GN_LIBINTL)
+gnunet_gns_DEPENDENCIES = \
+ libgnunetgns.la
gnunet_service_gns_SOURCES = \
gnunet-service-gns.c
{
const struct GNUNET_GNS_ClientShortenResultMessage *gns_msg = cls;
struct GNUNET_GNS_ShortenHandle *shorten_handle = value;
- const char *name = (const char*) &shorten_handle[1];
+ const char *name = (const char*)&((struct GNUNET_GNS_ClientShortenMessage *) &((shorten_handle->message)[1]))[1]; //FIXME
const char *short_name;
if (ntohs (((struct GNUNET_MessageHeader*)gns_msg)->size) <
struct GNUNET_GNS_Handle *handle = cls;
const struct GNUNET_GNS_ClientLookupResultMessage *lookup_msg;
const struct GNUNET_GNS_ClientShortenResultMessage *shorten_msg;
-
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got message\n");
if (msg == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got lookup msg\n");
lookup_msg = (const struct GNUNET_GNS_ClientLookupResultMessage *) msg;
GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_lookup_requests,
&lookup_msg->key,
}
else if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got shorten msg\n");
shorten_msg = (const struct GNUNET_GNS_ClientShortenResultMessage *) msg;
GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_shorten_requests,
&shorten_msg->key,
* @return handle to the GNS service, or NULL on error
*/
struct GNUNET_GNS_Handle *
-GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
- unsigned int ht_len)
+GNUNET_GNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_GNS_Handle *handle;
handle->uid_gen =
GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX);
handle->active_lookup_requests =
- GNUNET_CONTAINER_multihashmap_create (ht_len);
+ GNUNET_CONTAINER_multihashmap_create (5);
handle->active_shorten_requests =
- GNUNET_CONTAINER_multihashmap_create (ht_len);
+ GNUNET_CONTAINER_multihashmap_create (5);
if (GNUNET_NO == try_connect (handle))
{
GNUNET_GNS_disconnect (handle);
GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
pending);
pending->in_pending_queue = GNUNET_YES;
- shorten_handle = GNUNET_malloc (sizeof (struct GNUNET_GNS_LookupHandle));
+ shorten_handle = GNUNET_malloc (sizeof (struct GNUNET_GNS_ShortenHandle));
shorten_handle->proc = proc;
shorten_handle->proc_cls = proc_cls;
shorten_handle->message = pending;
/**
* GNS name to shorten. (-s option)
*/
-static struct char *name;
+static char *name;
/**
* Task run on shutdown. Cleans up everything.
}
+static void
+process_shorten_result(void* cls, const char* nlong, const char* nshort)
+{
+ printf("%s shortened to %s\n", nlong, nshort);
+}
+
/**
* Main function that will be run.
*
_("Failed to connect to GNS\n"));
return;
}
- if (NULL == s)
+
+ if (name != NULL)
{
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
- return;
+ /** shorten name */
+ GNUNET_GNS_shorten(gns, name, &process_shorten_result, NULL);
}
+
// FIXME: do work here...
GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
}
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'s', "shorten", NULL,
- gettext_noop ("try to shorten a given GNS name"), 0,
+ gettext_noop ("try to shorten a given GNS name"), 1,
&GNUNET_GETOPT_set_string, &name},
GNUNET_GETOPT_OPTION_END
};
rmsg->key = csh->key;
rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT);
rmsg->header.size =
- htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage *) +
+ htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) +
strlen(name));
strcpy((char*)&rmsg[1], name);
GNUNET_SERVER_notification_context_unicast (nc, csh->client,
- (const struct GNUNET_MessageHeader *) &rmsg,
+ (const struct GNUNET_MessageHeader *) rmsg,
GNUNET_NO);
GNUNET_SERVER_receive_done (csh->client, GNUNET_OK);
- GNUNET_free(csh);
- GNUNET_free(rmsg);
+ //GNUNET_free(csh);
+ //GNUNET_free(rmsg);
}
size_t msg_size = 0;
struct ClientShortenHandle *csh;
- if (ntohs (message->size) != sizeof (struct GNUNET_GNS_ClientShortenMessage))
+ if (ntohs (message->size) < sizeof (struct GNUNET_GNS_ClientShortenMessage))
{
GNUNET_break_op (0);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
+ GNUNET_SERVER_notification_context_add (nc, client);
+ GNUNET_SERVER_client_keep (client);
+
struct GNUNET_GNS_ClientShortenMessage *sh_msg =
(struct GNUNET_GNS_ClientShortenMessage *) message;