diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-12 19:09:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-12 19:09:52 +0000 |
commit | 5e05019536c0d38bf20f965613636f21ae7c2be6 (patch) | |
tree | eda1dee12e49c010171462d618162d28b21c9c6a /src/namestore/namestore_api_monitor.c | |
parent | 566dfe32be22ed1f071b974be3c4dd8bc5721151 (diff) | |
download | gnunet-5e05019536c0d38bf20f965613636f21ae7c2be6.tar.gz gnunet-5e05019536c0d38bf20f965613636f21ae7c2be6.zip |
-towards namestore support for the new privacy-preserving GNS queries
Diffstat (limited to 'src/namestore/namestore_api_monitor.c')
-rw-r--r-- | src/namestore/namestore_api_monitor.c | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/src/namestore/namestore_api_monitor.c b/src/namestore/namestore_api_monitor.c index a6a014839..050d88ba5 100644 --- a/src/namestore/namestore_api_monitor.c +++ b/src/namestore/namestore_api_monitor.c | |||
@@ -73,12 +73,8 @@ struct GNUNET_NAMESTORE_ZoneMonitor | |||
73 | /** | 73 | /** |
74 | * Monitored zone. | 74 | * Monitored zone. |
75 | */ | 75 | */ |
76 | struct GNUNET_CRYPTO_ShortHashCode zone; | 76 | struct GNUNET_CRYPTO_EccPrivateKey zone; |
77 | 77 | ||
78 | /** | ||
79 | * GNUNET_YES if we monitor all zones, GNUNET_NO if we only monitor 'zone'. | ||
80 | */ | ||
81 | int all_zones; | ||
82 | }; | 78 | }; |
83 | 79 | ||
84 | 80 | ||
@@ -108,8 +104,7 @@ reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm) | |||
108 | GNUNET_CLIENT_disconnect (zm->h); | 104 | GNUNET_CLIENT_disconnect (zm->h); |
109 | zm->monitor (zm->cls, | 105 | zm->monitor (zm->cls, |
110 | NULL, | 106 | NULL, |
111 | GNUNET_TIME_UNIT_ZERO_ABS, | 107 | NULL, 0, NULL); |
112 | NULL, 0, NULL, NULL); | ||
113 | GNUNET_assert (NULL != (zm->h = GNUNET_CLIENT_connect ("namestore", zm->cfg))); | 108 | GNUNET_assert (NULL != (zm->h = GNUNET_CLIENT_connect ("namestore", zm->cfg))); |
114 | zm->th = GNUNET_CLIENT_notify_transmit_ready (zm->h, | 109 | zm->th = GNUNET_CLIENT_notify_transmit_ready (zm->h, |
115 | sizeof (struct ZoneMonitorStartMessage), | 110 | sizeof (struct ZoneMonitorStartMessage), |
@@ -132,7 +127,7 @@ handle_updates (void *cls, | |||
132 | const struct GNUNET_MessageHeader *msg) | 127 | const struct GNUNET_MessageHeader *msg) |
133 | { | 128 | { |
134 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; | 129 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; |
135 | const struct LookupNameResponseMessage *lrm; | 130 | const struct RecordResultMessage *lrm; |
136 | size_t lrm_len; | 131 | size_t lrm_len; |
137 | size_t exp_lrm_len; | 132 | size_t exp_lrm_len; |
138 | size_t name_len; | 133 | size_t name_len; |
@@ -140,7 +135,6 @@ handle_updates (void *cls, | |||
140 | unsigned rd_count; | 135 | unsigned rd_count; |
141 | const char *name_tmp; | 136 | const char *name_tmp; |
142 | const char *rd_ser_tmp; | 137 | const char *rd_ser_tmp; |
143 | struct GNUNET_TIME_Absolute expire; | ||
144 | 138 | ||
145 | if (NULL == msg) | 139 | if (NULL == msg) |
146 | { | 140 | { |
@@ -158,20 +152,19 @@ handle_updates (void *cls, | |||
158 | zm->sync_cb (zm->cls); | 152 | zm->sync_cb (zm->cls); |
159 | return; | 153 | return; |
160 | } | 154 | } |
161 | if ( (ntohs (msg->size) < sizeof (struct LookupNameResponseMessage)) || | 155 | if ( (ntohs (msg->size) < sizeof (struct RecordResultMessage)) || |
162 | (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE != ntohs (msg->type) ) ) | 156 | (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_RESULT != ntohs (msg->type) ) ) |
163 | { | 157 | { |
164 | GNUNET_break (0); | 158 | GNUNET_break (0); |
165 | reconnect (zm); | 159 | reconnect (zm); |
166 | return; | 160 | return; |
167 | } | 161 | } |
168 | lrm = (const struct LookupNameResponseMessage *) msg; | 162 | lrm = (const struct RecordResultMessage *) msg; |
169 | lrm_len = ntohs (lrm->gns_header.header.size); | 163 | lrm_len = ntohs (lrm->gns_header.header.size); |
170 | rd_len = ntohs (lrm->rd_len); | 164 | rd_len = ntohs (lrm->rd_len); |
171 | rd_count = ntohs (lrm->rd_count); | 165 | rd_count = ntohs (lrm->rd_count); |
172 | name_len = ntohs (lrm->name_len); | 166 | name_len = ntohs (lrm->name_len); |
173 | expire = GNUNET_TIME_absolute_ntoh (lrm->expire); | 167 | exp_lrm_len = sizeof (struct RecordResultMessage) + name_len + rd_len; |
174 | exp_lrm_len = sizeof (struct LookupNameResponseMessage) + name_len + rd_len; | ||
175 | if (lrm_len != exp_lrm_len) | 168 | if (lrm_len != exp_lrm_len) |
176 | { | 169 | { |
177 | GNUNET_break (0); | 170 | GNUNET_break (0); |
@@ -206,9 +199,9 @@ handle_updates (void *cls, | |||
206 | zm, | 199 | zm, |
207 | GNUNET_TIME_UNIT_FOREVER_REL); | 200 | GNUNET_TIME_UNIT_FOREVER_REL); |
208 | zm->monitor (zm->cls, | 201 | zm->monitor (zm->cls, |
209 | &lrm->public_key, expire, | 202 | &lrm->private_key, |
210 | name_tmp, | 203 | name_tmp, |
211 | rd_count, rd, NULL); | 204 | rd_count, rd); |
212 | } | 205 | } |
213 | } | 206 | } |
214 | 207 | ||
@@ -239,7 +232,6 @@ transmit_monitor_message (void *cls, | |||
239 | sm.gns_header.header.size = htons (sizeof (struct ZoneMonitorStartMessage)); | 232 | sm.gns_header.header.size = htons (sizeof (struct ZoneMonitorStartMessage)); |
240 | sm.gns_header.r_id = htonl (0); | 233 | sm.gns_header.r_id = htonl (0); |
241 | sm.zone = zm->zone; | 234 | sm.zone = zm->zone; |
242 | sm.all_zones = htonl (zm->all_zones); | ||
243 | memcpy (buf, &sm, sizeof (sm)); | 235 | memcpy (buf, &sm, sizeof (sm)); |
244 | GNUNET_CLIENT_receive (zm->h, | 236 | GNUNET_CLIENT_receive (zm->h, |
245 | &handle_updates, | 237 | &handle_updates, |
@@ -255,7 +247,7 @@ transmit_monitor_message (void *cls, | |||
255 | * a record changes. | 247 | * a record changes. |
256 | * | 248 | * |
257 | * @param cfg configuration to use to connect to namestore | 249 | * @param cfg configuration to use to connect to namestore |
258 | * @param zone zone to monitor, NULL for all zones | 250 | * @param zone zone to monitor |
259 | * @param monitor function to call on zone changes | 251 | * @param monitor function to call on zone changes |
260 | * @param sync_cb function called when we're in sync with the namestore | 252 | * @param sync_cb function called when we're in sync with the namestore |
261 | * @param cls closure for 'monitor' and 'sync_cb' | 253 | * @param cls closure for 'monitor' and 'sync_cb' |
@@ -263,7 +255,7 @@ transmit_monitor_message (void *cls, | |||
263 | */ | 255 | */ |
264 | struct GNUNET_NAMESTORE_ZoneMonitor * | 256 | struct GNUNET_NAMESTORE_ZoneMonitor * |
265 | GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 257 | GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
266 | const struct GNUNET_CRYPTO_ShortHashCode *zone, | 258 | const struct GNUNET_CRYPTO_EccPrivateKey *zone, |
267 | GNUNET_NAMESTORE_RecordMonitor monitor, | 259 | GNUNET_NAMESTORE_RecordMonitor monitor, |
268 | GNUNET_NAMESTORE_RecordsSynchronizedCallback sync_cb, | 260 | GNUNET_NAMESTORE_RecordsSynchronizedCallback sync_cb, |
269 | void *cls) | 261 | void *cls) |
@@ -276,10 +268,7 @@ GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *c | |||
276 | zm = GNUNET_new (struct GNUNET_NAMESTORE_ZoneMonitor); | 268 | zm = GNUNET_new (struct GNUNET_NAMESTORE_ZoneMonitor); |
277 | zm->cfg = cfg; | 269 | zm->cfg = cfg; |
278 | zm->h = client; | 270 | zm->h = client; |
279 | if (NULL == zone) | 271 | zm->zone = *zone; |
280 | zm->all_zones = GNUNET_YES; | ||
281 | else | ||
282 | zm->zone = *zone; | ||
283 | zm->monitor = monitor; | 272 | zm->monitor = monitor; |
284 | zm->sync_cb = sync_cb; | 273 | zm->sync_cb = sync_cb; |
285 | zm->cls = cls; | 274 | zm->cls = cls; |