aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/gnsrecord
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/gnsrecord')
-rw-r--r--src/gnsrecord/gnsrecord.c137
-rw-r--r--src/gnsrecord/gnsrecord_serialization.c239
-rw-r--r--src/gnsrecord/perf_gnsrecord_crypto.c96
-rw-r--r--src/gnsrecord/plugin_gnsrecord_dns.c765
-rw-r--r--src/gnsrecord/test_gnsrecord_block_expiration.c39
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c131
-rw-r--r--src/gnsrecord/test_gnsrecord_serialization.c153
7 files changed, 788 insertions, 772 deletions
diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c
index 7672a7b00..9d01210be 100644
--- a/src/gnsrecord/gnsrecord.c
+++ b/src/gnsrecord/gnsrecord.c
@@ -32,13 +32,14 @@
32#include "gnunet_gnsrecord_plugin.h" 32#include "gnunet_gnsrecord_plugin.h"
33#include "gnunet_tun_lib.h" 33#include "gnunet_tun_lib.h"
34 34
35#define LOG(kind, ...) GNUNET_log_from(kind, "gnsrecord", __VA_ARGS__) 35#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
36 36
37 37
38/** 38/**
39 * Handle for a plugin. 39 * Handle for a plugin.
40 */ 40 */
41struct Plugin { 41struct Plugin
42{
42 /** 43 /**
43 * Name of the shared library. 44 * Name of the shared library.
44 */ 45 */
@@ -75,20 +76,20 @@ static int once;
75 * @param lib_ret the plugin API 76 * @param lib_ret the plugin API
76 */ 77 */
77static void 78static void
78add_plugin(void *cls, 79add_plugin (void *cls,
79 const char *library_name, 80 const char *library_name,
80 void *lib_ret) 81 void *lib_ret)
81{ 82{
82 struct GNUNET_GNSRECORD_PluginFunctions *api = lib_ret; 83 struct GNUNET_GNSRECORD_PluginFunctions *api = lib_ret;
83 struct Plugin *plugin; 84 struct Plugin *plugin;
84 85
85 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 86 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Loading block plugin `%s'\n", 87 "Loading block plugin `%s'\n",
87 library_name); 88 library_name);
88 plugin = GNUNET_new(struct Plugin); 89 plugin = GNUNET_new (struct Plugin);
89 plugin->api = api; 90 plugin->api = api;
90 plugin->library_name = GNUNET_strdup(library_name); 91 plugin->library_name = GNUNET_strdup (library_name);
91 GNUNET_array_append(gns_plugins, num_plugins, plugin); 92 GNUNET_array_append (gns_plugins, num_plugins, plugin);
92} 93}
93 94
94 95
@@ -96,13 +97,13 @@ add_plugin(void *cls,
96 * Loads all plugins (lazy initialization). 97 * Loads all plugins (lazy initialization).
97 */ 98 */
98static void 99static void
99init() 100init ()
100{ 101{
101 if (1 == once) 102 if (1 == once)
102 return; 103 return;
103 once = 1; 104 once = 1;
104 GNUNET_PLUGIN_load_all("libgnunet_plugin_gnsrecord_", NULL, 105 GNUNET_PLUGIN_load_all ("libgnunet_plugin_gnsrecord_", NULL,
105 &add_plugin, NULL); 106 &add_plugin, NULL);
106} 107}
107 108
108 109
@@ -110,20 +111,20 @@ init()
110 * Dual function to #init(). 111 * Dual function to #init().
111 */ 112 */
112void __attribute__ ((destructor)) 113void __attribute__ ((destructor))
113GNSRECORD_fini() 114GNSRECORD_fini ()
114{ 115{
115 struct Plugin *plugin; 116 struct Plugin *plugin;
116 117
117 for (unsigned int i = 0; i < num_plugins; i++) 118 for (unsigned int i = 0; i < num_plugins; i++)
118 { 119 {
119 plugin = gns_plugins[i]; 120 plugin = gns_plugins[i];
120 GNUNET_break(NULL == 121 GNUNET_break (NULL ==
121 GNUNET_PLUGIN_unload(plugin->library_name, 122 GNUNET_PLUGIN_unload (plugin->library_name,
122 plugin->api)); 123 plugin->api));
123 GNUNET_free(plugin->library_name); 124 GNUNET_free (plugin->library_name);
124 GNUNET_free(plugin); 125 GNUNET_free (plugin);
125 } 126 }
126 GNUNET_free_non_null(gns_plugins); 127 GNUNET_free_non_null (gns_plugins);
127 gns_plugins = NULL; 128 gns_plugins = NULL;
128 once = 0; 129 once = 0;
129 num_plugins = 0; 130 num_plugins = 0;
@@ -139,23 +140,23 @@ GNSRECORD_fini()
139 * @return NULL on error, otherwise human-readable representation of the value 140 * @return NULL on error, otherwise human-readable representation of the value
140 */ 141 */
141char * 142char *
142GNUNET_GNSRECORD_value_to_string(uint32_t type, 143GNUNET_GNSRECORD_value_to_string (uint32_t type,
143 const void *data, 144 const void *data,
144 size_t data_size) 145 size_t data_size)
145{ 146{
146 struct Plugin *plugin; 147 struct Plugin *plugin;
147 char *ret; 148 char *ret;
148 149
149 init(); 150 init ();
150 for (unsigned int i = 0; i < num_plugins; i++) 151 for (unsigned int i = 0; i < num_plugins; i++)
151 { 152 {
152 plugin = gns_plugins[i]; 153 plugin = gns_plugins[i];
153 if (NULL != (ret = plugin->api->value_to_string(plugin->api->cls, 154 if (NULL != (ret = plugin->api->value_to_string (plugin->api->cls,
154 type, 155 type,
155 data, 156 data,
156 data_size))) 157 data_size)))
157 return ret; 158 return ret;
158 } 159 }
159 return NULL; 160 return NULL;
160} 161}
161 162
@@ -171,24 +172,24 @@ GNUNET_GNSRECORD_value_to_string(uint32_t type,
171 * @return #GNUNET_OK on success 172 * @return #GNUNET_OK on success
172 */ 173 */
173int 174int
174GNUNET_GNSRECORD_string_to_value(uint32_t type, 175GNUNET_GNSRECORD_string_to_value (uint32_t type,
175 const char *s, 176 const char *s,
176 void **data, 177 void **data,
177 size_t *data_size) 178 size_t *data_size)
178{ 179{
179 struct Plugin *plugin; 180 struct Plugin *plugin;
180 181
181 init(); 182 init ();
182 for (unsigned int i = 0; i < num_plugins; i++) 183 for (unsigned int i = 0; i < num_plugins; i++)
183 { 184 {
184 plugin = gns_plugins[i]; 185 plugin = gns_plugins[i];
185 if (GNUNET_OK == plugin->api->string_to_value(plugin->api->cls, 186 if (GNUNET_OK == plugin->api->string_to_value (plugin->api->cls,
186 type, 187 type,
187 s, 188 s,
188 data, 189 data,
189 data_size)) 190 data_size))
190 return GNUNET_OK; 191 return GNUNET_OK;
191 } 192 }
192 return GNUNET_SYSERR; 193 return GNUNET_SYSERR;
193} 194}
194 195
@@ -200,22 +201,22 @@ GNUNET_GNSRECORD_string_to_value(uint32_t type,
200 * @return corresponding number, UINT32_MAX on error 201 * @return corresponding number, UINT32_MAX on error
201 */ 202 */
202uint32_t 203uint32_t
203GNUNET_GNSRECORD_typename_to_number(const char *dns_typename) 204GNUNET_GNSRECORD_typename_to_number (const char *dns_typename)
204{ 205{
205 struct Plugin *plugin; 206 struct Plugin *plugin;
206 uint32_t ret; 207 uint32_t ret;
207 208
208 if (0 == strcasecmp(dns_typename, 209 if (0 == strcasecmp (dns_typename,
209 "ANY")) 210 "ANY"))
210 return GNUNET_GNSRECORD_TYPE_ANY; 211 return GNUNET_GNSRECORD_TYPE_ANY;
211 init(); 212 init ();
212 for (unsigned int i = 0; i < num_plugins; i++) 213 for (unsigned int i = 0; i < num_plugins; i++)
213 { 214 {
214 plugin = gns_plugins[i]; 215 plugin = gns_plugins[i];
215 if (UINT32_MAX != (ret = plugin->api->typename_to_number(plugin->api->cls, 216 if (UINT32_MAX != (ret = plugin->api->typename_to_number (plugin->api->cls,
216 dns_typename))) 217 dns_typename)))
217 return ret; 218 return ret;
218 } 219 }
219 return UINT32_MAX; 220 return UINT32_MAX;
220} 221}
221 222
@@ -227,21 +228,21 @@ GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
227 * @return corresponding typestring, NULL on error 228 * @return corresponding typestring, NULL on error
228 */ 229 */
229const char * 230const char *
230GNUNET_GNSRECORD_number_to_typename(uint32_t type) 231GNUNET_GNSRECORD_number_to_typename (uint32_t type)
231{ 232{
232 struct Plugin *plugin; 233 struct Plugin *plugin;
233 const char * ret; 234 const char *ret;
234 235
235 if (GNUNET_GNSRECORD_TYPE_ANY == type) 236 if (GNUNET_GNSRECORD_TYPE_ANY == type)
236 return "ANY"; 237 return "ANY";
237 init(); 238 init ();
238 for (unsigned int i = 0; i < num_plugins; i++) 239 for (unsigned int i = 0; i < num_plugins; i++)
239 { 240 {
240 plugin = gns_plugins[i]; 241 plugin = gns_plugins[i];
241 if (NULL != (ret = plugin->api->number_to_typename(plugin->api->cls, 242 if (NULL != (ret = plugin->api->number_to_typename (plugin->api->cls,
242 type))) 243 type)))
243 return ret; 244 return ret;
244 } 245 }
245 return NULL; 246 return NULL;
246} 247}
247 248
diff --git a/src/gnsrecord/gnsrecord_serialization.c b/src/gnsrecord/gnsrecord_serialization.c
index 9d2c858ef..a2711538c 100644
--- a/src/gnsrecord/gnsrecord_serialization.c
+++ b/src/gnsrecord/gnsrecord_serialization.c
@@ -35,7 +35,7 @@
35#include "gnunet_tun_lib.h" 35#include "gnunet_tun_lib.h"
36 36
37 37
38#define LOG(kind, ...) GNUNET_log_from(kind, "gnsrecord", __VA_ARGS__) 38#define LOG(kind, ...) GNUNET_log_from (kind, "gnsrecord", __VA_ARGS__)
39 39
40/** 40/**
41 * Set to 1 to check that all records are well-formed (can be converted 41 * Set to 1 to check that all records are well-formed (can be converted
@@ -49,7 +49,8 @@ GNUNET_NETWORK_STRUCT_BEGIN
49/** 49/**
50 * Internal format of a record in the serialized form. 50 * Internal format of a record in the serialized form.
51 */ 51 */
52struct NetworkRecord { 52struct NetworkRecord
53{
53 /** 54 /**
54 * Expiration time for the DNS record; relative or absolute depends 55 * Expiration time for the DNS record; relative or absolute depends
55 * on @e flags, network byte order. 56 * on @e flags, network byte order.
@@ -84,8 +85,8 @@ GNUNET_NETWORK_STRUCT_END
84 * @return the required size to serialize, -1 on error 85 * @return the required size to serialize, -1 on error
85 */ 86 */
86ssize_t 87ssize_t
87GNUNET_GNSRECORD_records_get_size(unsigned int rd_count, 88GNUNET_GNSRECORD_records_get_size (unsigned int rd_count,
88 const struct GNUNET_GNSRECORD_Data *rd) 89 const struct GNUNET_GNSRECORD_Data *rd)
89{ 90{
90 size_t ret; 91 size_t ret;
91 92
@@ -94,35 +95,35 @@ GNUNET_GNSRECORD_records_get_size(unsigned int rd_count,
94 95
95 ret = sizeof(struct NetworkRecord) * rd_count; 96 ret = sizeof(struct NetworkRecord) * rd_count;
96 for (unsigned int i = 0; i < rd_count; i++) 97 for (unsigned int i = 0; i < rd_count; i++)
98 {
99 if ((ret + rd[i].data_size) < ret)
97 { 100 {
98 if ((ret + rd[i].data_size) < ret) 101 GNUNET_break (0);
99 { 102 return -1;
100 GNUNET_break(0); 103 }
101 return -1; 104 ret += rd[i].data_size;
102 }
103 ret += rd[i].data_size;
104#if DEBUG_GNSRECORDS 105#if DEBUG_GNSRECORDS
105 { 106 {
106 char *str; 107 char *str;
107 108
108 str = GNUNET_GNSRECORD_value_to_string(rd[i].record_type, 109 str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
109 rd[i].data, 110 rd[i].data,
110 rd[i].data_size); 111 rd[i].data_size);
111 if (NULL == str) 112 if (NULL == str)
112 { 113 {
113 GNUNET_break_op(0); 114 GNUNET_break_op (0);
114 return -1; 115 return -1;
115 }
116 GNUNET_free(str);
117 } 116 }
118#endif 117 GNUNET_free (str);
119 } 118 }
119#endif
120 }
120 if (ret > SSIZE_MAX) 121 if (ret > SSIZE_MAX)
121 { 122 {
122 GNUNET_break(0); 123 GNUNET_break (0);
123 return -1; 124 return -1;
124 } 125 }
125 //Do not pad PKEY 126 // Do not pad PKEY
126 if (GNUNET_GNSRECORD_TYPE_PKEY == rd->record_type) 127 if (GNUNET_GNSRECORD_TYPE_PKEY == rd->record_type)
127 return ret; 128 return ret;
128 /** 129 /**
@@ -137,7 +138,7 @@ GNUNET_GNSRECORD_records_get_size(unsigned int rd_count,
137 ret |= ret >> 8; 138 ret |= ret >> 8;
138 ret |= ret >> 16; 139 ret |= ret >> 16;
139 ret++; 140 ret++;
140 return (ssize_t)ret; 141 return (ssize_t) ret;
141} 142}
142 143
143 144
@@ -151,65 +152,65 @@ GNUNET_GNSRECORD_records_get_size(unsigned int rd_count,
151 * @return the size of serialized records, -1 if records do not fit 152 * @return the size of serialized records, -1 if records do not fit
152 */ 153 */
153ssize_t 154ssize_t
154GNUNET_GNSRECORD_records_serialize(unsigned int rd_count, 155GNUNET_GNSRECORD_records_serialize (unsigned int rd_count,
155 const struct GNUNET_GNSRECORD_Data *rd, 156 const struct GNUNET_GNSRECORD_Data *rd,
156 size_t dest_size, 157 size_t dest_size,
157 char *dest) 158 char *dest)
158{ 159{
159 struct NetworkRecord rec; 160 struct NetworkRecord rec;
160 size_t off; 161 size_t off;
161 162
162 off = 0; 163 off = 0;
163 for (unsigned int i = 0; i < rd_count; i++) 164 for (unsigned int i = 0; i < rd_count; i++)
165 {
166 LOG (GNUNET_ERROR_TYPE_DEBUG,
167 "Serializing record %u with flags %d and expiration time %llu\n",
168 i,
169 rd[i].flags,
170 (unsigned long long) rd[i].expiration_time);
171 rec.expiration_time = GNUNET_htonll (rd[i].expiration_time);
172 rec.data_size = htonl ((uint32_t) rd[i].data_size);
173 rec.record_type = htonl (rd[i].record_type);
174 rec.flags = htonl (rd[i].flags);
175 if ((off + sizeof(rec) > dest_size) ||
176 (off + sizeof(rec) < off))
164 { 177 {
165 LOG(GNUNET_ERROR_TYPE_DEBUG, 178 GNUNET_break (0);
166 "Serializing record %u with flags %d and expiration time %llu\n", 179 return -1;
167 i, 180 }
168 rd[i].flags, 181 GNUNET_memcpy (&dest[off],
169 (unsigned long long)rd[i].expiration_time); 182 &rec,
170 rec.expiration_time = GNUNET_htonll(rd[i].expiration_time); 183 sizeof(rec));
171 rec.data_size = htonl((uint32_t)rd[i].data_size); 184 off += sizeof(rec);
172 rec.record_type = htonl(rd[i].record_type); 185 if ((off + rd[i].data_size > dest_size) ||
173 rec.flags = htonl(rd[i].flags); 186 (off + rd[i].data_size < off))
174 if ((off + sizeof(rec) > dest_size) || 187 {
175 (off + sizeof(rec) < off)) 188 GNUNET_break (0);
176 { 189 return -1;
177 GNUNET_break(0); 190 }
178 return -1; 191 GNUNET_memcpy (&dest[off],
179 } 192 rd[i].data,
180 GNUNET_memcpy(&dest[off], 193 rd[i].data_size);
181 &rec, 194 off += rd[i].data_size;
182 sizeof(rec));
183 off += sizeof(rec);
184 if ((off + rd[i].data_size > dest_size) ||
185 (off + rd[i].data_size < off))
186 {
187 GNUNET_break(0);
188 return -1;
189 }
190 GNUNET_memcpy(&dest[off],
191 rd[i].data,
192 rd[i].data_size);
193 off += rd[i].data_size;
194#if DEBUG_GNSRECORDS 195#if DEBUG_GNSRECORDS
195 { 196 {
196 char *str; 197 char *str;
197 198
198 str = GNUNET_GNSRECORD_value_to_string(rd[i].record_type, 199 str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
199 rd[i].data, 200 rd[i].data,
200 rd[i].data_size); 201 rd[i].data_size);
201 if (NULL == str) 202 if (NULL == str)
202 { 203 {
203 GNUNET_break_op(0); 204 GNUNET_break_op (0);
204 return -1; 205 return -1;
205 }
206 GNUNET_free(str);
207 } 206 }
208#endif 207 GNUNET_free (str);
209 } 208 }
210 memset(&dest[off], 209#endif
211 0, 210 }
212 dest_size - off); 211 memset (&dest[off],
212 0,
213 dest_size - off);
213 return dest_size; 214 return dest_size;
214} 215}
215 216
@@ -224,60 +225,60 @@ GNUNET_GNSRECORD_records_serialize(unsigned int rd_count,
224 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error 225 * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
225 */ 226 */
226int 227int
227GNUNET_GNSRECORD_records_deserialize(size_t len, 228GNUNET_GNSRECORD_records_deserialize (size_t len,
228 const char *src, 229 const char *src,
229 unsigned int rd_count, 230 unsigned int rd_count,
230 struct GNUNET_GNSRECORD_Data *dest) 231 struct GNUNET_GNSRECORD_Data *dest)
231{ 232{
232 struct NetworkRecord rec; 233 struct NetworkRecord rec;
233 size_t off; 234 size_t off;
234 235
235 off = 0; 236 off = 0;
236 for (unsigned int i = 0; i < rd_count; i++) 237 for (unsigned int i = 0; i < rd_count; i++)
238 {
239 if ((off + sizeof(rec) > len) ||
240 (off + sizeof(rec) < off))
241 {
242 GNUNET_break_op (0);
243 return GNUNET_SYSERR;
244 }
245 GNUNET_memcpy (&rec,
246 &src[off],
247 sizeof(rec));
248 dest[i].expiration_time = GNUNET_ntohll (rec.expiration_time);
249 dest[i].data_size = ntohl ((uint32_t) rec.data_size);
250 dest[i].record_type = ntohl (rec.record_type);
251 dest[i].flags = ntohl (rec.flags);
252 off += sizeof(rec);
253 if ((off + dest[i].data_size > len) ||
254 (off + dest[i].data_size < off))
237 { 255 {
238 if ((off + sizeof(rec) > len) || 256 GNUNET_break_op (0);
239 (off + sizeof(rec) < off)) 257 return GNUNET_SYSERR;
240 { 258 }
241 GNUNET_break_op(0); 259 dest[i].data = &src[off];
242 return GNUNET_SYSERR; 260 off += dest[i].data_size;
243 }
244 GNUNET_memcpy(&rec,
245 &src[off],
246 sizeof(rec));
247 dest[i].expiration_time = GNUNET_ntohll(rec.expiration_time);
248 dest[i].data_size = ntohl((uint32_t)rec.data_size);
249 dest[i].record_type = ntohl(rec.record_type);
250 dest[i].flags = ntohl(rec.flags);
251 off += sizeof(rec);
252 if ((off + dest[i].data_size > len) ||
253 (off + dest[i].data_size < off))
254 {
255 GNUNET_break_op(0);
256 return GNUNET_SYSERR;
257 }
258 dest[i].data = &src[off];
259 off += dest[i].data_size;
260#if GNUNET_EXTRA_LOGGING 261#if GNUNET_EXTRA_LOGGING
261 { 262 {
262 char *str; 263 char *str;
263 264
264 str = GNUNET_GNSRECORD_value_to_string(dest[i].record_type, 265 str = GNUNET_GNSRECORD_value_to_string (dest[i].record_type,
265 dest[i].data, 266 dest[i].data,
266 dest[i].data_size); 267 dest[i].data_size);
267 if (NULL == str) 268 if (NULL == str)
268 { 269 {
269 GNUNET_break_op(0); 270 GNUNET_break_op (0);
270 return GNUNET_SYSERR; 271 return GNUNET_SYSERR;
271 }
272 GNUNET_free(str);
273 } 272 }
274#endif 273 GNUNET_free (str);
275 LOG(GNUNET_ERROR_TYPE_DEBUG,
276 "Deserialized record %u with flags %d and expiration time %llu\n",
277 i,
278 dest[i].flags,
279 (unsigned long long)dest[i].expiration_time);
280 } 274 }
275#endif
276 LOG (GNUNET_ERROR_TYPE_DEBUG,
277 "Deserialized record %u with flags %d and expiration time %llu\n",
278 i,
279 dest[i].flags,
280 (unsigned long long) dest[i].expiration_time);
281 }
281 return GNUNET_OK; 282 return GNUNET_OK;
282} 283}
283 284
diff --git a/src/gnsrecord/perf_gnsrecord_crypto.c b/src/gnsrecord/perf_gnsrecord_crypto.c
index a4fffd238..4dadbe9b6 100644
--- a/src/gnsrecord/perf_gnsrecord_crypto.c
+++ b/src/gnsrecord/perf_gnsrecord_crypto.c
@@ -43,77 +43,79 @@
43 43
44 44
45static struct GNUNET_GNSRECORD_Data * 45static struct GNUNET_GNSRECORD_Data *
46create_record(int count) 46create_record (int count)
47{ 47{
48 struct GNUNET_GNSRECORD_Data *rd; 48 struct GNUNET_GNSRECORD_Data *rd;
49 49
50 rd = GNUNET_new_array(count, 50 rd = GNUNET_new_array (count,
51 struct GNUNET_GNSRECORD_Data); 51 struct GNUNET_GNSRECORD_Data);
52 for (unsigned int c = 0; c < count; c++) 52 for (unsigned int c = 0; c < count; c++)
53 { 53 {
54 rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; 54 rd[c].expiration_time = GNUNET_TIME_absolute_get ().abs_value_us
55 rd[c].record_type = TEST_RECORD_TYPE; 55 + 1000000000;
56 rd[c].data_size = TEST_RECORD_DATALEN; 56 rd[c].record_type = TEST_RECORD_TYPE;
57 rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); 57 rd[c].data_size = TEST_RECORD_DATALEN;
58 memset((char *)rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 58 rd[c].data = GNUNET_malloc (TEST_RECORD_DATALEN);
59 } 59 memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
60 }
60 return rd; 61 return rd;
61} 62}
62 63
63 64
64static void 65static void
65run(void *cls, 66run (void *cls,
66 char *const *args, 67 char *const *args,
67 const char *cfgfile, 68 const char *cfgfile,
68 const struct GNUNET_CONFIGURATION_Handle *cfg) 69 const struct GNUNET_CONFIGURATION_Handle *cfg)
69{ 70{
70 struct GNUNET_GNSRECORD_Block *block; 71 struct GNUNET_GNSRECORD_Block *block;
71 struct GNUNET_HashCode query; 72 struct GNUNET_HashCode query;
72 struct GNUNET_GNSRECORD_Data *s_rd; 73 struct GNUNET_GNSRECORD_Data *s_rd;
73 const char *s_name; 74 const char *s_name;
74 struct GNUNET_TIME_Absolute start_time; 75 struct GNUNET_TIME_Absolute start_time;
75 struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey; 76 struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
76 struct GNUNET_TIME_Absolute expire; 77 struct GNUNET_TIME_Absolute expire;
77 78
78 (void)cls; 79 (void) cls;
79 (void)args; 80 (void) args;
80 (void)cfgfile; 81 (void) cfgfile;
81 (void)cfg; 82 (void) cfg;
82 expire = GNUNET_TIME_absolute_get(); 83 expire = GNUNET_TIME_absolute_get ();
83 privkey = GNUNET_CRYPTO_ecdsa_key_create(); 84 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
84 GNUNET_assert(NULL != privkey); 85 GNUNET_assert (NULL != privkey);
85 86
86 /* test block creation */ 87 /* test block creation */
87 s_name = "DUMMY.dummy.gnunet"; 88 s_name = "DUMMY.dummy.gnunet";
88 s_rd = create_record(RECORDS); 89 s_rd = create_record (RECORDS);
89 start_time = GNUNET_TIME_absolute_get(); 90 start_time = GNUNET_TIME_absolute_get ();
90 for (unsigned int i = 0; i < ROUNDS; i++) 91 for (unsigned int i = 0; i < ROUNDS; i++)
91 { 92 {
92 GNUNET_assert(NULL != (block = 93 GNUNET_assert (NULL != (block =
93 GNUNET_GNSRECORD_block_create2(privkey, 94 GNUNET_GNSRECORD_block_create2 (privkey,
94 expire, 95 expire,
95 s_name, 96 s_name,
96 s_rd, 97 s_rd,
97 RECORDS))); 98 RECORDS)));
98 GNUNET_GNSRECORD_query_from_private_key(privkey, 99 GNUNET_GNSRECORD_query_from_private_key (privkey,
99 s_name, 100 s_name,
100 &query); 101 &query);
101 GNUNET_free(block); 102 GNUNET_free (block);
102 } 103 }
103 fprintf(stderr, 104 fprintf (stderr,
104 "Took %s to produce %u GNS blocks for the DHT\n", 105 "Took %s to produce %u GNS blocks for the DHT\n",
105 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start_time), 106 GNUNET_STRINGS_relative_time_to_string (
106 GNUNET_YES), 107 GNUNET_TIME_absolute_get_duration (start_time),
107 ROUNDS); 108 GNUNET_YES),
109 ROUNDS);
108 for (unsigned int i = 0; i < RECORDS; i++) 110 for (unsigned int i = 0; i < RECORDS; i++)
109 GNUNET_free((void *)s_rd[i].data); 111 GNUNET_free ((void *) s_rd[i].data);
110 GNUNET_free(s_rd); 112 GNUNET_free (s_rd);
111 GNUNET_free(privkey); 113 GNUNET_free (privkey);
112} 114}
113 115
114 116
115int 117int
116main(int argc, char *argv[]) 118main (int argc, char *argv[])
117{ 119{
118 static char *const argvx[] = { 120 static char *const argvx[] = {
119 "perf-gnsrecord-crypto", 121 "perf-gnsrecord-crypto",
@@ -124,12 +126,12 @@ main(int argc, char *argv[])
124 }; 126 };
125 127
126 if (GNUNET_OK != 128 if (GNUNET_OK !=
127 GNUNET_PROGRAM_run((sizeof(argvx) / sizeof(char *)) - 1, 129 GNUNET_PROGRAM_run ((sizeof(argvx) / sizeof(char *)) - 1,
128 argvx, 130 argvx,
129 "perf-gnsrecord-crypto", 131 "perf-gnsrecord-crypto",
130 "nohelp", options, 132 "nohelp", options,
131 &run, 133 &run,
132 NULL)) 134 NULL))
133 return 1; 135 return 1;
134 return 0; 136 return 0;
135} 137}
diff --git a/src/gnsrecord/plugin_gnsrecord_dns.c b/src/gnsrecord/plugin_gnsrecord_dns.c
index 8c39603e3..9a45b5b93 100644
--- a/src/gnsrecord/plugin_gnsrecord_dns.c
+++ b/src/gnsrecord/plugin_gnsrecord_dns.c
@@ -39,177 +39,177 @@
39 * @return NULL on error, otherwise human-readable representation of the value 39 * @return NULL on error, otherwise human-readable representation of the value
40 */ 40 */
41static char * 41static char *
42dns_value_to_string(void *cls, 42dns_value_to_string (void *cls,
43 uint32_t type, 43 uint32_t type,
44 const void *data, 44 const void *data,
45 size_t data_size) 45 size_t data_size)
46{ 46{
47 char *result; 47 char *result;
48 char tmp[INET6_ADDRSTRLEN]; 48 char tmp[INET6_ADDRSTRLEN];
49 49
50 switch (type) 50 switch (type)
51 { 51 {
52 case GNUNET_DNSPARSER_TYPE_A: 52 case GNUNET_DNSPARSER_TYPE_A:
53 if (data_size != sizeof(struct in_addr)) 53 if (data_size != sizeof(struct in_addr))
54 return NULL; 54 return NULL;
55 if (NULL == inet_ntop(AF_INET, data, tmp, sizeof(tmp))) 55 if (NULL == inet_ntop (AF_INET, data, tmp, sizeof(tmp)))
56 return NULL; 56 return NULL;
57 return GNUNET_strdup(tmp); 57 return GNUNET_strdup (tmp);
58 58
59 case GNUNET_DNSPARSER_TYPE_NS: { 59 case GNUNET_DNSPARSER_TYPE_NS: {
60 char *ns; 60 char *ns;
61 size_t off; 61 size_t off;
62 62
63 off = 0; 63 off = 0;
64 ns = GNUNET_DNSPARSER_parse_name(data, data_size, &off); 64 ns = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
65 if ((NULL == ns) || (off != data_size)) 65 if ((NULL == ns) || (off != data_size))
66 { 66 {
67 GNUNET_break_op(0); 67 GNUNET_break_op (0);
68 GNUNET_free_non_null(ns); 68 GNUNET_free_non_null (ns);
69 return NULL; 69 return NULL;
70 } 70 }
71 return ns; 71 return ns;
72 } 72 }
73 73
74 case GNUNET_DNSPARSER_TYPE_CNAME: { 74 case GNUNET_DNSPARSER_TYPE_CNAME: {
75 char *cname; 75 char *cname;
76 size_t off; 76 size_t off;
77 77
78 off = 0; 78 off = 0;
79 cname = GNUNET_DNSPARSER_parse_name(data, data_size, &off); 79 cname = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
80 if ((NULL == cname) || (off != data_size)) 80 if ((NULL == cname) || (off != data_size))
81 { 81 {
82 GNUNET_break_op(0); 82 GNUNET_break_op (0);
83 GNUNET_free_non_null(cname); 83 GNUNET_free_non_null (cname);
84 return NULL; 84 return NULL;
85 } 85 }
86 return cname; 86 return cname;
87 } 87 }
88 88
89 case GNUNET_DNSPARSER_TYPE_SOA: { 89 case GNUNET_DNSPARSER_TYPE_SOA: {
90 struct GNUNET_DNSPARSER_SoaRecord *soa; 90 struct GNUNET_DNSPARSER_SoaRecord *soa;
91 size_t off; 91 size_t off;
92 92
93 off = 0; 93 off = 0;
94 soa = GNUNET_DNSPARSER_parse_soa(data, data_size, &off); 94 soa = GNUNET_DNSPARSER_parse_soa (data, data_size, &off);
95 if ((NULL == soa) || (off != data_size)) 95 if ((NULL == soa) || (off != data_size))
96 { 96 {
97 GNUNET_break_op(0); 97 GNUNET_break_op (0);
98 if (NULL != soa) 98 if (NULL != soa)
99 GNUNET_DNSPARSER_free_soa(soa); 99 GNUNET_DNSPARSER_free_soa (soa);
100 return NULL; 100 return NULL;
101 } 101 }
102 GNUNET_asprintf(&result, 102 GNUNET_asprintf (&result,
103 "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu", 103 "rname=%s mname=%s %lu,%lu,%lu,%lu,%lu",
104 soa->rname, 104 soa->rname,
105 soa->mname, 105 soa->mname,
106 soa->serial, 106 soa->serial,
107 soa->refresh, 107 soa->refresh,
108 soa->retry, 108 soa->retry,
109 soa->expire, 109 soa->expire,
110 soa->minimum_ttl); 110 soa->minimum_ttl);
111 GNUNET_DNSPARSER_free_soa(soa); 111 GNUNET_DNSPARSER_free_soa (soa);
112 return result; 112 return result;
113 } 113 }
114 114
115 case GNUNET_DNSPARSER_TYPE_PTR: { 115 case GNUNET_DNSPARSER_TYPE_PTR: {
116 char *ptr; 116 char *ptr;
117 size_t off; 117 size_t off;
118 118
119 off = 0; 119 off = 0;
120 ptr = GNUNET_DNSPARSER_parse_name(data, data_size, &off); 120 ptr = GNUNET_DNSPARSER_parse_name (data, data_size, &off);
121 if ((NULL == ptr) || (off != data_size)) 121 if ((NULL == ptr) || (off != data_size))
122 { 122 {
123 GNUNET_break_op(0); 123 GNUNET_break_op (0);
124 GNUNET_free_non_null(ptr); 124 GNUNET_free_non_null (ptr);
125 return NULL; 125 return NULL;
126 } 126 }
127 return ptr; 127 return ptr;
128 } 128 }
129 129
130 case GNUNET_DNSPARSER_TYPE_CERT: { 130 case GNUNET_DNSPARSER_TYPE_CERT: {
131 struct GNUNET_DNSPARSER_CertRecord *cert; 131 struct GNUNET_DNSPARSER_CertRecord *cert;
132 size_t off; 132 size_t off;
133 char *base64; 133 char *base64;
134 int len; 134 int len;
135 135
136 off = 0; 136 off = 0;
137 cert = GNUNET_DNSPARSER_parse_cert(data, data_size, &off); 137 cert = GNUNET_DNSPARSER_parse_cert (data, data_size, &off);
138 if ((NULL == cert) || (off != data_size)) 138 if ((NULL == cert) || (off != data_size))
139 { 139 {
140 GNUNET_break_op(0); 140 GNUNET_break_op (0);
141 GNUNET_DNSPARSER_free_cert(cert); 141 GNUNET_DNSPARSER_free_cert (cert);
142 return NULL; 142 return NULL;
143 } 143 }
144 len = GNUNET_STRINGS_base64_encode(cert->certificate_data, 144 len = GNUNET_STRINGS_base64_encode (cert->certificate_data,
145 cert->certificate_size, 145 cert->certificate_size,
146 &base64); 146 &base64);
147 GNUNET_asprintf(&result, 147 GNUNET_asprintf (&result,
148 "%u %u %u %.*s", 148 "%u %u %u %.*s",
149 cert->cert_type, 149 cert->cert_type,
150 cert->cert_tag, 150 cert->cert_tag,
151 cert->algorithm, 151 cert->algorithm,
152 len, 152 len,
153 base64); 153 base64);
154 GNUNET_free(base64); 154 GNUNET_free (base64);
155 GNUNET_DNSPARSER_free_cert(cert); 155 GNUNET_DNSPARSER_free_cert (cert);
156 return result; 156 return result;
157 } 157 }
158 158
159 case GNUNET_DNSPARSER_TYPE_MX: { 159 case GNUNET_DNSPARSER_TYPE_MX: {
160 struct GNUNET_DNSPARSER_MxRecord *mx; 160 struct GNUNET_DNSPARSER_MxRecord *mx;
161 size_t off; 161 size_t off;
162 162
163 off = 0; 163 off = 0;
164 mx = GNUNET_DNSPARSER_parse_mx(data, data_size, &off); 164 mx = GNUNET_DNSPARSER_parse_mx (data, data_size, &off);
165 if ((NULL == mx) || (off != data_size)) 165 if ((NULL == mx) || (off != data_size))
166 { 166 {
167 GNUNET_break_op(0); 167 GNUNET_break_op (0);
168 GNUNET_DNSPARSER_free_mx(mx); 168 GNUNET_DNSPARSER_free_mx (mx);
169 return NULL; 169 return NULL;
170 } 170 }
171 GNUNET_asprintf(&result, 171 GNUNET_asprintf (&result,
172 "%u,%s", 172 "%u,%s",
173 (unsigned int)mx->preference, 173 (unsigned int) mx->preference,
174 mx->mxhost); 174 mx->mxhost);
175 GNUNET_DNSPARSER_free_mx(mx); 175 GNUNET_DNSPARSER_free_mx (mx);
176 return result; 176 return result;
177 } 177 }
178 178
179 case GNUNET_DNSPARSER_TYPE_TXT: 179 case GNUNET_DNSPARSER_TYPE_TXT:
180 return GNUNET_strndup(data, data_size); 180 return GNUNET_strndup (data, data_size);
181 181
182 case GNUNET_DNSPARSER_TYPE_AAAA: 182 case GNUNET_DNSPARSER_TYPE_AAAA:
183 if (data_size != sizeof(struct in6_addr)) 183 if (data_size != sizeof(struct in6_addr))
184 return NULL; 184 return NULL;
185 if (NULL == inet_ntop(AF_INET6, data, tmp, sizeof(tmp))) 185 if (NULL == inet_ntop (AF_INET6, data, tmp, sizeof(tmp)))
186 return NULL; 186 return NULL;
187 return GNUNET_strdup(tmp); 187 return GNUNET_strdup (tmp);
188 188
189 case GNUNET_DNSPARSER_TYPE_SRV: { 189 case GNUNET_DNSPARSER_TYPE_SRV: {
190 struct GNUNET_DNSPARSER_SrvRecord *srv; 190 struct GNUNET_DNSPARSER_SrvRecord *srv;
191 size_t off; 191 size_t off;
192 192
193 off = 0; 193 off = 0;
194 srv = GNUNET_DNSPARSER_parse_srv(data, data_size, &off); 194 srv = GNUNET_DNSPARSER_parse_srv (data, data_size, &off);
195 if ((NULL == srv) || (off != data_size)) 195 if ((NULL == srv) || (off != data_size))
196 { 196 {
197 GNUNET_break_op(0); 197 GNUNET_break_op (0);
198 if (NULL != srv) 198 if (NULL != srv)
199 GNUNET_DNSPARSER_free_srv(srv); 199 GNUNET_DNSPARSER_free_srv (srv);
200 return NULL; 200 return NULL;
201 } 201 }
202 GNUNET_asprintf(&result, 202 GNUNET_asprintf (&result,
203 "%d %d %d %s", 203 "%d %d %d %s",
204 srv->priority, 204 srv->priority,
205 srv->weight, 205 srv->weight,
206 srv->port, 206 srv->port,
207 srv->target); 207 srv->target);
208 GNUNET_DNSPARSER_free_srv(srv); 208 GNUNET_DNSPARSER_free_srv (srv);
209 return result; 209 return result;
210 } 210 }
211 211
212 case GNUNET_DNSPARSER_TYPE_TLSA: { 212 case GNUNET_DNSPARSER_TYPE_TLSA: {
213 const struct GNUNET_TUN_DnsTlsaRecord *tlsa; 213 const struct GNUNET_TUN_DnsTlsaRecord *tlsa;
214 char *tlsa_str; 214 char *tlsa_str;
215 char *hex; 215 char *hex;
@@ -218,25 +218,25 @@ dns_value_to_string(void *cls,
218 return NULL; /* malformed */ 218 return NULL; /* malformed */
219 tlsa = data; 219 tlsa = data;
220 hex = 220 hex =
221 GNUNET_DNSPARSER_bin_to_hex(&tlsa[1], 221 GNUNET_DNSPARSER_bin_to_hex (&tlsa[1],
222 data_size - 222 data_size
223 sizeof(struct GNUNET_TUN_DnsTlsaRecord)); 223 - sizeof(struct GNUNET_TUN_DnsTlsaRecord));
224 if (0 == GNUNET_asprintf(&tlsa_str, 224 if (0 == GNUNET_asprintf (&tlsa_str,
225 "%u %u %u %s", 225 "%u %u %u %s",
226 (unsigned int)tlsa->usage, 226 (unsigned int) tlsa->usage,
227 (unsigned int)tlsa->selector, 227 (unsigned int) tlsa->selector,
228 (unsigned int)tlsa->matching_type, 228 (unsigned int) tlsa->matching_type,
229 hex)) 229 hex))
230 { 230 {
231 GNUNET_free(hex); 231 GNUNET_free (hex);
232 GNUNET_free(tlsa_str); 232 GNUNET_free (tlsa_str);
233 return NULL; 233 return NULL;
234 } 234 }
235 GNUNET_free(hex); 235 GNUNET_free (hex);
236 return tlsa_str; 236 return tlsa_str;
237 } 237 }
238 238
239 case GNUNET_DNSPARSER_TYPE_CAA: { //RFC6844 239 case GNUNET_DNSPARSER_TYPE_CAA: { // RFC6844
240 const struct GNUNET_DNSPARSER_CaaRecord *caa; 240 const struct GNUNET_DNSPARSER_CaaRecord *caa;
241 char tag[15]; // between 1 and 15 bytes 241 char tag[15]; // between 1 and 15 bytes
242 char value[data_size]; 242 char value[data_size];
@@ -246,27 +246,27 @@ dns_value_to_string(void *cls,
246 caa = data; 246 caa = data;
247 if ((1 > caa->tag_len) || (15 < caa->tag_len)) 247 if ((1 > caa->tag_len) || (15 < caa->tag_len))
248 return NULL; /* malformed */ 248 return NULL; /* malformed */
249 memset(tag, 0, sizeof(tag)); 249 memset (tag, 0, sizeof(tag));
250 memset(value, 0, data_size); 250 memset (value, 0, data_size);
251 memcpy(tag, &caa[1], caa->tag_len); 251 memcpy (tag, &caa[1], caa->tag_len);
252 memcpy(value, 252 memcpy (value,
253 (char *)&caa[1] + caa->tag_len, 253 (char *) &caa[1] + caa->tag_len,
254 data_size - caa->tag_len - 2); 254 data_size - caa->tag_len - 2);
255 if (0 == GNUNET_asprintf(&caa_str, 255 if (0 == GNUNET_asprintf (&caa_str,
256 "%u %s %s", 256 "%u %s %s",
257 (unsigned int)caa->flags, 257 (unsigned int) caa->flags,
258 tag, 258 tag,
259 value)) 259 value))
260 { 260 {
261 GNUNET_free(caa_str); 261 GNUNET_free (caa_str);
262 return NULL; 262 return NULL;
263 } 263 }
264 return caa_str; 264 return caa_str;
265 } 265 }
266 266
267 default: 267 default:
268 return NULL; 268 return NULL;
269 } 269 }
270} 270}
271 271
272 272
@@ -277,9 +277,10 @@ dns_value_to_string(void *cls,
277 * @return the value, 0 if not found 277 * @return the value, 0 if not found
278 */ 278 */
279static unsigned int 279static unsigned int
280rfc4398_mnemonic_to_value(const char *mnemonic) 280rfc4398_mnemonic_to_value (const char *mnemonic)
281{ 281{
282 static struct { 282 static struct
283 {
283 const char *mnemonic; 284 const char *mnemonic;
284 unsigned int val; 285 unsigned int val;
285 } table[] = { { "PKIX", 1 }, 286 } table[] = { { "PKIX", 1 },
@@ -296,7 +297,7 @@ rfc4398_mnemonic_to_value(const char *mnemonic)
296 unsigned int i; 297 unsigned int i;
297 298
298 for (i = 0; NULL != table[i].mnemonic; i++) 299 for (i = 0; NULL != table[i].mnemonic; i++)
299 if (0 == strcasecmp(mnemonic, table[i].mnemonic)) 300 if (0 == strcasecmp (mnemonic, table[i].mnemonic))
300 return table[i].val; 301 return table[i].val;
301 return 0; 302 return 0;
302} 303}
@@ -309,9 +310,10 @@ rfc4398_mnemonic_to_value(const char *mnemonic)
309 * @return the value, 0 if not found 310 * @return the value, 0 if not found
310 */ 311 */
311static unsigned int 312static unsigned int
312rfc4034_mnemonic_to_value(const char *mnemonic) 313rfc4034_mnemonic_to_value (const char *mnemonic)
313{ 314{
314 static struct { 315 static struct
316 {
315 const char *mnemonic; 317 const char *mnemonic;
316 unsigned int val; 318 unsigned int val;
317 } table[] = { { "RSAMD5", 1 }, 319 } table[] = { { "RSAMD5", 1 },
@@ -326,7 +328,7 @@ rfc4034_mnemonic_to_value(const char *mnemonic)
326 unsigned int i; 328 unsigned int i;
327 329
328 for (i = 0; NULL != table[i].mnemonic; i++) 330 for (i = 0; NULL != table[i].mnemonic; i++)
329 if (0 == strcasecmp(mnemonic, table[i].mnemonic)) 331 if (0 == strcasecmp (mnemonic, table[i].mnemonic))
330 return table[i].val; 332 return table[i].val;
331 return 0; 333 return 0;
332} 334}
@@ -344,11 +346,11 @@ rfc4034_mnemonic_to_value(const char *mnemonic)
344 * @return #GNUNET_OK on success 346 * @return #GNUNET_OK on success
345 */ 347 */
346static int 348static int
347dns_string_to_value(void *cls, 349dns_string_to_value (void *cls,
348 uint32_t type, 350 uint32_t type,
349 const char *s, 351 const char *s,
350 void **data, 352 void **data,
351 size_t *data_size) 353 size_t *data_size)
352{ 354{
353 struct in_addr value_a; 355 struct in_addr value_a;
354 struct in6_addr value_aaaa; 356 struct in6_addr value_aaaa;
@@ -357,61 +359,61 @@ dns_string_to_value(void *cls,
357 if (NULL == s) 359 if (NULL == s)
358 return GNUNET_SYSERR; 360 return GNUNET_SYSERR;
359 switch (type) 361 switch (type)
362 {
363 case GNUNET_DNSPARSER_TYPE_A:
364 if (1 != inet_pton (AF_INET, s, &value_a))
360 { 365 {
361 case GNUNET_DNSPARSER_TYPE_A: 366 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
362 if (1 != inet_pton(AF_INET, s, &value_a)) 367 _ ("Unable to parse IPv4 address `%s'\n"),
363 { 368 s);
364 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 369 return GNUNET_SYSERR;
365 _("Unable to parse IPv4 address `%s'\n"), 370 }
366 s); 371 *data = GNUNET_new (struct in_addr);
367 return GNUNET_SYSERR; 372 GNUNET_memcpy (*data, &value_a, sizeof(value_a));
368 } 373 *data_size = sizeof(value_a);
369 *data = GNUNET_new(struct in_addr); 374 return GNUNET_OK;
370 GNUNET_memcpy(*data, &value_a, sizeof(value_a));
371 *data_size = sizeof(value_a);
372 return GNUNET_OK;
373 375
374 case GNUNET_DNSPARSER_TYPE_NS: { 376 case GNUNET_DNSPARSER_TYPE_NS: {
375 char nsbuf[256]; 377 char nsbuf[256];
376 size_t off; 378 size_t off;
377 379
378 off = 0; 380 off = 0;
379 if (GNUNET_OK != 381 if (GNUNET_OK !=
380 GNUNET_DNSPARSER_builder_add_name(nsbuf, sizeof(nsbuf), &off, s)) 382 GNUNET_DNSPARSER_builder_add_name (nsbuf, sizeof(nsbuf), &off, s))
381 { 383 {
382 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 384 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
383 _("Failed to serialize NS record with value `%s'\n"), 385 _ ("Failed to serialize NS record with value `%s'\n"),
384 s); 386 s);
385 return GNUNET_SYSERR; 387 return GNUNET_SYSERR;
386 } 388 }
387 *data_size = off; 389 *data_size = off;
388 *data = GNUNET_malloc(off); 390 *data = GNUNET_malloc (off);
389 GNUNET_memcpy(*data, nsbuf, off); 391 GNUNET_memcpy (*data, nsbuf, off);
390 return GNUNET_OK; 392 return GNUNET_OK;
391 } 393 }
392 394
393 case GNUNET_DNSPARSER_TYPE_CNAME: { 395 case GNUNET_DNSPARSER_TYPE_CNAME: {
394 char cnamebuf[256]; 396 char cnamebuf[256];
395 size_t off; 397 size_t off;
396 398
397 off = 0; 399 off = 0;
398 if (GNUNET_OK != GNUNET_DNSPARSER_builder_add_name(cnamebuf, 400 if (GNUNET_OK != GNUNET_DNSPARSER_builder_add_name (cnamebuf,
399 sizeof(cnamebuf), 401 sizeof(cnamebuf),
400 &off, 402 &off,
401 s)) 403 s))
402 { 404 {
403 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 405 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
404 _("Failed to serialize CNAME record with value `%s'\n"), 406 _ ("Failed to serialize CNAME record with value `%s'\n"),
405 s); 407 s);
406 return GNUNET_SYSERR; 408 return GNUNET_SYSERR;
407 } 409 }
408 *data_size = off; 410 *data_size = off;
409 *data = GNUNET_malloc(off); 411 *data = GNUNET_malloc (off);
410 GNUNET_memcpy(*data, cnamebuf, off); 412 GNUNET_memcpy (*data, cnamebuf, off);
411 return GNUNET_OK; 413 return GNUNET_OK;
412 } 414 }
413 415
414 case GNUNET_DNSPARSER_TYPE_CERT: { 416 case GNUNET_DNSPARSER_TYPE_CERT: {
415 char *sdup; 417 char *sdup;
416 const char *typep; 418 const char *typep;
417 const char *keyp; 419 const char *keyp;
@@ -424,41 +426,41 @@ dns_string_to_value(void *cls,
424 char *cert_data; 426 char *cert_data;
425 struct GNUNET_DNSPARSER_CertRecord cert; 427 struct GNUNET_DNSPARSER_CertRecord cert;
426 428
427 sdup = GNUNET_strdup(s); 429 sdup = GNUNET_strdup (s);
428 typep = strtok(sdup, " "); 430 typep = strtok (sdup, " ");
429 if ((NULL == typep) || 431 if ((NULL == typep) ||
430 ((0 == (type = rfc4398_mnemonic_to_value(typep))) && 432 ((0 == (type = rfc4398_mnemonic_to_value (typep))) &&
431 ((1 != sscanf(typep, "%u", &type)) || (type > UINT16_MAX)))) 433 ((1 != sscanf (typep, "%u", &type)) || (type > UINT16_MAX))))
432 { 434 {
433 GNUNET_free(sdup); 435 GNUNET_free (sdup);
434 return GNUNET_SYSERR; 436 return GNUNET_SYSERR;
435 } 437 }
436 keyp = strtok(NULL, " "); 438 keyp = strtok (NULL, " ");
437 if ((NULL == keyp) || (1 != sscanf(keyp, "%u", &key)) || 439 if ((NULL == keyp) || (1 != sscanf (keyp, "%u", &key)) ||
438 (key > UINT16_MAX)) 440 (key > UINT16_MAX))
439 { 441 {
440 GNUNET_free(sdup); 442 GNUNET_free (sdup);
441 return GNUNET_SYSERR; 443 return GNUNET_SYSERR;
442 } 444 }
443 alg = 0; 445 alg = 0;
444 algp = strtok(NULL, " "); 446 algp = strtok (NULL, " ");
445 if ((NULL == algp) || 447 if ((NULL == algp) ||
446 ((0 == (type = rfc4034_mnemonic_to_value(typep))) && 448 ((0 == (type = rfc4034_mnemonic_to_value (typep))) &&
447 ((1 != sscanf(algp, "%u", &alg)) || (alg > UINT8_MAX)))) 449 ((1 != sscanf (algp, "%u", &alg)) || (alg > UINT8_MAX))))
448 { 450 {
449 GNUNET_free(sdup); 451 GNUNET_free (sdup);
450 return GNUNET_SYSERR; 452 return GNUNET_SYSERR;
451 } 453 }
452 certp = strtok(NULL, " "); 454 certp = strtok (NULL, " ");
453 if ((NULL == certp) || (0 == strlen(certp))) 455 if ((NULL == certp) || (0 == strlen (certp)))
454 { 456 {
455 GNUNET_free(sdup); 457 GNUNET_free (sdup);
456 return GNUNET_SYSERR; 458 return GNUNET_SYSERR;
457 } 459 }
458 cert_size = GNUNET_STRINGS_base64_decode(certp, 460 cert_size = GNUNET_STRINGS_base64_decode (certp,
459 strlen(certp), 461 strlen (certp),
460 (void **)&cert_data); 462 (void **) &cert_data);
461 GNUNET_free(sdup); 463 GNUNET_free (sdup);
462 cert.cert_type = type; 464 cert.cert_type = type;
463 cert.cert_tag = key; 465 cert.cert_tag = key;
464 cert.algorithm = alg; 466 cert.algorithm = alg;
@@ -469,26 +471,26 @@ dns_string_to_value(void *cls,
469 size_t off; 471 size_t off;
470 472
471 off = 0; 473 off = 0;
472 if (GNUNET_OK != GNUNET_DNSPARSER_builder_add_cert(certbuf, 474 if (GNUNET_OK != GNUNET_DNSPARSER_builder_add_cert (certbuf,
473 sizeof(certbuf), 475 sizeof(certbuf),
474 &off, 476 &off,
475 &cert)) 477 &cert))
476 { 478 {
477 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 479 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
478 _("Failed to serialize CERT record with %u bytes\n"), 480 _ ("Failed to serialize CERT record with %u bytes\n"),
479 (unsigned int)cert_size); 481 (unsigned int) cert_size);
480 GNUNET_free(cert_data); 482 GNUNET_free (cert_data);
481 return GNUNET_SYSERR; 483 return GNUNET_SYSERR;
482 } 484 }
483 *data_size = off; 485 *data_size = off;
484 *data = GNUNET_malloc(off); 486 *data = GNUNET_malloc (off);
485 GNUNET_memcpy(*data, certbuf, off); 487 GNUNET_memcpy (*data, certbuf, off);
486 } 488 }
487 GNUNET_free(cert_data); 489 GNUNET_free (cert_data);
488 return GNUNET_OK; 490 return GNUNET_OK;
489 } 491 }
490 492
491 case GNUNET_DNSPARSER_TYPE_SOA: { 493 case GNUNET_DNSPARSER_TYPE_SOA: {
492 struct GNUNET_DNSPARSER_SoaRecord soa; 494 struct GNUNET_DNSPARSER_SoaRecord soa;
493 char soabuf[540]; 495 char soabuf[540];
494 char soa_rname[253 + 1]; 496 char soa_rname[253 + 1];
@@ -500,97 +502,97 @@ dns_string_to_value(void *cls,
500 unsigned int soa_min; 502 unsigned int soa_min;
501 size_t off; 503 size_t off;
502 504
503 if (7 != sscanf(s, 505 if (7 != sscanf (s,
504 "rname=%253s mname=%253s %u,%u,%u,%u,%u", 506 "rname=%253s mname=%253s %u,%u,%u,%u,%u",
505 soa_rname, 507 soa_rname,
506 soa_mname, 508 soa_mname,
507 &soa_serial, 509 &soa_serial,
508 &soa_refresh, 510 &soa_refresh,
509 &soa_retry, 511 &soa_retry,
510 &soa_expire, 512 &soa_expire,
511 &soa_min)) 513 &soa_min))
512 { 514 {
513 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 515 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
514 _("Unable to parse SOA record `%s'\n"), 516 _ ("Unable to parse SOA record `%s'\n"),
515 s); 517 s);
516 return GNUNET_SYSERR; 518 return GNUNET_SYSERR;
517 } 519 }
518 soa.mname = soa_mname; 520 soa.mname = soa_mname;
519 soa.rname = soa_rname; 521 soa.rname = soa_rname;
520 soa.serial = (uint32_t)soa_serial; 522 soa.serial = (uint32_t) soa_serial;
521 soa.refresh = (uint32_t)soa_refresh; 523 soa.refresh = (uint32_t) soa_refresh;
522 soa.retry = (uint32_t)soa_retry; 524 soa.retry = (uint32_t) soa_retry;
523 soa.expire = (uint32_t)soa_expire; 525 soa.expire = (uint32_t) soa_expire;
524 soa.minimum_ttl = (uint32_t)soa_min; 526 soa.minimum_ttl = (uint32_t) soa_min;
525 off = 0; 527 off = 0;
526 if (GNUNET_OK != 528 if (GNUNET_OK !=
527 GNUNET_DNSPARSER_builder_add_soa(soabuf, sizeof(soabuf), &off, &soa)) 529 GNUNET_DNSPARSER_builder_add_soa (soabuf, sizeof(soabuf), &off, &soa))
528 { 530 {
529 GNUNET_log( 531 GNUNET_log (
530 GNUNET_ERROR_TYPE_ERROR, 532 GNUNET_ERROR_TYPE_ERROR,
531 _("Failed to serialize SOA record with mname `%s' and rname `%s'\n"), 533 _ ("Failed to serialize SOA record with mname `%s' and rname `%s'\n"),
532 soa_mname, 534 soa_mname,
533 soa_rname); 535 soa_rname);
534 return GNUNET_SYSERR; 536 return GNUNET_SYSERR;
535 } 537 }
536 *data_size = off; 538 *data_size = off;
537 *data = GNUNET_malloc(off); 539 *data = GNUNET_malloc (off);
538 GNUNET_memcpy(*data, soabuf, off); 540 GNUNET_memcpy (*data, soabuf, off);
539 return GNUNET_OK; 541 return GNUNET_OK;
540 } 542 }
541 543
542 case GNUNET_DNSPARSER_TYPE_PTR: { 544 case GNUNET_DNSPARSER_TYPE_PTR: {
543 char ptrbuf[256]; 545 char ptrbuf[256];
544 size_t off; 546 size_t off;
545 547
546 off = 0; 548 off = 0;
547 if (GNUNET_OK != 549 if (GNUNET_OK !=
548 GNUNET_DNSPARSER_builder_add_name(ptrbuf, sizeof(ptrbuf), &off, s)) 550 GNUNET_DNSPARSER_builder_add_name (ptrbuf, sizeof(ptrbuf), &off, s))
549 { 551 {
550 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 552 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
551 _("Failed to serialize PTR record with value `%s'\n"), 553 _ ("Failed to serialize PTR record with value `%s'\n"),
552 s); 554 s);
553 return GNUNET_SYSERR; 555 return GNUNET_SYSERR;
554 } 556 }
555 *data_size = off; 557 *data_size = off;
556 *data = GNUNET_malloc(off); 558 *data = GNUNET_malloc (off);
557 GNUNET_memcpy(*data, ptrbuf, off); 559 GNUNET_memcpy (*data, ptrbuf, off);
558 return GNUNET_OK; 560 return GNUNET_OK;
559 } 561 }
560 562
561 case GNUNET_DNSPARSER_TYPE_MX: { 563 case GNUNET_DNSPARSER_TYPE_MX: {
562 struct GNUNET_DNSPARSER_MxRecord mx; 564 struct GNUNET_DNSPARSER_MxRecord mx;
563 char mxbuf[258]; 565 char mxbuf[258];
564 char mxhost[253 + 1]; 566 char mxhost[253 + 1];
565 unsigned int mx_pref; 567 unsigned int mx_pref;
566 size_t off; 568 size_t off;
567 569
568 if (2 != sscanf(s, "%u,%253s", &mx_pref, mxhost)) 570 if (2 != sscanf (s, "%u,%253s", &mx_pref, mxhost))
569 { 571 {
570 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 572 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
571 _("Unable to parse MX record `%s'\n"), 573 _ ("Unable to parse MX record `%s'\n"),
572 s); 574 s);
573 return GNUNET_SYSERR; 575 return GNUNET_SYSERR;
574 } 576 }
575 mx.preference = (uint16_t)mx_pref; 577 mx.preference = (uint16_t) mx_pref;
576 mx.mxhost = mxhost; 578 mx.mxhost = mxhost;
577 off = 0; 579 off = 0;
578 580
579 if (GNUNET_OK != 581 if (GNUNET_OK !=
580 GNUNET_DNSPARSER_builder_add_mx(mxbuf, sizeof(mxbuf), &off, &mx)) 582 GNUNET_DNSPARSER_builder_add_mx (mxbuf, sizeof(mxbuf), &off, &mx))
581 { 583 {
582 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 584 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
583 _("Failed to serialize MX record with hostname `%s'\n"), 585 _ ("Failed to serialize MX record with hostname `%s'\n"),
584 mxhost); 586 mxhost);
585 return GNUNET_SYSERR; 587 return GNUNET_SYSERR;
586 } 588 }
587 *data_size = off; 589 *data_size = off;
588 *data = GNUNET_malloc(off); 590 *data = GNUNET_malloc (off);
589 GNUNET_memcpy(*data, mxbuf, off); 591 GNUNET_memcpy (*data, mxbuf, off);
590 return GNUNET_OK; 592 return GNUNET_OK;
591 } 593 }
592 594
593 case GNUNET_DNSPARSER_TYPE_SRV: { 595 case GNUNET_DNSPARSER_TYPE_SRV: {
594 struct GNUNET_DNSPARSER_SrvRecord srv; 596 struct GNUNET_DNSPARSER_SrvRecord srv;
595 char srvbuf[270]; 597 char srvbuf[270];
596 char srvtarget[253 + 1]; 598 char srvtarget[253 + 1];
@@ -599,111 +601,113 @@ dns_string_to_value(void *cls,
599 unsigned int port; 601 unsigned int port;
600 size_t off; 602 size_t off;
601 603
602 if (4 != sscanf(s, "%u %u %u %253s", &priority, &weight, &port, srvtarget)) 604 if (4 != sscanf (s, "%u %u %u %253s", &priority, &weight, &port,
603 { 605 srvtarget))
604 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 606 {
605 _("Unable to parse SRV record `%s'\n"), 607 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
606 s); 608 _ ("Unable to parse SRV record `%s'\n"),
607 return GNUNET_SYSERR; 609 s);
608 } 610 return GNUNET_SYSERR;
609 srv.priority = (uint16_t)priority; 611 }
610 srv.weight = (uint16_t)weight; 612 srv.priority = (uint16_t) priority;
611 srv.port = (uint16_t)port; 613 srv.weight = (uint16_t) weight;
614 srv.port = (uint16_t) port;
612 srv.target = srvtarget; 615 srv.target = srvtarget;
613 off = 0; 616 off = 0;
614 if (GNUNET_OK != 617 if (GNUNET_OK !=
615 GNUNET_DNSPARSER_builder_add_srv(srvbuf, sizeof(srvbuf), &off, &srv)) 618 GNUNET_DNSPARSER_builder_add_srv (srvbuf, sizeof(srvbuf), &off, &srv))
616 { 619 {
617 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 620 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
618 _("Failed to serialize SRV record with target `%s'\n"), 621 _ ("Failed to serialize SRV record with target `%s'\n"),
619 srvtarget); 622 srvtarget);
620 return GNUNET_SYSERR; 623 return GNUNET_SYSERR;
621 } 624 }
622 *data_size = off; 625 *data_size = off;
623 *data = GNUNET_malloc(off); 626 *data = GNUNET_malloc (off);
624 GNUNET_memcpy(*data, srvbuf, off); 627 GNUNET_memcpy (*data, srvbuf, off);
625 return GNUNET_OK; 628 return GNUNET_OK;
626 } 629 }
627 630
628 case GNUNET_DNSPARSER_TYPE_TXT: 631 case GNUNET_DNSPARSER_TYPE_TXT:
629 *data = GNUNET_strdup(s); 632 *data = GNUNET_strdup (s);
630 *data_size = strlen(s); 633 *data_size = strlen (s);
631 return GNUNET_OK; 634 return GNUNET_OK;
632 635
633 case GNUNET_DNSPARSER_TYPE_AAAA: 636 case GNUNET_DNSPARSER_TYPE_AAAA:
634 if (1 != inet_pton(AF_INET6, s, &value_aaaa)) 637 if (1 != inet_pton (AF_INET6, s, &value_aaaa))
635 { 638 {
636 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 639 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
637 _("Unable to parse IPv6 address `%s'\n"), 640 _ ("Unable to parse IPv6 address `%s'\n"),
638 s); 641 s);
639 return GNUNET_SYSERR; 642 return GNUNET_SYSERR;
640 } 643 }
641 *data = GNUNET_new(struct in6_addr); 644 *data = GNUNET_new (struct in6_addr);
642 *data_size = sizeof(struct in6_addr); 645 *data_size = sizeof(struct in6_addr);
643 GNUNET_memcpy(*data, &value_aaaa, sizeof(value_aaaa)); 646 GNUNET_memcpy (*data, &value_aaaa, sizeof(value_aaaa));
644 return GNUNET_OK; 647 return GNUNET_OK;
645 648
646 case GNUNET_DNSPARSER_TYPE_TLSA: { 649 case GNUNET_DNSPARSER_TYPE_TLSA: {
647 unsigned int usage; 650 unsigned int usage;
648 unsigned int selector; 651 unsigned int selector;
649 unsigned int matching_type; 652 unsigned int matching_type;
650 size_t slen = strlen(s) + 1; 653 size_t slen = strlen (s) + 1;
651 char hex[slen]; 654 char hex[slen];
652 655
653 if (4 != sscanf(s, "%u %u %u %s", &usage, &selector, &matching_type, hex)) 656 if (4 != sscanf (s, "%u %u %u %s", &usage, &selector, &matching_type,
654 { 657 hex))
655 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 658 {
656 _("Unable to parse TLSA record string `%s'\n"), 659 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
657 s); 660 _ ("Unable to parse TLSA record string `%s'\n"),
658 *data_size = 0; 661 s);
659 return GNUNET_SYSERR; 662 *data_size = 0;
660 } 663 return GNUNET_SYSERR;
664 }
661 665
662 *data_size = sizeof(struct GNUNET_TUN_DnsTlsaRecord) + strlen(hex) / 2; 666 *data_size = sizeof(struct GNUNET_TUN_DnsTlsaRecord) + strlen (hex) / 2;
663 *data = tlsa = GNUNET_malloc(*data_size); 667 *data = tlsa = GNUNET_malloc (*data_size);
664 tlsa->usage = (uint8_t)usage; 668 tlsa->usage = (uint8_t) usage;
665 tlsa->selector = (uint8_t)selector; 669 tlsa->selector = (uint8_t) selector;
666 tlsa->matching_type = (uint8_t)matching_type; 670 tlsa->matching_type = (uint8_t) matching_type;
667 if (strlen(hex) / 2 != GNUNET_DNSPARSER_hex_to_bin(hex, &tlsa[1])) 671 if (strlen (hex) / 2 != GNUNET_DNSPARSER_hex_to_bin (hex, &tlsa[1]))
668 { 672 {
669 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 673 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
670 _("Unable to parse TLSA record string `%s'\n"), 674 _ ("Unable to parse TLSA record string `%s'\n"),
671 s); 675 s);
672 GNUNET_free(*data); 676 GNUNET_free (*data);
673 *data = NULL; 677 *data = NULL;
674 *data_size = 0; 678 *data_size = 0;
675 return GNUNET_SYSERR; 679 return GNUNET_SYSERR;
676 } 680 }
677 return GNUNET_OK; 681 return GNUNET_OK;
678 } 682 }
679 683
680 case GNUNET_DNSPARSER_TYPE_CAA: { //RFC6844 684 case GNUNET_DNSPARSER_TYPE_CAA: { // RFC6844
681 struct GNUNET_DNSPARSER_CaaRecord *caa; 685 struct GNUNET_DNSPARSER_CaaRecord *caa;
682 unsigned int flags; 686 unsigned int flags;
683 char tag[15]; //Max tag length 15 687 char tag[15]; // Max tag length 15
684 char value[strlen(s) + 1]; //Should be more than enough 688 char value[strlen (s) + 1]; // Should be more than enough
685 689
686 if (3 != sscanf(s, "%u %s %[^\n]", &flags, tag, value)) 690 if (3 != sscanf (s, "%u %s %[^\n]", &flags, tag, value))
687 { 691 {
688 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, 692 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
689 _("Unable to parse CAA record string `%s'\n"), 693 _ ("Unable to parse CAA record string `%s'\n"),
690 s); 694 s);
691 *data_size = 0; 695 *data_size = 0;
692 return GNUNET_SYSERR; 696 return GNUNET_SYSERR;
693 } 697 }
694 *data_size = sizeof(struct GNUNET_DNSPARSER_CaaRecord) + strlen(tag) + 698 *data_size = sizeof(struct GNUNET_DNSPARSER_CaaRecord) + strlen (tag)
695 strlen(value); 699 + strlen (value);
696 *data = caa = GNUNET_malloc(*data_size); 700 *data = caa = GNUNET_malloc (*data_size);
697 caa->flags = flags; 701 caa->flags = flags;
698 memcpy(&caa[1], tag, strlen(tag)); 702 memcpy (&caa[1], tag, strlen (tag));
699 caa->tag_len = strlen(tag); 703 caa->tag_len = strlen (tag);
700 memcpy((char *)&caa[1] + caa->tag_len, value, strlen(value)); 704 memcpy ((char *) &caa[1] + caa->tag_len, value, strlen (value));
701 return GNUNET_OK; 705 return GNUNET_OK;
702 } 706 }
703 707
704 default: 708 default:
705 return GNUNET_SYSERR; 709 return GNUNET_SYSERR;
706 } 710 }
707} 711}
708 712
709 713
@@ -711,7 +715,8 @@ dns_string_to_value(void *cls,
711 * Mapping of record type numbers to human-readable 715 * Mapping of record type numbers to human-readable
712 * record type names. 716 * record type names.
713 */ 717 */
714static struct { 718static struct
719{
715 const char *name; 720 const char *name;
716 uint32_t number; 721 uint32_t number;
717} name_map[] = { { "A", GNUNET_DNSPARSER_TYPE_A }, 722} name_map[] = { { "A", GNUNET_DNSPARSER_TYPE_A },
@@ -737,13 +742,13 @@ static struct {
737 * @return corresponding number, UINT32_MAX on error 742 * @return corresponding number, UINT32_MAX on error
738 */ 743 */
739static uint32_t 744static uint32_t
740dns_typename_to_number(void *cls, const char *dns_typename) 745dns_typename_to_number (void *cls, const char *dns_typename)
741{ 746{
742 unsigned int i; 747 unsigned int i;
743 748
744 i = 0; 749 i = 0;
745 while ((NULL != name_map[i].name) && 750 while ((NULL != name_map[i].name) &&
746 (0 != strcasecmp(dns_typename, name_map[i].name))) 751 (0 != strcasecmp (dns_typename, name_map[i].name)))
747 i++; 752 i++;
748 return name_map[i].number; 753 return name_map[i].number;
749} 754}
@@ -757,7 +762,7 @@ dns_typename_to_number(void *cls, const char *dns_typename)
757 * @return corresponding typestring, NULL on error 762 * @return corresponding typestring, NULL on error
758 */ 763 */
759static const char * 764static const char *
760dns_number_to_typename(void *cls, uint32_t type) 765dns_number_to_typename (void *cls, uint32_t type)
761{ 766{
762 unsigned int i; 767 unsigned int i;
763 768
@@ -775,11 +780,11 @@ dns_number_to_typename(void *cls, uint32_t type)
775 * @return the exported block API 780 * @return the exported block API
776 */ 781 */
777void * 782void *
778libgnunet_plugin_gnsrecord_dns_init(void *cls) 783libgnunet_plugin_gnsrecord_dns_init (void *cls)
779{ 784{
780 struct GNUNET_GNSRECORD_PluginFunctions *api; 785 struct GNUNET_GNSRECORD_PluginFunctions *api;
781 786
782 api = GNUNET_new(struct GNUNET_GNSRECORD_PluginFunctions); 787 api = GNUNET_new (struct GNUNET_GNSRECORD_PluginFunctions);
783 api->value_to_string = &dns_value_to_string; 788 api->value_to_string = &dns_value_to_string;
784 api->string_to_value = &dns_string_to_value; 789 api->string_to_value = &dns_string_to_value;
785 api->typename_to_number = &dns_typename_to_number; 790 api->typename_to_number = &dns_typename_to_number;
@@ -795,11 +800,11 @@ libgnunet_plugin_gnsrecord_dns_init(void *cls)
795 * @return NULL 800 * @return NULL
796 */ 801 */
797void * 802void *
798libgnunet_plugin_gnsrecord_dns_done(void *cls) 803libgnunet_plugin_gnsrecord_dns_done (void *cls)
799{ 804{
800 struct GNUNET_GNSRECORD_PluginFunctions *api = cls; 805 struct GNUNET_GNSRECORD_PluginFunctions *api = cls;
801 806
802 GNUNET_free(api); 807 GNUNET_free (api);
803 return NULL; 808 return NULL;
804} 809}
805 810
diff --git a/src/gnsrecord/test_gnsrecord_block_expiration.c b/src/gnsrecord/test_gnsrecord_block_expiration.c
index 24aa3d921..9672c2ffb 100644
--- a/src/gnsrecord/test_gnsrecord_block_expiration.c
+++ b/src/gnsrecord/test_gnsrecord_block_expiration.c
@@ -44,49 +44,53 @@ static int res;
44 44
45 45
46static void 46static void
47run(void *cls, char *const *args, const char *cfgfile, 47run (void *cls, char *const *args, const char *cfgfile,
48 const struct GNUNET_CONFIGURATION_Handle *cfg) 48 const struct GNUNET_CONFIGURATION_Handle *cfg)
49{ 49{
50 struct GNUNET_GNSRECORD_Data rd[2]; 50 struct GNUNET_GNSRECORD_Data rd[2];
51 struct GNUNET_TIME_Absolute expiration_abs; 51 struct GNUNET_TIME_Absolute expiration_abs;
52 struct GNUNET_TIME_Absolute expiration_abs_shadow; 52 struct GNUNET_TIME_Absolute expiration_abs_shadow;
53 53
54 expiration_abs.abs_value_us = GNUNET_TIME_absolute_get().abs_value_us + 54 expiration_abs.abs_value_us = GNUNET_TIME_absolute_get ().abs_value_us
55 GNUNET_TIME_UNIT_SECONDS.rel_value_us; 55 + GNUNET_TIME_UNIT_SECONDS.rel_value_us;
56 expiration_abs_shadow.abs_value_us = GNUNET_TIME_absolute_get().abs_value_us + 56 expiration_abs_shadow.abs_value_us = GNUNET_TIME_absolute_get ().abs_value_us
57 GNUNET_TIME_UNIT_MINUTES.rel_value_us; 57 + GNUNET_TIME_UNIT_MINUTES.rel_value_us;
58 58
59 /* create record */ 59 /* create record */
60 rd[0].expiration_time = expiration_abs.abs_value_us; 60 rd[0].expiration_time = expiration_abs.abs_value_us;
61 rd[0].record_type = TEST_RECORD_TYPE; 61 rd[0].record_type = TEST_RECORD_TYPE;
62 rd[0].data_size = TEST_RECORD_DATALEN; 62 rd[0].data_size = TEST_RECORD_DATALEN;
63 rd[0].data = GNUNET_malloc(TEST_RECORD_DATALEN); 63 rd[0].data = GNUNET_malloc (TEST_RECORD_DATALEN);
64 rd[0].flags = GNUNET_GNSRECORD_RF_NONE; 64 rd[0].flags = GNUNET_GNSRECORD_RF_NONE;
65 memset((char *)rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 65 memset ((char *) rd[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
66 66
67 rd[1].expiration_time = expiration_abs.abs_value_us; 67 rd[1].expiration_time = expiration_abs.abs_value_us;
68 rd[1].record_type = TEST_RECORD_TYPE; 68 rd[1].record_type = TEST_RECORD_TYPE;
69 rd[1].data_size = TEST_RECORD_DATALEN; 69 rd[1].data_size = TEST_RECORD_DATALEN;
70 rd[1].data = GNUNET_malloc(TEST_RECORD_DATALEN); 70 rd[1].data = GNUNET_malloc (TEST_RECORD_DATALEN);
71 rd[1].flags = GNUNET_GNSRECORD_RF_NONE; 71 rd[1].flags = GNUNET_GNSRECORD_RF_NONE;
72 memset((char *)rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 72 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
73 73
74 GNUNET_assert(expiration_abs.abs_value_us == GNUNET_GNSRECORD_record_get_expiration_time(2, rd).abs_value_us); 74 GNUNET_assert (expiration_abs.abs_value_us ==
75 GNUNET_GNSRECORD_record_get_expiration_time (2,
76 rd).abs_value_us);
75 77
76 rd[1].expiration_time = expiration_abs_shadow.abs_value_us; 78 rd[1].expiration_time = expiration_abs_shadow.abs_value_us;
77 rd[1].record_type = TEST_RECORD_TYPE; 79 rd[1].record_type = TEST_RECORD_TYPE;
78 rd[1].data_size = TEST_RECORD_DATALEN; 80 rd[1].data_size = TEST_RECORD_DATALEN;
79 rd[1].data = GNUNET_malloc(TEST_RECORD_DATALEN); 81 rd[1].data = GNUNET_malloc (TEST_RECORD_DATALEN);
80 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW_RECORD; 82 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW_RECORD;
81 memset((char *)rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 83 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
82 84
83 GNUNET_assert(expiration_abs_shadow.abs_value_us == GNUNET_GNSRECORD_record_get_expiration_time(2, rd).abs_value_us); 85 GNUNET_assert (expiration_abs_shadow.abs_value_us ==
86 GNUNET_GNSRECORD_record_get_expiration_time (2,
87 rd).abs_value_us);
84 res = 0; 88 res = 0;
85} 89}
86 90
87 91
88int 92int
89main(int argc, char *argv[]) 93main (int argc, char *argv[])
90{ 94{
91 static char *const argvx[] = { "test-gnsrecord-crypto", 95 static char *const argvx[] = { "test-gnsrecord-crypto",
92 NULL }; 96 NULL };
@@ -95,8 +99,9 @@ main(int argc, char *argv[])
95 }; 99 };
96 100
97 res = 1; 101 res = 1;
98 GNUNET_PROGRAM_run((sizeof(argvx) / sizeof(char *)) - 1, argvx, "test-namestore-api", 102 GNUNET_PROGRAM_run ((sizeof(argvx) / sizeof(char *)) - 1, argvx,
99 "nohelp", options, &run, &res); 103 "test-namestore-api",
104 "nohelp", options, &run, &res);
100 return res; 105 return res;
101} 106}
102 107
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c
index 6be870e17..b16828147 100644
--- a/src/gnsrecord/test_gnsrecord_crypto.c
+++ b/src/gnsrecord/test_gnsrecord_crypto.c
@@ -41,7 +41,7 @@
41#define TEST_REMOVE_RECORD_DATA 'b' 41#define TEST_REMOVE_RECORD_DATA 'b'
42 42
43 43
44static struct GNUNET_CRYPTO_EcdsaPrivateKey * privkey; 44static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
45 45
46static struct GNUNET_GNSRECORD_Data *s_rd; 46static struct GNUNET_GNSRECORD_Data *s_rd;
47 47
@@ -51,102 +51,103 @@ static int res;
51 51
52 52
53static struct GNUNET_GNSRECORD_Data * 53static struct GNUNET_GNSRECORD_Data *
54create_record(int count) 54create_record (int count)
55{ 55{
56 struct GNUNET_GNSRECORD_Data *rd; 56 struct GNUNET_GNSRECORD_Data *rd;
57 57
58 rd = GNUNET_new_array(count, struct GNUNET_GNSRECORD_Data); 58 rd = GNUNET_new_array (count, struct GNUNET_GNSRECORD_Data);
59 for (unsigned int c = 0; c < count; c++) 59 for (unsigned int c = 0; c < count; c++)
60 { 60 {
61 rd[c].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000; 61 rd[c].expiration_time = GNUNET_TIME_absolute_get ().abs_value_us
62 rd[c].record_type = TEST_RECORD_TYPE; 62 + 1000000000;
63 rd[c].data_size = TEST_RECORD_DATALEN; 63 rd[c].record_type = TEST_RECORD_TYPE;
64 rd[c].data = GNUNET_malloc(TEST_RECORD_DATALEN); 64 rd[c].data_size = TEST_RECORD_DATALEN;
65 memset((char *)rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 65 rd[c].data = GNUNET_malloc (TEST_RECORD_DATALEN);
66 } 66 memset ((char *) rd[c].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
67 }
67 return rd; 68 return rd;
68} 69}
69 70
70 71
71static void 72static void
72rd_decrypt_cb(void *cls, 73rd_decrypt_cb (void *cls,
73 unsigned int rd_count, 74 unsigned int rd_count,
74 const struct GNUNET_GNSRECORD_Data *rd) 75 const struct GNUNET_GNSRECORD_Data *rd)
75{ 76{
76 char rd_cmp_data[TEST_RECORD_DATALEN]; 77 char rd_cmp_data[TEST_RECORD_DATALEN];
77 78
78 GNUNET_assert(RECORDS == rd_count); 79 GNUNET_assert (RECORDS == rd_count);
79 GNUNET_assert(NULL != rd); 80 GNUNET_assert (NULL != rd);
80 memset(rd_cmp_data, 81 memset (rd_cmp_data,
81 'a', 82 'a',
82 TEST_RECORD_DATALEN); 83 TEST_RECORD_DATALEN);
83 for (unsigned int c = 0; c < rd_count; c++) 84 for (unsigned int c = 0; c < rd_count; c++)
84 { 85 {
85 GNUNET_assert(TEST_RECORD_TYPE == rd[c].record_type); 86 GNUNET_assert (TEST_RECORD_TYPE == rd[c].record_type);
86 GNUNET_assert(TEST_RECORD_DATALEN == rd[c].data_size); 87 GNUNET_assert (TEST_RECORD_DATALEN == rd[c].data_size);
87 GNUNET_assert(0 == memcmp(&rd_cmp_data, 88 GNUNET_assert (0 == memcmp (&rd_cmp_data,
88 rd[c].data, 89 rd[c].data,
89 TEST_RECORD_DATALEN)); 90 TEST_RECORD_DATALEN));
90 } 91 }
91 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
92 "Block was decrypted successfully \n"); 93 "Block was decrypted successfully \n");
93 res = 0; 94 res = 0;
94} 95}
95 96
96static void 97static void
97run(void *cls, 98run (void *cls,
98 char *const *args, 99 char *const *args,
99 const char *cfgfile, 100 const char *cfgfile,
100 const struct GNUNET_CONFIGURATION_Handle *cfg) 101 const struct GNUNET_CONFIGURATION_Handle *cfg)
101{ 102{
102 struct GNUNET_GNSRECORD_Block *block; 103 struct GNUNET_GNSRECORD_Block *block;
103 struct GNUNET_CRYPTO_EcdsaPublicKey pubkey; 104 struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
104 struct GNUNET_HashCode query_pub; 105 struct GNUNET_HashCode query_pub;
105 struct GNUNET_HashCode query_priv; 106 struct GNUNET_HashCode query_priv;
106 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get(); 107 struct GNUNET_TIME_Absolute expire = GNUNET_TIME_absolute_get ();
107 108
108 privkey = GNUNET_CRYPTO_ecdsa_key_create(); 109 privkey = GNUNET_CRYPTO_ecdsa_key_create ();
109 GNUNET_assert(NULL != privkey); 110 GNUNET_assert (NULL != privkey);
110 /* get public key */ 111 /* get public key */
111 GNUNET_CRYPTO_ecdsa_key_get_public(privkey, 112 GNUNET_CRYPTO_ecdsa_key_get_public (privkey,
112 &pubkey); 113 &pubkey);
113 114
114 /* test query derivation */ 115 /* test query derivation */
115 GNUNET_GNSRECORD_query_from_private_key(privkey, 116 GNUNET_GNSRECORD_query_from_private_key (privkey,
117 "testlabel",
118 &query_priv);
119 GNUNET_GNSRECORD_query_from_public_key (&pubkey,
116 "testlabel", 120 "testlabel",
117 &query_priv); 121 &query_pub);
118 GNUNET_GNSRECORD_query_from_public_key(&pubkey, 122 GNUNET_assert (0 == memcmp (&query_priv,
119 "testlabel", 123 &query_pub,
120 &query_pub); 124 sizeof(struct GNUNET_HashCode)));
121 GNUNET_assert(0 == memcmp(&query_priv,
122 &query_pub,
123 sizeof(struct GNUNET_HashCode)));
124 /* create record */ 125 /* create record */
125 s_name = "DUMMY.dummy.gnunet"; 126 s_name = "DUMMY.dummy.gnunet";
126 s_rd = create_record(RECORDS); 127 s_rd = create_record (RECORDS);
127 128
128 /* Create block */ 129 /* Create block */
129 GNUNET_assert(NULL != (block = 130 GNUNET_assert (NULL != (block =
130 GNUNET_GNSRECORD_block_create(privkey, 131 GNUNET_GNSRECORD_block_create (privkey,
131 expire, 132 expire,
132 s_name, 133 s_name,
133 s_rd, 134 s_rd,
134 RECORDS))); 135 RECORDS)));
135 GNUNET_assert(GNUNET_OK == 136 GNUNET_assert (GNUNET_OK ==
136 GNUNET_GNSRECORD_block_verify(block)); 137 GNUNET_GNSRECORD_block_verify (block));
137 GNUNET_assert(GNUNET_OK == 138 GNUNET_assert (GNUNET_OK ==
138 GNUNET_GNSRECORD_block_decrypt(block, 139 GNUNET_GNSRECORD_block_decrypt (block,
139 &pubkey, 140 &pubkey,
140 s_name, 141 s_name,
141 &rd_decrypt_cb, 142 &rd_decrypt_cb,
142 s_name)); 143 s_name));
143 GNUNET_free(block); 144 GNUNET_free (block);
144 GNUNET_free(privkey); 145 GNUNET_free (privkey);
145} 146}
146 147
147 148
148int 149int
149main(int argc, char *argv[]) 150main (int argc, char *argv[])
150{ 151{
151 static char *const argvx[] = { 152 static char *const argvx[] = {
152 "test-gnsrecord-crypto", 153 "test-gnsrecord-crypto",
@@ -157,11 +158,11 @@ main(int argc, char *argv[])
157 }; 158 };
158 159
159 res = 1; 160 res = 1;
160 GNUNET_PROGRAM_run((sizeof(argvx) / sizeof(char *)) - 1, 161 GNUNET_PROGRAM_run ((sizeof(argvx) / sizeof(char *)) - 1,
161 argvx, 162 argvx,
162 "test-gnsrecord-crypto", 163 "test-gnsrecord-crypto",
163 "nohelp", options, 164 "nohelp", options,
164 &run, &res); 165 &run, &res);
165 return res; 166 return res;
166} 167}
167 168
diff --git a/src/gnsrecord/test_gnsrecord_serialization.c b/src/gnsrecord/test_gnsrecord_serialization.c
index 34dcff5cb..6905cf515 100644
--- a/src/gnsrecord/test_gnsrecord_serialization.c
+++ b/src/gnsrecord/test_gnsrecord_serialization.c
@@ -26,16 +26,16 @@
26#include "gnunet_gnsrecord_lib.h" 26#include "gnunet_gnsrecord_lib.h"
27#include "gnunet_dnsparser_lib.h" 27#include "gnunet_dnsparser_lib.h"
28 28
29#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 100) 29#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
30 30
31static int res; 31static int res;
32 32
33 33
34static void 34static void
35run(void *cls, 35run (void *cls,
36 char *const *args, 36 char *const *args,
37 const char *cfgfile, 37 const char *cfgfile,
38 const struct GNUNET_CONFIGURATION_Handle *cfg) 38 const struct GNUNET_CONFIGURATION_Handle *cfg)
39{ 39{
40 size_t len; 40 size_t len;
41 int c; 41 int c;
@@ -44,101 +44,101 @@ run(void *cls,
44 size_t data_len; 44 size_t data_len;
45 struct GNUNET_GNSRECORD_Data src[rd_count]; 45 struct GNUNET_GNSRECORD_Data src[rd_count];
46 46
47 memset(src, '\0', rd_count * sizeof(struct GNUNET_GNSRECORD_Data)); 47 memset (src, '\0', rd_count * sizeof(struct GNUNET_GNSRECORD_Data));
48 48
49 data_len = 0; 49 data_len = 0;
50 for (c = 0; c < rd_count; c++) 50 for (c = 0; c < rd_count; c++)
51 { 51 {
52 src[c].record_type = GNUNET_DNSPARSER_TYPE_TXT; 52 src[c].record_type = GNUNET_DNSPARSER_TYPE_TXT;
53 src[c].data_size = data_len; 53 src[c].data_size = data_len;
54 src[c].data = GNUNET_malloc(data_len); 54 src[c].data = GNUNET_malloc (data_len);
55 55
56 /* Setting data to data_len * record_type */ 56 /* Setting data to data_len * record_type */
57 memset((char *)src[c].data, 'a', data_len); 57 memset ((char *) src[c].data, 'a', data_len);
58 data_len += 10; 58 data_len += 10;
59 } 59 }
60 res = 0; 60 res = 0;
61 61
62 len = GNUNET_GNSRECORD_records_get_size(rd_count, src); 62 len = GNUNET_GNSRECORD_records_get_size (rd_count, src);
63 char rd_ser[len]; 63 char rd_ser[len];
64 GNUNET_assert(len == 64 GNUNET_assert (len ==
65 GNUNET_GNSRECORD_records_serialize(rd_count, 65 GNUNET_GNSRECORD_records_serialize (rd_count,
66 src, 66 src,
67 len, 67 len,
68 rd_ser)); 68 rd_ser));
69 69
70 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 70 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
71 "Serialized data len: %u\n", 71 "Serialized data len: %u\n",
72 (unsigned int)len); 72 (unsigned int) len);
73 73
74 GNUNET_assert(rd_ser != NULL); 74 GNUNET_assert (rd_ser != NULL);
75 { 75 {
76 struct GNUNET_GNSRECORD_Data dst[rd_count]; 76 struct GNUNET_GNSRECORD_Data dst[rd_count];
77 GNUNET_assert(GNUNET_OK == 77 GNUNET_assert (GNUNET_OK ==
78 GNUNET_GNSRECORD_records_deserialize(len, 78 GNUNET_GNSRECORD_records_deserialize (len,
79 rd_ser, 79 rd_ser,
80 rd_count, 80 rd_count,
81 dst)); 81 dst));
82 82
83 GNUNET_assert(dst != NULL); 83 GNUNET_assert (dst != NULL);
84 84
85 for (c = 0; c < rd_count; c++) 85 for (c = 0; c < rd_count; c++)
86 {
87 if (src[c].data_size != dst[c].data_size)
88 {
89 GNUNET_break (0);
90 res = 1;
91 }
92 if (src[c].expiration_time != dst[c].expiration_time)
93 {
94 GNUNET_break (0);
95 res = 1;
96 }
97 if (src[c].flags != dst[c].flags)
86 { 98 {
87 if (src[c].data_size != dst[c].data_size) 99 GNUNET_break (0);
88 { 100 res = 1;
89 GNUNET_break(0); 101 }
90 res = 1; 102 if (src[c].record_type != dst[c].record_type)
91 } 103 {
92 if (src[c].expiration_time != dst[c].expiration_time) 104 GNUNET_break (0);
93 { 105 res = 1;
94 GNUNET_break(0); 106 }
95 res = 1;
96 }
97 if (src[c].flags != dst[c].flags)
98 {
99 GNUNET_break(0);
100 res = 1;
101 }
102 if (src[c].record_type != dst[c].record_type)
103 {
104 GNUNET_break(0);
105 res = 1;
106 }
107 107
108 {
109 size_t data_size = src[c].data_size;
110 char data[data_size];
111
112 memset (data, 'a', data_size);
113 if (0 != memcmp (data, dst[c].data, data_size))
114 {
115 GNUNET_break (0);
116 res = 1;
117 }
118 if (0 != memcmp (data, src[c].data, data_size))
119 {
120 GNUNET_break (0);
121 res = 1;
122 }
123 if (0 != memcmp (src[c].data, dst[c].data, src[c].data_size))
108 { 124 {
109 size_t data_size = src[c].data_size; 125 GNUNET_break (0);
110 char data[data_size]; 126 res = 1;
111
112 memset(data, 'a', data_size);
113 if (0 != memcmp(data, dst[c].data, data_size))
114 {
115 GNUNET_break(0);
116 res = 1;
117 }
118 if (0 != memcmp(data, src[c].data, data_size))
119 {
120 GNUNET_break(0);
121 res = 1;
122 }
123 if (0 != memcmp(src[c].data, dst[c].data, src[c].data_size))
124 {
125 GNUNET_break(0);
126 res = 1;
127 }
128 } 127 }
129 } 128 }
130 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Element [%i]: EQUAL\n", c); 129 }
130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Element [%i]: EQUAL\n", c);
131 } 131 }
132 132
133 for (c = 0; c < rd_count; c++) 133 for (c = 0; c < rd_count; c++)
134 { 134 {
135 GNUNET_free((void *)src[c].data); 135 GNUNET_free ((void *) src[c].data);
136 } 136 }
137} 137}
138 138
139 139
140int 140int
141main(int argcx, char *argvx[]) 141main (int argcx, char *argvx[])
142{ 142{
143 static char *const argv[] = { "test_gnsrecord_serialization", 143 static char *const argv[] = { "test_gnsrecord_serialization",
144 NULL }; 144 NULL };
@@ -147,8 +147,9 @@ main(int argcx, char *argvx[])
147 }; 147 };
148 148
149 res = 1; 149 res = 1;
150 GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *)) - 1, argv, "test_namestore_record_serialization", 150 GNUNET_PROGRAM_run ((sizeof(argv) / sizeof(char *)) - 1, argv,
151 "nohelp", options, &run, &res); 151 "test_namestore_record_serialization",
152 "nohelp", options, &run, &res);
152 return res; 153 return res;
153} 154}
154 155