summaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_bluetooth.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-06-09 22:04:11 +0000
committerChristian Grothoff <christian@grothoff.org>2014-06-09 22:04:11 +0000
commit1dd22b0d681848af9980e5202e38b1a307cf2094 (patch)
treee013a7f735f2e967222890d87136bd5b76c1f803 /src/transport/plugin_transport_bluetooth.c
parentc9f75566447fd3a9c5c304dbc8e31fd68b6aa3ed (diff)
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.c77
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
* @return string representing the same address
*/
static const char *
-bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen);
+bluetooth_plugin_address_to_string (void *cls,
+ const void *addr,
+ size_t addrlen);
/**
* Print MAC addresses nicely.
@@ -1055,7 +1057,9 @@ create_macendpoint (struct Plugin *plugin,
1, GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"New MAC endpoint `%s'\n",
- bluetooth_plugin_address_to_string(NULL, addr, sizeof (struct WlanAddress)));
+ bluetooth_plugin_address_to_string(NULL,
+ addr,
+ sizeof (struct WlanAddress)));
return pos;
}
@@ -1119,8 +1123,11 @@ bluetooth_plugin_get_session (void *cls,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Service asked to create session for peer `%s' with MAC `%s'\n",
GNUNET_i2s (&address->peer),
- bluetooth_plugin_address_to_string(NULL, address->address, address->address_length));
- endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address);
+ bluetooth_plugin_address_to_string(NULL,
+ address->address,
+ address->address_length));
+ endpoint = create_macendpoint (plugin,
+ (struct WlanAddress *) address->address);
return get_session (endpoint, &address->peer);
}
@@ -1300,8 +1307,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
"Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
(unsigned int) msize,
GNUNET_i2s (&tmpsource),
- bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr,
- sizeof (mas->endpoint->addr)));
+ bluetooth_plugin_address_to_string (NULL,
+ &mas->endpoint->addr,
+ sizeof (mas->endpoint->addr)));
GNUNET_STATISTICS_update (plugin->env->stats,
_("# HELLO messages received via Bluetooth"), 1,
@@ -1325,10 +1333,13 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Processing %u bytes of FRAGMENT from MAC %s\n",
(unsigned int) msize,
- bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr,
- sizeof (mas->endpoint->addr)));
+ bluetooth_plugin_address_to_string (NULL,
+ &mas->endpoint->addr,
+ sizeof (mas->endpoint->addr)));
GNUNET_STATISTICS_update (plugin->env->stats,
- _("# fragments received via Bluetooth"), 1, GNUNET_NO);
+ _("# fragments received via Bluetooth"),
+ 1,
+ GNUNET_NO);
(void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
hdr);
break;
@@ -1347,8 +1358,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got last ACK, finished message transmission to `%s' (%p)\n",
- bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr,
- sizeof (mas->endpoint->addr)),
+ bluetooth_plugin_address_to_string (NULL,
+ &mas->endpoint->addr,
+ sizeof (mas->endpoint->addr)),
fm);
mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
if (NULL != fm->cont)
@@ -1363,15 +1375,17 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got an ACK, message transmission to `%s' not yet finished\n",
- bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr,
- sizeof (mas->endpoint->addr)));
+ bluetooth_plugin_address_to_string (NULL,
+ &mas->endpoint->addr,
+ sizeof (mas->endpoint->addr)));
break;
}
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"ACK not matched against any active fragmentation with MAC `%s'\n",
- bluetooth_plugin_address_to_string (NULL, &mas->endpoint->addr,
- sizeof (mas->endpoint->addr)));
+ bluetooth_plugin_address_to_string (NULL,
+ &mas->endpoint->addr,
+ sizeof (mas->endpoint->addr)));
break;
case GNUNET_MESSAGE_TYPE_WLAN_DATA:
if (NULL == mas->endpoint)
@@ -1675,7 +1689,9 @@ bluetooth_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
* @return string representing the same address
*/
static const char *
-bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
+bluetooth_plugin_address_to_string (void *cls,
+ const void *addr,
+ size_t addrlen)
{
const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
static char macstr[36];
@@ -1686,9 +1702,12 @@ bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
return NULL;
}
mac = &((struct WlanAddress *) addr)->mac;
- GNUNET_snprintf (macstr, sizeof (macstr), "%s.%u.%s",
- PLUGIN_NAME, ntohl (((struct WlanAddress *) addr)->options),
- mac_to_string (mac));
+ GNUNET_snprintf (macstr,
+ sizeof (macstr),
+ "%s.%u.%s",
+ PLUGIN_NAME,
+ ntohl (((struct WlanAddress *) addr)->options),
+ mac_to_string (mac));
return macstr;
}
@@ -1704,7 +1723,7 @@ bluetooth_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
* @param numeric should (IP) addresses be displayed in numeric form?
* @param timeout after how long should we give up?
* @param asc function to call on each string
- * @param asc_cls closure for asc
+ * @param asc_cls closure for @a asc
*/
static void
bluetooth_plugin_address_pretty_printer (void *cls, const char *type,
@@ -1714,19 +1733,15 @@ bluetooth_plugin_address_pretty_printer (void *cls, const char *type,
GNUNET_TRANSPORT_AddressStringCallback asc,
void *asc_cls)
{
- char *ret;
+ const char *ret;
- if (sizeof (struct WlanAddress) != addrlen)
- {
- /* invalid address */
- asc (asc_cls, NULL, GNUNET_SYSERR);
- }
+ if (sizeof (struct WlanAddress) == addrlen)
+ ret = bluetooth_plugin_address_to_string(NULL, addr, addrlen);
else
- {
- ret = GNUNET_strdup (bluetooth_plugin_address_to_string(NULL, addr, addrlen));
- asc (asc_cls, ret, GNUNET_OK);
- GNUNET_free (ret);
- }
+ ret = NULL;
+ asc (asc_cls,
+ ret,
+ (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
asc (asc_cls, NULL, GNUNET_OK);
}