-
-/**
- * Perform an asynchronous Lookup operation on the GNS.
- *
- * @param handle handle to the GNS service
- * @param name the name to look up
- * @param type the record type to look up
- * @param only_cached GNUNET_YES to only check locally not DHT for performance
- * @param shorten_key the private key of the shorten zone (can be NULL)
- * @param proc processor to call on result
- * @param proc_cls closure for processor
- * @return handle to the lookup request
- */
-struct GNUNET_GNS_LookupRequest*
-GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
- const char * name,
- enum GNUNET_GNS_RecordType type,
- int only_cached,
- struct GNUNET_CRYPTO_RsaPrivateKey *shorten_key,
- GNUNET_GNS_LookupResultProcessor proc,
- void *proc_cls)
-{
- return GNUNET_GNS_lookup_zone (handle, name,
- NULL,
- type, only_cached,
- shorten_key,
- proc, proc_cls);
-}
-
-
-/**
- * Perform a name shortening operation on the GNS.
- *
- * @param handle handle to the GNS service
- * @param name the name to look up
- * @param private_zone the public zone of the private zone
- * @param shorten_zone the public zone of the shorten zone
- * @param zone the zone to start the resolution in
- * @param proc function to call on result
- * @param proc_cls closure for processor
- * @return handle to the operation
- */
-struct GNUNET_GNS_ShortenRequest*
-GNUNET_GNS_shorten_zone (struct GNUNET_GNS_Handle *handle,
- const char * name,
- struct GNUNET_CRYPTO_ShortHashCode *private_zone,
- struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
- struct GNUNET_CRYPTO_ShortHashCode *zone,
- GNUNET_GNS_ShortenResultProcessor proc,
- void *proc_cls)
-{
- /* IPC to shorten gns names, return shorten_handle */
- struct GNUNET_GNS_ClientShortenMessage *shorten_msg;
- struct GNUNET_GNS_ShortenRequest *sr;
- size_t msize;
- struct PendingMessage *pending;
-
- if (NULL == name)
- {
- GNUNET_break (0);
- return NULL;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to shorten %s in GNS\n", name);
-
- msize = sizeof (struct GNUNET_GNS_ClientShortenMessage) + strlen(name) + 1;
- sr = GNUNET_malloc (sizeof (struct GNUNET_GNS_ShortenRequest));
- sr->gns_handle = handle;
- sr->shorten_proc = proc;
- sr->proc_cls = proc_cls;
- sr->r_id = handle->r_id++;
- GNUNET_CONTAINER_DLL_insert_tail (handle->shorten_head,
- handle->shorten_tail, sr);
-
- pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
- pending->size = msize;
- pending->r_id = sr->r_id;
-
- shorten_msg = (struct GNUNET_GNS_ClientShortenMessage *) &pending[1];
- shorten_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_SHORTEN);
- shorten_msg->header.size = htons (msize);
- shorten_msg->id = htonl (sr->r_id);
- shorten_msg->private_zone = *private_zone;
- shorten_msg->shorten_zone = *shorten_zone;
-
- if (NULL != zone)
- {
- shorten_msg->use_default_zone = htonl (GNUNET_NO);
- memcpy (&shorten_msg->zone, zone,
- sizeof (struct GNUNET_CRYPTO_ShortHashCode));
- }
- else
- {
- shorten_msg->use_default_zone = htonl (GNUNET_YES);
- memset (&shorten_msg->zone, 0, sizeof (struct GNUNET_CRYPTO_ShortHashCode));
- }
-
- memcpy (&shorten_msg[1], name, strlen (name) + 1);
-
- GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail,
- pending);
-
- process_pending_messages (handle);
- return sr;
-}
-
-
-/**
- * Perform a name shortening operation on the GNS.
- *
- * @param handle handle to the GNS service
- * @param name the name to look up
- * @param private_zone the public zone of the private zone
- * @param shorten_zone the public zone of the shorten zone
- * @param proc function to call on result
- * @param proc_cls closure for processor
- * @return handle to the operation
- */
-struct GNUNET_GNS_ShortenRequest*
-GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
- const char * name,
- struct GNUNET_CRYPTO_ShortHashCode *private_zone,
- struct GNUNET_CRYPTO_ShortHashCode *shorten_zone,
- GNUNET_GNS_ShortenResultProcessor proc,
- void *proc_cls)
-{
- return GNUNET_GNS_shorten_zone (handle, name,
- private_zone, shorten_zone,
- NULL, proc, proc_cls);
-}
-
-
-/**
- * Perform an authority lookup for a given name.
- *
- * @param handle handle to the GNS service
- * @param name the name to look up authority for
- * @param proc function to call on result
- * @param proc_cls closure for processor
- * @return handle to the operation
- */
-struct GNUNET_GNS_GetAuthRequest*
-GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
- const char * name,
- GNUNET_GNS_GetAuthResultProcessor proc,
- void *proc_cls)
-{
- struct GNUNET_GNS_ClientGetAuthMessage *get_auth_msg;
- struct GNUNET_GNS_GetAuthRequest *gar;
- size_t msize;
- struct PendingMessage *pending;
-
- if (NULL == name)
- {
- GNUNET_break (0);
- return NULL;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Trying to look up authority for %s in GNS\n", name);
-
- msize = sizeof (struct GNUNET_GNS_ClientGetAuthMessage) + strlen (name) + 1;
- gar = GNUNET_malloc (sizeof (struct GNUNET_GNS_GetAuthRequest));
- gar->gns_handle = handle;
- gar->auth_proc = proc;
- gar->proc_cls = proc_cls;
- gar->r_id = handle->r_id++;
- GNUNET_CONTAINER_DLL_insert_tail (handle->get_auth_head,
- handle->get_auth_tail, gar);
-
- pending = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
- pending->size = msize;
- pending->r_id = gar->r_id;
- get_auth_msg = (struct GNUNET_GNS_ClientGetAuthMessage *) &pending[1];
- get_auth_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_GET_AUTH);
- get_auth_msg->header.size = htons (msize);
- get_auth_msg->id = htonl (gar->r_id);
- memcpy (&get_auth_msg[1], name, strlen(name) + 1);
-
- GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head,
- handle->pending_tail,
- pending);
- process_pending_messages (handle);
- return gar;
-}
-
-