diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-28 18:14:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-28 18:14:01 +0000 |
commit | b4b5e74393c6d1621bd5b907e9a1fc5843ecb2f2 (patch) | |
tree | 86ce53299a672afc433e4e1f9fc687b8725380c7 /src/namestore | |
parent | d69f0353b867c65c84e46ac710d93685e25a4ed8 (diff) | |
download | gnunet-b4b5e74393c6d1621bd5b907e9a1fc5843ecb2f2.tar.gz gnunet-b4b5e74393c6d1621bd5b907e9a1fc5843ecb2f2.zip |
-namestore cleanup and fixes -- wip
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 216 |
1 files changed, 96 insertions, 120 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 95f9efac8..619119725 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -1133,7 +1133,7 @@ handle_record_create (void *cls, | |||
1133 | return; | 1133 | return; |
1134 | } | 1134 | } |
1135 | if (GNUNET_OK != | 1135 | if (GNUNET_OK != |
1136 | GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, 1, &rd)) | 1136 | GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, &rd)) |
1137 | { | 1137 | { |
1138 | GNUNET_break (0); | 1138 | GNUNET_break (0); |
1139 | GNUNET_CRYPTO_rsa_key_free (pkey); | 1139 | GNUNET_CRYPTO_rsa_key_free (pkey); |
@@ -1358,6 +1358,7 @@ handle_record_remove (void *cls, | |||
1358 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; | 1358 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub; |
1359 | struct GNUNET_CRYPTO_ShortHashCode pubkey_hash; | 1359 | struct GNUNET_CRYPTO_ShortHashCode pubkey_hash; |
1360 | struct GNUNET_HashCode long_hash; | 1360 | struct GNUNET_HashCode long_hash; |
1361 | struct GNUNET_NAMESTORE_RecordData rd; | ||
1361 | const char *pkey_tmp; | 1362 | const char *pkey_tmp; |
1362 | const char *name_tmp; | 1363 | const char *name_tmp; |
1363 | const char *rd_ser; | 1364 | const char *rd_ser; |
@@ -1365,11 +1366,11 @@ handle_record_remove (void *cls, | |||
1365 | size_t name_len; | 1366 | size_t name_len; |
1366 | size_t rd_ser_len; | 1367 | size_t rd_ser_len; |
1367 | size_t msg_size; | 1368 | size_t msg_size; |
1368 | size_t msg_size_exp = 0; | 1369 | size_t msg_size_exp; |
1369 | uint32_t rd_count; | 1370 | uint32_t rd_count; |
1370 | uint32_t rid; | 1371 | uint32_t rid; |
1371 | 1372 | struct RemoveRecordContext rrc; | |
1372 | int res = GNUNET_SYSERR; | 1373 | int res; |
1373 | 1374 | ||
1374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_REMOVE"); | 1375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "NAMESTORE_RECORD_REMOVE"); |
1375 | if (ntohs (message->size) < sizeof (struct RecordRemoveMessage)) | 1376 | if (ntohs (message->size) < sizeof (struct RecordRemoveMessage)) |
@@ -1391,8 +1392,7 @@ handle_record_remove (void *cls, | |||
1391 | rd_count = ntohs (rr_msg->rd_count); | 1392 | rd_count = ntohs (rr_msg->rd_count); |
1392 | key_len = ntohs (rr_msg->pkey_len); | 1393 | key_len = ntohs (rr_msg->pkey_len); |
1393 | msg_size = ntohs (message->size); | 1394 | msg_size = ntohs (message->size); |
1394 | 1395 | if ((name_len >= MAX_NAME_LEN) || (0 == name_len) || (1 < rd_count) ) | |
1395 | if ((name_len >=MAX_NAME_LEN) || (0 == name_len)) | ||
1396 | { | 1396 | { |
1397 | GNUNET_break (0); | 1397 | GNUNET_break (0); |
1398 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1398 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -1421,9 +1421,10 @@ handle_record_remove (void *cls, | |||
1421 | return; | 1421 | return; |
1422 | } | 1422 | } |
1423 | GNUNET_CRYPTO_rsa_key_get_public (pkey, &pub); | 1423 | GNUNET_CRYPTO_rsa_key_get_public (pkey, &pub); |
1424 | GNUNET_CRYPTO_short_hash (&pub, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &pubkey_hash); | 1424 | GNUNET_CRYPTO_short_hash (&pub, |
1425 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
1426 | &pubkey_hash); | ||
1425 | GNUNET_CRYPTO_short_hash_double (&pubkey_hash, &long_hash); | 1427 | GNUNET_CRYPTO_short_hash_double (&pubkey_hash, &long_hash); |
1426 | |||
1427 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (zonekeys, &long_hash)) | 1428 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (zonekeys, &long_hash)) |
1428 | { | 1429 | { |
1429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1437,26 +1438,24 @@ handle_record_remove (void *cls, | |||
1437 | &long_hash, cc, | 1438 | &long_hash, cc, |
1438 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1439 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1439 | } | 1440 | } |
1440 | 1441 | if (GNUNET_OK != | |
1441 | 1442 | GNUNET_NAMESTORE_records_deserialize (rd_ser_len, rd_ser, rd_count, &rd)) | |
1442 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | ||
1443 | res = GNUNET_NAMESTORE_records_deserialize(rd_ser_len, rd_ser, rd_count, rd); | ||
1444 | if ((res != GNUNET_OK) || (rd_count > 1)) | ||
1445 | { | 1443 | { |
1446 | GNUNET_break_op (0); | 1444 | GNUNET_break (0); |
1447 | goto send; | 1445 | GNUNET_CRYPTO_rsa_key_free (pkey); |
1446 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1447 | return; | ||
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | if (0 == rd_count) | 1450 | if (0 == rd_count) |
1451 | { | 1451 | { |
1452 | /* remove the whole name and all records */ | 1452 | /* remove the whole name and all records */ |
1453 | /* Database operation */ | ||
1454 | res = GSN_database->remove_records (GSN_database->cls, | 1453 | res = GSN_database->remove_records (GSN_database->cls, |
1455 | &pubkey_hash, | 1454 | &pubkey_hash, |
1456 | name_tmp); | 1455 | name_tmp); |
1457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing name `%s': %s\n", | 1456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1458 | name_tmp, (GNUNET_OK == res) ? "OK" : "FAIL"); | 1457 | "Removing name `%s': %s\n", |
1459 | 1458 | name_tmp, (GNUNET_OK == res) ? "OK" : "FAIL"); | |
1460 | if (GNUNET_OK != res) | 1459 | if (GNUNET_OK != res) |
1461 | /* Could not remove entry from database */ | 1460 | /* Could not remove entry from database */ |
1462 | res = 4; | 1461 | res = 4; |
@@ -1466,40 +1465,39 @@ handle_record_remove (void *cls, | |||
1466 | else | 1465 | else |
1467 | { | 1466 | { |
1468 | /* remove a single record */ | 1467 | /* remove a single record */ |
1469 | struct RemoveRecordContext rrc; | 1468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1470 | rrc.rd = rd; | 1469 | "Removing record for name `%s' in zone `%s'\n", name_tmp, |
1470 | GNUNET_short_h2s (&pubkey_hash)); | ||
1471 | rrc.rd = &rd; | ||
1471 | rrc.pkey = pkey; | 1472 | rrc.pkey = pkey; |
1472 | |||
1473 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for name `%s' in zone `%s'\n", name_tmp, GNUNET_short_h2s(&pubkey_hash)); | ||
1474 | |||
1475 | /* Database operation */ | ||
1476 | res = GSN_database->iterate_records (GSN_database->cls, | 1473 | res = GSN_database->iterate_records (GSN_database->cls, |
1477 | &pubkey_hash, | 1474 | &pubkey_hash, |
1478 | name_tmp, | 1475 | name_tmp, |
1479 | 0, | 1476 | 0, |
1480 | handle_record_remove_it, &rrc); | 1477 | handle_record_remove_it, &rrc); |
1481 | 1478 | ||
1482 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Removing record for name `%s': %s\n", | 1479 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1483 | name_tmp, (rrc.op_res == 0) ? "OK" : "FAIL"); | 1480 | "Removing record for name `%s': %s\n", |
1481 | name_tmp, | ||
1482 | (0 == rrc.op_res) ? "OK" : "FAIL"); | ||
1484 | res = rrc.op_res; | 1483 | res = rrc.op_res; |
1485 | } | 1484 | } |
1486 | /* Send response */ | 1485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1487 | send: | 1486 | "Sending `%s' message\n", |
1488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "RECORD_REMOVE_RESPONSE"); | 1487 | "RECORD_REMOVE_RESPONSE"); |
1489 | rrr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE); | 1488 | rrr_msg.gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_REMOVE_RESPONSE); |
1490 | rrr_msg.gns_header.header.size = htons (sizeof (struct RecordRemoveResponseMessage)); | 1489 | rrr_msg.gns_header.header.size = htons (sizeof (struct RecordRemoveResponseMessage)); |
1491 | rrr_msg.gns_header.r_id = htonl (rid); | 1490 | rrr_msg.gns_header.r_id = htonl (rid); |
1492 | rrr_msg.op_result = htonl (res); | 1491 | rrr_msg.op_result = htonl (res); |
1493 | GNUNET_SERVER_notification_context_unicast (snc, nc->client, (const struct GNUNET_MessageHeader *) &rrr_msg, GNUNET_NO); | 1492 | GNUNET_SERVER_notification_context_unicast (snc, nc->client, |
1494 | 1493 | &rrr_msg.gns_header.header, | |
1494 | GNUNET_NO); | ||
1495 | GNUNET_CRYPTO_rsa_key_free (pkey); | 1495 | GNUNET_CRYPTO_rsa_key_free (pkey); |
1496 | |||
1497 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1496 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1498 | } | 1497 | } |
1499 | 1498 | ||
1499 | |||
1500 | /** | 1500 | /** |
1501 | * ZoneToNameCtx | ||
1502 | * | ||
1503 | * Context for record remove operations passed from 'handle_zone_to_name' to | 1501 | * Context for record remove operations passed from 'handle_zone_to_name' to |
1504 | * 'handle_zone_to_name_it' as closure | 1502 | * 'handle_zone_to_name_it' as closure |
1505 | */ | 1503 | */ |
@@ -1514,6 +1512,11 @@ struct ZoneToNameCtx | |||
1514 | * Request id | 1512 | * Request id |
1515 | */ | 1513 | */ |
1516 | uint32_t rid; | 1514 | uint32_t rid; |
1515 | |||
1516 | /** | ||
1517 | * Set to GNUNET_OK on success, GNUNET_SYSERR on error | ||
1518 | */ | ||
1519 | int success; | ||
1517 | }; | 1520 | }; |
1518 | 1521 | ||
1519 | 1522 | ||
@@ -1530,22 +1533,19 @@ struct ZoneToNameCtx | |||
1530 | */ | 1533 | */ |
1531 | static void | 1534 | static void |
1532 | handle_zone_to_name_it (void *cls, | 1535 | handle_zone_to_name_it (void *cls, |
1533 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, | 1536 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key, |
1534 | struct GNUNET_TIME_Absolute expire, | 1537 | struct GNUNET_TIME_Absolute expire, |
1535 | const char *name, | 1538 | const char *name, |
1536 | unsigned int rd_count, | 1539 | unsigned int rd_count, |
1537 | const struct GNUNET_NAMESTORE_RecordData *rd, | 1540 | const struct GNUNET_NAMESTORE_RecordData *rd, |
1538 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 1541 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
1539 | { | 1542 | { |
1540 | struct ZoneToNameCtx *ztn_ctx = cls; | 1543 | struct ZoneToNameCtx *ztn_ctx = cls; |
1541 | struct ZoneToNameResponseMessage *ztnr_msg; | 1544 | struct ZoneToNameResponseMessage *ztnr_msg; |
1542 | int16_t res = GNUNET_SYSERR; | 1545 | int16_t res; |
1543 | uint16_t name_len = 0; | 1546 | size_t name_len; |
1544 | uint16_t rd_ser_len = 0 ; | 1547 | size_t rd_ser_len; |
1545 | int32_t contains_sig = 0; | 1548 | size_t msg_size; |
1546 | size_t msg_size = 0; | ||
1547 | |||
1548 | char *rd_ser = NULL; | ||
1549 | char *name_tmp; | 1549 | char *name_tmp; |
1550 | char *rd_tmp; | 1550 | char *rd_tmp; |
1551 | char *sig_tmp; | 1551 | char *sig_tmp; |
@@ -1555,7 +1555,7 @@ handle_zone_to_name_it (void *cls, | |||
1555 | /* found result */ | 1555 | /* found result */ |
1556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found results: name is `%s', has %u records\n", name, rd_count); | 1556 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found results: name is `%s', has %u records\n", name, rd_count); |
1557 | res = GNUNET_YES; | 1557 | res = GNUNET_YES; |
1558 | name_len = strlen (name) +1; | 1558 | name_len = strlen (name) + 1; |
1559 | } | 1559 | } |
1560 | else | 1560 | else |
1561 | { | 1561 | { |
@@ -1566,27 +1566,23 @@ handle_zone_to_name_it (void *cls, | |||
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | if (rd_count > 0) | 1568 | if (rd_count > 0) |
1569 | { | ||
1570 | rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); | 1569 | rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd); |
1571 | rd_ser = GNUNET_malloc (rd_ser_len); | ||
1572 | GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser); | ||
1573 | } | ||
1574 | else | 1570 | else |
1575 | rd_ser_len = 0; | 1571 | rd_ser_len = 0; |
1576 | 1572 | ||
1577 | if (signature != NULL) | 1573 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1578 | contains_sig = GNUNET_YES; | 1574 | "Sending `%s' message\n", |
1579 | else | 1575 | "ZONE_TO_NAME_RESPONSE"); |
1580 | contains_sig = GNUNET_NO; | 1576 | msg_size = sizeof (struct ZoneToNameResponseMessage) + name_len + rd_ser_len; |
1581 | 1577 | if (NULL != signature) | |
1582 | msg_size = sizeof (struct ZoneToNameResponseMessage) + name_len + rd_ser_len + contains_sig * sizeof (struct GNUNET_CRYPTO_RsaSignature); | 1578 | msg_size += sizeof (struct GNUNET_CRYPTO_RsaSignature); |
1579 | if (msg_size >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | ||
1580 | { | ||
1581 | GNUNET_break (0); | ||
1582 | ztn_ctx->success = GNUNET_SYSERR; | ||
1583 | return; | ||
1584 | } | ||
1583 | ztnr_msg = GNUNET_malloc (msg_size); | 1585 | ztnr_msg = GNUNET_malloc (msg_size); |
1584 | |||
1585 | name_tmp = (char *) &ztnr_msg[1]; | ||
1586 | rd_tmp = &name_tmp[name_len]; | ||
1587 | sig_tmp = &rd_tmp[rd_ser_len]; | ||
1588 | |||
1589 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message\n", "ZONE_TO_NAME_RESPONSE"); | ||
1590 | ztnr_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); | 1586 | ztnr_msg->gns_header.header.type = htons (GNUNET_MESSAGE_TYPE_NAMESTORE_ZONE_TO_NAME_RESPONSE); |
1591 | ztnr_msg->gns_header.header.size = htons (msg_size); | 1587 | ztnr_msg->gns_header.header.size = htons (msg_size); |
1592 | ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid); | 1588 | ztnr_msg->gns_header.r_id = htonl (ztn_ctx->rid); |
@@ -1594,24 +1590,22 @@ handle_zone_to_name_it (void *cls, | |||
1594 | ztnr_msg->rd_len = htons (rd_ser_len); | 1590 | ztnr_msg->rd_len = htons (rd_ser_len); |
1595 | ztnr_msg->rd_count = htons (rd_count); | 1591 | ztnr_msg->rd_count = htons (rd_count); |
1596 | ztnr_msg->name_len = htons (name_len); | 1592 | ztnr_msg->name_len = htons (name_len); |
1597 | ztnr_msg->expire = GNUNET_TIME_absolute_hton(expire); | 1593 | ztnr_msg->expire = GNUNET_TIME_absolute_hton (expire); |
1598 | if (zone_key != NULL) | 1594 | if (NULL != zone_key) |
1599 | ztnr_msg->zone_key = *zone_key; | 1595 | ztnr_msg->zone_key = *zone_key; |
1600 | else | 1596 | name_tmp = (char *) &ztnr_msg[1]; |
1601 | memset (&ztnr_msg->zone_key, '\0', sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 1597 | if (NULL != name) |
1602 | |||
1603 | if ((name_len > 0) && (name != NULL)) | ||
1604 | memcpy (name_tmp, name, name_len); | 1598 | memcpy (name_tmp, name, name_len); |
1605 | 1599 | rd_tmp = &name_tmp[name_len]; | |
1606 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Name is `%s', has %u records, rd ser len %u msg_size %u\n", name, rd_count, rd_ser_len, msg_size); | 1600 | GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_tmp); |
1607 | if ((rd_ser_len > 0) && (rd_ser != NULL)) | 1601 | sig_tmp = &rd_tmp[rd_ser_len]; |
1608 | memcpy (rd_tmp, rd_ser, rd_ser_len); | 1602 | if (NULL != signature) |
1609 | if ((GNUNET_YES == contains_sig) && (signature != NULL)) | 1603 | memcpy (sig_tmp, signature, sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
1610 | memcpy (sig_tmp, signature, contains_sig * sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 1604 | ztn_ctx->success = GNUNET_OK; |
1611 | 1605 | GNUNET_SERVER_notification_context_unicast (snc, ztn_ctx->nc->client, | |
1612 | GNUNET_SERVER_notification_context_unicast (snc, ztn_ctx->nc->client, (const struct GNUNET_MessageHeader *) ztnr_msg, GNUNET_NO); | 1606 | &ztnr_msg->gns_header.header, |
1607 | GNUNET_NO); | ||
1613 | GNUNET_free (ztnr_msg); | 1608 | GNUNET_free (ztnr_msg); |
1614 | GNUNET_free_non_null (rd_ser); | ||
1615 | } | 1609 | } |
1616 | 1610 | ||
1617 | 1611 | ||
@@ -1627,51 +1621,34 @@ handle_zone_to_name (void *cls, | |||
1627 | struct GNUNET_SERVER_Client *client, | 1621 | struct GNUNET_SERVER_Client *client, |
1628 | const struct GNUNET_MessageHeader *message) | 1622 | const struct GNUNET_MessageHeader *message) |
1629 | { | 1623 | { |
1630 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "ZONE_TO_NAME"); | ||
1631 | struct GNUNET_NAMESTORE_Client *nc; | 1624 | struct GNUNET_NAMESTORE_Client *nc; |
1632 | struct ZoneToNameMessage *ztn_msg; | 1625 | const struct ZoneToNameMessage *ztn_msg; |
1633 | struct ZoneToNameCtx ztn_ctx; | 1626 | struct ZoneToNameCtx ztn_ctx; |
1634 | size_t msg_size = 0; | ||
1635 | uint32_t rid = 0; | ||
1636 | 1627 | ||
1628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1629 | "Received `%s' message\n", | ||
1630 | "ZONE_TO_NAME"); | ||
1637 | if (ntohs (message->size) != sizeof (struct ZoneToNameMessage)) | 1631 | if (ntohs (message->size) != sizeof (struct ZoneToNameMessage)) |
1638 | { | 1632 | { |
1639 | GNUNET_break_op (0); | 1633 | GNUNET_break (0); |
1640 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1634 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1641 | return; | ||
1642 | } | ||
1643 | |||
1644 | nc = client_lookup(client); | ||
1645 | if (nc == NULL) | ||
1646 | { | ||
1647 | GNUNET_break_op (0); | ||
1648 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1649 | return; | 1635 | return; |
1650 | } | 1636 | } |
1651 | 1637 | if (NULL == (nc = client_lookup(client))) | |
1652 | ztn_msg = (struct ZoneToNameMessage *) message; | ||
1653 | |||
1654 | if (msg_size > GNUNET_SERVER_MAX_MESSAGE_SIZE) | ||
1655 | { | 1638 | { |
1656 | GNUNET_break_op (0); | 1639 | GNUNET_break (0); |
1657 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1640 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1658 | return; | 1641 | return; |
1659 | } | 1642 | } |
1660 | 1643 | ztn_msg = (const struct ZoneToNameMessage *) message; | |
1661 | rid = ntohl (ztn_msg->gns_header.r_id); | 1644 | ztn_ctx.rid = ntohl (ztn_msg->gns_header.r_id); |
1662 | |||
1663 | ztn_ctx.rid = rid; | ||
1664 | ztn_ctx.nc = nc; | 1645 | ztn_ctx.nc = nc; |
1665 | 1646 | ztn_ctx.success = GNUNET_SYSERR; | |
1666 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded z_tmp; | 1647 | GSN_database->zone_to_name (GSN_database->cls, |
1667 | GNUNET_CRYPTO_short_hash_to_enc(&ztn_msg->zone, &z_tmp); | 1648 | &ztn_msg->zone, |
1668 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Looking up name for zone `%s' in zone `%s'\n", | 1649 | &ztn_msg->value_zone, |
1669 | (char *) &z_tmp, | 1650 | &handle_zone_to_name_it, &ztn_ctx); |
1670 | GNUNET_short_h2s (&ztn_msg->value_zone)); | 1651 | GNUNET_SERVER_receive_done (client, ztn_ctx.success); |
1671 | |||
1672 | GSN_database->zone_to_name (GSN_database->cls, &ztn_msg->zone, &ztn_msg->value_zone, &handle_zone_to_name_it, &ztn_ctx); | ||
1673 | |||
1674 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
1675 | } | 1652 | } |
1676 | 1653 | ||
1677 | 1654 | ||
@@ -1682,7 +1659,8 @@ handle_zone_to_name (void *cls, | |||
1682 | * @param dest destination record | 1659 | * @param dest destination record |
1683 | */ | 1660 | */ |
1684 | static void | 1661 | static void |
1685 | copy_record (const struct GNUNET_NAMESTORE_RecordData *src, struct GNUNET_NAMESTORE_RecordData *dest) | 1662 | copy_record (const struct GNUNET_NAMESTORE_RecordData *src, |
1663 | struct GNUNET_NAMESTORE_RecordData *dest) | ||
1686 | { | 1664 | { |
1687 | memcpy (dest, src, sizeof (struct GNUNET_NAMESTORE_RecordData)); | 1665 | memcpy (dest, src, sizeof (struct GNUNET_NAMESTORE_RecordData)); |
1688 | dest->data = GNUNET_malloc (src->data_size); | 1666 | dest->data = GNUNET_malloc (src->data_size); |
@@ -1691,8 +1669,6 @@ copy_record (const struct GNUNET_NAMESTORE_RecordData *src, struct GNUNET_NAMEST | |||
1691 | 1669 | ||
1692 | 1670 | ||
1693 | /** | 1671 | /** |
1694 | * ZoneIterationProcResult | ||
1695 | * | ||
1696 | * Context for record remove operations passed from | 1672 | * Context for record remove operations passed from |
1697 | * 'find_next_zone_iteration_result' to 'zone_iteraterate_proc' as closure | 1673 | * 'find_next_zone_iteration_result' to 'zone_iteraterate_proc' as closure |
1698 | */ | 1674 | */ |
@@ -1719,7 +1695,7 @@ struct ZoneIterationProcResult | |||
1719 | int has_signature; | 1695 | int has_signature; |
1720 | 1696 | ||
1721 | /** | 1697 | /** |
1722 | * Name | 1698 | * Name???? |
1723 | */ | 1699 | */ |
1724 | char *name; | 1700 | char *name; |
1725 | 1701 | ||