fix peer ids
[oweals/gnunet.git] / src / transport / plugin_transport_bluetooth.c
index 3f432b90ef9175cdcb007066b9d94a4cd0ac022a..74fcd36a7c8d11dab0c8573708c27a039693629a 100644 (file)
 /**
  * time out of a mac endpoint
  */
-#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2)
+#define MACENDPOINT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 60)
 
 /**
  * We reduce the frequence of HELLO beacons in relation to
  * the number of MAC addresses currently visible to us.
  * This is the multiplication factor.
  */
-#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2)
+#define HELLO_BEACON_SCALING_FACTOR GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 
 /**
  * Maximum number of messages in defragmentation queue per MAC
@@ -694,7 +694,7 @@ session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   session->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   timeout = GNUNET_TIME_absolute_get_remaining (session->timeout);
-  if (0 == timeout.rel_value) 
+  if (0 == timeout.rel_value_us
   {
     free_session (session);
     return;
@@ -970,7 +970,7 @@ macendpoint_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   endpoint->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   timeout = GNUNET_TIME_absolute_get_remaining (endpoint->timeout);
-  if (0 == timeout.rel_value) 
+  if (0 == timeout.rel_value_us
   {
     free_macendpoint (endpoint);
     return;
@@ -1211,7 +1211,7 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
         bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)));
 
     GNUNET_STATISTICS_update (plugin->env->stats,
-                             _("# HELLO messages received via WLAN"), 1,
+                             _("# HELLO messages received via Bluetooth"), 1,
                              GNUNET_NO);
     plugin->env->receive (plugin->env->cls, 
                          &tmpsource,
@@ -1304,14 +1304,14 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
        GNUNET_CRYPTO_crc32_n (&wlanheader[1], msize - sizeof (struct WlanHeader)))
     {
       GNUNET_STATISTICS_update (plugin->env->stats,
-                               _("# BluetoothDATA messages discarded due to CRC32 error"), 1,
+                               _("# Bluetooth DATA messages discarded due to CRC32 error"), 1,
                                GNUNET_NO);
       break;
     }
     xmas.endpoint = mas->endpoint;
     xmas.session = create_session (mas->endpoint, &wlanheader->sender);
     LOG (GNUNET_ERROR_TYPE_DEBUG, 
-        "Processing %u bytes of WLAN DATA from peer `%s'\n",
+        "Processing %u bytes of BLUETOOTH DATA from peer `%s'\n",
         (unsigned int) msize,
         GNUNET_i2s (&wlanheader->sender));
     (void) GNUNET_SERVER_mst_receive (plugin->wlan_header_payload_tokenizer, 
@@ -1395,7 +1395,7 @@ handle_helper_message (void *cls, void *client,
       plugin->env->notify_address (plugin->env->cls, GNUNET_NO,
                                   &wa,
                                   sizeof (wa),
-                                  "wlan");
+                                  "bluetooth");
     }
     plugin->mac_address = cm->mac;
     plugin->have_mac = GNUNET_YES;
@@ -1403,13 +1403,13 @@ handle_helper_message (void *cls, void *client,
     wa.mac = plugin->mac_address;
     wa.options = htonl(plugin->options);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-        "Received WLAN_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
+        "Received BT_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n",
         mac_to_string (&cm->mac),
         GNUNET_i2s (plugin->env->my_identity));
     plugin->env->notify_address (plugin->env->cls, GNUNET_YES,
                                  &wa,
                                  sizeof (struct WlanAddress),
-                                 "wlan");
+                                 "bluetooth");
     break;
   case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER:
     LOG (GNUNET_ERROR_TYPE_DEBUG, 
@@ -1666,7 +1666,7 @@ libgnunet_plugin_transport_bluetooth_done (void *cls)
       plugin->env->notify_address (plugin->env->cls, GNUNET_NO,
                                &wa,
                                sizeof (struct WlanAddress),
-                               "wlan");
+                               "bluetooth");
       plugin->have_mac = GNUNET_NO;
   }
 
@@ -1727,7 +1727,7 @@ bluetooth_string_to_address (void *cls, const char *addr, uint16_t addrlen,
   struct WlanAddress *wa;
   unsigned int a[6];
   unsigned int i;
-  char plugin[5];
+  char plugin[10];
   uint32_t options;
 
   if ((NULL == addr) || (addrlen == 0))
@@ -1747,7 +1747,7 @@ bluetooth_string_to_address (void *cls, const char *addr, uint16_t addrlen,
   }
 
   if (8 != SSCANF (addr,
-                  "%4s.%u.%X:%X:%X:%X:%X:%X",
+                  "%9s.%u.%X:%X:%X:%X:%X:%X",
                   plugin, &options,
                   &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
   {
@@ -1803,7 +1803,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
         (testmode > 2) ) )
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
-                              "transport-wlan", "TESTMODE");
+                              "transport-bluetooth", "TESTMODE");
     return NULL;
   }
   binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-transport-bluetooth");
@@ -1811,7 +1811,7 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
        (GNUNET_YES != GNUNET_OS_check_helper_binary (binary, GNUNET_YES, NULL)) )
   {
     LOG (GNUNET_ERROR_TYPE_ERROR,
-        _("Helper binary `%s' not SUID, cannot run WLAN transport\n"),
+        _("Helper binary `%s' not SUID, cannot run bluetooth transport\n"),
         "gnunet-helper-transport-bluetooth");
     GNUNET_free (binary);
     return NULL;
@@ -1859,6 +1859,28 @@ libgnunet_plugin_transport_bluetooth_init (void *cls)
                                               NULL,
                                               plugin);
     break;
+  case 1: /* testmode, peer 1 */
+    plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
+    plugin->helper_argv[1] = (char *) "1";
+    plugin->helper_argv[2] = NULL;
+    plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
+                 "gnunet-helper-transport-wlan-dummy",
+                 plugin->helper_argv,
+                 &handle_helper_message,
+                 NULL,
+                 plugin);
+    break;
+  case 2: /* testmode, peer 2 */
+    plugin->helper_argv[0] = (char *) "gnunet-helper-transport-wlan-dummy";
+    plugin->helper_argv[1] = (char *) "2";
+    plugin->helper_argv[2] = NULL;
+    plugin->suid_helper = GNUNET_HELPER_start (GNUNET_NO,
+                 "gnunet-helper-transport-wlan-dummy",
+                 plugin->helper_argv,
+                 &handle_helper_message,
+                 NULL,
+                 plugin);
+    break;
   default:
     GNUNET_assert (0);
   }