aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/namestore_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-10-18 15:37:21 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-10-18 15:37:21 +0000
commitf38103524a5e65207ae029f7de0b880c6072e19f (patch)
treed936f5751dfd730bd1f0a8c0b9b32fe79cb20330 /src/namestore/namestore_api.c
parente7d3bc3354b7d3cba8a9482afc742e1ffe342afe (diff)
downloadgnunet-f38103524a5e65207ae029f7de0b880c6072e19f.tar.gz
gnunet-f38103524a5e65207ae029f7de0b880c6072e19f.zip
implementing api call
Diffstat (limited to 'src/namestore/namestore_api.c')
-rw-r--r--src/namestore/namestore_api.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index efdc3005b..8d3ea16dd 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -982,6 +982,60 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
982 982
983 983
984/** 984/**
985 * Lookup an item in the namestore.
986 *
987 * @param h handle to the namestore
988 * @param pkey private key of the zone
989 * @param label name that is being mapped (at most 255 characters long)
990 * @param rm function to call with the result (with 0 records if we don't have that label)
991 * @param rm_cls closure for @a rm
992 * @return handle to abort the request
993 */
994struct GNUNET_NAMESTORE_QueueEntry *
995GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h,
996 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey,
997 const char *label,
998 GNUNET_NAMESTORE_RecordMonitor rm,
999 void *rm_cls)
1000{
1001 struct GNUNET_NAMESTORE_QueueEntry *qe;
1002 struct PendingMessage *pe;
1003 struct LabelLookupMessage * msg;
1004 size_t msg_size;
1005 size_t label_len;
1006
1007 GNUNET_assert (NULL != h);
1008 GNUNET_assert (NULL != pkey);
1009 GNUNET_assert (NULL != label);
1010
1011 if (1 == (label_len = strlen (label) + 1))
1012 return NULL;
1013
1014 qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry);
1015 qe->nsh = h;
1016 qe->proc = rm;
1017 qe->proc_cls = rm_cls;
1018 qe->op_id = get_op_id(h);
1019 GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
1020
1021 msg_size = sizeof (struct LabelLookupMessage) + label_len;
1022 pe = GNUNET_malloc (sizeof (struct PendingMessage) + msg_size);
1023 pe->size = msg_size;
1024 msg = (struct LabelLookupMessage *) &pe[1];
1025 msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_LABEL_LOOKUP);
1026 msg->gns_header.header.size = htons (msg_size);
1027 msg->gns_header.r_id = htonl (qe->op_id);
1028 msg->zone = *pkey;
1029 msg->label_len = htons(label_len);
1030
1031 /* transmit message */
1032 GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
1033 do_transmit (h);
1034 return qe;
1035}
1036
1037
1038/**
985 * Look for an existing PKEY delegation record for a given public key. 1039 * Look for an existing PKEY delegation record for a given public key.
986 * Returns at most one result to the processor. 1040 * Returns at most one result to the processor.
987 * 1041 *