36#define LOG(kind, ...) GNUNET_log_from (kind, "gns-api", __VA_ARGS__)
42#define DEFAULT_LIMIT 128
105 handle->reconnect_task = NULL;
144 "Problem with message queue. error: %i\n",
160 size_t mlen = ntohs (lookup_msg->
header.
size) -
sizeof(*lookup_msg);
167 (
const char *) &lookup_msg[1],
189 size_t mlen = ntohs (lookup_msg->
header.
size) -
sizeof(*lookup_msg);
192 uint32_t r_id = ntohl (lookup_msg->
id);
198 "Received lookup reply from GNS service (%u records)\n",
211 char *) &lookup_msg[1],
244 "Trying to connect to GNS\n");
296 if (NULL !=
handle->reconnect_task)
299 handle->reconnect_task = NULL;
348 uint16_t recursion_depth_limit,
366 "Trying to lookup `%s' in GNS\n",
368 nlen = strlen (
name) + 1;
383 buf = (
char *) &lookup_msg[1];
384 lookup_msg->
id = htonl (
lr->r_id);
387 = htons (recursion_depth_limit);
388 lookup_msg->
key_len = htonl (key_len);
struct GNUNET_GETOPT_CommandLineOption options[]
struct GNUNET_MQ_MessageHandlers handlers[]
IPC messages between GNS API and GNS service.
static void handle_result(void *cls, const struct LookupResultMessage *lookup_msg)
Handler for messages received from the GNS service.
static void force_reconnect(struct GNUNET_GNS_Handle *handle)
Disconnect from service and then reconnect.
static void mq_error_handler(void *cls, enum GNUNET_MQ_Error error)
Generic error handler, called with the appropriate error code and the same closure specified at the c...
static int check_result(void *cls, const struct LookupResultMessage *lookup_msg)
Check validity of message received from the GNS service.
static void reconnect(struct GNUNET_GNS_Handle *handle)
Reconnect to GNS service.
#define DEFAULT_LIMIT
Default recursion depth limit to apply if the application does not specify any.
static void reconnect_task(void *cls)
Reconnect to GNS.
shared data structures of libgnunetgns
static int ret
Final status code.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_GNS_LookupWithTldRequest * lr
Handle to lookup request.
static char * name
Name (label) of the records to list.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static uint32_t type
Type string converted to DNS type value.
static int result
Global testing status.
static struct GNUNET_VPN_Handle * handle
Handle to vpn service.
Constants for network protocols.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
struct GNUNET_MQ_Handle * GNUNET_CLIENT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name, const struct GNUNET_MQ_MessageHandler *handlers, GNUNET_MQ_ErrorHandler error_handler, void *error_handler_cls)
Create a message queue to connect to a GNUnet service.
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_CRYPTO_PublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS.
void(* GNUNET_GNS_LookupResultProcessor)(void *cls, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Iterator called on obtained result for a GNS lookup.
void * GNUNET_GNS_lookup_cancel(struct GNUNET_GNS_LookupRequest *lr)
Cancel pending lookup request.
GNUNET_GNS_LocalOptions
Options for the GNS lookup.
struct GNUNET_GNS_LookupRequest * GNUNET_GNS_lookup_limited(struct GNUNET_GNS_Handle *handle, const char *name, const struct GNUNET_CRYPTO_PublicKey *zone, uint32_t type, enum GNUNET_GNS_LocalOptions options, uint16_t recursion_depth_limit, GNUNET_GNS_LookupResultProcessor proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
int GNUNET_GNSRECORD_records_deserialize(size_t len, const char *src, unsigned int rd_count, struct GNUNET_GNSRECORD_Data *dest)
Deserialize the given records to the given destination.
ssize_t GNUNET_CRYPTO_public_key_get_length(const struct GNUNET_CRYPTO_PublicKey *key)
Get the compacted length of a GNUNET_CRYPTO_PublicKey.
ssize_t GNUNET_CRYPTO_write_public_key_to_buffer(const struct GNUNET_CRYPTO_PublicKey *key, void *buffer, size_t len)
Writes a GNUNET_CRYPTO_PublicKey to a compact buffer.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_send_copy(struct GNUNET_MQ_Handle *mq, const struct GNUNET_MQ_Envelope *ev)
Send a copy of a message with the given message queue.
GNUNET_MQ_Error
Error codes for the queue.
#define GNUNET_MQ_handler_end()
End-marker for the handlers array.
void GNUNET_MQ_discard(struct GNUNET_MQ_Envelope *mqm)
Discard the message queue message, free all allocated resources.
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct.
#define GNUNET_MQ_hd_var_size(name, code, str, ctx)
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP
Client would like to resolve a name.
#define GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT
Service response to name resolution request from client.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define GNUNET_TIME_STD_BACKOFF(r)
Perform our standard exponential back-off calculation, starting at 1 ms and then going by a factor of...
An identity key as per LSD0001.
Connection to the GNS service.
Handle to a lookup request.
void * proc_cls
lookup_proc closure
struct GNUNET_GNS_LookupRequest * next
DLL.
struct GNUNET_GNS_LookupRequest * prev
DLL.
GNUNET_GNS_LookupResultProcessor lookup_proc
processor to call on lookup result
struct GNUNET_MQ_Envelope * env
Envelope with the message for this queue entry.
struct GNUNET_GNS_Handle * gns_handle
handle to gns
GNUNET_GNS_LookupResultProcessor2 lookup_proc
processor to call on lookup result
struct GNUNET_GNS_Handle * gns_handle
handle to gns
Message handler for a specific message type.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
struct GNUNET_MQ_Handle * mq
Connection to VPN service.
Message from client to GNS service to lookup records.
int16_t options
Local options for where to look for results (an enum GNUNET_GNS_LocalOptions in NBO).
uint32_t id
Unique identifier for this request (for key collisions).
uint32_t key_len
Length of the zone key.
uint16_t recursion_depth_limit
Recursion depth limit, i.e.
int32_t type
the type of record to look up
Message from GNS service to client: new results.
struct GNUNET_MessageHeader header
Header of type GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT.
uint32_t id
Unique identifier for this request (for key collisions).
uint32_t rd_count
The number of records contained in response.