diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-06-09 22:04:11 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-06-09 22:04:11 +0000 |
commit | 1dd22b0d681848af9980e5202e38b1a307cf2094 (patch) | |
tree | e013a7f735f2e967222890d87136bd5b76c1f803 /src/transport/plugin_transport_bluetooth.c | |
parent | c9f75566447fd3a9c5c304dbc8e31fd68b6aa3ed (diff) | |
download | gnunet-1dd22b0d681848af9980e5202e38b1a307cf2094.tar.gz gnunet-1dd22b0d681848af9980e5202e38b1a307cf2094.zip |
clarify prettyprinter API and protocols, make sure implementations are consistent in their implemenation, doxygen fixes, indentation fixes, subtle semantic fixes
Diffstat (limited to 'src/transport/plugin_transport_bluetooth.c')
-rw-r--r-- | src/transport/plugin_transport_bluetooth.c | 77 |
1 files changed, 46 insertions, 31 deletions
diff --git a/src/transport/plugin_transport_bluetooth.c b/src/transport/plugin_transport_bluetooth.c index aad96cf69..8ab64b15c 100644 --- a/src/transport/plugin_transport_bluetooth.c +++ b/src/transport/plugin_transport_bluetooth.c | |||
@@ -504,7 +504,9 @@ struct MacAndSession | |||
504 | * @return string representing the same address | 504 | * @return string representing the same address |
505 | */ | 505 | */ |
506 | static const char * | 506 | static const char * |
507 | bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen); | 507 | bluetooth_plugin_address_to_string (void *cls, |
508 | const void *addr, | ||
509 | size_t addrlen); | ||
508 | 510 | ||
509 | /** | 511 | /** |
510 | * Print MAC addresses nicely. | 512 | * Print MAC addresses nicely. |
@@ -1055,7 +1057,9 @@ create_macendpoint (struct Plugin *plugin, | |||
1055 | 1, GNUNET_NO); | 1057 | 1, GNUNET_NO); |
1056 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1058 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1057 | "New MAC endpoint `%s'\n", | 1059 | "New MAC endpoint `%s'\n", |
1058 | bluetooth_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress))); | 1060 | bluetooth_plugin_address_to_string(NULL, |
1061 | addr, | ||
1062 | sizeof (struct WlanAddress))); | ||
1059 | return pos; | 1063 | return pos; |
1060 | } | 1064 | } |
1061 | 1065 | ||
@@ -1119,8 +1123,11 @@ bluetooth_plugin_get_session (void *cls, | |||
1119 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1123 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1120 | "Service asked to create session for peer `%s' with MAC `%s'\n", | 1124 | "Service asked to create session for peer `%s' with MAC `%s'\n", |
1121 | GNUNET_i2s (&address->peer), | 1125 | GNUNET_i2s (&address->peer), |
1122 | bluetooth_plugin_address_to_string(NULL, address->address, address->address_length)); | 1126 | bluetooth_plugin_address_to_string(NULL, |
1123 | endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address); | 1127 | address->address, |
1128 | address->address_length)); | ||
1129 | endpoint = create_macendpoint (plugin, | ||
1130 | (struct WlanAddress *) address->address); | ||
1124 | return get_session (endpoint, &address->peer); | 1131 | return get_session (endpoint, &address->peer); |
1125 | } | 1132 | } |
1126 | 1133 | ||
@@ -1300,8 +1307,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1300 | "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", | 1307 | "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", |
1301 | (unsigned int) msize, | 1308 | (unsigned int) msize, |
1302 | GNUNET_i2s (&tmpsource), | 1309 | GNUNET_i2s (&tmpsource), |
1303 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, | 1310 | bluetooth_plugin_address_to_string (NULL, |
1304 | sizeof (mas->endpoint->addr))); | 1311 | &mas->endpoint->addr, |
1312 | sizeof (mas->endpoint->addr))); | ||
1305 | 1313 | ||
1306 | GNUNET_STATISTICS_update (plugin->env->stats, | 1314 | GNUNET_STATISTICS_update (plugin->env->stats, |
1307 | _("# HELLO messages received via Bluetooth"), 1, | 1315 | _("# HELLO messages received via Bluetooth"), 1, |
@@ -1325,10 +1333,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1325 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1333 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1326 | "Processing %u bytes of FRAGMENT from MAC %s\n", | 1334 | "Processing %u bytes of FRAGMENT from MAC %s\n", |
1327 | (unsigned int) msize, | 1335 | (unsigned int) msize, |
1328 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, | 1336 | bluetooth_plugin_address_to_string (NULL, |
1329 | sizeof (mas->endpoint->addr))); | 1337 | &mas->endpoint->addr, |
1338 | sizeof (mas->endpoint->addr))); | ||
1330 | GNUNET_STATISTICS_update (plugin->env->stats, | 1339 | GNUNET_STATISTICS_update (plugin->env->stats, |
1331 | _("# fragments received via Bluetooth"), 1, GNUNET_NO); | 1340 | _("# fragments received via Bluetooth"), |
1341 | 1, | ||
1342 | GNUNET_NO); | ||
1332 | (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, | 1343 | (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, |
1333 | hdr); | 1344 | hdr); |
1334 | break; | 1345 | break; |
@@ -1347,8 +1358,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1347 | { | 1358 | { |
1348 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1359 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1349 | "Got last ACK, finished message transmission to `%s' (%p)\n", | 1360 | "Got last ACK, finished message transmission to `%s' (%p)\n", |
1350 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, | 1361 | bluetooth_plugin_address_to_string (NULL, |
1351 | sizeof (mas->endpoint->addr)), | 1362 | &mas->endpoint->addr, |
1363 | sizeof (mas->endpoint->addr)), | ||
1352 | fm); | 1364 | fm); |
1353 | mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); | 1365 | mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); |
1354 | if (NULL != fm->cont) | 1366 | if (NULL != fm->cont) |
@@ -1363,15 +1375,17 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1363 | { | 1375 | { |
1364 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1376 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1365 | "Got an ACK, message transmission to `%s' not yet finished\n", | 1377 | "Got an ACK, message transmission to `%s' not yet finished\n", |
1366 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, | 1378 | bluetooth_plugin_address_to_string (NULL, |
1367 | sizeof (mas->endpoint->addr))); | 1379 | &mas->endpoint->addr, |
1380 | sizeof (mas->endpoint->addr))); | ||
1368 | break; | 1381 | break; |
1369 | } | 1382 | } |
1370 | } | 1383 | } |
1371 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1384 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1372 | "ACK not matched against any active fragmentation with MAC `%s'\n", | 1385 | "ACK not matched against any active fragmentation with MAC `%s'\n", |
1373 | bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr, | 1386 | bluetooth_plugin_address_to_string (NULL, |
1374 | sizeof (mas->endpoint->addr))); | 1387 | &mas->endpoint->addr, |
1388 | sizeof (mas->endpoint->addr))); | ||
1375 | break; | 1389 | break; |
1376 | case GNUNET_MESSAGE_TYPE_WLAN_DATA: | 1390 | case GNUNET_MESSAGE_TYPE_WLAN_DATA: |
1377 | if (NULL == mas->endpoint) | 1391 | if (NULL == mas->endpoint) |
@@ -1675,7 +1689,9 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen) | |||
1675 | * @return string representing the same address | 1689 | * @return string representing the same address |
1676 | */ | 1690 | */ |
1677 | static const char * | 1691 | static const char * |
1678 | bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | 1692 | bluetooth_plugin_address_to_string (void *cls, |
1693 | const void *addr, | ||
1694 | size_t addrlen) | ||
1679 | { | 1695 | { |
1680 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac; | 1696 | const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac; |
1681 | static char macstr[36]; | 1697 | static char macstr[36]; |
@@ -1686,9 +1702,12 @@ bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
1686 | return NULL; | 1702 | return NULL; |
1687 | } | 1703 | } |
1688 | mac = &((struct WlanAddress *) addr)->mac; | 1704 | mac = &((struct WlanAddress *) addr)->mac; |
1689 | GNUNET_snprintf (macstr, sizeof (macstr), "%s.%u.%s", | 1705 | GNUNET_snprintf (macstr, |
1690 | PLUGIN_NAME, ntohl (((struct WlanAddress *) addr)->options), | 1706 | sizeof (macstr), |
1691 | mac_to_string (mac)); | 1707 | "%s.%u.%s", |
1708 | PLUGIN_NAME, | ||
1709 | ntohl (((struct WlanAddress *) addr)->options), | ||
1710 | mac_to_string (mac)); | ||
1692 | return macstr; | 1711 | return macstr; |
1693 | } | 1712 | } |
1694 | 1713 | ||
@@ -1704,7 +1723,7 @@ bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
1704 | * @param numeric should (IP) addresses be displayed in numeric form? | 1723 | * @param numeric should (IP) addresses be displayed in numeric form? |
1705 | * @param timeout after how long should we give up? | 1724 | * @param timeout after how long should we give up? |
1706 | * @param asc function to call on each string | 1725 | * @param asc function to call on each string |
1707 | * @param asc_cls closure for asc | 1726 | * @param asc_cls closure for @a asc |
1708 | */ | 1727 | */ |
1709 | static void | 1728 | static void |
1710 | bluetooth_plugin_address_pretty_printer (void *cls, const char *type, | 1729 | bluetooth_plugin_address_pretty_printer (void *cls, const char *type, |
@@ -1714,19 +1733,15 @@ bluetooth_plugin_address_pretty_printer (void *cls, const char *type, | |||
1714 | GNUNET_TRANSPORT_AddressStringCallback asc, | 1733 | GNUNET_TRANSPORT_AddressStringCallback asc, |
1715 | void *asc_cls) | 1734 | void *asc_cls) |
1716 | { | 1735 | { |
1717 | char *ret; | 1736 | const char *ret; |
1718 | 1737 | ||
1719 | if (sizeof (struct WlanAddress) != addrlen) | 1738 | if (sizeof (struct WlanAddress) == addrlen) |
1720 | { | 1739 | ret = bluetooth_plugin_address_to_string(NULL, addr, addrlen); |
1721 | /* invalid address */ | ||
1722 | asc (asc_cls, NULL, GNUNET_SYSERR); | ||
1723 | } | ||
1724 | else | 1740 | else |
1725 | { | 1741 | ret = NULL; |
1726 | ret = GNUNET_strdup (bluetooth_plugin_address_to_string(NULL, addr, addrlen)); | 1742 | asc (asc_cls, |
1727 | asc (asc_cls, ret, GNUNET_OK); | 1743 | ret, |
1728 | GNUNET_free (ret); | 1744 | (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK); |
1729 | } | ||
1730 | asc (asc_cls, NULL, GNUNET_OK); | 1745 | asc (asc_cls, NULL, GNUNET_OK); |
1731 | } | 1746 | } |
1732 | 1747 | ||