GNUNET_free (db_lib_name);
}
-static void handle_start ()
+/**
+ * Called whenever a client is disconnected. Frees our
+ * resources associated with that client.
+ *
+ * @param cls closure
+ * @param client identification of the client
+ */
+static void
+client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
+{
+ if (NULL != client)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected \n", client);
+}
+
+static void handle_start (void *cls,
+ struct GNUNET_SERVER_Client * client,
+ const struct GNUNET_MessageHeader * message)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n");
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+static void handle_lookup_name (void *cls,
+ struct GNUNET_SERVER_Client * client,
+ const struct GNUNET_MessageHeader * message)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "START");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_LOOKUP_NAME");
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
{&handle_start, NULL,
GNUNET_MESSAGE_TYPE_NAMESTORE_START, sizeof (struct StartMessage)},
+ {&handle_lookup_name, NULL,
+ GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME, 0},
{NULL, NULL, 0, 0}
};
/* Configuring server handles */
GNUNET_SERVER_add_handlers (server, handlers);
+ GNUNET_SERVER_disconnect_notify (server,
+ &client_disconnect_notification,
+ NULL);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleanup_task,
NULL);
#ifndef NAMESTORE_H
#define NAMESTORE_H
+/*
+ * Collect message types here, move to protocols later
+ */
+#define GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME 431
+
GNUNET_NETWORK_STRUCT_BEGIN
/**
- * Change in blacklisting (either request or notification,
- * depending on which direction it is going).
+ * Connect to namestore service
*/
struct StartMessage
{
};
GNUNET_NETWORK_STRUCT_END
+GNUNET_NETWORK_STRUCT_BEGIN
+/**
+ * Connect to namestore service
+ */
+struct LookupNameMessage
+{
+
+ /**
+ * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME
+ */
+ struct GNUNET_MessageHeader header;
+
+};
+GNUNET_NETWORK_STRUCT_END
+
+
/* end of namestore.h */
#endif
return;
if (NULL == nsh->client)
return; /* currently reconnecting */
+
nsh->th = GNUNET_CLIENT_notify_transmit_ready (nsh->client, p->size,
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_NO, &transmit_message_to_namestore,
* cancel
*/
struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_lookup_name (struct GNUNET_NAMESTORE_Handle *h,
+GNUNET_NAMESTORE_lookup_name (struct GNUNET_NAMESTORE_Handle *nsh,
const GNUNET_HashCode *zone,
const char *name,
uint32_t record_type,
proc(proc_cls, zone, name, record_type,
GNUNET_TIME_absolute_get_forever(), 0, NULL, 0, NULL); /*TERMINATE*/
#endif
+
+ GNUNET_assert (NULL != nsh);
+
+ struct PendingMessage * p;
+ struct LookupNameMessage * msg;
+ size_t msg_len = sizeof (struct LookupNameMessage);
+
+ p = GNUNET_malloc (sizeof (struct PendingMessage) + msg_len);
+ p->size = msg_len;
+ p->is_init = GNUNET_NO;
+ msg = (struct LookupNameMessage *) &p[1];
+ msg->header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME);
+ msg->header.size = htons (msg_len);
+ GNUNET_CONTAINER_DLL_insert (nsh->pending_head, nsh->pending_tail, p);
+ do_transmit (nsh);
+
return qe;
}
static void
endbadly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ if (nsh != NULL)
+ GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+ nsh = NULL;
+
if (NULL != arm)
stop_arm();
+
res = 1;
}
endbadly_task = GNUNET_SCHEDULER_NO_TASK;
}
+ if (nsh != NULL)
+ GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+ nsh = NULL;
+
+
if (NULL != arm)
stop_arm();
nsh = GNUNET_NAMESTORE_connect (cfg);
GNUNET_break (NULL != nsh);
- GNUNET_NAMESTORE_disconnect (nsh, GNUNET_YES);
+
+ GNUNET_NAMESTORE_lookup_name (nsh, NULL, NULL, 0, NULL, NULL);
//stop_arm ();
//end ();