diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-07 13:58:09 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-10-07 13:58:09 +0000 |
commit | 6987c2bcfeb806cb4c223c8766ccfcd4358644b6 (patch) | |
tree | fec938c872a1605dcfcdcd6e6b41f8f57509439b /src/transport | |
parent | 297e089292b5acba6e0a2d560ec172e1ff41c89e (diff) | |
download | gnunet-6987c2bcfeb806cb4c223c8766ccfcd4358644b6.tar.gz gnunet-6987c2bcfeb806cb4c223c8766ccfcd4358644b6.zip |
fix for incoming addresses:
incoming addresses are only marked with address length 0 if the address cannot be used to initiate a connection to his address.
Therefor only for tcp and http(s) incoming connections an address length of 0 is reported whereas for other plugins (unix, udp, wlan) the incoming address can be used to initiate a connection to this address.
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/plugin_transport_unix.c | 37 | ||||
-rw-r--r-- | src/transport/plugin_transport_wlan.c | 13 |
2 files changed, 24 insertions, 26 deletions
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index f5ab3a694..e80102a33 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -985,7 +985,7 @@ unix_demultiplexer (struct Plugin *plugin, struct GNUNET_PeerIdentity *sender, | |||
985 | s->inbound = GNUNET_YES; | 985 | s->inbound = GNUNET_YES; |
986 | /* Notify transport and ATS about new inbound session */ | 986 | /* Notify transport and ATS about new inbound session */ |
987 | plugin->env->session_start (NULL, sender, | 987 | plugin->env->session_start (NULL, sender, |
988 | PLUGIN_NAME, NULL, 0, s, &plugin->ats_network, 1); | 988 | PLUGIN_NAME, ua, ua_len, s, &plugin->ats_network, 1); |
989 | } | 989 | } |
990 | reschedule_session_timeout (s); | 990 | reschedule_session_timeout (s); |
991 | 991 | ||
@@ -1288,40 +1288,37 @@ static const char * | |||
1288 | unix_address_to_string (void *cls, const void *addr, size_t addrlen) | 1288 | unix_address_to_string (void *cls, const void *addr, size_t addrlen) |
1289 | { | 1289 | { |
1290 | static char rbuf[1024]; | 1290 | static char rbuf[1024]; |
1291 | struct UnixAddress *ua = (struct UnixAddress *) addr; | 1291 | struct UnixAddress *ua = (struct UnixAddress *) addr; |
1292 | char *addrstr; | 1292 | char *addrstr; |
1293 | size_t addr_str_len; | 1293 | size_t addr_str_len; |
1294 | 1294 | ||
1295 | if (0 == addrlen) | ||
1296 | { | ||
1297 | GNUNET_snprintf(rbuf, sizeof (rbuf), "%s", TRANSPORT_SESSION_INBOUND_STRING); | ||
1298 | } | ||
1299 | if ((NULL == addr) || (sizeof (struct UnixAddress) > addrlen)) | 1295 | if ((NULL == addr) || (sizeof (struct UnixAddress) > addrlen)) |
1300 | { | 1296 | { |
1301 | GNUNET_break (0); | 1297 | GNUNET_break(0); |
1302 | return NULL; | 1298 | return NULL ; |
1303 | } | 1299 | } |
1304 | addrstr = (char *) &ua[1]; | 1300 | addrstr = (char *) &ua[1]; |
1305 | addr_str_len = ntohl (ua->addrlen); | 1301 | addr_str_len = ntohl (ua->addrlen); |
1306 | 1302 | ||
1307 | if (addr_str_len != addrlen - sizeof (struct UnixAddress)) | 1303 | if (addr_str_len != addrlen - sizeof(struct UnixAddress)) |
1308 | { | 1304 | { |
1309 | GNUNET_break (0); | 1305 | GNUNET_break(0); |
1310 | return NULL; | 1306 | return NULL ; |
1311 | } | 1307 | } |
1312 | 1308 | ||
1313 | if ('\0' != addrstr[addr_str_len - 1]) | 1309 | if ('\0' != addrstr[addr_str_len - 1]) |
1314 | { | 1310 | { |
1315 | GNUNET_break (0); | 1311 | GNUNET_break(0); |
1316 | return NULL; | 1312 | return NULL ; |
1317 | } | 1313 | } |
1318 | if (strlen (addrstr) + 1 != addr_str_len) | 1314 | if (strlen (addrstr) + 1 != addr_str_len) |
1319 | { | 1315 | { |
1320 | GNUNET_break (0); | 1316 | GNUNET_break(0); |
1321 | return NULL; | 1317 | return NULL ; |
1322 | } | 1318 | } |
1323 | 1319 | ||
1324 | GNUNET_snprintf(rbuf, sizeof (rbuf), "%s.%u.%s", PLUGIN_NAME, ntohl (ua->options), addrstr); | 1320 | GNUNET_snprintf (rbuf, sizeof(rbuf), "%s.%u.%s", PLUGIN_NAME, |
1321 | ntohl (ua->options), addrstr); | ||
1325 | return rbuf; | 1322 | return rbuf; |
1326 | } | 1323 | } |
1327 | 1324 | ||
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c index 932d3b762..43d367ac5 100644 --- a/src/transport/plugin_transport_wlan.c +++ b/src/transport/plugin_transport_wlan.c | |||
@@ -1367,14 +1367,15 @@ process_data (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
1367 | break; | 1367 | break; |
1368 | } | 1368 | } |
1369 | xmas.endpoint = mas->endpoint; | 1369 | xmas.endpoint = mas->endpoint; |
1370 | if (NULL == (xmas.session = lookup_session (mas->endpoint, &wlanheader->sender, GNUNET_YES))) | 1370 | if (NULL == (xmas.session = lookup_session (mas->endpoint, &wlanheader->sender, GNUNET_YES))) |
1371 | { | 1371 | { |
1372 | xmas.session = create_session (mas->endpoint, &wlanheader->sender, GNUNET_YES); | 1372 | xmas.session = create_session (mas->endpoint, &wlanheader->sender, GNUNET_YES); |
1373 | plugin->env->session_start (NULL, &wlanheader->sender, | 1373 | plugin->env->session_start (NULL, &wlanheader->sender, |
1374 | PLUGIN_NAME, NULL, 0, xmas.session, NULL, 0); | 1374 | PLUGIN_NAME, &mas->endpoint->addr, |
1375 | sizeof (struct WlanAddress), xmas.session, NULL, 0); | ||
1375 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1376 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1376 | "Notifying transport about peer `%s''s new inbound session %p \n", | 1377 | "Notifying transport about peer `%s''s new inbound session %p \n", |
1377 | GNUNET_i2s (&wlanheader->sender), xmas.session); | 1378 | GNUNET_i2s (&wlanheader->sender), xmas.session); |
1378 | } | 1379 | } |
1379 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1380 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1380 | "Processing %u bytes of WLAN DATA from peer `%s'\n", | 1381 | "Processing %u bytes of WLAN DATA from peer `%s'\n", |