aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2014-01-14 13:07:46 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2014-01-14 13:07:46 +0000
commit6bbea7ecc4cc9bd1571b10c0530490b25f1762ca (patch)
treed68ec5d47f5af192cdd2887c338a48c82c7737c7 /src
parente80da3ab091fdaaf65222689d10e73ef210b5f23 (diff)
downloadgnunet-6bbea7ecc4cc9bd1571b10c0530490b25f1762ca.tar.gz
gnunet-6bbea7ecc4cc9bd1571b10c0530490b25f1762ca.zip
improved checking for direction
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport.c11
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c32
-rw-r--r--src/transport/plugin_transport_udp.c10
3 files changed, 22 insertions, 31 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 0f24892bd..d52d6ab69 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -621,7 +621,6 @@ plugin_env_session_start (void *cls, struct GNUNET_HELLO_Address *address,
621 struct Session *session, const struct GNUNET_ATS_Information *ats, 621 struct Session *session, const struct GNUNET_ATS_Information *ats,
622 uint32_t ats_count) 622 uint32_t ats_count)
623{ 623{
624 int inbound;
625 if (NULL == address) 624 if (NULL == address)
626 { 625 {
627 GNUNET_break(0); 626 GNUNET_break(0);
@@ -633,15 +632,11 @@ plugin_env_session_start (void *cls, struct GNUNET_HELLO_Address *address,
633 return; 632 return;
634 } 633 }
635 634
636 if (GNUNET_HELLO_ADDRESS_INFO_INBOUND
637 == (address->local_info & GNUNET_HELLO_ADDRESS_INFO_INBOUND))
638 inbound = GNUNET_YES;
639 else
640 inbound = GNUNET_NO;
641
642 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 635 GNUNET_log(GNUNET_ERROR_TYPE_INFO,
643 "Notification from plugin `%s' about new %ssession %p from peer `%s' address `%s'\n", 636 "Notification from plugin `%s' about new %ssession %p from peer `%s' address `%s'\n",
644 address->transport_name, (GNUNET_YES == inbound) ? "inbound " : "", 637 address->transport_name,
638 GNUNET_HELLO_address_check_option (address,
639 GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound " : "",
645 session, GNUNET_i2s (&address->peer), GST_plugins_a2s (address)); 640 session, GNUNET_i2s (&address->peer), GST_plugins_a2s (address));
646 GST_ats_add_address (address, session, ats, ats_count); 641 GST_ats_add_address (address, session, ats, ats_count);
647} 642}
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 0cb719f02..2090c71b5 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -2292,25 +2292,29 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
2292 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 2292 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
2293 return; 2293 return;
2294 } 2294 }
2295 if ((NULL == session) && (0 == address->address_length)) 2295 if ((NULL == session) &&
2296 (GNUNET_HELLO_address_check_option (address, GNUNET_HELLO_ADDRESS_INFO_INBOUND)))
2296 { 2297 {
2297 GNUNET_break (0); 2298 /* This is a inbound address and we do not have a session to use! */
2298 if (strlen (address->transport_name) > 0) 2299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2299 GNUNET_ATS_address_destroyed (GST_ats, address, NULL); 2300 "Inbound address without session `%s'! Destroying address...\n",
2301 GST_plugins_a2s (address));
2302 GNUNET_ATS_address_destroyed (GST_ats, address, NULL);
2300 return; 2303 return;
2301 } 2304 }
2302 2305
2303 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 2306 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
2304 "ATS tells us to switch to %s address '%s' session %p for " 2307 "ATS tells us to switch to %s address '%s' session %p for "
2305 "peer `%s' in state %s/%d (quota in/out %u %u )\n", 2308 "peer `%s' in state %s/%d (quota in/out %u %u )\n",
2306 (GNUNET_HELLO_ADDRESS_INFO_INBOUND == (GNUNET_HELLO_ADDRESS_INFO_INBOUND & address->local_info)) ? "inbound" : "", 2309 GNUNET_HELLO_address_check_option (address,
2307 GST_plugins_a2s (address), 2310 GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "",
2308 session, 2311 GST_plugins_a2s (address),
2309 GNUNET_i2s (peer), 2312 session,
2310 GNUNET_TRANSPORT_p2s (n->state), 2313 GNUNET_i2s (peer),
2311 n->send_connect_ack, 2314 GNUNET_TRANSPORT_p2s (n->state),
2312 ntohl (bandwidth_in.value__), 2315 n->send_connect_ack,
2313 ntohl (bandwidth_out.value__)); 2316 ntohl (bandwidth_in.value__),
2317 ntohl (bandwidth_out.value__));
2314 2318
2315 if (NULL == session) 2319 if (NULL == session)
2316 { 2320 {
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 8f847b0eb..d5aef62ce 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -1444,14 +1444,6 @@ udp_plugin_lookup_session (void *cls,
1444 return NULL ; 1444 return NULL ;
1445} 1445}
1446 1446
1447static int
1448udp_address_is_inbound (const struct GNUNET_HELLO_Address *address)
1449{
1450 if (GNUNET_HELLO_ADDRESS_INFO_INBOUND == (address->local_info & GNUNET_HELLO_ADDRESS_INFO_INBOUND))
1451 return GNUNET_YES;
1452 else
1453 return GNUNET_NO;
1454}
1455 1447
1456static struct Session * 1448static struct Session *
1457udp_plugin_create_session (void *cls, 1449udp_plugin_create_session (void *cls,
@@ -1495,7 +1487,7 @@ udp_plugin_create_session (void *cls,
1495 return NULL ; /* protocol not supported or address invalid */ 1487 return NULL ; /* protocol not supported or address invalid */
1496 LOG(GNUNET_ERROR_TYPE_ERROR, 1488 LOG(GNUNET_ERROR_TYPE_ERROR,
1497 "Creating new %s session %p for peer `%s' address `%s'\n", 1489 "Creating new %s session %p for peer `%s' address `%s'\n",
1498 (GNUNET_YES == udp_address_is_inbound(address)) ? "inbound" : "outbound", 1490 GNUNET_HELLO_address_check_option (address, GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound",
1499 s, GNUNET_i2s (&address->peer), 1491 s, GNUNET_i2s (&address->peer),
1500 udp_address_to_string(NULL,address->address,address->address_length)); 1492 udp_address_to_string(NULL,address->address,address->address_length));
1501 GNUNET_assert( 1493 GNUNET_assert(