From: Martin Schanzenbach Date: Sun, 26 Feb 2012 14:34:56 +0000 (+0000) Subject: -doxygen, more block plugin X-Git-Tag: initial-import-from-subversion-38251~14637 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=39670859fe230805056e8128c7c0bf5d5c92665b;p=oweals%2Fgnunet.git -doxygen, more block plugin --- diff --git a/src/gns/block_gns.h b/src/gns/block_gns.h deleted file mode 100644 index d34e33c5d..000000000 --- a/src/gns/block_gns.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - This file is part of GNUnet. - (C) 2012 Christian Grothoff (and other contributing authors) - - 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 3, or (at your - option) any later version. - - GNUnet is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -/** - * @file include/block_gns.h - * @brief fs block formats (shared between fs and block) - * @author Martin Schanzenbach - */ -#ifndef BLOCK_GNS_H -#define BLOCK_GNS_H - -#include "gnunet_util_lib.h" - -GNUNET_NETWORK_STRUCT_BEGIN - -/** - * @brief a simgle record inside a record block - */ -struct GNSRecordBlock -{ - /** - * the record type - */ - uint32_t type GNUNET_PACKED; - - /** - * expiration time of the record - */ - struct GNUNET_TIME_AbsoluteNBO expiration; - - /** - * length of the data - */ - uint32_t data_length GNUNET_PACKED; - - /* record flags */ - uint32_t flags GNUNET_PACKED; - - //Class of the record? - - /* followed by the record data */ -} - -/** - * @brief a record block for a given name of a single authority - */ -struct GNSNameRecordBlock -{ - - /** - * GNUNET_RSA_Signature using RSA-key generated from the records. - */ - struct GNUNET_CRYPTO_RsaSignature signature; - - /** - * What is being signed and why? - */ - struct GNUNET_CRYPTO_RsaSignaturePurpose purpose; - - /** - * The public key of the authority - */ - struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; - - /* 0-terminated name here */ - - /* number of records that follow */ - uint32_t rd_num GNUNET_PACKED; - - /* variable-size GNSRecordBlocks follows here */ - - -}; - -GNUNET_NETWORK_STRUCT_END -#endif diff --git a/src/gns/gnunet-gns-lookup.c b/src/gns/gnunet-gns-lookup.c index 5adb4064e..f33264f61 100644 --- a/src/gns/gnunet-gns-lookup.c +++ b/src/gns/gnunet-gns-lookup.c @@ -104,15 +104,9 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) * operation that expects a reply * * @param cls closure - * @param exp when will this value expire - * @param key key of the result - * @param get_path peers on reply path (or NULL if not recorded) - * @param get_path_length number of entries in get_path - * @param put_path peers on the PUT path (or NULL if not recorded) - * @param put_path_length number of entries in get_path - * @param type type of the result - * @param size number of bytes in data - * @param data pointer to the result data + * @param name name + * @param record a record + * @param num_records number of records */ static void lookup_result_iterator (void *cls, diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index e4e28c14b..d2cb477f6 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c @@ -303,7 +303,7 @@ process_authority_dht_result(void* cls, * Start DHT lookup for a name -> PKEY (compare NS) record in * query->authority's zone * - * @param query the pending gns query + * @param rh the pending gns query * @param name the name of the PKEY record */ void @@ -459,7 +459,7 @@ process_name_dht_result(void* cls, * Start DHT lookup for a (name -> query->record_type) record in * query->authority's zone * - * @param query the pending gns query + * @param rh the pending gns query context * @param name the name to query record */ void @@ -501,7 +501,7 @@ resolve_name(struct GNUNET_GNS_ResolverHandle *query, GNUNET_HashCode *zone); * @param expiration expiration date of the record data set in the namestore * @param name the name for which we need an authority * @param rd_count the number of records with 'name' - * @param data the record data + * @param rd the record data * @param signature the signature of the authority for the record data */ void @@ -697,7 +697,7 @@ reply_to_dns(struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count, * @param expiration expiration date of the namestore entry * @param name the name for which we need an authority * @param rd_count the number of records with 'name' - * @param data the record data + * @param rd the record data * @param signature the signature of the authority for the record data */ static void @@ -854,7 +854,7 @@ char* pop_tld(char* name) * If it is then try to resolve directly. * If not then first have to resolve the authoritative entities. * - * @param query the pending lookup + * @param rh the pending lookup * @param zone the zone we are currently resolving in */ void @@ -889,7 +889,7 @@ resolve_name(struct GNUNET_GNS_ResolverHandle *rh, GNUNET_HashCode *zone) * * Setup a new query and try to resolve * - * @param rh the request handle of the DNS request from a client + * @param request the request handle of the DNS request from a client * @param p the DNS query packet we received * @param q the DNS query we received parsed from p */ diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index 33699a32c..1a33b2d1a 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c @@ -61,10 +61,86 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, size_t xquery_size, const void *reply_block, size_t reply_block_size) { - if (type != GNUNET_BLOCK_TYPE_GNS_RECORD) + if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; + + struct GNUNET_CRYPTO_RsaSignature *signature; + struct GNUNET_CRYPTO_RsaSignaturePurpose *purpose; + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key; + char* name; + GNUNET_HashCode pkey_hash; + GNUNET_HashCode query_pkey; + GNUNET_HashCode name_hash; + + uint32_t rd_num; + uint32_t type; + struct GNUNET_TIME_AbsoluteNBO; + uint32_t data_length; + uint32_t flags; + + char* pos = (char*) reply_block; + signature = pos; + pos += sizeof(struct GNUNET_CRYPTO_RsaSignature); + pos += sizeof(struct GNUNET_CRYPTO_RsaSignaturePurpose); + + public_key = pos; + pos += sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded); + name = pos; + pos += namelen(name); //Off by 1? + + GNUNET_CRYPTO_hash(public_key, + sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + &pkey_hash); + + GNUNET_CRYPTO_hash(name, strlen(name), &name_hash); + + GNUNET_CRYPTO_hash_xor(query, &name_hash, &query_pkey); - //FIXME check signatures here + //Check query key against public key + if (0 != GNUNET_CRYPTO_hash_cmp(&query_pkey, &pkey_hash)) + return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; + + rd_count = ntohl(*pos); + pos += sizeof(uint32_t); + + struct GNUNET_NAMESTORE_RecordData rd[rd_count]; + int i = 0; + + for (i=0; i