- * Store an item in the namestore. If the item is already present,
- * the expiration time is updated to the max of the existing time and
- * the new time. This API is used when we cache signatures from other
- * authorities.
- *
- * @param h handle to the namestore
- * @param zone_key public key of the zone
- * @param name name that is being mapped (at most 255 characters long)
- * @param freshness when does the corresponding block in the DHT expire (until
- * when should we never do a DHT lookup for the same name again)?
- * @param rd_count number of entries in 'rd' array
- * @param rd array of records with data to store
- * @param signature signature for all the records in the zone under the given name
- * @param cont continuation to call when done
- * @param cont_cls closure for cont
- * @return handle to abort the request
- */
-struct GNUNET_NAMESTORE_QueueEntry *
-GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
- const char *name,
- struct GNUNET_TIME_Absolute freshness,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_RsaSignature *signature,
- GNUNET_NAMESTORE_ContinuationWithStatus cont,
- void *cont_cls)
-{
- struct GNUNET_NAMESTORE_QueueEntry *qe;
- struct PendingMessage *pe;
- struct RecordPutMessage * msg;
- char * rd_ser;
- char * name_tmp;
- size_t msg_size;
- size_t name_len;
- size_t rd_ser_len;
- uint32_t rid;
-
- GNUNET_assert (NULL != h);
- GNUNET_assert (NULL != zone_key);
- GNUNET_assert (NULL != name);
- GNUNET_assert (NULL != rd);
- GNUNET_assert (NULL != signature);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Storing %u records under name `%s'\n",
- rd_count,
- name);
- name_len = strlen(name) + 1;
- if (name_len > MAX_NAME_LEN)
- {
- GNUNET_break (0);
- return NULL;
- }
- rid = get_op_id (h);
- qe = GNUNET_malloc(sizeof (struct GNUNET_NAMESTORE_QueueEntry));
- qe->nsh = h;
- qe->cont = cont;
- qe->cont_cls = cont_cls;
- qe->op_id = rid;
- GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, qe);
-
- /* setup msg */
- rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd);
- msg_size = sizeof (struct RecordPutMessage) + name_len + rd_ser_len;
- pe = GNUNET_malloc(sizeof (struct PendingMessage) + msg_size);
- pe->size = msg_size;
- pe->is_init = GNUNET_NO;
- msg = (struct RecordPutMessage *) &pe[1];
- msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT);
- msg->gns_header.header.size = htons (msg_size);
- msg->gns_header.r_id = htonl (rid);
- msg->signature = *signature;
- msg->name_len = htons (name_len);
- msg->expire = GNUNET_TIME_absolute_hton (freshness);
- msg->rd_len = htons (rd_ser_len);
- msg->rd_count = htons (rd_count);
- msg->public_key = *zone_key;
- name_tmp = (char *) &msg[1];
- memcpy (name_tmp, name, name_len);
- rd_ser = &name_tmp[name_len];
- GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Sending `%s' message for name `%s' with size %u\n",
- "NAMESTORE_RECORD_PUT",
- name, msg_size);
- GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
- do_transmit(h);
- return qe;
-}
-
-
-/**
- * Check if a signature is valid. This API is used by the GNS Block
- * to validate signatures received from the network.