aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 17:51:46 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-02-26 17:51:46 +0000
commit8be6916ef54f9952b099276d63ef1ebe4b88d4d6 (patch)
tree8726543afbca1a3937223b91e74cb613c400b11f /src
parentf897fb93d7c425eecd1611a06280bff508257f72 (diff)
downloadgnunet-8be6916ef54f9952b099276d63ef1ebe4b88d4d6.tar.gz
gnunet-8be6916ef54f9952b099276d63ef1ebe4b88d4d6.zip
-block compiles and added to makefile
Diffstat (limited to 'src')
-rw-r--r--src/gns/Makefile.am10
-rw-r--r--src/gns/plugin_block_gns.c60
-rw-r--r--src/include/block_gns.h4
3 files changed, 46 insertions, 28 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 9f947b2c1..52776993e 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -27,6 +27,9 @@ bin_PROGRAMS = \
27check_SCRIPTS = \ 27check_SCRIPTS = \
28 test_gnunet_gns.sh 28 test_gnunet_gns.sh
29 29
30plugin_LTLIBRARIES = \
31 libgnunet_plugin_block_gns.la
32
30#gnunet_gns_lookup_SOURCES = \ 33#gnunet_gns_lookup_SOURCES = \
31# gnunet-gns-lookup.c 34# gnunet-gns-lookup.c
32#gnunet_gns_lookup_LDADD = \ 35#gnunet_gns_lookup_LDADD = \
@@ -56,6 +59,13 @@ libgnunetgns_la_LIBADD = \
56libgnunetgns_la_LDFLAGS = \ 59libgnunetgns_la_LDFLAGS = \
57 $(GN_LIB_LDFLAGS) 60 $(GN_LIB_LDFLAGS)
58 61
62libgnunet_plugin_block_gns_la_SOURCES = \
63 plugin_block_gns.c
64libgnunet_plugin_block_gns_la_LIBADD = \
65 $(top_builddir)/src/util/libgnunetutil.la
66libgnunet_plugin_block_gns_la_LDFLAGS = \
67 $(top_builddir)/src/block/$(GN_PLUGIN_LDFLAGS)
68
59#Build stub api 69#Build stub api
60libgnunetnamestore_la_SOURCES = \ 70libgnunetnamestore_la_SOURCES = \
61 namestore_stub_api.c 71 namestore_stub_api.c
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index 7bf4e29cd..f31b9a9c4 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -26,6 +26,7 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_block_plugin.h" 28#include "gnunet_block_plugin.h"
29#include "gnunet_namestore_service.h"
29#include "block_gns.h" 30#include "block_gns.h"
30#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
31 32
@@ -35,6 +36,9 @@
35 */ 36 */
36#define BLOOMFILTER_K 16 37#define BLOOMFILTER_K 16
37 38
39//Not taken until now
40#define GNUNET_BLOCK_TYPE_GNS_NAMERECORD 11
41
38/** 42/**
39 * Function called to validate a reply or a request. For 43 * Function called to validate a reply or a request. For
40 * request evaluation, simply pass "NULL" for the reply_block. 44 * request evaluation, simply pass "NULL" for the reply_block.
@@ -63,27 +67,20 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
63{ 67{
64 if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) 68 if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
65 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 69 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
66 70
67 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key;
68 char* name; 71 char* name;
69 GNUNET_HashCode pkey_hash; 72 GNUNET_HashCode pkey_hash;
70 GNUNET_HashCode query_pkey; 73 GNUNET_HashCode query_pkey;
71 GNUNET_HashCode name_hash; 74 GNUNET_HashCode name_hash;
72 struct GNSNameRecordBlock *nrb; 75 struct GNSNameRecordBlock *nrb;
73 struct GNSRecordBlock *rb; 76 struct GNSRecordBlock *rb;
77 uint32_t rd_count;
74 78
75 uint32_t rd_num; 79 nrb = (struct GNSNameRecordBlock *)reply_block;
76 uint32_t type;
77 struct GNUNET_TIME_AbsoluteNBO;
78 uint32_t data_length;
79 uint32_t flags;
80 80
81 char* pos = (char*) reply_block; 81 name = (char*)&nrb[1];
82 nrb = reply_block;
83 82
84 name = &nrb[1]; 83 GNUNET_CRYPTO_hash(&nrb->public_key,
85
86 GNUNET_CRYPTO_hash(nrb->public_key,
87 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), 84 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
88 &pkey_hash); 85 &pkey_hash);
89 86
@@ -95,35 +92,35 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
95 if (0 != GNUNET_CRYPTO_hash_cmp(&query_pkey, &pkey_hash)) 92 if (0 != GNUNET_CRYPTO_hash_cmp(&query_pkey, &pkey_hash))
96 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 93 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
97 94
98 rd_count = ntohl(nrb->rd_num); 95 rd_count = ntohl(nrb->rd_count);
99 96
100 struct GNUNET_NAMESTORE_RecordData rd[rd_count]; 97 struct GNUNET_NAMESTORE_RecordData rd[rd_count];
101 int i = 0; 98 int i = 0;
102 rb = &nrb[1] + strlen(name); 99 rb = (struct GNSRecordBlock*)(&nrb[1] + strlen(name));
103 100
104 for (i=0; i<rd_count; i++) 101 for (i=0; i<rd_count; i++)
105 { 102 {
106 rd[i].type = ntohl(rb->type); 103 rd[i].record_type = ntohl(rb->type);
107 rd[i].expiration = 104 rd[i].expiration =
108 GNUNET_TIME_relative_ntoh(rb->expiration); 105 GNUNET_TIME_absolute_ntoh(rb->expiration);
109 rd[i].data_length = ntohl(rb->data_length); 106 rd[i].data_size = ntohl(rb->data_length);
110 rd[i].flags = ntohl(rb->flags); 107 rd[i].flags = ntohl(rb->flags);
111 rd[i].data = rb[1]; 108 rd[i].data = (char*)&rb[1];
112 rb = &rb[1] + rd[i].data_length; 109 rb = &rb[1] + rd[i].data_size;
113 } 110 }
114 111
115 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (nrb->public_key, 112 if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key,
116 name, 113 name,
117 nrb->rd_count, 114 nrb->rd_count,
118 rd, 115 rd,
119 nrb->signature)) 116 &nrb->signature))
120 { 117 {
121 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Signature invalid\n"); 118 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Signature invalid\n");
122 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 119 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
123 } 120 }
124 121
125 //Cache 122 //Cache FIXME we need a static function here to namestore?
126 GNUNET_NAMESTORE_record_put (handle, //FIXME where do i get this from? 123 /*GNUNET_NAMESTORE_record_put (handle, //FIXME where do i get this from?
127 &pkey_hash, 124 &pkey_hash,
128 name, 125 name,
129 expiration, //FIXME uh where do i get this from? 126 expiration, //FIXME uh where do i get this from?
@@ -131,7 +128,7 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
131 rd, 128 rd,
132 signature, 129 signature,
133 NULL, //cont 130 NULL, //cont
134 NULL); //cls 131 NULL); //cls*/
135 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; 132 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
136} 133}
137 134
@@ -152,8 +149,19 @@ block_plugin_gns_get_key (void *cls, enum GNUNET_BLOCK_Type type,
152 const void *block, size_t block_size, 149 const void *block, size_t block_size,
153 GNUNET_HashCode * key) 150 GNUNET_HashCode * key)
154{ 151{
155 if (type != GNUNET_BLOCK_TYPE_GNS_RECORD) 152 if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD)
156 return GNUNET_NO; 153 return GNUNET_NO;
154 GNUNET_HashCode name_hash;
155 GNUNET_HashCode pkey_hash;
156 struct GNSNameRecordBlock *nrb = (struct GNSNameRecordBlock *)block;
157
158 GNUNET_CRYPTO_hash(&nrb[1], strlen((char*)&nrb[1]), &name_hash);
159 GNUNET_CRYPTO_hash(&nrb->public_key,
160 sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
161 &pkey_hash);
162
163 GNUNET_CRYPTO_hash_xor(&name_hash, &pkey_hash, key);
164
157 //FIXME calculate key from name and hash(pkey) here 165 //FIXME calculate key from name and hash(pkey) here
158 return GNUNET_OK; 166 return GNUNET_OK;
159} 167}
@@ -167,7 +175,7 @@ libgnunet_plugin_block_gns_init (void *cls)
167{ 175{
168 static enum GNUNET_BLOCK_Type types[] = 176 static enum GNUNET_BLOCK_Type types[] =
169 { 177 {
170 GNUNET_BLOCK_TYPE_GNS_RECORD, 178 GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
171 GNUNET_BLOCK_TYPE_ANY /* end of list */ 179 GNUNET_BLOCK_TYPE_ANY /* end of list */
172 }; 180 };
173 struct GNUNET_BLOCK_PluginFunctions *api; 181 struct GNUNET_BLOCK_PluginFunctions *api;
diff --git a/src/include/block_gns.h b/src/include/block_gns.h
index 99f019a11..4514acf6b 100644
--- a/src/include/block_gns.h
+++ b/src/include/block_gns.h
@@ -56,7 +56,7 @@ struct GNSRecordBlock
56 //Class of the record? 56 //Class of the record?
57 57
58 /* followed by the record data */ 58 /* followed by the record data */
59} 59};
60 60
61/** 61/**
62 * @brief a record block for a given name of a single authority 62 * @brief a record block for a given name of a single authority
@@ -80,7 +80,7 @@ struct GNSNameRecordBlock
80 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; 80 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key;
81 81
82 /* number of records that follow */ 82 /* number of records that follow */
83 uint32_t rd_num GNUNET_PACKED; 83 uint32_t rd_count GNUNET_PACKED;
84 84
85 /* 0-terminated name here */ 85 /* 0-terminated name here */
86 86