diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-11 12:06:25 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2013-07-11 12:06:25 +0000 |
commit | 494fb46a6401194dfb4d5267775125172d0c0441 (patch) | |
tree | 91ae471f53549dc21ff591e8b9b0e492a182d8cb /src/transport/plugin_transport_udp.c | |
parent | b87c0fc2cbb822b12f1c198113450a702cce2add (diff) | |
download | gnunet-494fb46a6401194dfb4d5267775125172d0c0441.tar.gz gnunet-494fb46a6401194dfb4d5267775125172d0c0441.zip |
fixed:
printing of inbound session
size of inbound sessions
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 65 |
1 files changed, 55 insertions, 10 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 8080b67b3..9c8c585de 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -153,6 +153,8 @@ struct Session | |||
153 | unsigned int rc; | 153 | unsigned int rc; |
154 | 154 | ||
155 | int in_destroy; | 155 | int in_destroy; |
156 | |||
157 | int inbound; | ||
156 | }; | 158 | }; |
157 | 159 | ||
158 | 160 | ||
@@ -545,6 +547,11 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
545 | memcpy (&a4, &t4->ipv4_addr, sizeof (a4)); | 547 | memcpy (&a4, &t4->ipv4_addr, sizeof (a4)); |
546 | sb = &a4; | 548 | sb = &a4; |
547 | } | 549 | } |
550 | else if (addrlen == 0) | ||
551 | { | ||
552 | GNUNET_snprintf (rbuf, sizeof (rbuf), "%s", "<inbound>"); | ||
553 | return rbuf; | ||
554 | } | ||
548 | else | 555 | else |
549 | { | 556 | { |
550 | GNUNET_break_op (0); | 557 | GNUNET_break_op (0); |
@@ -1378,6 +1385,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
1378 | s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS; | 1385 | s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS; |
1379 | s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO_ABS; | 1386 | s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO_ABS; |
1380 | s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO; | 1387 | s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO; |
1388 | s->inbound = GNUNET_NO; | ||
1381 | start_session_timeout (s); | 1389 | start_session_timeout (s); |
1382 | return s; | 1390 | return s; |
1383 | } | 1391 | } |
@@ -1451,10 +1459,9 @@ udp_get_network (void *cls, void *session) | |||
1451 | * @return the session or NULL of max connections exceeded | 1459 | * @return the session or NULL of max connections exceeded |
1452 | */ | 1460 | */ |
1453 | static struct Session * | 1461 | static struct Session * |
1454 | udp_plugin_get_session (void *cls, | 1462 | udp_plugin_lookup_session (void *cls, |
1455 | const struct GNUNET_HELLO_Address *address) | 1463 | const struct GNUNET_HELLO_Address *address) |
1456 | { | 1464 | { |
1457 | struct Session * s = NULL; | ||
1458 | struct Plugin * plugin = cls; | 1465 | struct Plugin * plugin = cls; |
1459 | struct IPv6UdpAddress * udp_a6; | 1466 | struct IPv6UdpAddress * udp_a6; |
1460 | struct IPv4UdpAddress * udp_a4; | 1467 | struct IPv4UdpAddress * udp_a4; |
@@ -1507,6 +1514,14 @@ udp_plugin_get_session (void *cls, | |||
1507 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res); | 1514 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res); |
1508 | return cctx.res; | 1515 | return cctx.res; |
1509 | } | 1516 | } |
1517 | return NULL; | ||
1518 | } | ||
1519 | |||
1520 | static struct Session * | ||
1521 | udp_plugin_create_session (void *cls, | ||
1522 | const struct GNUNET_HELLO_Address *address) | ||
1523 | { | ||
1524 | struct Session * s = NULL; | ||
1510 | 1525 | ||
1511 | /* otherwise create new */ | 1526 | /* otherwise create new */ |
1512 | s = create_session (plugin, | 1527 | s = create_session (plugin, |
@@ -1524,8 +1539,6 @@ udp_plugin_get_session (void *cls, | |||
1524 | &s->target.hashPubKey, | 1539 | &s->target.hashPubKey, |
1525 | s, | 1540 | s, |
1526 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 1541 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
1527 | plugin->env->session_start (NULL, &address->peer, PLUGIN_NAME, | ||
1528 | address->address, address->address_length, s, NULL, 0); | ||
1529 | GNUNET_STATISTICS_set(plugin->env->stats, | 1542 | GNUNET_STATISTICS_set(plugin->env->stats, |
1530 | "# UDP, sessions active", | 1543 | "# UDP, sessions active", |
1531 | GNUNET_CONTAINER_multihashmap_size(plugin->sessions), | 1544 | GNUNET_CONTAINER_multihashmap_size(plugin->sessions), |
@@ -1533,6 +1546,30 @@ udp_plugin_get_session (void *cls, | |||
1533 | return s; | 1546 | return s; |
1534 | } | 1547 | } |
1535 | 1548 | ||
1549 | |||
1550 | |||
1551 | /** | ||
1552 | * Creates a new outbound session the transport service will use to send data to the | ||
1553 | * peer | ||
1554 | * | ||
1555 | * @param cls the plugin | ||
1556 | * @param address the address | ||
1557 | * @return the session or NULL of max connections exceeded | ||
1558 | */ | ||
1559 | static struct Session * | ||
1560 | udp_plugin_get_session (void *cls, | ||
1561 | const struct GNUNET_HELLO_Address *address) | ||
1562 | { | ||
1563 | struct Session * s = NULL; | ||
1564 | |||
1565 | /* otherwise create new */ | ||
1566 | if (NULL != (s = udp_plugin_lookup_session(cls, address))) | ||
1567 | return s; | ||
1568 | else | ||
1569 | return udp_plugin_create_session (cls, address); | ||
1570 | } | ||
1571 | |||
1572 | |||
1536 | static void | 1573 | static void |
1537 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) | 1574 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw) |
1538 | { | 1575 | { |
@@ -1830,13 +1867,13 @@ process_inbound_tokenized_messages (void *cls, void *client, | |||
1830 | &si->sender, | 1867 | &si->sender, |
1831 | hdr, | 1868 | hdr, |
1832 | si->session, | 1869 | si->session, |
1833 | si->arg, | 1870 | (GNUNET_YES == si->session->inbound) ? NULL : si->arg, |
1834 | si->args); | 1871 | (GNUNET_YES == si->session->inbound) ? 0 : si->args); |
1835 | 1872 | ||
1836 | plugin->env->update_address_metrics (plugin->env->cls, | 1873 | plugin->env->update_address_metrics (plugin->env->cls, |
1837 | &si->sender, | 1874 | &si->sender, |
1838 | si->arg, | 1875 | (GNUNET_YES == si->session->inbound) ? NULL : si->arg, |
1839 | si->args, | 1876 | (GNUNET_YES == si->session->inbound) ? 0 : si->args, |
1840 | si->session, | 1877 | si->session, |
1841 | &si->session->ats, 1); | 1878 | &si->session->ats, 1); |
1842 | 1879 | ||
@@ -1909,7 +1946,15 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, | |||
1909 | GNUNET_a2s (sender_addr, sender_addr_len)); | 1946 | GNUNET_a2s (sender_addr, sender_addr_len)); |
1910 | 1947 | ||
1911 | struct GNUNET_HELLO_Address * address = GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args); | 1948 | struct GNUNET_HELLO_Address * address = GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args); |
1912 | s = udp_plugin_get_session(plugin, address); | 1949 | if (NULL == (s = udp_plugin_lookup_session (plugin, address))) |
1950 | { | ||
1951 | s = udp_plugin_create_session(plugin, address); | ||
1952 | s->inbound = GNUNET_YES; | ||
1953 | plugin->env->session_start (NULL, &address->peer, PLUGIN_NAME, | ||
1954 | (GNUNET_YES == s->inbound) ? NULL : address->address, | ||
1955 | (GNUNET_YES == s->inbound) ? 0 : address->address_length, | ||
1956 | s, NULL, 0); | ||
1957 | } | ||
1913 | GNUNET_free (address); | 1958 | GNUNET_free (address); |
1914 | 1959 | ||
1915 | /* iterate over all embedded messages */ | 1960 | /* iterate over all embedded messages */ |