diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-05 15:40:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-05 15:40:55 +0000 |
commit | 95b51ca1ee2a3d75a9570934dfcf1862cf830b7e (patch) | |
tree | b9784d7a5669524f4b28a08218a2cc95e420766a /src/namestore | |
parent | d710c7df91151dde63d3304e4fdb27dc5fa8c781 (diff) | |
download | gnunet-95b51ca1ee2a3d75a9570934dfcf1862cf830b7e.tar.gz gnunet-95b51ca1ee2a3d75a9570934dfcf1862cf830b7e.zip |
-enable printing and parsing of conversation's PHONE records
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/namestore_api_common.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/namestore/namestore_api_common.c b/src/namestore/namestore_api_common.c index 5ba8e6f37..c965b528e 100644 --- a/src/namestore/namestore_api_common.c +++ b/src/namestore/namestore_api_common.c | |||
@@ -652,6 +652,25 @@ GNUNET_NAMESTORE_value_to_string (uint32_t type, | |||
652 | if (data_size != sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)) | 652 | if (data_size != sizeof (struct GNUNET_CRYPTO_EccPublicSignKey)) |
653 | return NULL; | 653 | return NULL; |
654 | return GNUNET_CRYPTO_ecc_public_sign_key_to_string (data); | 654 | return GNUNET_CRYPTO_ecc_public_sign_key_to_string (data); |
655 | case GNUNET_NAMESTORE_TYPE_PKEY: | ||
656 | { | ||
657 | const struct GNUNET_CONVERSATION_PhoneRecord *pr; | ||
658 | char *ret; | ||
659 | char *pkey; | ||
660 | |||
661 | if (data_size != sizeof (struct GNUNET_CONVERSATION_PhoneRecord)) | ||
662 | return NULL; | ||
663 | pr = data; | ||
664 | if (0 != ntohl (pr->version)) | ||
665 | return NULL; | ||
666 | pkey = GNUNET_CRYPTO_ecc_public_sign_key_to_string (&pr->peer.public_key); | ||
667 | GNUNET_asprintf (&ret, | ||
668 | "%u-%s", | ||
669 | ntohl (pr->line), | ||
670 | pkey); | ||
671 | GNUNET_free (pkey); | ||
672 | return ret; | ||
673 | } | ||
655 | case GNUNET_NAMESTORE_TYPE_PSEU: | 674 | case GNUNET_NAMESTORE_TYPE_PSEU: |
656 | return GNUNET_strndup (data, data_size); | 675 | return GNUNET_strndup (data, data_size); |
657 | case GNUNET_NAMESTORE_TYPE_LEHO: | 676 | case GNUNET_NAMESTORE_TYPE_LEHO: |
@@ -974,6 +993,33 @@ GNUNET_NAMESTORE_string_to_value (uint32_t type, | |||
974 | memcpy (*data, &pkey, sizeof (pkey)); | 993 | memcpy (*data, &pkey, sizeof (pkey)); |
975 | *data_size = sizeof (struct GNUNET_CRYPTO_EccPublicSignKey); | 994 | *data_size = sizeof (struct GNUNET_CRYPTO_EccPublicSignKey); |
976 | return GNUNET_OK; | 995 | return GNUNET_OK; |
996 | case GNUNET_NAMESTORE_TYPE_PHONE: | ||
997 | { | ||
998 | struct GNUNET_CONVERSATION_PhoneRecord *pr; | ||
999 | unsigned int line; | ||
1000 | const char *dash; | ||
1001 | struct GNUNET_PeerIdentity peer; | ||
1002 | |||
1003 | if ( (NULL == (dash = strchr (s, "-"))) || | ||
1004 | (1 != sscanf (s, "%u-", &line)) || | ||
1005 | (GNUNET_OK != | ||
1006 | GNUNET_CRYPTO_ecc_public_sign_key_from_string (dash + 1, | ||
1007 | strlen (dash + 1), | ||
1008 | &peer.public_key)) ) | ||
1009 | { | ||
1010 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
1011 | _("Unable to parse PHONE record `%s'\n"), | ||
1012 | s); | ||
1013 | return GNUNET_SYSERR; | ||
1014 | } | ||
1015 | pr = GNUNET_new (struct GNUNET_CONVERSATION_PhoneRecord); | ||
1016 | pr->version = htonl (0); | ||
1017 | pr->line = htonl ((uint32_t) line); | ||
1018 | pr->peer = peer; | ||
1019 | *data = pr; | ||
1020 | *data_size = sizeof (struct GNUNET_CONVERSATION_PhoneRecord); | ||
1021 | return GNUNET_OK; | ||
1022 | } | ||
977 | case GNUNET_NAMESTORE_TYPE_PSEU: | 1023 | case GNUNET_NAMESTORE_TYPE_PSEU: |
978 | *data = GNUNET_strdup (s); | 1024 | *data = GNUNET_strdup (s); |
979 | *data_size = strlen (s); | 1025 | *data_size = strlen (s); |
@@ -1073,6 +1119,7 @@ static struct { | |||
1073 | { "LEHO", GNUNET_NAMESTORE_TYPE_LEHO }, | 1119 | { "LEHO", GNUNET_NAMESTORE_TYPE_LEHO }, |
1074 | { "VPN", GNUNET_NAMESTORE_TYPE_VPN }, | 1120 | { "VPN", GNUNET_NAMESTORE_TYPE_VPN }, |
1075 | { "GNS2DNS", GNUNET_NAMESTORE_TYPE_GNS2DNS }, | 1121 | { "GNS2DNS", GNUNET_NAMESTORE_TYPE_GNS2DNS }, |
1122 | { "PHONE", GNUNET_NAMESTORE_TYPE_PHONE }, | ||
1076 | { "TLSA", GNUNET_DNSPARSER_TYPE_TLSA }, | 1123 | { "TLSA", GNUNET_DNSPARSER_TYPE_TLSA }, |
1077 | { NULL, UINT32_MAX } | 1124 | { NULL, UINT32_MAX } |
1078 | }; | 1125 | }; |