diff options
Diffstat (limited to 'src/conversation/plugin_gnsrecord_conversation.c')
-rw-r--r-- | src/conversation/plugin_gnsrecord_conversation.c | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/conversation/plugin_gnsrecord_conversation.c b/src/conversation/plugin_gnsrecord_conversation.c index f68377a64..ecdcb2057 100644 --- a/src/conversation/plugin_gnsrecord_conversation.c +++ b/src/conversation/plugin_gnsrecord_conversation.c | |||
@@ -49,6 +49,8 @@ conversation_value_to_string (void *cls, | |||
49 | const void *data, | 49 | const void *data, |
50 | size_t data_size) | 50 | size_t data_size) |
51 | { | 51 | { |
52 | char *s; | ||
53 | |||
52 | switch (type) | 54 | switch (type) |
53 | { | 55 | { |
54 | case GNUNET_GNSRECORD_TYPE_PHONE: | 56 | case GNUNET_GNSRECORD_TYPE_PHONE: |
@@ -63,10 +65,14 @@ conversation_value_to_string (void *cls, | |||
63 | if (0 != ntohl (pr->version)) | 65 | if (0 != ntohl (pr->version)) |
64 | return NULL; | 66 | return NULL; |
65 | pkey = GNUNET_CRYPTO_eddsa_public_key_to_string (&pr->peer.public_key); | 67 | pkey = GNUNET_CRYPTO_eddsa_public_key_to_string (&pr->peer.public_key); |
68 | s = GNUNET_STRINGS_data_to_string_alloc (&pr->line_port, | ||
69 | sizeof (struct GNUNET_HashCode)); | ||
70 | |||
66 | GNUNET_asprintf (&ret, | 71 | GNUNET_asprintf (&ret, |
67 | "%u-%s", | 72 | "%s-%s", |
68 | ntohl (pr->line), | 73 | s, |
69 | pkey); | 74 | pkey); |
75 | GNUNET_free (s); | ||
70 | GNUNET_free (pkey); | 76 | GNUNET_free (pkey); |
71 | return ret; | 77 | return ret; |
72 | } | 78 | } |
@@ -89,10 +95,10 @@ conversation_value_to_string (void *cls, | |||
89 | */ | 95 | */ |
90 | static int | 96 | static int |
91 | conversation_string_to_value (void *cls, | 97 | conversation_string_to_value (void *cls, |
92 | uint32_t type, | 98 | uint32_t type, |
93 | const char *s, | 99 | const char *s, |
94 | void **data, | 100 | void **data, |
95 | size_t *data_size) | 101 | size_t *data_size) |
96 | { | 102 | { |
97 | if (NULL == s) | 103 | if (NULL == s) |
98 | return GNUNET_SYSERR; | 104 | return GNUNET_SYSERR; |
@@ -101,16 +107,16 @@ conversation_string_to_value (void *cls, | |||
101 | case GNUNET_GNSRECORD_TYPE_PHONE: | 107 | case GNUNET_GNSRECORD_TYPE_PHONE: |
102 | { | 108 | { |
103 | struct GNUNET_CONVERSATION_PhoneRecord *pr; | 109 | struct GNUNET_CONVERSATION_PhoneRecord *pr; |
104 | unsigned int line; | 110 | char line_port[128]; |
105 | const char *dash; | 111 | const char *dash; |
106 | struct GNUNET_PeerIdentity peer; | 112 | struct GNUNET_PeerIdentity peer; |
107 | 113 | ||
108 | if ( (NULL == (dash = strchr (s, '-'))) || | 114 | if ( (NULL == (dash = strchr (s, '-'))) || |
109 | (1 != sscanf (s, "%u-", &line)) || | 115 | (1 != sscanf (s, "%128s-", line_port)) || |
110 | (GNUNET_OK != | 116 | (GNUNET_OK != |
111 | GNUNET_CRYPTO_eddsa_public_key_from_string (dash + 1, | 117 | GNUNET_CRYPTO_eddsa_public_key_from_string (dash + 1, |
112 | strlen (dash + 1), | 118 | strlen (dash + 1), |
113 | &peer.public_key)) ) | 119 | &peer.public_key)) ) |
114 | { | 120 | { |
115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 121 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
116 | _("Unable to parse PHONE record `%s'\n"), | 122 | _("Unable to parse PHONE record `%s'\n"), |
@@ -118,8 +124,20 @@ conversation_string_to_value (void *cls, | |||
118 | return GNUNET_SYSERR; | 124 | return GNUNET_SYSERR; |
119 | } | 125 | } |
120 | pr = GNUNET_new (struct GNUNET_CONVERSATION_PhoneRecord); | 126 | pr = GNUNET_new (struct GNUNET_CONVERSATION_PhoneRecord); |
121 | pr->version = htonl (0); | 127 | pr->version = htonl (1); |
122 | pr->line = htonl ((uint32_t) line); | 128 | pr->reserved = htonl (0); |
129 | if (GNUNET_OK != | ||
130 | GNUNET_STRINGS_string_to_data (line_port, | ||
131 | strlen (line_port), | ||
132 | &pr->line_port, | ||
133 | sizeof (struct GNUNET_HashCode))) | ||
134 | { | ||
135 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
136 | _("Unable to parse PHONE record `%s'\n"), | ||
137 | s); | ||
138 | GNUNET_free (pr); | ||
139 | return GNUNET_SYSERR; | ||
140 | } | ||
123 | pr->peer = peer; | 141 | pr->peer = peer; |
124 | *data = pr; | 142 | *data = pr; |
125 | *data_size = sizeof (struct GNUNET_CONVERSATION_PhoneRecord); | 143 | *data_size = sizeof (struct GNUNET_CONVERSATION_PhoneRecord); |
@@ -153,7 +171,7 @@ static struct { | |||
153 | */ | 171 | */ |
154 | static uint32_t | 172 | static uint32_t |
155 | conversation_typename_to_number (void *cls, | 173 | conversation_typename_to_number (void *cls, |
156 | const char *gns_typename) | 174 | const char *gns_typename) |
157 | { | 175 | { |
158 | unsigned int i; | 176 | unsigned int i; |
159 | 177 | ||
@@ -174,7 +192,7 @@ conversation_typename_to_number (void *cls, | |||
174 | */ | 192 | */ |
175 | static const char * | 193 | static const char * |
176 | conversation_number_to_typename (void *cls, | 194 | conversation_number_to_typename (void *cls, |
177 | uint32_t type) | 195 | uint32_t type) |
178 | { | 196 | { |
179 | unsigned int i; | 197 | unsigned int i; |
180 | 198 | ||