aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 14:34:56 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 14:34:56 +0000
commit39670859fe230805056e8128c7c0bf5d5c92665b (patch)
tree424af2bf213d5a5df41905b21dc17e21af9454a0 /src
parent1cd1726ff32df42d13f6cc469bda4881b1f9fbc0 (diff)
downloadgnunet-39670859fe230805056e8128c7c0bf5d5c92665b.tar.gz
gnunet-39670859fe230805056e8128c7c0bf5d5c92665b.zip
-doxygen, more block plugin
Diffstat (limited to 'src')
-rw-r--r--src/gns/gnunet-gns-lookup.c12
-rw-r--r--src/gns/gnunet-service-gns.c12
-rw-r--r--src/gns/plugin_block_gns.c80
-rw-r--r--src/include/block_gns.h (renamed from src/gns/block_gns.h)0
-rw-r--r--src/include/gnunet_gns_service.h5
5 files changed, 90 insertions, 19 deletions
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)
104 * operation that expects a reply 104 * operation that expects a reply
105 * 105 *
106 * @param cls closure 106 * @param cls closure
107 * @param exp when will this value expire 107 * @param name name
108 * @param key key of the result 108 * @param record a record
109 * @param get_path peers on reply path (or NULL if not recorded) 109 * @param num_records number of records
110 * @param get_path_length number of entries in get_path
111 * @param put_path peers on the PUT path (or NULL if not recorded)
112 * @param put_path_length number of entries in get_path
113 * @param type type of the result
114 * @param size number of bytes in data
115 * @param data pointer to the result data
116 */ 110 */
117static void 111static void
118lookup_result_iterator (void *cls, 112lookup_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,
303 * Start DHT lookup for a name -> PKEY (compare NS) record in 303 * Start DHT lookup for a name -> PKEY (compare NS) record in
304 * query->authority's zone 304 * query->authority's zone
305 * 305 *
306 * @param query the pending gns query 306 * @param rh the pending gns query
307 * @param name the name of the PKEY record 307 * @param name the name of the PKEY record
308 */ 308 */
309void 309void
@@ -459,7 +459,7 @@ process_name_dht_result(void* cls,
459 * Start DHT lookup for a (name -> query->record_type) record in 459 * Start DHT lookup for a (name -> query->record_type) record in
460 * query->authority's zone 460 * query->authority's zone
461 * 461 *
462 * @param query the pending gns query 462 * @param rh the pending gns query context
463 * @param name the name to query record 463 * @param name the name to query record
464 */ 464 */
465void 465void
@@ -501,7 +501,7 @@ resolve_name(struct GNUNET_GNS_ResolverHandle *query, GNUNET_HashCode *zone);
501 * @param expiration expiration date of the record data set in the namestore 501 * @param expiration expiration date of the record data set in the namestore
502 * @param name the name for which we need an authority 502 * @param name the name for which we need an authority
503 * @param rd_count the number of records with 'name' 503 * @param rd_count the number of records with 'name'
504 * @param data the record data 504 * @param rd the record data
505 * @param signature the signature of the authority for the record data 505 * @param signature the signature of the authority for the record data
506 */ 506 */
507void 507void
@@ -697,7 +697,7 @@ reply_to_dns(struct GNUNET_GNS_ResolverHandle *rh, uint32_t rd_count,
697 * @param expiration expiration date of the namestore entry 697 * @param expiration expiration date of the namestore entry
698 * @param name the name for which we need an authority 698 * @param name the name for which we need an authority
699 * @param rd_count the number of records with 'name' 699 * @param rd_count the number of records with 'name'
700 * @param data the record data 700 * @param rd the record data
701 * @param signature the signature of the authority for the record data 701 * @param signature the signature of the authority for the record data
702 */ 702 */
703static void 703static void
@@ -854,7 +854,7 @@ char* pop_tld(char* name)
854 * If it is then try to resolve directly. 854 * If it is then try to resolve directly.
855 * If not then first have to resolve the authoritative entities. 855 * If not then first have to resolve the authoritative entities.
856 * 856 *
857 * @param query the pending lookup 857 * @param rh the pending lookup
858 * @param zone the zone we are currently resolving in 858 * @param zone the zone we are currently resolving in
859 */ 859 */
860void 860void
@@ -889,7 +889,7 @@ resolve_name(struct GNUNET_GNS_ResolverHandle *rh, GNUNET_HashCode *zone)
889 * 889 *
890 * Setup a new query and try to resolve 890 * Setup a new query and try to resolve
891 * 891 *
892 * @param rh the request handle of the DNS request from a client 892 * @param request the request handle of the DNS request from a client
893 * @param p the DNS query packet we received 893 * @param p the DNS query packet we received
894 * @param q the DNS query we received parsed from p 894 * @param q the DNS query we received parsed from p
895 */ 895 */
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,
61 size_t xquery_size, const void *reply_block, 61 size_t xquery_size, const void *reply_block,
62 size_t reply_block_size) 62 size_t reply_block_size)
63{ 63{
64 if (type != GNUNET_BLOCK_TYPE_GNS_RECORD) 64 if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
65 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 65 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
66
67 struct GNUNET_CRYPTO_RsaSignature *signature;
68 struct GNUNET_CRYPTO_RsaSignaturePurpose *purpose;
69 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key;
70 char* name;
71 GNUNET_HashCode pkey_hash;
72 GNUNET_HashCode query_pkey;
73 GNUNET_HashCode name_hash;
74
75 uint32_t rd_num;
76 uint32_t type;
77 struct GNUNET_TIME_AbsoluteNBO;
78 uint32_t data_length;
79 uint32_t flags;
80
81 char* pos = (char*) reply_block;
82 signature = pos;
83 pos += sizeof(struct GNUNET_CRYPTO_RsaSignature);
84 pos += sizeof(struct GNUNET_CRYPTO_RsaSignaturePurpose);
85
86 public_key = pos;
87 pos += sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);
88 name = pos;
89 pos += namelen(name); //Off by 1?
90
91 GNUNET_CRYPTO_hash(public_key,
92 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
93 &pkey_hash);
94
95 GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
96
97 GNUNET_CRYPTO_hash_xor(query, &name_hash, &query_pkey);
66 98
67 //FIXME check signatures here 99 //Check query key against public key
100 if (0 != GNUNET_CRYPTO_hash_cmp(&query_pkey, &pkey_hash))
101 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
102
103 rd_count = ntohl(*pos);
104 pos += sizeof(uint32_t);
105
106 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
107 int i = 0;
108
109 for (i=0; i<rd_count; i++)
110 {
111 rd[i].type = ntohl(*pos);
112 pos += sizeof(uint32_t);
113 rd[i].expiration =
114 GNUNET_TIME_relative_ntoh(*((struct GNUNET_TIME_AbsoluteNBO*)pos));
115 pos += sizeof(struct GNUNET_TIME_AbsoluteNBO);
116 rd[i].data_length = ntohl(*pos);
117 pos += sizeof(uint32_t);
118 rd[i].flags = ntohl(*pos);
119 pos += sizeof(uint32_t);
120 rd[i].data = pos;
121 pos += rd[i].data_length;
122 }
123
124 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (public_key,
125 name,
126 rd_count,
127 rd,
128 signature))
129 {
130 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Signature invalid\n");
131 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
132 }
133
134 //Cache
135 GNUNET_NAMESTORE_record_put (handle, //FIXME where do i get this from?
136 &pkey_hash,
137 name,
138 expiration, //FIXME uh where do i get this from?
139 rd_count,
140 rd,
141 signature,
142 NULL, //cont
143 NULL); //cls
68 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 144 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
69} 145}
70 146
diff --git a/src/gns/block_gns.h b/src/include/block_gns.h
index d34e33c5d..d34e33c5d 100644
--- a/src/gns/block_gns.h
+++ b/src/include/block_gns.h
diff --git a/src/include/gnunet_gns_service.h b/src/include/gnunet_gns_service.h
index 7f3fd77d3..242217866 100644
--- a/src/include/gnunet_gns_service.h
+++ b/src/include/gnunet_gns_service.h
@@ -121,13 +121,14 @@ typedef void (*GNUNET_GNS_LookupIterator) (void *cls,
121 * @param handle handle to the GNS service 121 * @param handle handle to the GNS service
122 * @param timeout how long to wait for transmission of this request to the service 122 * @param timeout how long to wait for transmission of this request to the service
123 * // FIXME: what happens afterwards? 123 * // FIXME: what happens afterwards?
124 * @param type expected type of the response object 124 * @param handle handle to the GNS service
125 * @param timeout timeout of request
125 * @param name the name to look up 126 * @param name the name to look up
126 * @param type the GNUNET_GNS_RecordType to look for 127 * @param type the GNUNET_GNS_RecordType to look for
127 * @param iter function to call on each result 128 * @param iter function to call on each result
128 * @param iter_cls closure for iter 129 * @param iter_cls closure for iter
129 * 130 *
130 * @return handle to stop the async get 131 * @return handle to stop the async lookup
131 */ 132 */
132struct GNUNET_GNS_LookupHandle * 133struct GNUNET_GNS_LookupHandle *
133GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle, 134GNUNET_GNS_lookup_start (struct GNUNET_GNS_Handle *handle,