aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/gnunet-daemon-testbed-underlay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/gnunet-daemon-testbed-underlay.c')
-rw-r--r--src/testbed/gnunet-daemon-testbed-underlay.c366
1 files changed, 182 insertions, 184 deletions
diff --git a/src/testbed/gnunet-daemon-testbed-underlay.c b/src/testbed/gnunet-daemon-testbed-underlay.c
index f5f6899e9..0c6a3c3df 100644
--- a/src/testbed/gnunet-daemon-testbed-underlay.c
+++ b/src/testbed/gnunet-daemon-testbed-underlay.c
@@ -11,12 +11,12 @@
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU Affero General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 17
18 SPDX-License-Identifier: AGPL3.0-or-later 18 SPDX-License-Identifier: AGPL3.0-or-later
19*/ 19 */
20 20
21 21
22/** 22/**
@@ -37,14 +37,14 @@
37/** 37/**
38 * Logging shorthand 38 * Logging shorthand
39 */ 39 */
40#define LOG(type,...) \ 40#define LOG(type, ...) \
41 GNUNET_log (type, __VA_ARGS__) 41 GNUNET_log(type, __VA_ARGS__)
42 42
43/** 43/**
44 * Debug logging shorthand 44 * Debug logging shorthand
45 */ 45 */
46#define DEBUG(...) \ 46#define DEBUG(...) \
47 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) 47 LOG(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
48 48
49/** 49/**
50 * Log an error message at log-level 'level' that indicates 50 * Log an error message at log-level 'level' that indicates
@@ -53,12 +53,12 @@
53 */ 53 */
54#define LOG_SQLITE(db, msg, level, cmd) \ 54#define LOG_SQLITE(db, msg, level, cmd) \
55 do { \ 55 do { \
56 GNUNET_log_from (level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), \ 56 GNUNET_log_from(level, "sqlite", _("`%s' failed at %s:%d with error: %s\n"), \
57 cmd, __FILE__,__LINE__, sqlite3_errmsg(db)); \ 57 cmd, __FILE__, __LINE__, sqlite3_errmsg(db)); \
58 if (msg != NULL) \ 58 if (msg != NULL) \
59 GNUNET_asprintf(msg, _("`%s' failed at %s:%u with error: %s"), cmd, \ 59 GNUNET_asprintf (msg, _("`%s' failed at %s:%u with error: %s"), cmd, \
60 __FILE__, __LINE__, sqlite3_errmsg(db)); \ 60 __FILE__, __LINE__, sqlite3_errmsg(db)); \
61 } while(0) 61 } while (0)
62 62
63 63
64/** 64/**
@@ -115,10 +115,10 @@ static unsigned int num_hostkeys;
115 * #GNUNET_NO if not. 115 * #GNUNET_NO if not.
116 */ 116 */
117static int 117static int
118iterator (void *cls, const struct GNUNET_PeerIdentity *key, void *value) 118iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
119{ 119{
120 GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (map, key, 120 GNUNET_assert(GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove(map, key,
121 value)); 121 value));
122 return GNUNET_YES; 122 return GNUNET_YES;
123} 123}
124 124
@@ -127,16 +127,16 @@ iterator (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
127 * Cleaup and destroy the map 127 * Cleaup and destroy the map
128 */ 128 */
129static void 129static void
130cleanup_map () 130cleanup_map()
131{ 131{
132 if (NULL != map) 132 if (NULL != map)
133 { 133 {
134 GNUNET_assert (GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_iterate (map, 134 GNUNET_assert(GNUNET_SYSERR != GNUNET_CONTAINER_multipeermap_iterate(map,
135 &iterator, 135 &iterator,
136 NULL)); 136 NULL));
137 GNUNET_CONTAINER_multipeermap_destroy (map); 137 GNUNET_CONTAINER_multipeermap_destroy(map);
138 map = NULL; 138 map = NULL;
139 } 139 }
140} 140}
141 141
142 142
@@ -148,35 +148,35 @@ cleanup_map ()
148 * @return GNUNET_OK if the connection is allowed, GNUNET_SYSERR if not 148 * @return GNUNET_OK if the connection is allowed, GNUNET_SYSERR if not
149 */ 149 */
150static int 150static int
151check_access (void *cls, const struct GNUNET_PeerIdentity * pid) 151check_access(void *cls, const struct GNUNET_PeerIdentity * pid)
152{ 152{
153 int contains; 153 int contains;
154 154
155 GNUNET_assert (NULL != map); 155 GNUNET_assert(NULL != map);
156 contains = GNUNET_CONTAINER_multipeermap_contains (map, pid); 156 contains = GNUNET_CONTAINER_multipeermap_contains(map, pid);
157 if (GNUNET_YES == contains) 157 if (GNUNET_YES == contains)
158 { 158 {
159 DEBUG ("Permitting `%s'\n", GNUNET_i2s (pid)); 159 DEBUG("Permitting `%s'\n", GNUNET_i2s(pid));
160 return GNUNET_OK; 160 return GNUNET_OK;
161 } 161 }
162 DEBUG ("Not permitting `%s'\n", GNUNET_i2s (pid)); 162 DEBUG("Not permitting `%s'\n", GNUNET_i2s(pid));
163 return GNUNET_SYSERR; 163 return GNUNET_SYSERR;
164} 164}
165 165
166 166
167static int 167static int
168get_identity (unsigned int offset, 168get_identity(unsigned int offset,
169 struct GNUNET_PeerIdentity *id) 169 struct GNUNET_PeerIdentity *id)
170{ 170{
171 struct GNUNET_CRYPTO_EddsaPrivateKey private_key; 171 struct GNUNET_CRYPTO_EddsaPrivateKey private_key;
172 172
173 if (offset >= num_hostkeys) 173 if (offset >= num_hostkeys)
174 return GNUNET_SYSERR; 174 return GNUNET_SYSERR;
175 GNUNET_memcpy (&private_key, 175 GNUNET_memcpy(&private_key,
176 hostkeys_data + (offset * GNUNET_TESTING_HOSTKEYFILESIZE), 176 hostkeys_data + (offset * GNUNET_TESTING_HOSTKEYFILESIZE),
177 GNUNET_TESTING_HOSTKEYFILESIZE); 177 GNUNET_TESTING_HOSTKEYFILESIZE);
178 GNUNET_CRYPTO_eddsa_key_get_public (&private_key, 178 GNUNET_CRYPTO_eddsa_key_get_public(&private_key,
179 &id->public_key); 179 &id->public_key);
180 return GNUNET_OK; 180 return GNUNET_OK;
181} 181}
182 182
@@ -184,8 +184,7 @@ get_identity (unsigned int offset,
184/** 184/**
185 * Whilelist entry 185 * Whilelist entry
186 */ 186 */
187struct WhiteListRow 187struct WhiteListRow {
188{
189 /** 188 /**
190 * Next ptr 189 * Next ptr
191 */ 190 */
@@ -200,7 +199,6 @@ struct WhiteListRow
200 * Latency to be assigned to the link 199 * Latency to be assigned to the link
201 */ 200 */
202 int latency; 201 int latency;
203
204}; 202};
205 203
206 204
@@ -208,7 +206,7 @@ struct WhiteListRow
208 * Function to load keys 206 * Function to load keys
209 */ 207 */
210static int 208static int
211load_keys (const struct GNUNET_CONFIGURATION_Handle *c) 209load_keys(const struct GNUNET_CONFIGURATION_Handle *c)
212{ 210{
213 char *data_dir; 211 char *data_dir;
214 char *idfile; 212 char *idfile;
@@ -217,43 +215,42 @@ load_keys (const struct GNUNET_CONFIGURATION_Handle *c)
217 data_dir = NULL; 215 data_dir = NULL;
218 idfile = NULL; 216 idfile = NULL;
219 fsize = 0; 217 fsize = 0;
220 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); 218 data_dir = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_DATADIR);
221 GNUNET_asprintf (&idfile, "%s/testing_hostkeys.ecc", data_dir); 219 GNUNET_asprintf(&idfile, "%s/testing_hostkeys.ecc", data_dir);
222 GNUNET_free (data_dir); 220 GNUNET_free(data_dir);
223 data_dir = NULL; 221 data_dir = NULL;
224 if (GNUNET_OK != 222 if (GNUNET_OK !=
225 GNUNET_DISK_file_size (idfile, &fsize, GNUNET_YES, GNUNET_YES)) 223 GNUNET_DISK_file_size(idfile, &fsize, GNUNET_YES, GNUNET_YES))
226 { 224 {
227 GNUNET_free (idfile); 225 GNUNET_free(idfile);
228 return GNUNET_SYSERR; 226 return GNUNET_SYSERR;
229 } 227 }
230 if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE)) 228 if (0 != (fsize % GNUNET_TESTING_HOSTKEYFILESIZE))
231 { 229 {
232 LOG (GNUNET_ERROR_TYPE_ERROR, 230 LOG(GNUNET_ERROR_TYPE_ERROR,
233 _("Incorrect hostkey file format: %s\n"), idfile); 231 _("Incorrect hostkey file format: %s\n"), idfile);
234 GNUNET_free (idfile); 232 GNUNET_free(idfile);
235 return GNUNET_SYSERR; 233 return GNUNET_SYSERR;
236 } 234 }
237 hostkeys_fd = GNUNET_DISK_file_open (idfile, GNUNET_DISK_OPEN_READ, 235 hostkeys_fd = GNUNET_DISK_file_open(idfile, GNUNET_DISK_OPEN_READ,
238 GNUNET_DISK_PERM_NONE); 236 GNUNET_DISK_PERM_NONE);
239 if (NULL == hostkeys_fd) 237 if (NULL == hostkeys_fd)
240 { 238 {
241 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", idfile); 239 GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_ERROR, "open", idfile);
242 GNUNET_free (idfile); 240 GNUNET_free(idfile);
243 return GNUNET_SYSERR; 241 return GNUNET_SYSERR;
244 } 242 }
245 GNUNET_free (idfile); 243 GNUNET_free(idfile);
246 idfile = NULL; 244 idfile = NULL;
247 hostkeys_data = GNUNET_DISK_file_map (hostkeys_fd, 245 hostkeys_data = GNUNET_DISK_file_map(hostkeys_fd,
248 &hostkeys_map, 246 &hostkeys_map,
249 GNUNET_DISK_MAP_TYPE_READ, 247 GNUNET_DISK_MAP_TYPE_READ,
250 fsize); 248 fsize);
251 if (NULL == hostkeys_data) 249 if (NULL == hostkeys_data)
252 { 250 {
253 251 GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR, "mmap");
254 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "mmap"); 252 return GNUNET_SYSERR;
255 return GNUNET_SYSERR; 253 }
256 }
257 num_hostkeys = fsize / GNUNET_TESTING_HOSTKEYFILESIZE; 254 num_hostkeys = fsize / GNUNET_TESTING_HOSTKEYFILESIZE;
258 return GNUNET_OK; 255 return GNUNET_OK;
259} 256}
@@ -263,20 +260,20 @@ load_keys (const struct GNUNET_CONFIGURATION_Handle *c)
263 * Function to unload keys 260 * Function to unload keys
264 */ 261 */
265static void 262static void
266unload_keys () 263unload_keys()
267{ 264{
268 if (NULL != hostkeys_map) 265 if (NULL != hostkeys_map)
269 { 266 {
270 GNUNET_assert (NULL != hostkeys_data); 267 GNUNET_assert(NULL != hostkeys_data);
271 GNUNET_DISK_file_unmap (hostkeys_map); 268 GNUNET_DISK_file_unmap(hostkeys_map);
272 hostkeys_map = NULL; 269 hostkeys_map = NULL;
273 hostkeys_data = NULL; 270 hostkeys_data = NULL;
274 } 271 }
275 if (NULL != hostkeys_fd) 272 if (NULL != hostkeys_fd)
276 { 273 {
277 GNUNET_DISK_file_close (hostkeys_fd); 274 GNUNET_DISK_file_close(hostkeys_fd);
278 hostkeys_fd = NULL; 275 hostkeys_fd = NULL;
279 } 276 }
280} 277}
281 278
282 279
@@ -286,17 +283,17 @@ unload_keys ()
286 * @param cls NULL 283 * @param cls NULL
287 */ 284 */
288static void 285static void
289do_shutdown (void *cls) 286do_shutdown(void *cls)
290{ 287{
291 if (NULL != transport) 288 if (NULL != transport)
292 { 289 {
293 GNUNET_TRANSPORT_manipulation_disconnect (transport); 290 GNUNET_TRANSPORT_manipulation_disconnect(transport);
294 transport = NULL; 291 transport = NULL;
295 } 292 }
296 cleanup_map (); 293 cleanup_map();
297 unload_keys (); 294 unload_keys();
298 if (NULL != bh) 295 if (NULL != bh)
299 GNUNET_TRANSPORT_blacklist_cancel (bh); 296 GNUNET_TRANSPORT_blacklist_cancel(bh);
300} 297}
301 298
302 299
@@ -309,7 +306,7 @@ do_shutdown (void *cls)
309 * @return GNUNET_SYSERR upon error OR the number of rows retrieved 306 * @return GNUNET_SYSERR upon error OR the number of rows retrieved
310 */ 307 */
311static int 308static int
312db_read_whitelist (struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows) 309db_read_whitelist(struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows)
313{ 310{
314 static const char *query_wl = "SELECT oid, latency FROM whitelist WHERE (id == ?);"; 311 static const char *query_wl = "SELECT oid, latency FROM whitelist WHERE (id == ?);";
315 struct sqlite3_stmt *stmt_wl; 312 struct sqlite3_stmt *stmt_wl;
@@ -317,31 +314,32 @@ db_read_whitelist (struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows)
317 int nrows; 314 int nrows;
318 int ret; 315 int ret;
319 316
320 if (SQLITE_OK != (ret = sqlite3_prepare_v2 (db, query_wl, -1, &stmt_wl, NULL))) 317 if (SQLITE_OK != (ret = sqlite3_prepare_v2(db, query_wl, -1, &stmt_wl, NULL)))
321 { 318 {
322 LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2"); 319 LOG_SQLITE(db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_prepare_v2");
323 return GNUNET_SYSERR; 320 return GNUNET_SYSERR;
324 } 321 }
325 if (SQLITE_OK != (ret = sqlite3_bind_int (stmt_wl, 1, pid))) 322 if (SQLITE_OK != (ret = sqlite3_bind_int(stmt_wl, 1, pid)))
326 { 323 {
327 LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int"); 324 LOG_SQLITE(db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite3_bind_int");
328 sqlite3_finalize (stmt_wl); 325 sqlite3_finalize(stmt_wl);
329 return GNUNET_SYSERR; 326 return GNUNET_SYSERR;
330 } 327 }
331 nrows = 0; 328 nrows = 0;
332 do 329 do
333 { 330 {
334 ret = sqlite3_step (stmt_wl); 331 ret = sqlite3_step(stmt_wl);
335 if (SQLITE_ROW != ret) 332 if (SQLITE_ROW != ret)
336 break; 333 break;
337 nrows++; 334 nrows++;
338 lr = GNUNET_new (struct WhiteListRow); 335 lr = GNUNET_new(struct WhiteListRow);
339 lr->id = sqlite3_column_int (stmt_wl, 0); 336 lr->id = sqlite3_column_int(stmt_wl, 0);
340 lr->latency = sqlite3_column_int (stmt_wl, 1); 337 lr->latency = sqlite3_column_int(stmt_wl, 1);
341 lr->next = *wl_rows; 338 lr->next = *wl_rows;
342 *wl_rows = lr; 339 *wl_rows = lr;
343 } while (1); 340 }
344 sqlite3_finalize (stmt_wl); 341 while (1);
342 sqlite3_finalize(stmt_wl);
345 return nrows; 343 return nrows;
346} 344}
347 345
@@ -355,8 +353,8 @@ db_read_whitelist (struct sqlite3 *db, int pid, struct WhiteListRow **wl_rows)
355 * @param c configuration 353 * @param c configuration
356 */ 354 */
357static void 355static void
358run (void *cls, char *const *args, const char *cfgfile, 356run(void *cls, char *const *args, const char *cfgfile,
359 const struct GNUNET_CONFIGURATION_Handle *c) 357 const struct GNUNET_CONFIGURATION_Handle *c)
360{ 358{
361 char *dbfile; 359 char *dbfile;
362 struct WhiteListRow *wl_head; 360 struct WhiteListRow *wl_head;
@@ -369,78 +367,78 @@ run (void *cls, char *const *args, const char *cfgfile,
369 int ret; 367 int ret;
370 368
371 if (GNUNET_OK != 369 if (GNUNET_OK !=
372 GNUNET_CONFIGURATION_get_value_number (c, "TESTBED", 370 GNUNET_CONFIGURATION_get_value_number(c, "TESTBED",
373 "PEERID", &pid)) 371 "PEERID", &pid))
374 {
375 GNUNET_break (0);
376 return;
377 }
378 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, "TESTBED-UNDERLAY",
379 "DBFILE",
380 &dbfile))
381 {
382 GNUNET_break (0);
383 return;
384 }
385 if (SQLITE_OK != (ret = sqlite3_open_v2 (dbfile, &db, SQLITE_OPEN_READONLY, NULL)))
386 {
387 if (NULL != db)
388 { 372 {
389 LOG_SQLITE (db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite_open_v2"); 373 GNUNET_break(0);
390 GNUNET_break (SQLITE_OK == sqlite3_close (db)); 374 return;
391 } 375 }
392 else 376 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename(c, "TESTBED-UNDERLAY",
393 LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot open sqlite file %s\n", dbfile); 377 "DBFILE",
394 GNUNET_free (dbfile); 378 &dbfile))
395 return; 379 {
396 } 380 GNUNET_break(0);
397 DEBUG ("Opened database %s\n", dbfile); 381 return;
398 GNUNET_free (dbfile); 382 }
383 if (SQLITE_OK != (ret = sqlite3_open_v2(dbfile, &db, SQLITE_OPEN_READONLY, NULL)))
384 {
385 if (NULL != db)
386 {
387 LOG_SQLITE(db, NULL, GNUNET_ERROR_TYPE_ERROR, "sqlite_open_v2");
388 GNUNET_break(SQLITE_OK == sqlite3_close(db));
389 }
390 else
391 LOG(GNUNET_ERROR_TYPE_ERROR, "Cannot open sqlite file %s\n", dbfile);
392 GNUNET_free(dbfile);
393 return;
394 }
395 DEBUG("Opened database %s\n", dbfile);
396 GNUNET_free(dbfile);
399 dbfile = NULL; 397 dbfile = NULL;
400 wl_head = NULL; 398 wl_head = NULL;
401 if (GNUNET_OK != load_keys (c)) 399 if (GNUNET_OK != load_keys(c))
402 goto close_db; 400 goto close_db;
403 401
404 transport = GNUNET_TRANSPORT_manipulation_connect (c); 402 transport = GNUNET_TRANSPORT_manipulation_connect(c);
405 if (NULL == transport) 403 if (NULL == transport)
406 { 404 {
407 GNUNET_break (0); 405 GNUNET_break(0);
408 return; 406 return;
409 } 407 }
410 /* read and process whitelist */ 408 /* read and process whitelist */
411 nrows = 0; 409 nrows = 0;
412 wl_head = NULL; 410 wl_head = NULL;
413 nrows = db_read_whitelist (db, pid, &wl_head); 411 nrows = db_read_whitelist(db, pid, &wl_head);
414 if ((GNUNET_SYSERR == nrows) || (0 == nrows)) 412 if ((GNUNET_SYSERR == nrows) || (0 == nrows))
415 { 413 {
416 GNUNET_TRANSPORT_manipulation_disconnect (transport); 414 GNUNET_TRANSPORT_manipulation_disconnect(transport);
417 goto close_db; 415 goto close_db;
418 } 416 }
419 map = GNUNET_CONTAINER_multipeermap_create (nrows, GNUNET_NO); 417 map = GNUNET_CONTAINER_multipeermap_create(nrows, GNUNET_NO);
420 while (NULL != (wl_entry = wl_head)) 418 while (NULL != (wl_entry = wl_head))
421 { 419 {
422 wl_head = wl_entry->next; 420 wl_head = wl_entry->next;
423 delay.rel_value_us = wl_entry->latency; 421 delay.rel_value_us = wl_entry->latency;
424 memset (&prop, 0, sizeof (prop)); 422 memset(&prop, 0, sizeof(prop));
425 GNUNET_assert (GNUNET_OK == get_identity (wl_entry->id, &identity)); 423 GNUNET_assert(GNUNET_OK == get_identity(wl_entry->id, &identity));
426 GNUNET_break (GNUNET_OK == 424 GNUNET_break(GNUNET_OK ==
427 GNUNET_CONTAINER_multipeermap_put (map, &identity, &identity, 425 GNUNET_CONTAINER_multipeermap_put(map, &identity, &identity,
428 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 426 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
429 DEBUG ("Setting %u ms latency to peer `%s'\n", 427 DEBUG("Setting %u ms latency to peer `%s'\n",
430 wl_entry->latency, 428 wl_entry->latency,
431 GNUNET_i2s (&identity)); 429 GNUNET_i2s(&identity));
432 GNUNET_TRANSPORT_manipulation_set (transport, 430 GNUNET_TRANSPORT_manipulation_set(transport,
433 &identity, 431 &identity,
434 &prop, 432 &prop,
435 delay, 433 delay,
436 delay); 434 delay);
437 GNUNET_free (wl_entry); 435 GNUNET_free(wl_entry);
438 } 436 }
439 bh = GNUNET_TRANSPORT_blacklist (c, &check_access, NULL); 437 bh = GNUNET_TRANSPORT_blacklist(c, &check_access, NULL);
440 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL); 438 GNUNET_SCHEDULER_add_shutdown(&do_shutdown, NULL);
441 439
442 close_db: 440close_db:
443 GNUNET_break (SQLITE_OK == sqlite3_close (db)); 441 GNUNET_break(SQLITE_OK == sqlite3_close(db));
444} 442}
445 443
446 444
@@ -452,24 +450,24 @@ run (void *cls, char *const *args, const char *cfgfile,
452 * @return 0 ok, 1 on error 450 * @return 0 ok, 1 on error
453 */ 451 */
454int 452int
455main (int argc, char *const *argv) 453main(int argc, char *const *argv)
456{ 454{
457 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 455 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
458 GNUNET_GETOPT_OPTION_END 456 GNUNET_GETOPT_OPTION_END
459 }; 457 };
460 int ret; 458 int ret;
461 459
462 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 460 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
463 return 2; 461 return 2;
464#ifdef SQLITE_CONFIG_MMAP_SIZE 462#ifdef SQLITE_CONFIG_MMAP_SIZE
465 (void) sqlite3_config (SQLITE_CONFIG_MMAP_SIZE, 512000, 256000000); 463 (void)sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, 512000, 256000000);
466#endif 464#endif
467 ret = 465 ret =
468 (GNUNET_OK == 466 (GNUNET_OK ==
469 GNUNET_PROGRAM_run (argc, argv, "testbed-underlay", 467 GNUNET_PROGRAM_run(argc, argv, "testbed-underlay",
470 _ 468 _
471 ("Daemon to restrict underlay network in testbed deployments"), 469 ("Daemon to restrict underlay network in testbed deployments"),
472 options, &run, NULL)) ? 0 : 1; 470 options, &run, NULL)) ? 0 : 1;
473 GNUNET_free ((void*) argv); 471 GNUNET_free((void*)argv);
474 return ret; 472 return ret;
475} 473}