diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-06 12:32:16 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-03-06 12:32:16 +0000 |
commit | 10b2ef580e79924e9117e1654dd9d58b23d618e2 (patch) | |
tree | 3fd102121a0171764118cddae2796bee74da80c3 /src/namestore | |
parent | b45ab93426129c5b4460067a6fac06abf536b461 (diff) | |
download | gnunet-10b2ef580e79924e9117e1654dd9d58b23d618e2.tar.gz gnunet-10b2ef580e79924e9117e1654dd9d58b23d618e2.zip |
- step 1) compiles again
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 119 | ||||
-rw-r--r-- | src/namestore/namestore.h | 131 | ||||
-rw-r--r-- | src/namestore/namestore_api.c | 105 | ||||
-rw-r--r-- | src/namestore/namestore_common.c | 2 | ||||
-rw-r--r-- | src/namestore/plugin_namestore_sqlite.c | 2 |
5 files changed, 129 insertions, 230 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 40f3c477a..7408f7ad7 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -219,57 +219,6 @@ void drop_iterator (void *cls, | |||
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | /** | ||
223 | * Called whenever a client is disconnected. Frees our | ||
224 | * resources associated with that client. | ||
225 | * | ||
226 | * @param cls closure | ||
227 | * @param client identification of the client | ||
228 | * @param message the stop message | ||
229 | */ | ||
230 | static void handle_stop (void *cls, | ||
231 | struct GNUNET_SERVER_Client * client, | ||
232 | const struct GNUNET_MessageHeader * message) | ||
233 | { | ||
234 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_REMOVE"); | ||
235 | struct DisconnectMessage * msg = (struct DisconnectMessage *) message; | ||
236 | struct GNUNET_NAMESTORE_ZoneIteration * no; | ||
237 | struct GNUNET_NAMESTORE_Client * nc; | ||
238 | int drop; | ||
239 | |||
240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p disconnected \n", client); | ||
241 | |||
242 | nc = client_lookup (client); | ||
243 | if (nc == NULL) | ||
244 | { | ||
245 | GNUNET_break (0); | ||
246 | return; | ||
247 | } | ||
248 | |||
249 | for (no = nc->op_head; no != NULL; no = no->next) | ||
250 | { | ||
251 | GNUNET_CONTAINER_DLL_remove (nc->op_head, nc->op_tail, no); | ||
252 | GNUNET_free (no); | ||
253 | } | ||
254 | |||
255 | drop = ntohl(msg->drop); | ||
256 | if (GNUNET_YES == drop) | ||
257 | { | ||
258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Dropping namestore content\n"); | ||
259 | int stop = GNUNET_NO; | ||
260 | int offset = 0; | ||
261 | while (stop == GNUNET_NO) | ||
262 | { | ||
263 | GSN_database->iterate_records (GSN_database->cls, NULL, NULL, offset, &drop_iterator, &stop); | ||
264 | offset ++; | ||
265 | } | ||
266 | } | ||
267 | |||
268 | GNUNET_SERVER_client_drop(nc->client); | ||
269 | GNUNET_CONTAINER_DLL_remove (client_head, client_tail, nc); | ||
270 | GNUNET_free (nc); | ||
271 | } | ||
272 | |||
273 | static void | 222 | static void |
274 | handle_lookup_name_it (void *cls, | 223 | handle_lookup_name_it (void *cls, |
275 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 224 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
@@ -288,18 +237,16 @@ handle_lookup_name_it (void *cls, | |||
288 | char *rd_tmp; | 237 | char *rd_tmp; |
289 | char *name_tmp; | 238 | char *name_tmp; |
290 | size_t rd_ser_len; | 239 | size_t rd_ser_len; |
291 | struct GNUNET_CRYPTO_RsaSignature *signature_tmp; | ||
292 | |||
293 | size_t r_size = 0; | 240 | size_t r_size = 0; |
294 | |||
295 | size_t name_len = 0; | 241 | size_t name_len = 0; |
296 | if (NULL != name) | ||
297 | name_len = strlen(name) + 1; | ||
298 | 242 | ||
299 | int copied_elements = 0; | 243 | int copied_elements = 0; |
300 | int contains_signature = 0; | 244 | int contains_signature = 0; |
301 | int c; | 245 | int c; |
302 | 246 | ||
247 | if (NULL != name) | ||
248 | name_len = strlen(name) + 1; | ||
249 | |||
303 | /* count records to copy */ | 250 | /* count records to copy */ |
304 | if (rd_count != 0) | 251 | if (rd_count != 0) |
305 | { | 252 | { |
@@ -341,25 +288,24 @@ handle_lookup_name_it (void *cls, | |||
341 | char rd_ser[rd_ser_len]; | 288 | char rd_ser[rd_ser_len]; |
342 | GNUNET_NAMESTORE_records_serialize(copied_elements, rd_selected, rd_ser_len, rd_ser); | 289 | GNUNET_NAMESTORE_records_serialize(copied_elements, rd_selected, rd_ser_len, rd_ser); |
343 | 290 | ||
291 | if (rd_selected != rd) | ||
292 | GNUNET_free (rd_selected); | ||
293 | |||
344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u records for name `%s' in zone `%s'\n", | 294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u records for name `%s' in zone `%s'\n", |
345 | copied_elements, lnc->name, GNUNET_h2s(lnc->zone)); | 295 | copied_elements, lnc->name, GNUNET_h2s(lnc->zone)); |
346 | 296 | ||
347 | if ((copied_elements == rd_count) && (signature != NULL)) | 297 | if ((copied_elements == rd_count) && (signature != NULL)) |
348 | contains_signature = GNUNET_YES; | 298 | contains_signature = GNUNET_YES; |
349 | 299 | else | |
350 | if (rd_selected != rd) | 300 | contains_signature = GNUNET_NO; |
351 | GNUNET_free (rd_selected); | ||
352 | 301 | ||
353 | r_size = sizeof (struct LookupNameResponseMessage) + | 302 | r_size = sizeof (struct LookupNameResponseMessage) + |
354 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 303 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + |
355 | name_len + | 304 | name_len + |
356 | rd_ser_len + | 305 | rd_ser_len; |
357 | contains_signature * sizeof (struct GNUNET_CRYPTO_RsaSignature); | ||
358 | 306 | ||
359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "NAMESTORE_LOOKUP_NAME_RESPONSE"); | 307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "NAMESTORE_LOOKUP_NAME_RESPONSE"); |
360 | |||
361 | lnr_msg = GNUNET_malloc (r_size); | 308 | lnr_msg = GNUNET_malloc (r_size); |
362 | |||
363 | lnr_msg->gns_header.header.type = ntohs (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE); | 309 | lnr_msg->gns_header.header.type = ntohs (GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME_RESPONSE); |
364 | lnr_msg->gns_header.header.size = ntohs (r_size); | 310 | lnr_msg->gns_header.header.size = ntohs (r_size); |
365 | lnr_msg->gns_header.r_id = htonl (lnc->request_id); | 311 | lnr_msg->gns_header.r_id = htonl (lnc->request_id); |
@@ -368,25 +314,19 @@ handle_lookup_name_it (void *cls, | |||
368 | lnr_msg->name_len = htons (name_len); | 314 | lnr_msg->name_len = htons (name_len); |
369 | lnr_msg->expire = GNUNET_TIME_absolute_hton(expire); | 315 | lnr_msg->expire = GNUNET_TIME_absolute_hton(expire); |
370 | lnr_msg->contains_sig = htons (contains_signature); | 316 | lnr_msg->contains_sig = htons (contains_signature); |
317 | if (GNUNET_YES == contains_signature) | ||
318 | lnr_msg->signature = *signature; | ||
319 | else | ||
320 | memset (&lnr_msg->signature, '\0', sizeof (lnr_msg->signature)); | ||
371 | 321 | ||
372 | zone_key_tmp = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &lnr_msg[1]; | 322 | zone_key_tmp = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &lnr_msg[1]; |
373 | name_tmp = (char *) &zone_key_tmp[1]; | 323 | name_tmp = (char *) &zone_key_tmp[1]; |
374 | rd_tmp = &name_tmp[name_len]; | 324 | rd_tmp = &name_tmp[name_len]; |
375 | signature_tmp = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_ser_len]; | ||
376 | 325 | ||
377 | if (zone_key != NULL) | 326 | memcpy (zone_key_tmp, zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
378 | memcpy (zone_key_tmp, zone_key, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | ||
379 | else | ||
380 | { | ||
381 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded dummy; | ||
382 | memset (&dummy, '0', sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | ||
383 | memcpy (zone_key_tmp, &dummy, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | ||
384 | } | ||
385 | memcpy (name_tmp, name, name_len); | 327 | memcpy (name_tmp, name, name_len); |
386 | memcpy (rd_tmp, rd_ser, rd_ser_len); | 328 | memcpy (rd_tmp, rd_ser, rd_ser_len); |
387 | 329 | ||
388 | if (GNUNET_YES == contains_signature) | ||
389 | memcpy (signature_tmp, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); | ||
390 | GNUNET_SERVER_notification_context_unicast (snc, lnc->nc->client, (const struct GNUNET_MessageHeader *) lnr_msg, GNUNET_NO); | 330 | GNUNET_SERVER_notification_context_unicast (snc, lnc->nc->client, (const struct GNUNET_MessageHeader *) lnr_msg, GNUNET_NO); |
391 | 331 | ||
392 | GNUNET_free (lnr_msg); | 332 | GNUNET_free (lnr_msg); |
@@ -444,6 +384,7 @@ static void handle_lookup_name (void *cls, | |||
444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up all records for name `%s' in zone `%s'\n", name, GNUNET_h2s(&ln_msg->zone)); | 384 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up all records for name `%s' in zone `%s'\n", name, GNUNET_h2s(&ln_msg->zone)); |
445 | else | 385 | else |
446 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up records with type %u for name `%s' in zone `%s'\n", type, name, GNUNET_h2s(&ln_msg->zone)); | 386 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up records with type %u for name `%s' in zone `%s'\n", type, name, GNUNET_h2s(&ln_msg->zone)); |
387 | |||
447 | /* do the actual lookup */ | 388 | /* do the actual lookup */ |
448 | lnc.request_id = rid; | 389 | lnc.request_id = rid; |
449 | lnc.nc = nc; | 390 | lnc.nc = nc; |
@@ -462,13 +403,11 @@ static void handle_record_put (void *cls, | |||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_PUT"); | 403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_PUT"); |
463 | struct GNUNET_NAMESTORE_Client *nc; | 404 | struct GNUNET_NAMESTORE_Client *nc; |
464 | struct GNUNET_TIME_Absolute expire; | 405 | struct GNUNET_TIME_Absolute expire; |
465 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key; | ||
466 | struct GNUNET_CRYPTO_RsaSignature *signature; | 406 | struct GNUNET_CRYPTO_RsaSignature *signature; |
467 | struct RecordPutResponseMessage rpr_msg; | 407 | struct RecordPutResponseMessage rpr_msg; |
468 | size_t name_len; | 408 | size_t name_len; |
469 | size_t msg_size; | 409 | size_t msg_size; |
470 | size_t msg_size_exp; | 410 | size_t msg_size_exp; |
471 | size_t key_len; | ||
472 | char * name; | 411 | char * name; |
473 | char * rd_ser; | 412 | char * rd_ser; |
474 | uint32_t rid = 0; | 413 | uint32_t rid = 0; |
@@ -495,7 +434,6 @@ static void handle_record_put (void *cls, | |||
495 | 434 | ||
496 | rid = ntohl (rp_msg->gns_header.r_id); | 435 | rid = ntohl (rp_msg->gns_header.r_id); |
497 | msg_size = ntohs (rp_msg->gns_header.header.size); | 436 | msg_size = ntohs (rp_msg->gns_header.header.size); |
498 | key_len = ntohs (rp_msg->key_len); | ||
499 | name_len = ntohs (rp_msg->name_len); | 437 | name_len = ntohs (rp_msg->name_len); |
500 | rd_count = ntohs (rp_msg->rd_count); | 438 | rd_count = ntohs (rp_msg->rd_count); |
501 | rd_ser_len = ntohs(rp_msg->rd_len); | 439 | rd_ser_len = ntohs(rp_msg->rd_len); |
@@ -514,7 +452,7 @@ static void handle_record_put (void *cls, | |||
514 | return; | 452 | return; |
515 | } | 453 | } |
516 | 454 | ||
517 | msg_size_exp = sizeof (struct RecordPutMessage) + key_len + name_len + rd_ser_len; | 455 | msg_size_exp = sizeof (struct RecordPutMessage) + name_len + rd_ser_len; |
518 | if (msg_size != msg_size_exp) | 456 | if (msg_size != msg_size_exp) |
519 | { | 457 | { |
520 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expected message %u size but message size is %u \n", msg_size_exp, msg_size); | 458 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Expected message %u size but message size is %u \n", msg_size_exp, msg_size); |
@@ -529,8 +467,7 @@ static void handle_record_put (void *cls, | |||
529 | return; | 467 | return; |
530 | } | 468 | } |
531 | 469 | ||
532 | zone_key = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &rp_msg[1]; | 470 | name = (char *) &rp_msg[1]; |
533 | name = &((char *)zone_key)[key_len]; | ||
534 | 471 | ||
535 | if (name[name_len -1] != '\0') | 472 | if (name[name_len -1] != '\0') |
536 | { | 473 | { |
@@ -553,13 +490,13 @@ static void handle_record_put (void *cls, | |||
553 | 490 | ||
554 | 491 | ||
555 | GNUNET_HashCode zone_hash; | 492 | GNUNET_HashCode zone_hash; |
556 | GNUNET_CRYPTO_hash (zone_key, key_len, &zone_hash); | 493 | GNUNET_CRYPTO_hash (&rp_msg->public_key, sizeof (rp_msg->public_key), &zone_hash); |
557 | 494 | ||
558 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting %u record for name `%s' in zone `%s'\n", rd_count, name, GNUNET_h2s(&zone_hash)); | 495 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting %u record for name `%s' in zone `%s'\n", rd_count, name, GNUNET_h2s(&zone_hash)); |
559 | 496 | ||
560 | /* Database operation */ | 497 | /* Database operation */ |
561 | res = GSN_database->put_records(GSN_database->cls, | 498 | res = GSN_database->put_records(GSN_database->cls, |
562 | zone_key, | 499 | &rp_msg->public_key, |
563 | expire, | 500 | expire, |
564 | name, | 501 | name, |
565 | rd_count, rd, | 502 | rd_count, rd, |
@@ -571,9 +508,10 @@ static void handle_record_put (void *cls, | |||
571 | /* Send response */ | 508 | /* Send response */ |
572 | send: | 509 | send: |
573 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "RECORD_PUT_RESPONSE"); | 510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "RECORD_PUT_RESPONSE"); |
574 | rpr_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE); | 511 | rpr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT_RESPONSE); |
575 | rpr_msg.op_id = rp_msg->gns_header.r_id; | 512 | rpr_msg.gns_header.header.size = htons (sizeof (struct RecordPutResponseMessage)); |
576 | rpr_msg.header.size = htons (sizeof (struct RecordPutResponseMessage)); | 513 | rpr_msg.gns_header.r_id = rp_msg->gns_header.r_id; |
514 | |||
577 | if (GNUNET_OK == res) | 515 | if (GNUNET_OK == res) |
578 | rpr_msg.op_result = htons (GNUNET_OK); | 516 | rpr_msg.op_result = htons (GNUNET_OK); |
579 | else | 517 | else |
@@ -965,7 +903,7 @@ static void handle_record_remove (void *cls, | |||
965 | name_len = ntohs (rr_msg->name_len); | 903 | name_len = ntohs (rr_msg->name_len); |
966 | rd_ser_len = ntohs (rr_msg->rd_len); | 904 | rd_ser_len = ntohs (rr_msg->rd_len); |
967 | rd_count = ntohs (rr_msg->rd_count); | 905 | rd_count = ntohs (rr_msg->rd_count); |
968 | key_len = ntohs (rr_msg->key_len); | 906 | key_len = ntohs (rr_msg->pkey_len); |
969 | msg_size = ntohs (message->size); | 907 | msg_size = ntohs (message->size); |
970 | 908 | ||
971 | if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE) | 909 | if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE) |
@@ -1137,7 +1075,6 @@ handle_zone_to_name_it (void *cls, | |||
1137 | ztnr_msg->rd_len = htons (rd_ser_len); | 1075 | ztnr_msg->rd_len = htons (rd_ser_len); |
1138 | ztnr_msg->rd_count = htons (rd_count); | 1076 | ztnr_msg->rd_count = htons (rd_count); |
1139 | ztnr_msg->name_len = htons (name_len); | 1077 | ztnr_msg->name_len = htons (name_len); |
1140 | ztnr_msg->contains_sig = htons (contains_sig); | ||
1141 | ztnr_msg->expire = GNUNET_TIME_absolute_hton(expire); | 1078 | ztnr_msg->expire = GNUNET_TIME_absolute_hton(expire); |
1142 | if (zone_key != NULL) | 1079 | if (zone_key != NULL) |
1143 | ztnr_msg->zone_key = *zone_key; | 1080 | ztnr_msg->zone_key = *zone_key; |
@@ -1425,8 +1362,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1425 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 1362 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
1426 | {&handle_start, NULL, | 1363 | {&handle_start, NULL, |
1427 | GNUNET_MESSAGE_TYPE_NAMESTORE_START, sizeof (struct StartMessage)}, | 1364 | GNUNET_MESSAGE_TYPE_NAMESTORE_START, sizeof (struct StartMessage)}, |
1428 | {&handle_stop, NULL, | ||
1429 | GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT, sizeof (struct DisconnectMessage)}, | ||
1430 | {&handle_lookup_name, NULL, | 1365 | {&handle_lookup_name, NULL, |
1431 | GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME, 0}, | 1366 | GNUNET_MESSAGE_TYPE_NAMESTORE_LOOKUP_NAME, 0}, |
1432 | {&handle_record_put, NULL, | 1367 | {&handle_record_put, NULL, |
@@ -1439,10 +1374,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
1439 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, 0}, | 1374 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME, 0}, |
1440 | {&handle_iteration_start, NULL, | 1375 | {&handle_iteration_start, NULL, |
1441 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, sizeof (struct ZoneIterationStartMessage)}, | 1376 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_START, sizeof (struct ZoneIterationStartMessage)}, |
1442 | {&handle_iteration_stop, NULL, | ||
1443 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, sizeof (struct ZoneIterationStopMessage)}, | ||
1444 | {&handle_iteration_next, NULL, | 1377 | {&handle_iteration_next, NULL, |
1445 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, 0}, | 1378 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_NEXT, 0}, |
1379 | {&handle_iteration_stop, NULL, | ||
1380 | GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_ITERATION_STOP, 0}, | ||
1446 | {NULL, NULL, 0, 0} | 1381 | {NULL, NULL, 0, 0} |
1447 | }; | 1382 | }; |
1448 | 1383 | ||
diff --git a/src/namestore/namestore.h b/src/namestore/namestore.h index 17229ab24..5b4c02385 100644 --- a/src/namestore/namestore.h +++ b/src/namestore/namestore.h | |||
@@ -47,7 +47,7 @@ | |||
47 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT 449 | 47 | #define GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT 449 |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Sign name and records | 50 | * Create a signature based on name and records |
51 | * | 51 | * |
52 | * @param key the private key | 52 | * @param key the private key |
53 | * @param name the name | 53 | * @param name the name |
@@ -57,13 +57,16 @@ | |||
57 | * @return the signature | 57 | * @return the signature |
58 | */ | 58 | */ |
59 | struct GNUNET_CRYPTO_RsaSignature * | 59 | struct GNUNET_CRYPTO_RsaSignature * |
60 | GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, const char *name, struct GNUNET_NAMESTORE_RecordData *rd, unsigned int rd_count); | 60 | GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
61 | const char *name, | ||
62 | const struct GNUNET_NAMESTORE_RecordData *rd, | ||
63 | unsigned int rd_count); | ||
61 | 64 | ||
62 | /** | 65 | /** |
63 | * Compares if two records are equal | 66 | * Compares if two records are equal |
64 | * | 67 | * |
65 | * @param a record | 68 | * @param a Record a |
66 | * @param b record | 69 | * @param b Record b |
67 | * | 70 | * |
68 | * @return GNUNET_YES or GNUNET_NO | 71 | * @return GNUNET_YES or GNUNET_NO |
69 | */ | 72 | */ |
@@ -71,10 +74,12 @@ int | |||
71 | GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, | 74 | GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a, |
72 | const struct GNUNET_NAMESTORE_RecordData *b); | 75 | const struct GNUNET_NAMESTORE_RecordData *b); |
73 | 76 | ||
77 | |||
74 | GNUNET_NETWORK_STRUCT_BEGIN | 78 | GNUNET_NETWORK_STRUCT_BEGIN |
75 | /** | 79 | /** |
76 | * A GNS record serialized for network transmission. | 80 | * A GNS record serialized for network transmission. |
77 | * layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data] | 81 | * |
82 | * Layout is [struct GNUNET_NAMESTORE_NetworkRecord][char[data_size] data] | ||
78 | */ | 83 | */ |
79 | struct GNUNET_NAMESTORE_NetworkRecord | 84 | struct GNUNET_NAMESTORE_NetworkRecord |
80 | { | 85 | { |
@@ -114,24 +119,6 @@ struct StartMessage | |||
114 | 119 | ||
115 | }; | 120 | }; |
116 | 121 | ||
117 | /** | ||
118 | * Connect to namestore service. FIXME: UNNECESSARY. | ||
119 | */ | ||
120 | struct DisconnectMessage | ||
121 | { | ||
122 | |||
123 | /** | ||
124 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT | ||
125 | */ | ||
126 | struct GNUNET_MessageHeader header; | ||
127 | |||
128 | /** | ||
129 | * Drop namestore? | ||
130 | * GNUNET_YES or _NO in NBO | ||
131 | */ | ||
132 | uint32_t drop; | ||
133 | }; | ||
134 | |||
135 | 122 | ||
136 | /** | 123 | /** |
137 | * Generic namestore message with op id | 124 | * Generic namestore message with op id |
@@ -152,7 +139,7 @@ struct GNUNET_NAMESTORE_Header | |||
152 | 139 | ||
153 | 140 | ||
154 | /** | 141 | /** |
155 | * Connect to namestore service | 142 | * Lookup a name in the namestore |
156 | */ | 143 | */ |
157 | struct LookupNameMessage | 144 | struct LookupNameMessage |
158 | { | 145 | { |
@@ -179,8 +166,6 @@ struct LookupNameMessage | |||
179 | 166 | ||
180 | /** | 167 | /** |
181 | * Lookup response | 168 | * Lookup response |
182 | * Memory layout: | ||
183 | * [struct LookupNameResponseMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData] | ||
184 | */ | 169 | */ |
185 | struct LookupNameResponseMessage | 170 | struct LookupNameResponseMessage |
186 | { | 171 | { |
@@ -189,14 +174,31 @@ struct LookupNameResponseMessage | |||
189 | */ | 174 | */ |
190 | struct GNUNET_NAMESTORE_Header gns_header; | 175 | struct GNUNET_NAMESTORE_Header gns_header; |
191 | 176 | ||
177 | /** | ||
178 | * Expiration time | ||
179 | */ | ||
192 | struct GNUNET_TIME_AbsoluteNBO expire; | 180 | struct GNUNET_TIME_AbsoluteNBO expire; |
193 | 181 | ||
182 | |||
183 | /** | ||
184 | * Name length | ||
185 | */ | ||
194 | uint16_t name_len; | 186 | uint16_t name_len; |
195 | 187 | ||
188 | /** | ||
189 | * Bytes of serialized record data | ||
190 | */ | ||
196 | uint16_t rd_len; | 191 | uint16_t rd_len; |
197 | 192 | ||
193 | /** | ||
194 | * Number of records contained | ||
195 | */ | ||
198 | uint16_t rd_count; | 196 | uint16_t rd_count; |
199 | 197 | ||
198 | /** | ||
199 | * Is the signature valid | ||
200 | * GNUNET_YES or GNUNET_NO | ||
201 | */ | ||
200 | int16_t contains_sig; | 202 | int16_t contains_sig; |
201 | 203 | ||
202 | /** | 204 | /** |
@@ -205,18 +207,17 @@ struct LookupNameResponseMessage | |||
205 | struct GNUNET_CRYPTO_RsaSignature signature; | 207 | struct GNUNET_CRYPTO_RsaSignature signature; |
206 | 208 | ||
207 | /** | 209 | /** |
208 | * | 210 | * The public key for the name |
209 | */ | 211 | */ |
210 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; | 212 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; |
211 | 213 | ||
212 | /* 0-terminated name and serialized record data */ | 214 | /* 0-terminated name and serialized record data */ |
215 | /* rd_len bytes serialized record data */ | ||
213 | }; | 216 | }; |
214 | 217 | ||
215 | 218 | ||
216 | /** | 219 | /** |
217 | * Put a record to the namestore | 220 | * Put a record to the namestore |
218 | * Memory layout: | ||
219 | * [struct RecordPutMessage][char *name][rc_count * struct GNUNET_NAMESTORE_RecordData] | ||
220 | */ | 221 | */ |
221 | struct RecordPutMessage | 222 | struct RecordPutMessage |
222 | { | 223 | { |
@@ -226,17 +227,17 @@ struct RecordPutMessage | |||
226 | struct GNUNET_NAMESTORE_Header gns_header; | 227 | struct GNUNET_NAMESTORE_Header gns_header; |
227 | 228 | ||
228 | /** | 229 | /** |
229 | * | 230 | * Expiration time |
230 | */ | 231 | */ |
231 | struct GNUNET_TIME_AbsoluteNBO expire; | 232 | struct GNUNET_TIME_AbsoluteNBO expire; |
232 | 233 | ||
233 | /** | 234 | /** |
234 | * name length | 235 | * Name length |
235 | */ | 236 | */ |
236 | uint16_t name_len; | 237 | uint16_t name_len; |
237 | 238 | ||
238 | /** | 239 | /** |
239 | * Length of serialized rd data | 240 | * Length of serialized record data |
240 | */ | 241 | */ |
241 | uint16_t rd_len; | 242 | uint16_t rd_len; |
242 | 243 | ||
@@ -251,12 +252,12 @@ struct RecordPutMessage | |||
251 | uint16_t reserved; | 252 | uint16_t reserved; |
252 | 253 | ||
253 | /** | 254 | /** |
254 | * | 255 | * The signature |
255 | */ | 256 | */ |
256 | struct GNUNET_CRYPTO_RsaSignature signature; | 257 | struct GNUNET_CRYPTO_RsaSignature signature; |
257 | 258 | ||
258 | /** | 259 | /** |
259 | * | 260 | * The public key |
260 | */ | 261 | */ |
261 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; | 262 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; |
262 | 263 | ||
@@ -297,12 +298,12 @@ struct RecordCreateMessage | |||
297 | struct GNUNET_TIME_AbsoluteNBO expire; | 298 | struct GNUNET_TIME_AbsoluteNBO expire; |
298 | 299 | ||
299 | /** | 300 | /** |
300 | * name length | 301 | * Name length |
301 | */ | 302 | */ |
302 | uint16_t name_len; | 303 | uint16_t name_len; |
303 | 304 | ||
304 | /** | 305 | /** |
305 | * Record data length | 306 | * Length of serialized record data |
306 | */ | 307 | */ |
307 | uint16_t rd_len; | 308 | uint16_t rd_len; |
308 | 309 | ||
@@ -316,13 +317,16 @@ struct RecordCreateMessage | |||
316 | */ | 317 | */ |
317 | uint16_t pkey_len; | 318 | uint16_t pkey_len; |
318 | 319 | ||
319 | /* followed by: name and serialized record data --- PK??? */ | 320 | /* followed by: |
321 | * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len | ||
322 | * name with length name_len | ||
323 | * serialized record data with length rd_len | ||
324 | * */ | ||
320 | }; | 325 | }; |
321 | 326 | ||
322 | 327 | ||
323 | /** | 328 | /** |
324 | * Create a record to the namestore response | 329 | * Create a record to the namestore response |
325 | * Memory layout: | ||
326 | */ | 330 | */ |
327 | struct RecordCreateResponseMessage | 331 | struct RecordCreateResponseMessage |
328 | { | 332 | { |
@@ -335,14 +339,12 @@ struct RecordCreateResponseMessage | |||
335 | * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error | 339 | * name length: GNUNET_NO already exists, GNUNET_YES on success, GNUNET_SYSERR error |
336 | */ | 340 | */ |
337 | int32_t op_result; | 341 | int32_t op_result; |
338 | |||
339 | }; | 342 | }; |
340 | 343 | ||
341 | 344 | ||
342 | /** | 345 | /** |
343 | * Remove a record from the namestore | 346 | * Remove a record from the namestore |
344 | * Memory layout: | 347 | * Memory layout: |
345 | * [struct RecordRemoveMessage][char *name][struct GNUNET_NAMESTORE_RecordData] | ||
346 | */ | 348 | */ |
347 | struct RecordRemoveMessage | 349 | struct RecordRemoveMessage |
348 | { | 350 | { |
@@ -367,9 +369,15 @@ struct RecordRemoveMessage | |||
367 | uint16_t rd_count; | 369 | uint16_t rd_count; |
368 | 370 | ||
369 | /** | 371 | /** |
370 | * Length of pubkey | 372 | * Length of private key |
371 | */ | 373 | */ |
372 | uint16_t key_len; | 374 | uint16_t pkey_len; |
375 | |||
376 | /* followed by: | ||
377 | * GNUNET_CRYPTO_RsaPrivateKeyBinaryEncoded private key with length pkey_len | ||
378 | * name with length name_len | ||
379 | * serialized record data with length rd_len | ||
380 | * */ | ||
373 | }; | 381 | }; |
374 | 382 | ||
375 | 383 | ||
@@ -396,10 +404,13 @@ struct RecordRemoveResponseMessage | |||
396 | 404 | ||
397 | 405 | ||
398 | /** | 406 | /** |
399 | * Connect to namestore service | 407 | * Lookup a name for a zone hash |
400 | */ | 408 | */ |
401 | struct ZoneToNameMessage | 409 | struct ZoneToNameMessage |
402 | { | 410 | { |
411 | /** | ||
412 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME | ||
413 | */ | ||
403 | struct GNUNET_NAMESTORE_Header gns_header; | 414 | struct GNUNET_NAMESTORE_Header gns_header; |
404 | 415 | ||
405 | /** | 416 | /** |
@@ -414,28 +425,46 @@ struct ZoneToNameMessage | |||
414 | }; | 425 | }; |
415 | 426 | ||
416 | /** | 427 | /** |
417 | * Connect to namestore service | 428 | * Respone for zone to name lookup |
418 | */ | 429 | */ |
419 | struct ZoneToNameResponseMessage | 430 | struct ZoneToNameResponseMessage |
420 | { | 431 | { |
432 | /** | ||
433 | * Type will be GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE | ||
434 | */ | ||
421 | struct GNUNET_NAMESTORE_Header gns_header; | 435 | struct GNUNET_NAMESTORE_Header gns_header; |
422 | 436 | ||
437 | /** | ||
438 | * Record block expiration | ||
439 | */ | ||
423 | struct GNUNET_TIME_AbsoluteNBO expire; | 440 | struct GNUNET_TIME_AbsoluteNBO expire; |
424 | 441 | ||
442 | /** | ||
443 | * Length of the name | ||
444 | */ | ||
425 | uint16_t name_len; | 445 | uint16_t name_len; |
426 | 446 | ||
447 | /** | ||
448 | * Length of serialized record data | ||
449 | */ | ||
427 | uint16_t rd_len; | 450 | uint16_t rd_len; |
428 | 451 | ||
452 | /** | ||
453 | * Number of records contained | ||
454 | */ | ||
429 | uint16_t rd_count; | 455 | uint16_t rd_count; |
430 | 456 | ||
431 | /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */ | 457 | /* result in NBO: GNUNET_OK on success, GNUNET_NO if there were no results, GNUNET_SYSERR on error */ |
432 | int16_t res; | 458 | int16_t res; |
433 | 459 | ||
434 | /** | 460 | /** |
435 | * | 461 | * Signature |
436 | */ | 462 | */ |
437 | struct GNUNET_CRYPTO_RsaSignature signature; | 463 | struct GNUNET_CRYPTO_RsaSignature signature; |
438 | 464 | ||
465 | /** | ||
466 | * Publik key | ||
467 | */ | ||
439 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key; | 468 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key; |
440 | 469 | ||
441 | }; | 470 | }; |
@@ -452,12 +481,20 @@ struct ZoneIterationStartMessage | |||
452 | */ | 481 | */ |
453 | struct GNUNET_NAMESTORE_Header gns_header; | 482 | struct GNUNET_NAMESTORE_Header gns_header; |
454 | 483 | ||
484 | /** | ||
485 | * Zone hash | ||
486 | */ | ||
455 | GNUNET_HashCode zone; | 487 | GNUNET_HashCode zone; |
456 | 488 | ||
489 | /** | ||
490 | * Which flags must be included | ||
491 | */ | ||
457 | uint16_t must_have_flags; | 492 | uint16_t must_have_flags; |
458 | 493 | ||
494 | /** | ||
495 | * Which flags must not be included | ||
496 | */ | ||
459 | uint16_t must_not_have_flags; | 497 | uint16_t must_not_have_flags; |
460 | |||
461 | }; | 498 | }; |
462 | 499 | ||
463 | 500 | ||
@@ -519,7 +556,7 @@ struct ZoneIterationResponseMessage | |||
519 | struct GNUNET_CRYPTO_RsaSignature signature; | 556 | struct GNUNET_CRYPTO_RsaSignature signature; |
520 | 557 | ||
521 | /** | 558 | /** |
522 | * | 559 | * The public key |
523 | */ | 560 | */ |
524 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; | 561 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; |
525 | 562 | ||
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index 9634b6d4d..f885c2b7c 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -254,12 +254,10 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
254 | "LOOKUP_NAME_RESPONSE"); | 254 | "LOOKUP_NAME_RESPONSE"); |
255 | 255 | ||
256 | struct GNUNET_NAMESTORE_Handle *h = qe->nsh; | 256 | struct GNUNET_NAMESTORE_Handle *h = qe->nsh; |
257 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key; | ||
258 | char *name; | 257 | char *name; |
259 | char * rd_tmp; | 258 | char * rd_tmp; |
260 | 259 | ||
261 | struct GNUNET_CRYPTO_RsaSignature *signature = NULL; | 260 | struct GNUNET_CRYPTO_RsaSignature *signature = NULL; |
262 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded dummy; | ||
263 | struct GNUNET_TIME_Absolute expire; | 261 | struct GNUNET_TIME_Absolute expire; |
264 | size_t exp_msg_len; | 262 | size_t exp_msg_len; |
265 | size_t msg_len = 0; | 263 | size_t msg_len = 0; |
@@ -277,9 +275,7 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
277 | 275 | ||
278 | exp_msg_len = sizeof (struct LookupNameResponseMessage) + | 276 | exp_msg_len = sizeof (struct LookupNameResponseMessage) + |
279 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + | 277 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) + |
280 | name_len + | 278 | name_len + rd_len; |
281 | rd_len + | ||
282 | contains_sig * sizeof (struct GNUNET_CRYPTO_RsaSignature); | ||
283 | 279 | ||
284 | if (msg_len != exp_msg_len) | 280 | if (msg_len != exp_msg_len) |
285 | { | 281 | { |
@@ -288,11 +284,16 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
288 | GNUNET_break_op (0); | 284 | GNUNET_break_op (0); |
289 | return; | 285 | return; |
290 | } | 286 | } |
287 | if (name_len == 0) | ||
288 | { | ||
289 | GNUNET_break_op (0); | ||
290 | return; | ||
291 | } | ||
291 | 292 | ||
292 | zone_key = (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *) &msg[1]; | 293 | name = (char *) &msg[1]; |
293 | name = (char *) &zone_key[1]; | ||
294 | rd_tmp = &name[name_len]; | 294 | rd_tmp = &name[name_len]; |
295 | 295 | ||
296 | /* deserialize records */ | ||
296 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | 297 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
297 | GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd); | 298 | GNUNET_NAMESTORE_records_deserialize(rd_len, rd_tmp, rd_count, rd); |
298 | 299 | ||
@@ -300,17 +301,11 @@ handle_lookup_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
300 | if (contains_sig == GNUNET_NO) | 301 | if (contains_sig == GNUNET_NO) |
301 | signature = NULL; | 302 | signature = NULL; |
302 | else | 303 | else |
303 | signature = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_len]; | 304 | signature = &msg->signature; |
304 | if (name_len == 0) | ||
305 | name = NULL; | ||
306 | |||
307 | memset (&dummy, '0', sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | ||
308 | if (0 == memcmp (zone_key, &dummy, sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) | ||
309 | zone_key = NULL; | ||
310 | 305 | ||
311 | if (qe->proc != NULL) | 306 | if (qe->proc != NULL) |
312 | { | 307 | { |
313 | qe->proc (qe->proc_cls, zone_key, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature); | 308 | qe->proc (qe->proc_cls, &msg->public_key, expire, name, rd_count, (rd_count > 0) ? rd : NULL, signature); |
314 | } | 309 | } |
315 | 310 | ||
316 | /* Operation done, remove */ | 311 | /* Operation done, remove */ |
@@ -482,11 +477,9 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
482 | size_t name_len; | 477 | size_t name_len; |
483 | size_t rd_ser_len; | 478 | size_t rd_ser_len; |
484 | unsigned int rd_count; | 479 | unsigned int rd_count; |
485 | int have_signature; | ||
486 | 480 | ||
487 | char * name_tmp; | 481 | char * name_tmp; |
488 | char * rd_tmp; | 482 | char * rd_tmp; |
489 | struct GNUNET_CRYPTO_RsaSignature* sig_tmp; | ||
490 | 483 | ||
491 | if (res == GNUNET_SYSERR) | 484 | if (res == GNUNET_SYSERR) |
492 | { | 485 | { |
@@ -507,22 +500,16 @@ handle_zone_to_name_response (struct GNUNET_NAMESTORE_QueueEntry *qe, | |||
507 | name_len = ntohs (msg->name_len); | 500 | name_len = ntohs (msg->name_len); |
508 | rd_count = ntohs (msg->rd_count); | 501 | rd_count = ntohs (msg->rd_count); |
509 | rd_ser_len = ntohs (msg->rd_len); | 502 | rd_ser_len = ntohs (msg->rd_len); |
510 | have_signature = ntohl (msg->contains_sig); | ||
511 | expire = GNUNET_TIME_absolute_ntoh(msg->expire); | 503 | expire = GNUNET_TIME_absolute_ntoh(msg->expire); |
512 | 504 | ||
513 | name_tmp = (char *) &msg[1]; | 505 | name_tmp = (char *) &msg[1]; |
514 | rd_tmp = &name_tmp[name_len]; | 506 | rd_tmp = &name_tmp[name_len]; |
515 | if (have_signature == GNUNET_YES) | ||
516 | sig_tmp = (struct GNUNET_CRYPTO_RsaSignature *) &rd_tmp[rd_ser_len]; | ||
517 | else | ||
518 | sig_tmp = NULL; | ||
519 | 507 | ||
520 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | 508 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
521 | GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd); | 509 | GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_tmp, rd_count, rd); |
522 | 510 | ||
523 | if (qe->proc != NULL) | 511 | if (qe->proc != NULL) |
524 | qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, sig_tmp); | 512 | qe->proc (qe->proc_cls, &msg->zone_key, expire, name_tmp, rd_count, rd, &msg->signature); |
525 | |||
526 | } | 513 | } |
527 | else | 514 | else |
528 | GNUNET_break_op (0); | 515 | GNUNET_break_op (0); |
@@ -869,12 +856,6 @@ GNUNET_NAMESTORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
869 | return h; | 856 | return h; |
870 | } | 857 | } |
871 | 858 | ||
872 | struct DisconnectContext | ||
873 | { | ||
874 | struct GNUNET_NAMESTORE_Handle *h; | ||
875 | int drop; | ||
876 | }; | ||
877 | |||
878 | static void | 859 | static void |
879 | clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 860 | clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
880 | { | 861 | { |
@@ -917,36 +898,6 @@ clean_up_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
917 | h = NULL; | 898 | h = NULL; |
918 | }; | 899 | }; |
919 | 900 | ||
920 | static size_t | ||
921 | transmit_disconnect_to_namestore (void *cls, size_t size, void *buf) | ||
922 | { | ||
923 | struct DisconnectContext * d_ctx = cls; | ||
924 | struct DisconnectMessage d_msg; | ||
925 | struct GNUNET_NAMESTORE_Handle *h = d_ctx->h; | ||
926 | int res; | ||
927 | |||
928 | d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_DISCONNECT); | ||
929 | d_msg.header.size = htons (sizeof (struct DisconnectMessage)); | ||
930 | d_msg.drop = htonl (d_ctx->drop); | ||
931 | |||
932 | h->th = NULL; | ||
933 | if ((size == 0) || (buf == NULL) || (size < sizeof (struct DisconnectMessage))) | ||
934 | { | ||
935 | GNUNET_break (0); | ||
936 | res = 0; | ||
937 | } | ||
938 | else | ||
939 | { | ||
940 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to service \n", "NAMESTORE_DISCONNECT"); | ||
941 | memcpy (buf, &d_msg, sizeof (struct DisconnectMessage)); | ||
942 | res = sizeof (struct DisconnectMessage); | ||
943 | } | ||
944 | |||
945 | GNUNET_SCHEDULER_add_now (&clean_up_task, h); | ||
946 | GNUNET_free (d_ctx); | ||
947 | return res; | ||
948 | } | ||
949 | |||
950 | /** | 901 | /** |
951 | * Disconnect from the namestore service (and free associated | 902 | * Disconnect from the namestore service (and free associated |
952 | * resources). | 903 | * resources). |
@@ -957,29 +908,8 @@ transmit_disconnect_to_namestore (void *cls, size_t size, void *buf) | |||
957 | void | 908 | void |
958 | GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop) | 909 | GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h, int drop) |
959 | { | 910 | { |
960 | if (h->th != NULL) | 911 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Disconnecting from namestore service\n"); |
961 | { | ||
962 | GNUNET_CLIENT_notify_transmit_ready_cancel(h->th); | ||
963 | h->th = NULL; | ||
964 | } | ||
965 | if (h->client != NULL) | ||
966 | { | ||
967 | struct DisconnectContext *d_ctx = GNUNET_malloc (sizeof (struct DisconnectContext)); | ||
968 | d_ctx->h = h; | ||
969 | d_ctx->drop = drop; | ||
970 | |||
971 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, sizeof (struct DisconnectMessage), | ||
972 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
973 | GNUNET_NO, &transmit_disconnect_to_namestore, | ||
974 | d_ctx); | ||
975 | } | ||
976 | else | ||
977 | { | ||
978 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not send disconnect notification to namestore service, we are not connected!\n"); | ||
979 | if (GNUNET_YES == drop) | ||
980 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "NAMESTORE will not drop content\n"); | ||
981 | GNUNET_SCHEDULER_add_now (&clean_up_task, h); | 912 | GNUNET_SCHEDULER_add_now (&clean_up_task, h); |
982 | } | ||
983 | } | 913 | } |
984 | 914 | ||
985 | 915 | ||
@@ -1016,7 +946,6 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, | |||
1016 | struct PendingMessage *pe; | 946 | struct PendingMessage *pe; |
1017 | 947 | ||
1018 | /* pointer to elements */ | 948 | /* pointer to elements */ |
1019 | char * zone_key_tmp; | ||
1020 | char * rd_tmp; | 949 | char * rd_tmp; |
1021 | char * name_tmp; | 950 | char * name_tmp; |
1022 | 951 | ||
@@ -1061,22 +990,20 @@ GNUNET_NAMESTORE_record_put (struct GNUNET_NAMESTORE_Handle *h, | |||
1061 | pe->size = msg_size; | 990 | pe->size = msg_size; |
1062 | pe->is_init = GNUNET_NO; | 991 | pe->is_init = GNUNET_NO; |
1063 | msg = (struct RecordPutMessage *) &pe[1]; | 992 | msg = (struct RecordPutMessage *) &pe[1]; |
1064 | zone_key_tmp = (char *) &msg[1]; | 993 | name_tmp = (char *) &msg[1]; |
1065 | name_tmp = (char *) &zone_key_tmp[pubkey_len]; | ||
1066 | rd_tmp = &name_tmp[name_len]; | 994 | rd_tmp = &name_tmp[name_len]; |
1067 | 995 | ||
1068 | msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT); | 996 | msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_PUT); |
1069 | msg->gns_header.header.size = htons (msg_size); | 997 | msg->gns_header.header.size = htons (msg_size); |
1070 | msg->gns_header.r_id = htonl (rid); | 998 | msg->gns_header.r_id = htonl (rid); |
1071 | msg->key_len = htons (pubkey_len); | ||
1072 | memcpy (zone_key_tmp, zone_key, pubkey_len); | ||
1073 | msg->signature = *signature; | 999 | msg->signature = *signature; |
1074 | msg->name_len = htons (name_len); | 1000 | msg->name_len = htons (name_len); |
1075 | memcpy (name_tmp, name, name_len); | ||
1076 | msg->expire = GNUNET_TIME_absolute_hton (expire); | 1001 | msg->expire = GNUNET_TIME_absolute_hton (expire); |
1077 | msg->rd_len = htons (rd_ser_len); | 1002 | msg->rd_len = htons (rd_ser_len); |
1078 | msg->rd_count = htons (rd_count); | 1003 | msg->rd_count = htons (rd_count); |
1079 | 1004 | ||
1005 | msg->public_key = *zone_key; | ||
1006 | memcpy (name_tmp, name, name_len); | ||
1080 | memcpy (rd_tmp, rd_ser, rd_ser_len); | 1007 | memcpy (rd_tmp, rd_ser, rd_ser_len); |
1081 | 1008 | ||
1082 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size); | 1009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message for name `%s' with size %u\n", "NAMESTORE_RECORD_PUT", name, msg_size); |
@@ -1306,7 +1233,7 @@ GNUNET_NAMESTORE_record_remove (struct GNUNET_NAMESTORE_Handle *h, | |||
1306 | msg->name_len = htons (name_len); | 1233 | msg->name_len = htons (name_len); |
1307 | msg->rd_len = htons (rd_ser_len); | 1234 | msg->rd_len = htons (rd_ser_len); |
1308 | msg->rd_count = htons (1); | 1235 | msg->rd_count = htons (1); |
1309 | msg->key_len = htons (key_len); | 1236 | msg->pkey_len = htons (key_len); |
1310 | memcpy (pkey_tmp, pkey_enc, key_len); | 1237 | memcpy (pkey_tmp, pkey_enc, key_len); |
1311 | memcpy (name_tmp, name, name_len); | 1238 | memcpy (name_tmp, name, name_len); |
1312 | memcpy (rd_tmp, rd_ser, rd_ser_len); | 1239 | memcpy (rd_tmp, rd_ser, rd_ser_len); |
diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c index c1b5ddc1e..aa4603232 100644 --- a/src/namestore/namestore_common.c +++ b/src/namestore/namestore_common.c | |||
@@ -206,7 +206,7 @@ GNUNET_NAMESTORE_records_deserialize (size_t len, | |||
206 | struct GNUNET_CRYPTO_RsaSignature * | 206 | struct GNUNET_CRYPTO_RsaSignature * |
207 | GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, | 207 | GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, |
208 | const char *name, | 208 | const char *name, |
209 | struct GNUNET_NAMESTORE_RecordData *rd, | 209 | const struct GNUNET_NAMESTORE_RecordData *rd, |
210 | unsigned int rd_count) | 210 | unsigned int rd_count) |
211 | { | 211 | { |
212 | struct GNUNET_CRYPTO_RsaSignature *sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 212 | struct GNUNET_CRYPTO_RsaSignature *sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
diff --git a/src/namestore/plugin_namestore_sqlite.c b/src/namestore/plugin_namestore_sqlite.c index 429426701..98f89b3da 100644 --- a/src/namestore/plugin_namestore_sqlite.c +++ b/src/namestore/plugin_namestore_sqlite.c | |||
@@ -480,7 +480,7 @@ namestore_sqlite_put_records (void *cls, | |||
480 | GNUNET_CRYPTO_hash (name, name_len, &nh); | 480 | GNUNET_CRYPTO_hash (name, name_len, &nh); |
481 | memset (&zone_delegation, 0, sizeof (zone_delegation)); | 481 | memset (&zone_delegation, 0, sizeof (zone_delegation)); |
482 | for (i=0;i<rd_count;i++) | 482 | for (i=0;i<rd_count;i++) |
483 | if (rd[i].record_type == GNUNET_GNS_TYPE_PKEY) | 483 | if (rd[i].record_type == GNUNET_NAMESTORE_TYPE_PKEY) |
484 | { | 484 | { |
485 | GNUNET_assert (sizeof (GNUNET_HashCode) == rd[i].data_size); | 485 | GNUNET_assert (sizeof (GNUNET_HashCode) == rd[i].data_size); |
486 | memcpy (&zone_delegation, | 486 | memcpy (&zone_delegation, |