diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-01 10:37:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-01 10:37:47 +0000 |
commit | c93c582dfed6b36d507308a2b677753f37b1d31b (patch) | |
tree | 9b303394930f68bcea5d90a329680401b88d022b /src/gns/plugin_block_gns.c | |
parent | 8e0a942237b701e2d03db2def2204417acdc6f4c (diff) | |
download | gnunet-c93c582dfed6b36d507308a2b677753f37b1d31b.tar.gz gnunet-c93c582dfed6b36d507308a2b677753f37b1d31b.zip |
-stuff
Diffstat (limited to 'src/gns/plugin_block_gns.c')
-rw-r--r-- | src/gns/plugin_block_gns.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c index a4d6ad9c8..e1677b35b 100644 --- a/src/gns/plugin_block_gns.c +++ b/src/gns/plugin_block_gns.c | |||
@@ -62,11 +62,6 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
62 | size_t xquery_size, const void *reply_block, | 62 | size_t xquery_size, const void *reply_block, |
63 | size_t reply_block_size) | 63 | size_t reply_block_size) |
64 | { | 64 | { |
65 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | ||
66 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
67 | if (reply_block_size == 0) | ||
68 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
69 | |||
70 | char* name; | 65 | char* name; |
71 | GNUNET_HashCode pkey_hash; | 66 | GNUNET_HashCode pkey_hash; |
72 | GNUNET_HashCode query_key; | 67 | GNUNET_HashCode query_key; |
@@ -76,7 +71,13 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
76 | struct GNSNameRecordBlock *nrb; | 71 | struct GNSNameRecordBlock *nrb; |
77 | struct GNSRecordBlock *rb; | 72 | struct GNSRecordBlock *rb; |
78 | uint32_t rd_count; | 73 | uint32_t rd_count; |
79 | 74 | unsigned int record_match; | |
75 | |||
76 | if (type != GNUNET_BLOCK_TYPE_GNS_NAMERECORD) | ||
77 | return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED; | ||
78 | if (reply_block_size == 0) | ||
79 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | ||
80 | |||
80 | nrb = (struct GNSNameRecordBlock *)reply_block; | 81 | nrb = (struct GNSNameRecordBlock *)reply_block; |
81 | name = (char*)&nrb[1]; | 82 | name = (char*)&nrb[1]; |
82 | GNUNET_CRYPTO_hash(&nrb->public_key, | 83 | GNUNET_CRYPTO_hash(&nrb->public_key, |
@@ -91,33 +92,31 @@ block_plugin_gns_evaluate (void *cls, enum GNUNET_BLOCK_Type type, | |||
91 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) | 92 | if (0 != GNUNET_CRYPTO_hash_cmp(query, &query_key)) |
92 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; | 93 | return GNUNET_BLOCK_EVALUATION_REQUEST_VALID; |
93 | 94 | ||
95 | record_match = 0; | ||
94 | rd_count = ntohl(nrb->rd_count); | 96 | rd_count = ntohl(nrb->rd_count); |
95 | |||
96 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | ||
97 | int i = 0; | ||
98 | int record_match = 0; | ||
99 | uint32_t record_xquery = ntohl(*((uint32_t*)xquery)); | ||
100 | rb = (struct GNSRecordBlock*)(&name[strlen(name) + 1]); | ||
101 | |||
102 | for (i=0; i<rd_count; i++) | ||
103 | { | 97 | { |
104 | rd[i].record_type = ntohl(rb->type); | 98 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
105 | rd[i].expiration = | 99 | unsigned int i; |
106 | GNUNET_TIME_absolute_ntoh(rb->expiration); | 100 | uint32_t record_xquery = ntohl(*((uint32_t*)xquery)); |
107 | rd[i].data_size = ntohl(rb->data_length); | 101 | |
108 | rd[i].flags = ntohl(rb->flags); | 102 | rb = (struct GNSRecordBlock*)(&name[strlen(name) + 1]); |
109 | rd[i].data = (char*)&rb[1]; | 103 | for (i=0; i<rd_count; i++) |
110 | rb = (struct GNSRecordBlock *)((char*)&rb[1] + rd[i].data_size); | ||
111 | |||
112 | if (xquery_size == 0) | ||
113 | continue; | ||
114 | |||
115 | if (rd[i].record_type == record_xquery) | ||
116 | { | 104 | { |
117 | record_match++; | 105 | rd[i].record_type = ntohl(rb->type); |
106 | rd[i].expiration = | ||
107 | GNUNET_TIME_absolute_ntoh(rb->expiration); | ||
108 | rd[i].data_size = ntohl(rb->data_length); | ||
109 | rd[i].flags = ntohl(rb->flags); | ||
110 | rd[i].data = (char*)&rb[1]; | ||
111 | rb = (struct GNSRecordBlock *)((char*)&rb[1] + rd[i].data_size); | ||
112 | |||
113 | if (xquery_size == 0) | ||
114 | continue; | ||
115 | |||
116 | if (rd[i].record_type == record_xquery) | ||
117 | record_match++; | ||
118 | } | 118 | } |
119 | } | 119 | } |
120 | |||
121 | 120 | ||
122 | /*if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, | 121 | /*if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key, |
123 | name, | 122 | name, |