GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
+ by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
/**
* @file dns/dns_api.c
- * @brief API to access the DNS service.
+ * @brief API to access the DNS service.
* @author Christian Grothoff
*/
#include "platform.h"
* Function to call to get replies.
*/
GNUNET_DNS_RequestHandler rh;
-
+
/**
* Closure for 'rh'.
*/
* Re-connect counter, to make sure we did not reconnect in the meantime.
*/
uint32_t generation;
-
+
/**
* Flags for events we care about.
*/
}
if (NULL != dh->dns_connection)
{
- GNUNET_CLIENT_disconnect (dh->dns_connection, GNUNET_NO);
+ GNUNET_CLIENT_disconnect (dh->dns_connection);
dh->dns_connection = NULL;
}
while (NULL != (qe = dh->rq_head))
req = (const struct GNUNET_DNS_Request *) msg;
GNUNET_break (ntohl (req->reserved) == 0);
payload_length = ntohs (req->header.size) - sizeof (struct GNUNET_DNS_Request);
- GNUNET_CLIENT_receive (dh->dns_connection,
+ GNUNET_CLIENT_receive (dh->dns_connection,
&request_handler, dh,
GNUNET_TIME_UNIT_FOREVER_REL);
/* finally, pass request to callback for answers */
- rh = GNUNET_malloc (sizeof (struct GNUNET_DNS_RequestHandle));
+ rh = GNUNET_new (struct GNUNET_DNS_RequestHandle);
rh->dh =dh;
rh->request_id = req->request_id;
- rh->generation = dh->generation;
+ rh->generation = dh->generation;
dh->pending_requests++;
dh->rh (dh->rh_cls,
rh,
struct GNUNET_DNS_Handle *dh = cls;
struct ReplyQueueEntry *qe;
size_t len;
-
+
dh->dns_transmit_handle = NULL;
if (NULL == buf)
{
return 0;
len = ntohs (qe->msg->size);
if (len > size)
- {
+ {
dh->dns_transmit_handle =
GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection,
len,
GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_NO,
+ GNUNET_NO,
&send_response, dh);
return 0;
}
if (GNUNET_NO == dh->in_receive)
{
dh->in_receive = GNUNET_YES;
- GNUNET_CLIENT_receive (dh->dns_connection,
+ GNUNET_CLIENT_receive (dh->dns_connection,
&request_handler, dh,
GNUNET_TIME_UNIT_FOREVER_REL);
}
GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection,
ntohs (qe->msg->size),
GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_NO,
+ GNUNET_NO,
&send_response, dh);
}
return len;
-}
+}
/**
queue_reply (struct GNUNET_DNS_Handle *dh,
struct ReplyQueueEntry *qe)
{
- if (NULL == dh->dns_connection)
+ if (NULL == dh->dns_connection)
{
GNUNET_free (qe);
return;
qe);
if (NULL != dh->dns_transmit_handle)
return;
- /* trigger sending */
+ /* trigger sending */
dh->dns_transmit_handle =
GNUNET_CLIENT_notify_transmit_ready (dh->dns_connection,
ntohs (dh->rq_head->msg->size),
GNUNET_TIME_UNIT_FOREVER_REL,
- GNUNET_NO,
+ GNUNET_NO,
&send_response, dh);
}
* @param reply reply data
*/
void
-GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh,
+GNUNET_DNS_request_answer (struct GNUNET_DNS_RequestHandle *rh,
uint16_t reply_length,
const char *reply)
{
* @param flags when to call rh
* @param rh function to call with DNS requests
* @param rh_cls closure to pass to rh
- * @return DNS handle
+ * @return DNS handle
*/
struct GNUNET_DNS_Handle *
GNUNET_DNS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
void *rh_cls)
{
struct GNUNET_DNS_Handle *dh;
-
- dh = GNUNET_malloc (sizeof (struct GNUNET_DNS_Handle));
+
+ dh = GNUNET_new (struct GNUNET_DNS_Handle);
dh->cfg = cfg;
dh->flags = flags;
dh->rh = rh;