aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-11-03 10:03:20 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-11-03 10:03:20 +0000
commit353b34332b0909aaf5119f55f706f7a80d1f7c0e (patch)
tree8d933923cd0adab74f1a2fa11259f0a6a85d8a8f /src/transport/plugin_transport_wlan.c
parentc5b614c1f7e8cc175417336ef968f2b8897f49ad (diff)
downloadgnunet-353b34332b0909aaf5119f55f706f7a80d1f7c0e.tar.gz
gnunet-353b34332b0909aaf5119f55f706f7a80d1f7c0e.zip
improved and centralized helper path detection
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c84
1 files changed, 51 insertions, 33 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index e536afd67..9976ae65b 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -737,6 +737,7 @@ hexdump (const void *mem, unsigned length)
737 t += sprintf (t, "%02X", src[j] & 0xff); 737 t += sprintf (t, "%02X", src[j] & 0xff);
738 else 738 else
739 t += sprintf (t, " "); 739 t += sprintf (t, " ");
740
740 t += sprintf (t, j % 2 ? " " : "-"); 741 t += sprintf (t, j % 2 ? " " : "-");
741 } 742 }
742 743
@@ -1481,7 +1482,8 @@ static int
1481wlan_transport_start_wlan_helper (struct Plugin *plugin) 1482wlan_transport_start_wlan_helper (struct Plugin *plugin)
1482{ 1483{
1483 const char *filenamehw = "gnunet-transport-wlan-helper"; 1484 const char *filenamehw = "gnunet-transport-wlan-helper";
1484 const char *filenameloopback = "gnunet-transport-wlan-helper-dummy"; 1485 char *filenameloopback = "gnunet-transport-wlan-helper-dummy";
1486 char *absolute_filename = NULL;
1485 1487
1486 plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES); 1488 plugin->server_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
1487 if (plugin->server_stdout == NULL) 1489 if (plugin->server_stdout == NULL)
@@ -1491,6 +1493,28 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1491 if (plugin->server_stdin == NULL) 1493 if (plugin->server_stdin == NULL)
1492 return GNUNET_SYSERR; 1494 return GNUNET_SYSERR;
1493 1495
1496 if ((plugin->testmode == 1) || (plugin->testmode == 2))
1497 {
1498 if (GNUNET_OS_check_helper_binary (filenameloopback) == GNUNET_YES)
1499 {
1500 absolute_filename = strdup (filenameloopback);
1501 }
1502 else
1503 {
1504 char cwd[FILENAME_MAX];
1505 GNUNET_assert (getcwd(cwd, sizeof(cwd)) != NULL);
1506
1507 GNUNET_asprintf (&absolute_filename, "%s%s%s", cwd, DIR_SEPARATOR_STR, filenameloopback);
1508
1509 if (GNUNET_DISK_file_test (filenameloopback) != GNUNET_YES)
1510 {
1511 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1512 "Helper `%s' not found! %i\n", absolute_filename);
1513 GNUNET_break(0);
1514 }
1515 }
1516 }
1517
1494 /* Start the server process */ 1518 /* Start the server process */
1495 1519
1496 if (plugin->testmode == 0) 1520 if (plugin->testmode == 0)
@@ -1527,50 +1551,42 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1527 { 1551 {
1528 1552
1529#if DEBUG_wlan 1553#if DEBUG_wlan
1530 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1531 "Starting gnunet-wlan-helper loopback 1 process cmd: %s %s %i\n",
1532 filenameloopback, plugin->interface, plugin->testmode);
1533#endif 1554#endif
1555 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1556 "Starting gnunet-wlan-helper loopback 1 process cmd: %s %s %i\n",
1557 absolute_filename, plugin->interface, plugin->testmode);
1534 1558
1535 if (GNUNET_OS_check_helper_binary (filenameloopback) == GNUNET_SYSERR) 1559 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
1536 filenameloopback = "./gnunet-transport-wlan-helper-dummy"; 1560 absolute_filename, absolute_filename, "1",
1537 if (GNUNET_OS_check_helper_binary (filenameloopback) != GNUNET_SYSERR) 1561 NULL);
1538 { 1562 if (plugin->server_proc == NULL)
1539 plugin->server_proc =
1540 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
1541 filenameloopback, filenameloopback, "1",
1542 NULL);
1543 }
1544 else
1545 { 1563 {
1546 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1564 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1547 "gnunet-transport-wlan-helper-dummy not found, please look if it exists and is the $PATH variable!\n"); 1565 "`%s' not found, please look if it exists and is in the $PATH variable!\n", absolute_filename);
1548 GNUNET_break (0); 1566 GNUNET_break (0);
1549 } 1567 }
1550 } 1568 }
1551 else if (plugin->testmode == 2) 1569 else if (plugin->testmode == 2)
1552 { 1570 {
1553#if DEBUG_wlan 1571#if DEBUG_wlan
1554 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, PLUGIN_LOG_NAME,
1555 "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n",
1556 filenameloopback, plugin->interface, plugin->testmode);
1557#endif 1572#endif
1558 if (GNUNET_OS_check_helper_binary (filenameloopback) == GNUNET_SYSERR) 1573 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1559 filenameloopback = "./gnunet-transport-wlan-helper-dummy"; 1574 "Starting gnunet-wlan-helper loopback 2 process cmd: %s %s %i\n",
1560 if (GNUNET_OS_check_helper_binary (filenameloopback) != GNUNET_SYSERR) 1575 absolute_filename, plugin->interface, plugin->testmode);
1561 { 1576
1562 plugin->server_proc = 1577
1563 GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout, 1578 plugin->server_proc = GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
1564 filenameloopback, filenameloopback, "2", 1579 absolute_filename, absolute_filename, "2",
1565 NULL); 1580 NULL);
1566 } 1581 if (plugin->server_proc == NULL)
1567 else 1582 {
1568 { 1583 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME,
1569 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PLUGIN_LOG_NAME, 1584 "`%s' not found, please look if it exists and is in the $PATH variable!\n", absolute_filename);
1570 "gnunet-transport-wlan-helper-dummy not found, please look if it exists and is in the $PATH variable!\n");
1571 GNUNET_break (0); 1585 GNUNET_break (0);
1572 } 1586 }
1573 } 1587 }
1588 if (absolute_filename != NULL)
1589 GNUNET_free(absolute_filename);
1574 if (plugin->server_proc == NULL) 1590 if (plugin->server_proc == NULL)
1575 { 1591 {
1576#if DEBUG_wlan 1592#if DEBUG_wlan
@@ -1580,6 +1596,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1580 return GNUNET_SYSERR; 1596 return GNUNET_SYSERR;
1581 } 1597 }
1582 1598
1599
1600
1583 /* Close the write end of the read pipe */ 1601 /* Close the write end of the read pipe */
1584 GNUNET_DISK_pipe_close_end (plugin->server_stdout, 1602 GNUNET_DISK_pipe_close_end (plugin->server_stdout,
1585 GNUNET_DISK_PIPE_END_WRITE); 1603 GNUNET_DISK_PIPE_END_WRITE);