diff options
Diffstat (limited to 'src/transport/plugin_transport_bluetooth.c')
-rw-r--r-- | src/transport/plugin_transport_bluetooth.c | 105 |
1 files changed, 56 insertions, 49 deletions
diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c index a7d3cf3f5..f301d55b3 100644 --- a/src/transport/plugin_transport_bluetooth.c +++ b/src/transport/plugin_transport_bluetooth.c | |||
@@ -355,7 +355,9 @@ struct MacEndpoint | |||
355 | /** | 355 | /** |
356 | * peer mac address | 356 | * peer mac address |
357 | */ | 357 | */ |
358 | struct WlanAddress addr; | 358 | //struct WlanAddress addr; |
359 | |||
360 | struct GNUNET_HELLO_Address *address; | ||
359 | 361 | ||
360 | /** | 362 | /** |
361 | * Message delay for fragmentation context | 363 | * Message delay for fragmentation context |
@@ -605,8 +607,8 @@ send_ack (void *cls, uint32_t msg_id, | |||
605 | get_radiotap_header (endpoint, radio_header, size); | 607 | get_radiotap_header (endpoint, radio_header, size); |
606 | get_wlan_header (endpoint->plugin, | 608 | get_wlan_header (endpoint->plugin, |
607 | &radio_header->frame, | 609 | &radio_header->frame, |
608 | &endpoint->addr.mac, | 610 | endpoint->address->address, |
609 | size); | 611 | endpoint->address->address_length); |
610 | memcpy (&radio_header[1], hdr, msize); | 612 | memcpy (&radio_header[1], hdr, msize); |
611 | if (NULL != | 613 | if (NULL != |
612 | GNUNET_HELPER_send (endpoint->plugin->suid_helper, | 614 | GNUNET_HELPER_send (endpoint->plugin->suid_helper, |
@@ -742,7 +744,7 @@ create_session (struct MacEndpoint *endpoint, | |||
742 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 744 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
743 | "Created new session for peer `%s' with endpoint %s\n", | 745 | "Created new session for peer `%s' with endpoint %s\n", |
744 | GNUNET_i2s (peer), | 746 | GNUNET_i2s (peer), |
745 | mac_to_string (&endpoint->addr.mac)); | 747 | mac_to_string (endpoint->address->address)); |
746 | return session; | 748 | return session; |
747 | } | 749 | } |
748 | 750 | ||
@@ -793,8 +795,8 @@ transmit_fragment (void *cls, | |||
793 | get_radiotap_header (endpoint, radio_header, size); | 795 | get_radiotap_header (endpoint, radio_header, size); |
794 | get_wlan_header (endpoint->plugin, | 796 | get_wlan_header (endpoint->plugin, |
795 | &radio_header->frame, | 797 | &radio_header->frame, |
796 | &endpoint->addr.mac, | 798 | endpoint->address->address, |
797 | size); | 799 | endpoint->address->address_length); |
798 | memcpy (&radio_header[1], hdr, msize); | 800 | memcpy (&radio_header[1], hdr, msize); |
799 | GNUNET_assert (NULL == fm->sh); | 801 | GNUNET_assert (NULL == fm->sh); |
800 | fm->sh = GNUNET_HELPER_send (endpoint->plugin->suid_helper, | 802 | fm->sh = GNUNET_HELPER_send (endpoint->plugin->suid_helper, |
@@ -999,10 +1001,11 @@ create_macendpoint (struct Plugin *plugin, | |||
999 | struct MacEndpoint *pos; | 1001 | struct MacEndpoint *pos; |
1000 | 1002 | ||
1001 | for (pos = plugin->mac_head; NULL != pos; pos = pos->next) | 1003 | for (pos = plugin->mac_head; NULL != pos; pos = pos->next) |
1002 | if (0 == memcmp (addr, &pos->addr, sizeof (struct WlanAddress))) | 1004 | if (0 == memcmp (addr, &pos->address->address, sizeof (struct WlanAddress))) |
1003 | return pos; | 1005 | return pos; |
1004 | pos = GNUNET_new (struct MacEndpoint); | 1006 | pos = GNUNET_new (struct MacEndpoint); |
1005 | pos->addr = *addr; | 1007 | pos->address = GNUNET_HELLO_address_allocate (NULL, PLUGIN_NAME, addr, |
1008 | sizeof (struct WlanAddress), GNUNET_HELLO_ADDRESS_INFO_NONE); | ||
1006 | pos->plugin = plugin; | 1009 | pos->plugin = plugin; |
1007 | pos->defrag = | 1010 | pos->defrag = |
1008 | GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, | 1011 | GNUNET_DEFRAGMENT_context_create (plugin->env->stats, WLAN_MTU, |
@@ -1244,23 +1247,20 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1244 | "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", | 1247 | "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", |
1245 | (unsigned int) msize, | 1248 | (unsigned int) msize, |
1246 | GNUNET_i2s (&tmpsource), | 1249 | GNUNET_i2s (&tmpsource), |
1247 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); | 1250 | bluetooth_plugin_address_to_string (NULL, mas->endpoint->address, |
1251 | mas->endpoint->address->address_length)); | ||
1248 | 1252 | ||
1249 | GNUNET_STATISTICS_update (plugin->env->stats, | 1253 | GNUNET_STATISTICS_update (plugin->env->stats, |
1250 | _("# HELLO messages received via Bluetooth"), 1, | 1254 | _("# HELLO messages received via Bluetooth"), 1, |
1251 | GNUNET_NO); | 1255 | GNUNET_NO); |
1252 | plugin->env->receive (plugin->env->cls, | 1256 | plugin->env->receive (plugin->env->cls, |
1253 | &tmpsource, | 1257 | mas->endpoint->address, |
1254 | hdr, | 1258 | mas->session, |
1255 | mas->session, | 1259 | hdr); |
1256 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, | ||
1257 | (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); | ||
1258 | plugin->env->update_address_metrics (plugin->env->cls, | 1260 | plugin->env->update_address_metrics (plugin->env->cls, |
1259 | &tmpsource, | 1261 | mas->endpoint->address, |
1260 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, | 1262 | mas->session, |
1261 | (mas->endpoint == NULL) ? 0 : sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress), | 1263 | &ats, 1); |
1262 | mas->session, | ||
1263 | &ats, 1); | ||
1264 | break; | 1264 | break; |
1265 | case GNUNET_MESSAGE_TYPE_FRAGMENT: | 1265 | case GNUNET_MESSAGE_TYPE_FRAGMENT: |
1266 | if (NULL == mas->endpoint) | 1266 | if (NULL == mas->endpoint) |
@@ -1271,7 +1271,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1271 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1271 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1272 | "Processing %u bytes of FRAGMENT from MAC %s\n", | 1272 | "Processing %u bytes of FRAGMENT from MAC %s\n", |
1273 | (unsigned int) msize, | 1273 | (unsigned int) msize, |
1274 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); | 1274 | bluetooth_plugin_address_to_string (NULL, mas->endpoint->address->address, |
1275 | mas->endpoint->address->address_length)); | ||
1275 | GNUNET_STATISTICS_update (plugin->env->stats, | 1276 | GNUNET_STATISTICS_update (plugin->env->stats, |
1276 | _("# fragments received via Bluetooth"), 1, GNUNET_NO); | 1277 | _("# fragments received via Bluetooth"), 1, GNUNET_NO); |
1277 | (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, | 1278 | (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, |
@@ -1292,7 +1293,8 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1292 | { | 1293 | { |
1293 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1294 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1294 | "Got last ACK, finished message transmission to `%s' (%p)\n", | 1295 | "Got last ACK, finished message transmission to `%s' (%p)\n", |
1295 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress)), | 1296 | bluetooth_plugin_address_to_string (NULL, mas->endpoint->address->address, |
1297 | mas->endpoint->address->address_length), | ||
1296 | fm); | 1298 | fm); |
1297 | mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); | 1299 | mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); |
1298 | if (NULL != fm->cont) | 1300 | if (NULL != fm->cont) |
@@ -1307,13 +1309,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1307 | { | 1309 | { |
1308 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1310 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1309 | "Got an ACK, message transmission to `%s' not yet finished\n", | 1311 | "Got an ACK, message transmission to `%s' not yet finished\n", |
1310 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); | 1312 | bluetooth_plugin_address_to_string (NULL, mas->endpoint->address->address, |
1313 | mas->endpoint->address->address_length)); | ||
1311 | break; | 1314 | break; |
1312 | } | 1315 | } |
1313 | } | 1316 | } |
1314 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1317 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1315 | "ACK not matched against any active fragmentation with MAC `%s'\n", | 1318 | "ACK not matched against any active fragmentation with MAC `%s'\n", |
1316 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, sizeof (struct WlanAddress))); | 1319 | bluetooth_plugin_address_to_string (NULL, mas->endpoint->address->address, |
1320 | mas->endpoint->address->address_length)); | ||
1317 | break; | 1321 | break; |
1318 | case GNUNET_MESSAGE_TYPE_WLAN_DATA: | 1322 | case GNUNET_MESSAGE_TYPE_WLAN_DATA: |
1319 | if (NULL == mas->endpoint) | 1323 | if (NULL == mas->endpoint) |
@@ -1373,17 +1377,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1373 | (unsigned int) ntohs (hdr->type), | 1377 | (unsigned int) ntohs (hdr->type), |
1374 | GNUNET_i2s (&mas->session->target)); | 1378 | GNUNET_i2s (&mas->session->target)); |
1375 | plugin->env->receive (plugin->env->cls, | 1379 | plugin->env->receive (plugin->env->cls, |
1376 | &mas->session->target, | 1380 | mas->endpoint->address, |
1377 | hdr, | ||
1378 | mas->session, | 1381 | mas->session, |
1379 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, | 1382 | hdr); |
1380 | (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress)); | ||
1381 | plugin->env->update_address_metrics (plugin->env->cls, | 1383 | plugin->env->update_address_metrics (plugin->env->cls, |
1382 | &mas->session->target, | 1384 | mas->endpoint->address, |
1383 | (mas->endpoint == NULL) ? NULL : (const char *) &mas->endpoint->addr, | 1385 | mas->session, |
1384 | (mas->endpoint == NULL) ? 0 : sizeof (struct WlanAddress), | 1386 | &ats, 1); |
1385 | mas->session, | ||
1386 | &ats, 1); | ||
1387 | break; | 1387 | break; |
1388 | } | 1388 | } |
1389 | return GNUNET_OK; | 1389 | return GNUNET_OK; |
@@ -1402,6 +1402,7 @@ handle_helper_message (void *cls, void *client, | |||
1402 | const struct GNUNET_MessageHeader *hdr) | 1402 | const struct GNUNET_MessageHeader *hdr) |
1403 | { | 1403 | { |
1404 | struct Plugin *plugin = cls; | 1404 | struct Plugin *plugin = cls; |
1405 | struct GNUNET_HELLO_Address *address; | ||
1405 | const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo; | 1406 | const struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *rxinfo; |
1406 | const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *cm; | 1407 | const struct GNUNET_TRANSPORT_WLAN_HelperControlMessage *cm; |
1407 | struct WlanAddress wa; | 1408 | struct WlanAddress wa; |
@@ -1428,24 +1429,26 @@ handle_helper_message (void *cls, void *client, | |||
1428 | memset (&wa, 0, sizeof (struct WlanAddress)); | 1429 | memset (&wa, 0, sizeof (struct WlanAddress)); |
1429 | wa.mac = plugin->mac_address; | 1430 | wa.mac = plugin->mac_address; |
1430 | wa.options = htonl(plugin->options); | 1431 | wa.options = htonl(plugin->options); |
1431 | plugin->env->notify_address (plugin->env->cls, GNUNET_NO, | 1432 | address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, |
1432 | &wa, | 1433 | PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE); |
1433 | sizeof (wa), | 1434 | plugin->env->notify_address (plugin->env->cls, GNUNET_NO, address); |
1434 | "bluetooth"); | 1435 | GNUNET_HELLO_address_free (address); |
1435 | } | 1436 | } |
1436 | plugin->mac_address = cm->mac; | 1437 | plugin->mac_address = cm->mac; |
1437 | plugin->have_mac = GNUNET_YES; | 1438 | plugin->have_mac = GNUNET_YES; |
1438 | memset (&wa, 0, sizeof (struct WlanAddress)); | 1439 | memset (&wa, 0, sizeof (struct WlanAddress)); |
1439 | wa.mac = plugin->mac_address; | 1440 | wa.mac = plugin->mac_address; |
1440 | wa.options = htonl(plugin->options); | 1441 | wa.options = htonl(plugin->options); |
1442 | address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, | ||
1443 | PLUGIN_NAME, &wa, sizeof (wa), GNUNET_HELLO_ADDRESS_INFO_NONE); | ||
1444 | |||
1441 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1445 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1442 | "Received BT_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n", | 1446 | "Received BT_HELPER_CONTROL message with MAC address `%s' for peer `%s'\n", |
1443 | mac_to_string (&cm->mac), | 1447 | mac_to_string (&cm->mac), |
1444 | GNUNET_i2s (plugin->env->my_identity)); | 1448 | GNUNET_i2s (plugin->env->my_identity)); |
1445 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, | 1449 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, address); |
1446 | &wa, | 1450 | GNUNET_HELLO_address_free (address); |
1447 | sizeof (struct WlanAddress), | 1451 | |
1448 | "bluetooth"); | ||
1449 | break; | 1452 | break; |
1450 | case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: | 1453 | case GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER: |
1451 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1454 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1682,7 +1685,8 @@ bluetooth_plugin_address_pretty_printer (void *cls, const char *type, | |||
1682 | void * | 1685 | void * |
1683 | libgnunet_plugin_transport_bluetooth_done (void *cls) | 1686 | libgnunet_plugin_transport_bluetooth_done (void *cls) |
1684 | { | 1687 | { |
1685 | struct WlanAddress wa; | 1688 | struct WlanAddress wa; |
1689 | struct GNUNET_HELLO_Address *address; | ||
1686 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; | 1690 | struct GNUNET_TRANSPORT_PluginFunctions *api = cls; |
1687 | struct Plugin *plugin = api->cls; | 1691 | struct Plugin *plugin = api->cls; |
1688 | struct MacEndpoint *endpoint; | 1692 | struct MacEndpoint *endpoint; |
@@ -1696,14 +1700,17 @@ libgnunet_plugin_transport_bluetooth_done (void *cls) | |||
1696 | 1700 | ||
1697 | if (GNUNET_YES == plugin->have_mac) | 1701 | if (GNUNET_YES == plugin->have_mac) |
1698 | { | 1702 | { |
1699 | memset (&wa, 0, sizeof (wa)); | 1703 | memset (&wa, 0, sizeof(wa)); |
1700 | wa.options = htonl (plugin->options); | 1704 | wa.options = htonl (plugin->options); |
1701 | wa.mac = plugin->mac_address; | 1705 | wa.mac = plugin->mac_address; |
1702 | plugin->env->notify_address (plugin->env->cls, GNUNET_NO, | 1706 | address = GNUNET_HELLO_address_allocate (plugin->env->my_identity, |
1703 | &wa, | 1707 | PLUGIN_NAME, &wa, sizeof (struct WlanAddress), |
1704 | sizeof (struct WlanAddress), | 1708 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
1705 | "bluetooth"); | 1709 | |
1706 | plugin->have_mac = GNUNET_NO; | 1710 | plugin->env->notify_address (plugin->env->cls, GNUNET_NO, address); |
1711 | plugin->have_mac = GNUNET_NO; | ||
1712 | |||
1713 | GNUNET_HELLO_address_free (address); | ||
1707 | } | 1714 | } |
1708 | 1715 | ||
1709 | if (GNUNET_SCHEDULER_NO_TASK != plugin->beacon_task) | 1716 | if (GNUNET_SCHEDULER_NO_TASK != plugin->beacon_task) |