aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_wlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/plugin_transport_wlan.c')
-rw-r--r--src/transport/plugin_transport_wlan.c87
1 files changed, 52 insertions, 35 deletions
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index f0197feb8..6da3365eb 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -1073,7 +1073,9 @@ create_macendpoint (struct Plugin *plugin, struct WlanAddress *mac)
1073 if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr))) 1073 if (0 == memcmp (mac, &pos->wlan_addr, sizeof (pos->wlan_addr)))
1074 { 1074 {
1075 LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing MAC endpoint `%s'\n", 1075 LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing MAC endpoint `%s'\n",
1076 wlan_plugin_address_to_string(NULL, &pos->wlan_addr.mac, sizeof (pos->wlan_addr))); 1076 wlan_plugin_address_to_string (NULL,
1077 &pos->wlan_addr.mac,
1078 sizeof (pos->wlan_addr)));
1077 return pos; 1079 return pos;
1078 } 1080 }
1079 } 1081 }
@@ -1097,8 +1099,11 @@ create_macendpoint (struct Plugin *plugin, struct WlanAddress *mac)
1097 plugin->mac_count++; 1099 plugin->mac_count++;
1098 GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"), 1100 GNUNET_STATISTICS_update (plugin->env->stats, _("# WLAN MAC endpoints allocated"),
1099 1, GNUNET_NO); 1101 1, GNUNET_NO);
1100 LOG (GNUNET_ERROR_TYPE_DEBUG, "New MAC endpoint `%s'\n", 1102 LOG (GNUNET_ERROR_TYPE_DEBUG,
1101 wlan_plugin_address_to_string(NULL, &pos->wlan_addr, sizeof (struct WlanAddress))); 1103 "New MAC endpoint `%s'\n",
1104 wlan_plugin_address_to_string (NULL,
1105 &pos->wlan_addr,
1106 sizeof (struct WlanAddress)));
1102 return pos; 1107 return pos;
1103} 1108}
1104 1109
@@ -1144,7 +1149,9 @@ wlan_plugin_get_session (void *cls,
1144 LOG (GNUNET_ERROR_TYPE_DEBUG, 1149 LOG (GNUNET_ERROR_TYPE_DEBUG,
1145 "Service asked to create session for peer `%s' with MAC `%s'\n", 1150 "Service asked to create session for peer `%s' with MAC `%s'\n",
1146 GNUNET_i2s (&address->peer), 1151 GNUNET_i2s (&address->peer),
1147 wlan_plugin_address_to_string(NULL, address->address, address->address_length)); 1152 wlan_plugin_address_to_string (NULL,
1153 address->address,
1154 address->address_length));
1148 endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address); 1155 endpoint = create_macendpoint (plugin, (struct WlanAddress *) address->address);
1149 return get_session (endpoint, &address->peer); 1156 return get_session (endpoint, &address->peer);
1150} 1157}
@@ -1295,8 +1302,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1295 "Processing %u bytes of HELLO from peer `%s' at MAC %s\n", 1302 "Processing %u bytes of HELLO from peer `%s' at MAC %s\n",
1296 (unsigned int) msize, 1303 (unsigned int) msize,
1297 GNUNET_i2s (&tmpsource), 1304 GNUNET_i2s (&tmpsource),
1298 wlan_plugin_address_to_string (NULL, &mas->endpoint->wlan_addr, 1305 wlan_plugin_address_to_string (NULL,
1299 sizeof (mas->endpoint->wlan_addr))); 1306 &mas->endpoint->wlan_addr,
1307 sizeof (mas->endpoint->wlan_addr)));
1300 1308
1301 GNUNET_STATISTICS_update (plugin->env->stats, 1309 GNUNET_STATISTICS_update (plugin->env->stats,
1302 _("# HELLO messages received via WLAN"), 1, 1310 _("# HELLO messages received via WLAN"), 1,
@@ -1320,8 +1328,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1320 LOG (GNUNET_ERROR_TYPE_DEBUG, 1328 LOG (GNUNET_ERROR_TYPE_DEBUG,
1321 "Processing %u bytes of FRAGMENT from MAC %s\n", 1329 "Processing %u bytes of FRAGMENT from MAC %s\n",
1322 (unsigned int) msize, 1330 (unsigned int) msize,
1323 wlan_plugin_address_to_string (NULL, &mas->endpoint->wlan_addr, 1331 wlan_plugin_address_to_string (NULL,
1324 sizeof (mas->endpoint->wlan_addr))); 1332 &mas->endpoint->wlan_addr,
1333 sizeof (mas->endpoint->wlan_addr)));
1325 GNUNET_STATISTICS_update (plugin->env->stats, 1334 GNUNET_STATISTICS_update (plugin->env->stats,
1326 _("# fragments received via WLAN"), 1, GNUNET_NO); 1335 _("# fragments received via WLAN"), 1, GNUNET_NO);
1327 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag, 1336 (void) GNUNET_DEFRAGMENT_process_fragment (mas->endpoint->defrag,
@@ -1342,8 +1351,9 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1342 { 1351 {
1343 LOG (GNUNET_ERROR_TYPE_DEBUG, 1352 LOG (GNUNET_ERROR_TYPE_DEBUG,
1344 "Got last ACK, finished message transmission to `%s' (%p)\n", 1353 "Got last ACK, finished message transmission to `%s' (%p)\n",
1345 wlan_plugin_address_to_string (NULL, &mas->endpoint->wlan_addr, 1354 wlan_plugin_address_to_string (NULL,
1346 sizeof (mas->endpoint->wlan_addr)), 1355 &mas->endpoint->wlan_addr,
1356 sizeof (mas->endpoint->wlan_addr)),
1347 fm); 1357 fm);
1348 mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT); 1358 mas->endpoint->timeout = GNUNET_TIME_relative_to_absolute (MACENDPOINT_TIMEOUT);
1349 if (NULL != fm->cont) 1359 if (NULL != fm->cont)
@@ -1358,15 +1368,17 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr)
1358 { 1368 {
1359 LOG (GNUNET_ERROR_TYPE_DEBUG, 1369 LOG (GNUNET_ERROR_TYPE_DEBUG,
1360 "Got an ACK, message transmission to `%s' not yet finished\n", 1370 "Got an ACK, message transmission to `%s' not yet finished\n",
1361 wlan_plugin_address_to_string (NULL, &mas->endpoint->wlan_addr, 1371 wlan_plugin_address_to_string (NULL,
1362 sizeof (mas->endpoint->wlan_addr))); 1372 &mas->endpoint->wlan_addr,
1373 sizeof (mas->endpoint->wlan_addr)));
1363 break; 1374 break;
1364 } 1375 }
1365 } 1376 }
1366 LOG (GNUNET_ERROR_TYPE_DEBUG, 1377 LOG (GNUNET_ERROR_TYPE_DEBUG,
1367 "ACK not matched against any active fragmentation with MAC `%s'\n", 1378 "ACK not matched against any active fragmentation with MAC `%s'\n",
1368 wlan_plugin_address_to_string (NULL, &mas->endpoint->wlan_addr, 1379 wlan_plugin_address_to_string (NULL,
1369 sizeof (mas->endpoint->wlan_addr))); 1380 &mas->endpoint->wlan_addr,
1381 sizeof (mas->endpoint->wlan_addr)));
1370 break; 1382 break;
1371 case GNUNET_MESSAGE_TYPE_WLAN_DATA: 1383 case GNUNET_MESSAGE_TYPE_WLAN_DATA:
1372 if (NULL == mas->endpoint) 1384 if (NULL == mas->endpoint)
@@ -1681,7 +1693,9 @@ wlan_plugin_address_suggested (void *cls, const void *addr, size_t addrlen)
1681 * @return string representing the same address 1693 * @return string representing the same address
1682 */ 1694 */
1683static const char * 1695static const char *
1684wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) 1696wlan_plugin_address_to_string (void *cls,
1697 const void *addr,
1698 size_t addrlen)
1685{ 1699{
1686 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac; 1700 const struct GNUNET_TRANSPORT_WLAN_MacAddress *mac;
1687 static char macstr[36]; 1701 static char macstr[36];
@@ -1692,9 +1706,12 @@ wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
1692 return NULL; 1706 return NULL;
1693 } 1707 }
1694 mac = &((struct WlanAddress *) addr)->mac; 1708 mac = &((struct WlanAddress *) addr)->mac;
1695 GNUNET_snprintf (macstr, sizeof (macstr), "%s.%u.%s", 1709 GNUNET_snprintf (macstr,
1696 PLUGIN_NAME, ntohl (((struct WlanAddress *) addr)->options), 1710 sizeof (macstr),
1697 mac_to_string (mac)); 1711 "%s.%u.%s",
1712 PLUGIN_NAME,
1713 ntohl (((struct WlanAddress *) addr)->options),
1714 mac_to_string (mac));
1698 return macstr; 1715 return macstr;
1699} 1716}
1700 1717
@@ -1710,29 +1727,29 @@ wlan_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
1710 * @param numeric should (IP) addresses be displayed in numeric form? 1727 * @param numeric should (IP) addresses be displayed in numeric form?
1711 * @param timeout after how long should we give up? 1728 * @param timeout after how long should we give up?
1712 * @param asc function to call on each string 1729 * @param asc function to call on each string
1713 * @param asc_cls closure for asc 1730 * @param asc_cls closure for @a asc
1714 */ 1731 */
1715static void 1732static void
1716wlan_plugin_address_pretty_printer (void *cls, const char *type, 1733wlan_plugin_address_pretty_printer (void *cls,
1717 const void *addr, size_t addrlen, 1734 const char *type,
1735 const void *addr,
1736 size_t addrlen,
1718 int numeric, 1737 int numeric,
1719 struct GNUNET_TIME_Relative timeout, 1738 struct GNUNET_TIME_Relative timeout,
1720 GNUNET_TRANSPORT_AddressStringCallback asc, 1739 GNUNET_TRANSPORT_AddressStringCallback asc,
1721 void *asc_cls) 1740 void *asc_cls)
1722{ 1741{
1723 char *ret; 1742 const char *ret;
1724 1743
1725 if (sizeof (struct WlanAddress) != addrlen) 1744 if (sizeof (struct WlanAddress) == addrlen)
1726 { 1745 ret = wlan_plugin_address_to_string (NULL,
1727 /* invalid address */ 1746 addr,
1728 asc (asc_cls, NULL, GNUNET_SYSERR); 1747 addrlen);
1729 }
1730 else 1748 else
1731 { 1749 ret = NULL;
1732 ret = GNUNET_strdup (wlan_plugin_address_to_string(NULL, addr, addrlen)); 1750 asc (asc_cls,
1733 asc (asc_cls, ret, GNUNET_OK); 1751 ret,
1734 GNUNET_free (ret); 1752 (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
1735 }
1736 asc (asc_cls, NULL, GNUNET_OK); 1753 asc (asc_cls, NULL, GNUNET_OK);
1737} 1754}
1738 1755
@@ -1815,13 +1832,13 @@ libgnunet_plugin_transport_wlan_done (void *cls)
1815 * Function called to convert a string address to 1832 * Function called to convert a string address to
1816 * a binary address. 1833 * a binary address.
1817 * 1834 *
1818 * @param cls closure ('struct Plugin*') 1835 * @param cls closure (`struct Plugin *`)
1819 * @param addr string address 1836 * @param addr string address
1820 * @param addrlen length of the address 1837 * @param addrlen length of the address
1821 * @param buf location to store the buffer 1838 * @param buf location to store the buffer
1822 * @param added location to store the number of bytes in the buffer. 1839 * @param added location to store the number of bytes in the buffer.
1823 * If the function returns GNUNET_SYSERR, its contents are undefined. 1840 * If the function returns #GNUNET_SYSERR, its contents are undefined.
1824 * @return GNUNET_OK on success, GNUNET_SYSERR on failure 1841 * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure
1825 */ 1842 */
1826static int 1843static int
1827wlan_string_to_address (void *cls, const char *addr, uint16_t addrlen, 1844wlan_string_to_address (void *cls, const char *addr, uint16_t addrlen,