aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/block/plugin_block_test.c6
-rw-r--r--src/fs/plugin_block_fs.c1
-rw-r--r--src/include/gnunet_block_lib.h7
-rw-r--r--src/mesh/plugin_block_mesh.c77
-rw-r--r--src/namestore/gnunet-service-namestore.c37
5 files changed, 95 insertions, 33 deletions
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c
index e6b4f4960..dacf04535 100644
--- a/src/block/plugin_block_test.c
+++ b/src/block/plugin_block_test.c
@@ -28,8 +28,6 @@
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_block_plugin.h" 29#include "gnunet_block_plugin.h"
30 30
31#define DEBUG_TEST GNUNET_EXTRA_LOGGING
32
33 31
34/** 32/**
35 * Number of bits we set per entry in the bloomfilter. 33 * Number of bits we set per entry in the bloomfilter.
@@ -63,9 +61,9 @@ block_plugin_test_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
63 struct GNUNET_HashCode chash; 61 struct GNUNET_HashCode chash;
64 struct GNUNET_HashCode mhash; 62 struct GNUNET_HashCode mhash;
65 63
66 if (type != GNUNET_BLOCK_TYPE_TEST) 64 if ( GNUNET_BLOCK_TYPE_TEST != type)
67 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; 65 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
68 if (xquery_size != 0) 66 if (0 != xquery_size)
69 { 67 {
70 GNUNET_break_op (0); 68 GNUNET_break_op (0);
71 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID; 69 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index c43a5de5e..2e4f7ef87 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -29,7 +29,6 @@
29#include "block_fs.h" 29#include "block_fs.h"
30#include "gnunet_signatures.h" 30#include "gnunet_signatures.h"
31 31
32#define DEBUG_FS_BLOCK GNUNET_EXTRA_LOGGING
33 32
34/** 33/**
35 * Number of bits we set per entry in the bloomfilter. 34 * Number of bits we set per entry in the bloomfilter.
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index d651476a8..5498fe74d 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -103,7 +103,12 @@ enum GNUNET_BLOCK_Type
103 /** 103 /**
104 * Block for storing mesh peers 104 * Block for storing mesh peers
105 */ 105 */
106 GNUNET_BLOCK_TYPE_MESH_PEER = 20 106 GNUNET_BLOCK_TYPE_MESH_PEER = 20,
107
108 /**
109 * Block for finding peers by type
110 */
111 GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE = 21
107}; 112};
108 113
109 114
diff --git a/src/mesh/plugin_block_mesh.c b/src/mesh/plugin_block_mesh.c
index c5bb458bd..8b601652f 100644
--- a/src/mesh/plugin_block_mesh.c
+++ b/src/mesh/plugin_block_mesh.c
@@ -26,8 +26,14 @@
26 26
27#include "platform.h" 27#include "platform.h"
28#include "gnunet_block_plugin.h" 28#include "gnunet_block_plugin.h"
29#include "block_mesh.h"
30
31/**
32 * Number of bits we set per entry in the bloomfilter.
33 * Do not change!
34 */
35#define BLOOMFILTER_K 16
29 36
30#define DEBUG_MESH_BLOCK GNUNET_EXTRA_LOGGING
31 37
32/** 38/**
33 * Function called to validate a reply or a request. For 39 * Function called to validate a reply or a request. For
@@ -55,16 +61,52 @@ block_plugin_mesh_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
55 size_t xquery_size, const void *reply_block, 61 size_t xquery_size, const void *reply_block,
56 size_t reply_block_size) 62 size_t reply_block_size)
57{ 63{
58 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Evaluate called\n"); 64 struct GNUNET_HashCode chash;
59 if (GNUNET_BLOCK_TYPE_MESH_PEER == type) 65 struct GNUNET_HashCode mhash;
60 { 66
61 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Type MESH PEER\n"); 67 switch (type)
62 }
63 else
64 { 68 {
65 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Other type\n"); 69 case GNUNET_BLOCK_TYPE_MESH_PEER:
70 if (0 != xquery_size)
71 {
72 GNUNET_break_op (0);
73 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
74 }
75 if (NULL == reply_block)
76 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
77 if (sizeof (struct PBlock) != reply_block_size)
78 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
79 return GNUNET_BLOCK_EVALUATION_OK_LAST;
80 case GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE:
81 /* FIXME: have an xquery? not sure */
82 if (0 != xquery_size)
83 {
84 GNUNET_break_op (0);
85 return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
86 }
87 if (NULL == reply_block)
88 return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
89 if (sizeof (struct PBlock) != reply_block_size)
90 return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
91 if (NULL != bf)
92 {
93 GNUNET_CRYPTO_hash (reply_block, reply_block_size, &chash);
94 GNUNET_BLOCK_mingle_hash (&chash, bf_mutator, &mhash);
95 if (NULL != *bf)
96 {
97 if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test (*bf, &mhash))
98 return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
99 }
100 else
101 {
102 *bf = GNUNET_CONTAINER_bloomfilter_init (NULL, 8, BLOOMFILTER_K);
103 }
104 GNUNET_CONTAINER_bloomfilter_add (*bf, &mhash);
105 }
106 return GNUNET_BLOCK_EVALUATION_OK_MORE;
107 default:
108 return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
66 } 109 }
67 return GNUNET_BLOCK_EVALUATION_OK_LAST;
68} 110}
69 111
70 112
@@ -84,8 +126,20 @@ block_plugin_mesh_get_key (void *cls, enum GNUNET_BLOCK_Type type,
84 const void *block, size_t block_size, 126 const void *block, size_t block_size,
85 struct GNUNET_HashCode * key) 127 struct GNUNET_HashCode * key)
86{ 128{
87 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get key called\n"); 129 const struct PBlock *pb;
88 return GNUNET_SYSERR; 130
131 switch (type)
132 {
133 case GNUNET_BLOCK_TYPE_MESH_PEER:
134 if (sizeof (struct PBlock) != block_size)
135 return GNUNET_SYSERR;
136 pb = block;
137 *key = pb->id.hashPubKey;
138 return GNUNET_OK;
139 // FIXME: other types...
140 default:
141 return GNUNET_SYSERR;
142 }
89} 143}
90 144
91 145
@@ -98,6 +152,7 @@ libgnunet_plugin_block_mesh_init (void *cls)
98 static enum GNUNET_BLOCK_Type types[] = 152 static enum GNUNET_BLOCK_Type types[] =
99 { 153 {
100 GNUNET_BLOCK_TYPE_MESH_PEER, 154 GNUNET_BLOCK_TYPE_MESH_PEER,
155 GNUNET_BLOCK_TYPE_MESH_PEER_BY_TYPE,
101 GNUNET_BLOCK_TYPE_ANY /* end of list */ 156 GNUNET_BLOCK_TYPE_ANY /* end of list */
102 }; 157 };
103 struct GNUNET_BLOCK_PluginFunctions *api; 158 struct GNUNET_BLOCK_PluginFunctions *api;
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index e67ffaa65..250e2b812 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -1137,31 +1137,34 @@ handle_record_remove_it (void *cls,
1137 rrc->op_res = 0; 1137 rrc->op_res = 0;
1138} 1138}
1139 1139
1140static void handle_record_remove (void *cls, 1140
1141 struct GNUNET_SERVER_Client * client, 1141static void
1142 const struct GNUNET_MessageHeader * message) 1142handle_record_remove (void *cls,
1143 struct GNUNET_SERVER_Client * client,
1144 const struct GNUNET_MessageHeader * message)
1143{ 1145{
1144 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_REMOVE");
1145 struct GNUNET_NAMESTORE_Client *nc; 1146 struct GNUNET_NAMESTORE_Client *nc;
1147 const struct RecordRemoveMessage * rr_msg;
1146 struct RecordRemoveResponseMessage rrr_msg; 1148 struct RecordRemoveResponseMessage rrr_msg;
1147 struct GNUNET_CRYPTO_RsaPrivateKey *pkey; 1149 struct GNUNET_CRYPTO_RsaPrivateKey *pkey;
1148 struct GNUNET_NAMESTORE_CryptoContainer *cc = NULL; 1150 struct GNUNET_NAMESTORE_CryptoContainer *cc;
1149 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; 1151 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub;
1150 struct GNUNET_CRYPTO_ShortHashCode pubkey_hash; 1152 struct GNUNET_CRYPTO_ShortHashCode pubkey_hash;
1151 struct GNUNET_HashCode long_hash; 1153 struct GNUNET_HashCode long_hash;
1152 char * pkey_tmp = NULL; 1154 const char * pkey_tmp;
1153 char * name_tmp = NULL; 1155 const char * name_tmp;
1154 char * rd_ser = NULL; 1156 const char * rd_ser;
1155 size_t key_len = 0; 1157 size_t key_len;
1156 size_t name_len = 0; 1158 size_t name_len;
1157 size_t rd_ser_len = 0; 1159 size_t rd_ser_len;
1158 size_t msg_size = 0; 1160 size_t msg_size;
1159 size_t msg_size_exp = 0; 1161 size_t msg_size_exp = 0;
1160 uint32_t rd_count; 1162 uint32_t rd_count;
1161 uint32_t rid = 0; 1163 uint32_t rid;
1162 1164
1163 int res = GNUNET_SYSERR; 1165 int res = GNUNET_SYSERR;
1164 1166
1167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_REMOVE");
1165 if (ntohs (message->size) < sizeof (struct RecordRemoveMessage)) 1168 if (ntohs (message->size) < sizeof (struct RecordRemoveMessage))
1166 { 1169 {
1167 GNUNET_break_op (0); 1170 GNUNET_break_op (0);
@@ -1177,7 +1180,7 @@ static void handle_record_remove (void *cls,
1177 return; 1180 return;
1178 } 1181 }
1179 1182
1180 struct RecordRemoveMessage * rr_msg = (struct RecordRemoveMessage *) message; 1183 rr_msg = (const struct RecordRemoveMessage *) message;
1181 rid = ntohl (rr_msg->gns_header.r_id); 1184 rid = ntohl (rr_msg->gns_header.r_id);
1182 name_len = ntohs (rr_msg->name_len); 1185 name_len = ntohs (rr_msg->name_len);
1183 rd_ser_len = ntohs (rr_msg->rd_len); 1186 rd_ser_len = ntohs (rr_msg->rd_len);
@@ -1208,7 +1211,7 @@ static void handle_record_remove (void *cls,
1208 return; 1211 return;
1209 } 1212 }
1210 1213
1211 pkey_tmp = (char *) &rr_msg[1]; 1214 pkey_tmp = (const char *) &rr_msg[1];
1212 name_tmp = &pkey_tmp[key_len]; 1215 name_tmp = &pkey_tmp[key_len];
1213 rd_ser = &name_tmp[name_len]; 1216 rd_ser = &name_tmp[name_len];
1214 1217
@@ -1236,7 +1239,9 @@ static void handle_record_remove (void *cls,
1236 1239
1237 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &long_hash)) 1240 if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains(zonekeys, &long_hash))
1238 { 1241 {
1239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received new private key for zone `%s'\n",GNUNET_short_h2s(&pubkey_hash)); 1242 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1243 "Received new private key for zone `%s'\n",
1244 GNUNET_short_h2s(&pubkey_hash));
1240 cc = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer)); 1245 cc = GNUNET_malloc (sizeof (struct GNUNET_NAMESTORE_CryptoContainer));
1241 cc->privkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len); 1246 cc->privkey = GNUNET_CRYPTO_rsa_decode_key((char *) pkey_tmp, key_len);
1242 cc->pubkey = GNUNET_malloc(sizeof (pub)); 1247 cc->pubkey = GNUNET_malloc(sizeof (pub));