aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-27 16:37:56 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-27 16:37:56 +0000
commit1f5714ff6c83585cb7cd701ca3b7176ef42d3e60 (patch)
treed68317d8b4e6aafe83c4f3448fdfe1d125777599 /src/namestore
parent0773a954d6ed9a5c155b9cbceca7a6a316400ba6 (diff)
downloadgnunet-1f5714ff6c83585cb7cd701ca3b7176ef42d3e60.tar.gz
gnunet-1f5714ff6c83585cb7cd701ca3b7176ef42d3e60.zip
using DNS2GNS record type instead of recycling NS record type in GNS; fixing testcase by properly converting DNS records back to GNS blocks
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/namestore_api_common.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/namestore/namestore_api_common.c b/src/namestore/namestore_api_common.c
index 42969778f..b5a777083 100644
--- a/src/namestore/namestore_api_common.c
+++ b/src/namestore/namestore_api_common.c
@@ -501,7 +501,7 @@ GNUNET_NAMESTORE_block_decrypt (const struct GNUNET_NAMESTORE_Block *block,
501 * 501 *
502 * @param type type of the record 502 * @param type type of the record
503 * @param data value in binary encoding 503 * @param data value in binary encoding
504 * @param data_size number of bytes in data 504 * @param data_size number of bytes in @a data
505 * @return NULL on error, otherwise human-readable representation of the value 505 * @return NULL on error, otherwise human-readable representation of the value
506 */ 506 */
507char * 507char *
@@ -661,6 +661,23 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type,
661 } 661 }
662 return vpn_str; 662 return vpn_str;
663 } 663 }
664 case GNUNET_NAMESTORE_TYPE_GNS2DNS:
665 {
666 char *ns;
667 size_t off;
668
669 off = 0;
670 ns = GNUNET_DNSPARSER_parse_name (data,
671 data_size,
672 &off);
673 if ( (NULL == ns) ||
674 (off != data_size) )
675 {
676 GNUNET_break_op (0);
677 return NULL;
678 }
679 return ns;
680 }
664 case GNUNET_DNSPARSER_TYPE_SRV: 681 case GNUNET_DNSPARSER_TYPE_SRV:
665 { 682 {
666 struct GNUNET_DNSPARSER_SrvRecord *srv; 683 struct GNUNET_DNSPARSER_SrvRecord *srv;
@@ -971,6 +988,28 @@ GNUNET_NAMESTORE_string_to_value (uint32_t type,
971 vpn->proto = htons ((uint16_t) proto); 988 vpn->proto = htons ((uint16_t) proto);
972 strcpy ((char*)&vpn[1], s_serv); 989 strcpy ((char*)&vpn[1], s_serv);
973 return GNUNET_OK; 990 return GNUNET_OK;
991 case GNUNET_NAMESTORE_TYPE_GNS2DNS:
992 {
993 char nsbuf[256];
994 size_t off;
995
996 off = 0;
997 if (GNUNET_OK !=
998 GNUNET_DNSPARSER_builder_add_name (nsbuf,
999 sizeof (nsbuf),
1000 &off,
1001 s))
1002 {
1003 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1004 _("Failed to serialize GNS2DNS record with value `%s'\n"),
1005 s);
1006 return GNUNET_SYSERR;
1007 }
1008 *data_size = off;
1009 *data = GNUNET_malloc (off);
1010 memcpy (*data, nsbuf, off);
1011 return GNUNET_OK;
1012 }
974 case GNUNET_DNSPARSER_TYPE_TLSA: 1013 case GNUNET_DNSPARSER_TYPE_TLSA:
975 *data_size = sizeof (struct GNUNET_TUN_DnsTlsaRecord) + strlen (s) - 6; 1014 *data_size = sizeof (struct GNUNET_TUN_DnsTlsaRecord) + strlen (s) - 6;
976 *data = tlsa = GNUNET_malloc (*data_size); 1015 *data = tlsa = GNUNET_malloc (*data_size);
@@ -1017,6 +1056,7 @@ static struct {
1017 { "PSEU", GNUNET_NAMESTORE_TYPE_PSEU }, 1056 { "PSEU", GNUNET_NAMESTORE_TYPE_PSEU },
1018 { "LEHO", GNUNET_NAMESTORE_TYPE_LEHO }, 1057 { "LEHO", GNUNET_NAMESTORE_TYPE_LEHO },
1019 { "VPN", GNUNET_NAMESTORE_TYPE_VPN }, 1058 { "VPN", GNUNET_NAMESTORE_TYPE_VPN },
1059 { "GNS2DNS", GNUNET_NAMESTORE_TYPE_GNS2DNS },
1020 { "TLSA", GNUNET_DNSPARSER_TYPE_TLSA }, 1060 { "TLSA", GNUNET_DNSPARSER_TYPE_TLSA },
1021 { NULL, UINT32_MAX } 1061 { NULL, UINT32_MAX }
1022}; 1062};