aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_plugins.c3
-rw-r--r--src/transport/gnunet-service-transport_validation.c32
-rw-r--r--src/transport/gnunet-transport.c135
-rw-r--r--src/transport/plugin_transport_tcp.c3
-rw-r--r--src/transport/plugin_transport_udp.c331
-rw-r--r--src/transport/transport_api_monitor_plugins.c23
6 files changed, 312 insertions, 215 deletions
diff --git a/src/transport/gnunet-service-transport_plugins.c b/src/transport/gnunet-service-transport_plugins.c
index cbfa50afd..5cdc55518 100644
--- a/src/transport/gnunet-service-transport_plugins.c
+++ b/src/transport/gnunet-service-transport_plugins.c
@@ -440,7 +440,8 @@ GST_plugins_monitor_subscribe (GNUNET_TRANSPORT_SessionInfoCallback cb,
440 GNUNET_break (0); 440 GNUNET_break (0);
441 else 441 else
442 pos->api->setup_monitor (pos->api->cls, 442 pos->api->setup_monitor (pos->api->cls,
443 cb, cb_cls); 443 cb,
444 cb_cls);
444} 445}
445 446
446 447
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index de6edc90a..ee8cd9308 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -1524,9 +1524,13 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
1524 /* build HELLO to store in PEERINFO */ 1524 /* build HELLO to store in PEERINFO */
1525 ve->copied = GNUNET_NO; 1525 ve->copied = GNUNET_NO;
1526 hello = GNUNET_HELLO_create (&ve->address->peer.public_key, 1526 hello = GNUNET_HELLO_create (&ve->address->peer.public_key,
1527 &add_valid_peer_address, ve, 1527 &add_valid_peer_address,
1528 ve,
1528 GNUNET_NO); 1529 GNUNET_NO);
1529 GNUNET_PEERINFO_add_peer (GST_peerinfo, hello, NULL, NULL); 1530 GNUNET_PEERINFO_add_peer (GST_peerinfo,
1531 hello,
1532 NULL,
1533 NULL);
1530 GNUNET_free (hello); 1534 GNUNET_free (hello);
1531 return GNUNET_OK; 1535 return GNUNET_OK;
1532} 1536}
@@ -1565,26 +1569,10 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello)
1565 /* got our own HELLO, how boring */ 1569 /* got our own HELLO, how boring */
1566 return GNUNET_OK; 1570 return GNUNET_OK;
1567 } 1571 }
1568 if (GNUNET_NO == 1572 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1569 GNUNET_CONTAINER_multipeermap_contains (validation_map, 1573 "Validation received HELLO message for peer `%s' with size %u, checking for new addresses\n",
1570 &pid)) 1574 GNUNET_i2s (&pid),
1571 { 1575 ntohs (hello->size));
1572 /* Add peer identity without addresses to peerinfo service */
1573 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1574 "Adding HELLO without addresses for peer `%s'\n",
1575 GNUNET_i2s (&pid));
1576 h = GNUNET_HELLO_create (&pid.public_key, NULL, NULL, friend);
1577 GNUNET_PEERINFO_add_peer (GST_peerinfo, h, NULL, NULL);
1578
1579 GNUNET_free (h);
1580 }
1581 else
1582 {
1583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1584 "Validation received HELLO message for peer `%s' with size %u, checking for new addresses\n",
1585 GNUNET_i2s (&pid),
1586 ntohs (hello->size));
1587 }
1588 GNUNET_assert (NULL == 1576 GNUNET_assert (NULL ==
1589 GNUNET_HELLO_iterate_addresses (hm, 1577 GNUNET_HELLO_iterate_addresses (hm,
1590 GNUNET_NO, 1578 GNUNET_NO,
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index bf586b7f0..f4895e154 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -144,11 +144,6 @@ struct PeerResolutionContext
144 struct PeerResolutionContext *prev; 144 struct PeerResolutionContext *prev;
145 145
146 /** 146 /**
147 * The peer id
148 */
149 struct GNUNET_PeerIdentity id;
150
151 /**
152 * address to resolve 147 * address to resolve
153 */ 148 */
154 struct GNUNET_HELLO_Address *addrcp; 149 struct GNUNET_HELLO_Address *addrcp;
@@ -516,6 +511,7 @@ shutdown_task (void *cls,
516 struct GNUNET_TIME_Relative duration; 511 struct GNUNET_TIME_Relative duration;
517 struct ValidationResolutionContext *cur; 512 struct ValidationResolutionContext *cur;
518 struct ValidationResolutionContext *next; 513 struct ValidationResolutionContext *next;
514 struct PeerResolutionContext *rc;
519 515
520 end = NULL; 516 end = NULL;
521 if (NULL != op_timeout) 517 if (NULL != op_timeout)
@@ -550,12 +546,23 @@ shutdown_task (void *cls,
550 next = cur->next; 546 next = cur->next;
551 547
552 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc); 548 GNUNET_TRANSPORT_address_to_string_cancel (cur->asc);
553 GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, cur); 549 GNUNET_CONTAINER_DLL_remove (vc_head,
550 vc_tail,
551 cur);
554 GNUNET_free (cur->transport); 552 GNUNET_free (cur->transport);
555 GNUNET_HELLO_address_free (cur->addrcp); 553 GNUNET_HELLO_address_free (cur->addrcp);
556 GNUNET_free (cur); 554 GNUNET_free (cur);
557 } 555 }
558 556 while (NULL != (rc = rc_head))
557 {
558 GNUNET_CONTAINER_DLL_remove (rc_head,
559 rc_tail,
560 rc);
561 GNUNET_TRANSPORT_address_to_string_cancel (rc->asc);
562 GNUNET_free (rc->transport);
563 GNUNET_free (rc->addrcp);
564 GNUNET_free (rc);
565 }
559 if (NULL != th) 566 if (NULL != th)
560 { 567 {
561 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); 568 GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
@@ -649,7 +656,7 @@ operation_timeout (void *cls,
649 656
650 657
651static void 658static void
652run_nat_test (); 659run_nat_test (void);
653 660
654 661
655/** 662/**
@@ -720,6 +727,7 @@ display_test_result (struct TestContext *tc,
720 run_nat_test (); 727 run_nat_test ();
721} 728}
722 729
730
723/** 731/**
724 * Function called by NAT to report the outcome of the nat-test. 732 * Function called by NAT to report the outcome of the nat-test.
725 * Clean up and update GUI. 733 * Clean up and update GUI.
@@ -733,7 +741,8 @@ result_callback (void *cls,
733{ 741{
734 struct TestContext *tc = cls; 742 struct TestContext *tc = cls;
735 743
736 display_test_result (tc, result); 744 display_test_result (tc,
745 result);
737} 746}
738 747
739 748
@@ -965,11 +974,12 @@ run_nat_test ()
965 (uint16_t) head->adv_port); 974 (uint16_t) head->adv_port);
966 975
967 head->tst = GNUNET_NAT_test_start (cfg, 976 head->tst = GNUNET_NAT_test_start (cfg,
968 (0 == strcasecmp (head->name, "udp")) ? GNUNET_NO : GNUNET_YES, 977 (0 == strcasecmp (head->name, "udp"))
969 (uint16_t) head->bnd_port, 978 ? GNUNET_NO : GNUNET_YES,
970 (uint16_t) head->adv_port, 979 (uint16_t) head->bnd_port,
971 TIMEOUT, 980 (uint16_t) head->adv_port,
972 &result_callback, head); 981 TIMEOUT,
982 &result_callback, head);
973} 983}
974 984
975 985
@@ -1270,9 +1280,17 @@ notify_receive (void *cls,
1270} 1280}
1271 1281
1272 1282
1283/**
1284 * Convert address to a printable format.
1285 *
1286 * @param address the address
1287 * @param numeric #GNUNET_YES to convert to numeric format, #GNUNET_NO
1288 * to try to use reverse DNS
1289 * @param state state the peer is in
1290 * @param state_timeout when will the peer's state expire
1291 */
1273static void 1292static void
1274resolve_peer_address (const struct GNUNET_PeerIdentity *id, 1293resolve_peer_address (const struct GNUNET_HELLO_Address *address,
1275 const struct GNUNET_HELLO_Address *address,
1276 int numeric, 1294 int numeric,
1277 enum GNUNET_TRANSPORT_PeerState state, 1295 enum GNUNET_TRANSPORT_PeerState state,
1278 struct GNUNET_TIME_Absolute state_timeout); 1296 struct GNUNET_TIME_Absolute state_timeout);
@@ -1339,10 +1357,10 @@ process_peer_string (void *cls,
1339 { 1357 {
1340 FPRINTF (stderr, 1358 FPRINTF (stderr,
1341 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n", 1359 "Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
1342 GNUNET_i2s (&rc->id), 1360 GNUNET_i2s (&rc->addrcp->peer),
1343 rc->addrcp->transport_name, 1361 rc->addrcp->transport_name,
1344 (unsigned int) rc->addrcp->address_length); 1362 (unsigned int) rc->addrcp->address_length);
1345 print_info (&rc->id, 1363 print_info (&rc->addrcp->peer,
1346 rc->transport, 1364 rc->transport,
1347 NULL, 1365 NULL,
1348 rc->state, 1366 rc->state,
@@ -1352,7 +1370,7 @@ process_peer_string (void *cls,
1352 } 1370 }
1353 if (GNUNET_OK == res) 1371 if (GNUNET_OK == res)
1354 { 1372 {
1355 print_info (&rc->id, 1373 print_info (&rc->addrcp->peer,
1356 rc->transport, 1374 rc->transport,
1357 address, 1375 address,
1358 rc->state, 1376 rc->state,
@@ -1365,6 +1383,7 @@ process_peer_string (void *cls,
1365 } 1383 }
1366 /* NULL == address, last call, we are done */ 1384 /* NULL == address, last call, we are done */
1367 1385
1386 rc->asc = NULL;
1368 GNUNET_assert (address_resolutions > 0); 1387 GNUNET_assert (address_resolutions > 0);
1369 address_resolutions--; 1388 address_resolutions--;
1370 if (GNUNET_NO == rc->printed) 1389 if (GNUNET_NO == rc->printed)
@@ -1375,15 +1394,14 @@ process_peer_string (void *cls,
1375 (note: this should not be needed, as transport 1394 (note: this should not be needed, as transport
1376 should fallback to numeric conversion if DNS takes 1395 should fallback to numeric conversion if DNS takes
1377 too long) */ 1396 too long) */
1378 resolve_peer_address (&rc->id, 1397 resolve_peer_address (rc->addrcp,
1379 rc->addrcp,
1380 GNUNET_YES, 1398 GNUNET_YES,
1381 rc->state, 1399 rc->state,
1382 rc->state_timeout); 1400 rc->state_timeout);
1383 } 1401 }
1384 else 1402 else
1385 { 1403 {
1386 print_info (&rc->id, 1404 print_info (&rc->addrcp->peer,
1387 rc->transport, 1405 rc->transport,
1388 NULL, 1406 NULL,
1389 rc->state, 1407 rc->state,
@@ -1407,14 +1425,24 @@ process_peer_string (void *cls,
1407 op_timeout = NULL; 1425 op_timeout = NULL;
1408 } 1426 }
1409 ret = 0; 1427 ret = 0;
1410 end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); 1428 end = GNUNET_SCHEDULER_add_now (&shutdown_task,
1429 NULL);
1411 } 1430 }
1412} 1431}
1413 1432
1414 1433
1434/**
1435 * Convert address to a printable format and print it
1436 * together with the given state data.
1437 *
1438 * @param address the address
1439 * @param numeric #GNUNET_YES to convert to numeric format, #GNUNET_NO
1440 * to try to use reverse DNS
1441 * @param state state the peer is in
1442 * @param state_timeout when will the peer's state expire
1443 */
1415static void 1444static void
1416resolve_peer_address (const struct GNUNET_PeerIdentity *id, 1445resolve_peer_address (const struct GNUNET_HELLO_Address *address,
1417 const struct GNUNET_HELLO_Address *address,
1418 int numeric, 1446 int numeric,
1419 enum GNUNET_TRANSPORT_PeerState state, 1447 enum GNUNET_TRANSPORT_PeerState state,
1420 struct GNUNET_TIME_Absolute state_timeout) 1448 struct GNUNET_TIME_Absolute state_timeout)
@@ -1422,12 +1450,11 @@ resolve_peer_address (const struct GNUNET_PeerIdentity *id,
1422 struct PeerResolutionContext *rc; 1450 struct PeerResolutionContext *rc;
1423 1451
1424 rc = GNUNET_new (struct PeerResolutionContext); 1452 rc = GNUNET_new (struct PeerResolutionContext);
1425 GNUNET_assert(NULL != rc); 1453 GNUNET_CONTAINER_DLL_insert (rc_head,
1426 GNUNET_CONTAINER_DLL_insert(rc_head, rc_tail, rc); 1454 rc_tail,
1455 rc);
1427 address_resolutions++; 1456 address_resolutions++;
1428 1457 rc->transport = GNUNET_strdup (address->transport_name);
1429 rc->id = *id;
1430 rc->transport = GNUNET_strdup(address->transport_name);
1431 rc->addrcp = GNUNET_HELLO_address_copy (address); 1458 rc->addrcp = GNUNET_HELLO_address_copy (address);
1432 rc->printed = GNUNET_NO; 1459 rc->printed = GNUNET_NO;
1433 rc->state = state; 1460 rc->state = state;
@@ -1485,9 +1512,16 @@ process_peer_iteration_cb (void *cls,
1485 address->transport_name); 1512 address->transport_name);
1486 1513
1487 if (NULL != address) 1514 if (NULL != address)
1488 resolve_peer_address (peer, address, numeric, state, state_timeout); 1515 resolve_peer_address (address,
1516 numeric,
1517 state,
1518 state_timeout);
1489 else 1519 else
1490 print_info (peer, NULL, NULL, state, state_timeout); 1520 print_info (peer,
1521 NULL,
1522 NULL,
1523 state,
1524 state_timeout);
1491} 1525}
1492 1526
1493 1527
@@ -1653,13 +1687,12 @@ plugin_monitoring_cb (void *cls,
1653/** 1687/**
1654 * Function called with information about a peers 1688 * Function called with information about a peers
1655 * 1689 *
1656 * @param cls closure 1690 * @param cls closure, NULL
1657 * @param peer identity of the peer, NULL for final callback when operation done 1691 * @param peer identity of the peer, NULL for final callback when operation done
1658 * @param address binary address used to communicate with this peer, 1692 * @param address binary address used to communicate with this peer,
1659 * NULL on disconnect or when done 1693 * NULL on disconnect or when done
1660 * @param state current state this peer is in 1694 * @param state current state this peer is in
1661 * @param state_timeout time out for the current state 1695 * @param state_timeout time out for the current state
1662 *
1663 */ 1696 */
1664static void 1697static void
1665process_peer_monitoring_cb (void *cls, 1698process_peer_monitoring_cb (void *cls,
@@ -1684,22 +1717,28 @@ process_peer_monitoring_cb (void *cls,
1684 &operation_timeout, 1717 &operation_timeout,
1685 NULL); 1718 NULL);
1686 1719
1687 if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers, peer))) 1720 if (NULL == (m = GNUNET_CONTAINER_multipeermap_get (monitored_peers,
1721 peer)))
1688 { 1722 {
1689 m = GNUNET_new (struct MonitoredPeer); 1723 m = GNUNET_new (struct MonitoredPeer);
1690 GNUNET_CONTAINER_multipeermap_put (monitored_peers, peer, 1724 GNUNET_CONTAINER_multipeermap_put (monitored_peers,
1691 m, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); 1725 peer,
1726 m,
1727 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
1692 } 1728 }
1693 else 1729 else
1694 { 1730 {
1695 if ( (m->state == state) && 1731 if ( (m->state == state) &&
1696 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) && 1732 (m->state_timeout.abs_value_us == state_timeout.abs_value_us) &&
1697 ((NULL == address) && (NULL == m->address))) 1733 (NULL == address) &&
1734 (NULL == m->address) )
1698 { 1735 {
1699 return; /* No real change */ 1736 return; /* No real change */
1700 } 1737 }
1701 if ( (m->state == state) && ((NULL != address) && (NULL != m->address)) && 1738 if ( (m->state == state) &&
1702 (0 == GNUNET_HELLO_address_cmp(m->address, address))) 1739 (NULL != address) &&
1740 (NULL != m->address) &&
1741 (0 == GNUNET_HELLO_address_cmp(m->address, address)) )
1703 return; /* No real change */ 1742 return; /* No real change */
1704 } 1743 }
1705 1744
@@ -1714,8 +1753,7 @@ process_peer_monitoring_cb (void *cls,
1714 m->state_timeout = state_timeout; 1753 m->state_timeout = state_timeout;
1715 1754
1716 if (NULL != address) 1755 if (NULL != address)
1717 resolve_peer_address (peer, 1756 resolve_peer_address (m->address,
1718 m->address,
1719 numeric, 1757 numeric,
1720 m->state, 1758 m->state,
1721 m->state_timeout); 1759 m->state_timeout);
@@ -1970,11 +2008,14 @@ testservice_task (void *cls,
1970 } 2008 }
1971 else if (monitor_connections) /* -m: List information about peers continuously */ 2009 else if (monitor_connections) /* -m: List information about peers continuously */
1972 { 2010 {
1973 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO); 2011 monitored_peers = GNUNET_CONTAINER_multipeermap_create (10,
2012 GNUNET_NO);
1974 address_resolution_in_progress = GNUNET_YES; 2013 address_resolution_in_progress = GNUNET_YES;
1975 pic = GNUNET_TRANSPORT_monitor_peers (cfg, (NULL == cpid) ? NULL : &pid, 2014 pic = GNUNET_TRANSPORT_monitor_peers (cfg,
1976 GNUNET_NO, TIMEOUT, 2015 (NULL == cpid) ? NULL : &pid,
1977 &process_peer_monitoring_cb, (void *) cfg); 2016 GNUNET_NO,
2017 TIMEOUT,
2018 &process_peer_monitoring_cb, NULL);
1978 } 2019 }
1979 else if (monitor_plugins) /* -P: List information about plugins continuously */ 2020 else if (monitor_plugins) /* -P: List information about plugins continuously */
1980 { 2021 {
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 34d3881f6..874811a7b 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -2385,9 +2385,6 @@ handle_tcp_welcome (void *cls,
2385 session->address, 2385 session->address,
2386 session, 2386 session,
2387 session->scope); 2387 session->scope);
2388 notify_session_monitor (plugin,
2389 session,
2390 GNUNET_TRANSPORT_SS_INIT);
2391 } 2388 }
2392 else 2389 else
2393 { 2390 {
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 477efc0a1..38210f322 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -508,7 +508,9 @@ notify_session_monitor (struct Plugin *plugin,
508 struct GNUNET_TRANSPORT_SessionInfo info; 508 struct GNUNET_TRANSPORT_SessionInfo info;
509 509
510 if (NULL == plugin->sic) 510 if (NULL == plugin->sic)
511 return; 511 return;
512 if (GNUNET_YES == session->in_destroy)
513 return; /* already destroyed, just RC>0 left-over actions */
512 memset (&info, 0, sizeof (info)); 514 memset (&info, 0, sizeof (info));
513 info.state = state; 515 info.state = state;
514 info.is_inbound = GNUNET_SYSERR; /* hard to say */ 516 info.is_inbound = GNUNET_SYSERR; /* hard to say */
@@ -935,7 +937,8 @@ call_continuation (struct UDP_MessageWrapper *udpw,
935 937
936 LOG (GNUNET_ERROR_TYPE_DEBUG, 938 LOG (GNUNET_ERROR_TYPE_DEBUG,
937 "Calling continuation for %u byte message to `%s' with result %s\n", 939 "Calling continuation for %u byte message to `%s' with result %s\n",
938 udpw->payload_size, GNUNET_i2s (&udpw->session->target), 940 udpw->payload_size,
941 GNUNET_i2s (&udpw->session->target),
939 (GNUNET_OK == result) ? "OK" : "SYSERR"); 942 (GNUNET_OK == result) ? "OK" : "SYSERR");
940 943
941 if (udpw->msg_size >= udpw->payload_size) 944 if (udpw->msg_size >= udpw->payload_size)
@@ -952,63 +955,97 @@ call_continuation (struct UDP_MessageWrapper *udpw,
952 if (NULL != udpw->cont) 955 if (NULL != udpw->cont)
953 { 956 {
954 /* Transport continuation */ 957 /* Transport continuation */
955 udpw->cont (udpw->cont_cls, &udpw->session->target, result, 958 udpw->cont (udpw->cont_cls,
956 udpw->payload_size, udpw->msg_size); 959 &udpw->session->target,
960 result,
961 udpw->payload_size,
962 udpw->msg_size);
957 } 963 }
958 GNUNET_STATISTICS_update (plugin->env->stats, 964 GNUNET_STATISTICS_update (plugin->env->stats,
959 "# UDP, unfragmented msgs, messages, sent, success", 1, GNUNET_NO); 965 "# UDP, unfragmented msgs, messages, sent, success",
966 1,
967 GNUNET_NO);
960 GNUNET_STATISTICS_update (plugin->env->stats, 968 GNUNET_STATISTICS_update (plugin->env->stats,
961 "# UDP, unfragmented msgs, bytes payload, sent, success", 969 "# UDP, unfragmented msgs, bytes payload, sent, success",
962 udpw->payload_size, GNUNET_NO); 970 udpw->payload_size,
971 GNUNET_NO);
963 GNUNET_STATISTICS_update (plugin->env->stats, 972 GNUNET_STATISTICS_update (plugin->env->stats,
964 "# UDP, unfragmented msgs, bytes overhead, sent, success", overhead, 973 "# UDP, unfragmented msgs, bytes overhead, sent, success",
965 GNUNET_NO); 974 overhead,
975 GNUNET_NO);
966 GNUNET_STATISTICS_update (plugin->env->stats, 976 GNUNET_STATISTICS_update (plugin->env->stats,
967 "# UDP, total, bytes overhead, sent", overhead, GNUNET_NO); 977 "# UDP, total, bytes overhead, sent",
978 overhead,
979 GNUNET_NO);
968 GNUNET_STATISTICS_update (plugin->env->stats, 980 GNUNET_STATISTICS_update (plugin->env->stats,
969 "# UDP, total, bytes payload, sent", udpw->payload_size, GNUNET_NO); 981 "# UDP, total, bytes payload, sent",
982 udpw->payload_size,
983 GNUNET_NO);
970 break; 984 break;
971 case UMT_MSG_FRAGMENTED_COMPLETE: 985 case UMT_MSG_FRAGMENTED_COMPLETE:
972 GNUNET_assert(NULL != udpw->frag_ctx); 986 GNUNET_assert(NULL != udpw->frag_ctx);
973 if (udpw->frag_ctx->cont != NULL ) 987 if (udpw->frag_ctx->cont != NULL )
974 udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls, &udpw->session->target, 988 udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls,
975 GNUNET_OK, udpw->frag_ctx->payload_size, 989 &udpw->session->target,
976 udpw->frag_ctx->on_wire_size); 990 GNUNET_OK,
991 udpw->frag_ctx->payload_size,
992 udpw->frag_ctx->on_wire_size);
977 GNUNET_STATISTICS_update (plugin->env->stats, 993 GNUNET_STATISTICS_update (plugin->env->stats,
978 "# UDP, fragmented msgs, messages, sent, success", 1, GNUNET_NO); 994 "# UDP, fragmented msgs, messages, sent, success",
995 1,
996 GNUNET_NO);
979 GNUNET_STATISTICS_update (plugin->env->stats, 997 GNUNET_STATISTICS_update (plugin->env->stats,
980 "# UDP, fragmented msgs, bytes payload, sent, success", 998 "# UDP, fragmented msgs, bytes payload, sent, success",
981 udpw->payload_size, GNUNET_NO); 999 udpw->payload_size,
1000 GNUNET_NO);
982 GNUNET_STATISTICS_update (plugin->env->stats, 1001 GNUNET_STATISTICS_update (plugin->env->stats,
983 "# UDP, fragmented msgs, bytes overhead, sent, success", overhead, 1002 "# UDP, fragmented msgs, bytes overhead, sent, success",
984 GNUNET_NO); 1003 overhead,
1004 GNUNET_NO);
985 GNUNET_STATISTICS_update (plugin->env->stats, 1005 GNUNET_STATISTICS_update (plugin->env->stats,
986 "# UDP, total, bytes overhead, sent", overhead, GNUNET_NO); 1006 "# UDP, total, bytes overhead, sent",
1007 overhead,
1008 GNUNET_NO);
987 GNUNET_STATISTICS_update (plugin->env->stats, 1009 GNUNET_STATISTICS_update (plugin->env->stats,
988 "# UDP, total, bytes payload, sent", udpw->payload_size, GNUNET_NO); 1010 "# UDP, total, bytes payload, sent",
1011 udpw->payload_size,
1012 GNUNET_NO);
989 GNUNET_STATISTICS_update (plugin->env->stats, 1013 GNUNET_STATISTICS_update (plugin->env->stats,
990 "# UDP, fragmented msgs, messages, pending", -1, GNUNET_NO); 1014 "# UDP, fragmented msgs, messages, pending",
1015 -1,
1016 GNUNET_NO);
991 break; 1017 break;
992 case UMT_MSG_FRAGMENTED: 1018 case UMT_MSG_FRAGMENTED:
993 /* Fragmented message: enqueue next fragment */ 1019 /* Fragmented message: enqueue next fragment */
994 if (NULL != udpw->cont) 1020 if (NULL != udpw->cont)
995 udpw->cont (udpw->cont_cls, &udpw->session->target, result, 1021 udpw->cont (udpw->cont_cls,
996 udpw->payload_size, udpw->msg_size); 1022 &udpw->session->target,
1023 result,
1024 udpw->payload_size,
1025 udpw->msg_size);
997 GNUNET_STATISTICS_update (plugin->env->stats, 1026 GNUNET_STATISTICS_update (plugin->env->stats,
998 "# UDP, fragmented msgs, fragments, sent, success", 1, GNUNET_NO); 1027 "# UDP, fragmented msgs, fragments, sent, success",
1028 1,
1029 GNUNET_NO);
999 GNUNET_STATISTICS_update (plugin->env->stats, 1030 GNUNET_STATISTICS_update (plugin->env->stats,
1000 "# UDP, fragmented msgs, fragments bytes, sent, success", 1031 "# UDP, fragmented msgs, fragments bytes, sent, success",
1001 udpw->msg_size, GNUNET_NO); 1032 udpw->msg_size,
1033 GNUNET_NO);
1002 break; 1034 break;
1003 case UMT_MSG_ACK: 1035 case UMT_MSG_ACK:
1004 /* No continuation */ 1036 /* No continuation */
1005 GNUNET_STATISTICS_update (plugin->env->stats, 1037 GNUNET_STATISTICS_update (plugin->env->stats,
1006 "# UDP, ACK msgs, messages, sent, success", 1, GNUNET_NO); 1038 "# UDP, ACK msgs, messages, sent, success",
1039 1,
1040 GNUNET_NO);
1007 GNUNET_STATISTICS_update (plugin->env->stats, 1041 GNUNET_STATISTICS_update (plugin->env->stats,
1008 "# UDP, ACK msgs, bytes overhead, sent, success", overhead, 1042 "# UDP, ACK msgs, bytes overhead, sent, success",
1009 GNUNET_NO); 1043 overhead,
1044 GNUNET_NO);
1010 GNUNET_STATISTICS_update (plugin->env->stats, 1045 GNUNET_STATISTICS_update (plugin->env->stats,
1011 "# UDP, total, bytes overhead, sent", overhead, GNUNET_NO); 1046 "# UDP, total, bytes overhead, sent",
1047 overhead,
1048 GNUNET_NO);
1012 break; 1049 break;
1013 default: 1050 default:
1014 GNUNET_break(0); 1051 GNUNET_break(0);
@@ -1021,50 +1058,71 @@ call_continuation (struct UDP_MessageWrapper *udpw,
1021 case UMT_MSG_UNFRAGMENTED: 1058 case UMT_MSG_UNFRAGMENTED:
1022 /* Unfragmented message: failed to send */ 1059 /* Unfragmented message: failed to send */
1023 if (NULL != udpw->cont) 1060 if (NULL != udpw->cont)
1024 udpw->cont (udpw->cont_cls, &udpw->session->target, result, 1061 udpw->cont (udpw->cont_cls,
1025 udpw->payload_size, overhead); 1062 &udpw->session->target,
1063 result,
1064 udpw->payload_size,
1065 overhead);
1026 GNUNET_STATISTICS_update (plugin->env->stats, 1066 GNUNET_STATISTICS_update (plugin->env->stats,
1027 "# UDP, unfragmented msgs, messages, sent, failure", 1, GNUNET_NO); 1067 "# UDP, unfragmented msgs, messages, sent, failure",
1068 1,
1069 GNUNET_NO);
1028 GNUNET_STATISTICS_update (plugin->env->stats, 1070 GNUNET_STATISTICS_update (plugin->env->stats,
1029 "# UDP, unfragmented msgs, bytes payload, sent, failure", 1071 "# UDP, unfragmented msgs, bytes payload, sent, failure",
1030 udpw->payload_size, GNUNET_NO); 1072 udpw->payload_size,
1073 GNUNET_NO);
1031 GNUNET_STATISTICS_update (plugin->env->stats, 1074 GNUNET_STATISTICS_update (plugin->env->stats,
1032 "# UDP, unfragmented msgs, bytes overhead, sent, failure", overhead, 1075 "# UDP, unfragmented msgs, bytes overhead, sent, failure",
1033 GNUNET_NO); 1076 overhead,
1077 GNUNET_NO);
1034 break; 1078 break;
1035 case UMT_MSG_FRAGMENTED_COMPLETE: 1079 case UMT_MSG_FRAGMENTED_COMPLETE:
1036 GNUNET_assert(NULL != udpw->frag_ctx); 1080 GNUNET_assert (NULL != udpw->frag_ctx);
1037 if (udpw->frag_ctx->cont != NULL ) 1081 if (udpw->frag_ctx->cont != NULL)
1038 udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls, &udpw->session->target, 1082 udpw->frag_ctx->cont (udpw->frag_ctx->cont_cls,
1039 GNUNET_SYSERR, udpw->frag_ctx->payload_size, 1083 &udpw->session->target,
1040 udpw->frag_ctx->on_wire_size); 1084 GNUNET_SYSERR,
1085 udpw->frag_ctx->payload_size,
1086 udpw->frag_ctx->on_wire_size);
1041 GNUNET_STATISTICS_update (plugin->env->stats, 1087 GNUNET_STATISTICS_update (plugin->env->stats,
1042 "# UDP, fragmented msgs, messages, sent, failure", 1, GNUNET_NO); 1088 "# UDP, fragmented msgs, messages, sent, failure",
1089 1,
1090 GNUNET_NO);
1043 GNUNET_STATISTICS_update (plugin->env->stats, 1091 GNUNET_STATISTICS_update (plugin->env->stats,
1044 "# UDP, fragmented msgs, bytes payload, sent, failure", 1092 "# UDP, fragmented msgs, bytes payload, sent, failure",
1045 udpw->payload_size, GNUNET_NO); 1093 udpw->payload_size,
1094 GNUNET_NO);
1046 GNUNET_STATISTICS_update (plugin->env->stats, 1095 GNUNET_STATISTICS_update (plugin->env->stats,
1047 "# UDP, fragmented msgs, bytes payload, sent, failure", overhead, 1096 "# UDP, fragmented msgs, bytes payload, sent, failure",
1048 GNUNET_NO); 1097 overhead,
1098 GNUNET_NO);
1049 GNUNET_STATISTICS_update (plugin->env->stats, 1099 GNUNET_STATISTICS_update (plugin->env->stats,
1050 "# UDP, fragmented msgs, bytes payload, sent, failure", overhead, 1100 "# UDP, fragmented msgs, bytes payload, sent, failure",
1051 GNUNET_NO); 1101 overhead,
1102 GNUNET_NO);
1052 GNUNET_STATISTICS_update (plugin->env->stats, 1103 GNUNET_STATISTICS_update (plugin->env->stats,
1053 "# UDP, fragmented msgs, messages, pending", -1, GNUNET_NO); 1104 "# UDP, fragmented msgs, messages, pending",
1105 -1,
1106 GNUNET_NO);
1054 break; 1107 break;
1055 case UMT_MSG_FRAGMENTED: 1108 case UMT_MSG_FRAGMENTED:
1056 GNUNET_assert(NULL != udpw->frag_ctx); 1109 GNUNET_assert (NULL != udpw->frag_ctx);
1057 /* Fragmented message: failed to send */ 1110 /* Fragmented message: failed to send */
1058 GNUNET_STATISTICS_update (plugin->env->stats, 1111 GNUNET_STATISTICS_update (plugin->env->stats,
1059 "# UDP, fragmented msgs, fragments, sent, failure", 1, GNUNET_NO); 1112 "# UDP, fragmented msgs, fragments, sent, failure",
1113 1,
1114 GNUNET_NO);
1060 GNUNET_STATISTICS_update (plugin->env->stats, 1115 GNUNET_STATISTICS_update (plugin->env->stats,
1061 "# UDP, fragmented msgs, fragments bytes, sent, failure", 1116 "# UDP, fragmented msgs, fragments bytes, sent, failure",
1062 udpw->msg_size, GNUNET_NO); 1117 udpw->msg_size,
1118 GNUNET_NO);
1063 break; 1119 break;
1064 case UMT_MSG_ACK: 1120 case UMT_MSG_ACK:
1065 /* ACK message: failed to send */ 1121 /* ACK message: failed to send */
1066 GNUNET_STATISTICS_update (plugin->env->stats, 1122 GNUNET_STATISTICS_update (plugin->env->stats,
1067 "# UDP, ACK msgs, messages, sent, failure", 1, GNUNET_NO); 1123 "# UDP, ACK msgs, messages, sent, failure",
1124 1,
1125 GNUNET_NO);
1068 break; 1126 break;
1069 default: 1127 default:
1070 GNUNET_break(0); 1128 GNUNET_break(0);
@@ -1224,7 +1282,14 @@ dequeue (struct Plugin *plugin,
1224 1282
1225 1283
1226/** 1284/**
1227 * FIXME. 1285 * We have completed our (attempt) to transmit a message
1286 * that had to be fragmented -- either because we got an
1287 * ACK saying that all fragments were received, or because
1288 * of timeout / disconnect. Clean up our state.
1289 *
1290 * @param fc fragmentation context to clean up
1291 * @param result #GNUNET_OK if we succeeded (got ACK),
1292 * #GNUNET_SYSERR if the transmission failed
1228 */ 1293 */
1229static void 1294static void
1230fragmented_message_done (struct UDP_FragmentationContext *fc, 1295fragmented_message_done (struct UDP_FragmentationContext *fc,
@@ -1258,11 +1323,13 @@ fragmented_message_done (struct UDP_FragmentationContext *fc,
1258 while (NULL != udpw) 1323 while (NULL != udpw)
1259 { 1324 {
1260 tmp = udpw->next; 1325 tmp = udpw->next;
1261 if ((udpw->frag_ctx != NULL )&& (udpw->frag_ctx == s->frag_ctx)){ 1326 if ( (udpw->frag_ctx != NULL) &&
1262 dequeue (plugin, udpw); 1327 (udpw->frag_ctx == s->frag_ctx) )
1263 call_continuation (udpw, GNUNET_SYSERR); 1328 {
1264 GNUNET_free (udpw); 1329 dequeue (plugin, udpw);
1265 } 1330 call_continuation (udpw, GNUNET_SYSERR);
1331 GNUNET_free (udpw);
1332 }
1266 udpw = tmp; 1333 udpw = tmp;
1267 } 1334 }
1268 } 1335 }
@@ -1559,34 +1626,9 @@ reschedule_session_timeout (struct Session *s)
1559 1626
1560 1627
1561/** 1628/**
1562 * FIXME.
1563 */
1564static struct Session *
1565create_session (struct Plugin *plugin,
1566 const struct GNUNET_HELLO_Address *address)
1567{
1568 struct Session *s;
1569
1570 s = GNUNET_new (struct Session);
1571 s->plugin = plugin;
1572 s->address = GNUNET_HELLO_address_copy (address);
1573 s->target = address->peer;
1574 s->last_expected_ack_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
1575 250);
1576 s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS;
1577 s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO_ABS;
1578 s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO;
1579 s->timeout = GNUNET_TIME_relative_to_absolute (UDP_SESSION_TIME_OUT);
1580 s->timeout_task = GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT,
1581 &session_timeout, s);
1582 return s;
1583}
1584
1585
1586/**
1587 * Function obtain the network type for a session 1629 * Function obtain the network type for a session
1588 * 1630 *
1589 * @param cls closure ('struct Plugin*') 1631 * @param cls closure (`struct Plugin *`)
1590 * @param session the session 1632 * @param session the session
1591 * @return the network type 1633 * @return the network type
1592 */ 1634 */
@@ -1740,7 +1782,18 @@ udp_plugin_create_session (void *cls,
1740 struct Plugin *plugin = cls; 1782 struct Plugin *plugin = cls;
1741 struct Session *s; 1783 struct Session *s;
1742 1784
1743 s = create_session (plugin, address); 1785 s = GNUNET_new (struct Session);
1786 s->plugin = plugin;
1787 s->address = GNUNET_HELLO_address_copy (address);
1788 s->target = address->peer;
1789 s->last_expected_ack_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
1790 250);
1791 s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS;
1792 s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO_ABS;
1793 s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO;
1794 s->timeout = GNUNET_TIME_relative_to_absolute (UDP_SESSION_TIME_OUT);
1795 s->timeout_task = GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT,
1796 &session_timeout, s);
1744 s->scope = network_type; 1797 s->scope = network_type;
1745 1798
1746 LOG (GNUNET_ERROR_TYPE_DEBUG, 1799 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1768,7 +1821,7 @@ udp_plugin_create_session (void *cls,
1768 * notify the plugin that a session is still active and in use and 1821 * notify the plugin that a session is still active and in use and
1769 * therefore the session timeout for this session has to be updated 1822 * therefore the session timeout for this session has to be updated
1770 * 1823 *
1771 * @param cls closure 1824 * @param cls closure with the `struct Plugin`
1772 * @param peer which peer was the session for 1825 * @param peer which peer was the session for
1773 * @param session which session is being updated 1826 * @param session which session is being updated
1774 */ 1827 */
@@ -1796,7 +1849,7 @@ udp_plugin_update_session_timeout (void *cls,
1796 * Creates a new outbound session the transport service will use to 1849 * Creates a new outbound session the transport service will use to
1797 * send data to the peer. 1850 * send data to the peer.
1798 * 1851 *
1799 * @param cls the plugin 1852 * @param cls the `struct Plugin *`
1800 * @param address the address 1853 * @param address the address
1801 * @return the session or NULL of max connections exceeded 1854 * @return the session or NULL of max connections exceeded
1802 */ 1855 */
@@ -1812,16 +1865,20 @@ udp_plugin_get_session (void *cls,
1812 1865
1813 if (NULL == address) 1866 if (NULL == address)
1814 { 1867 {
1815 GNUNET_break(0); 1868 GNUNET_break (0);
1816 return NULL; 1869 return NULL;
1817 } 1870 }
1818 if ( (address->address_length != sizeof(struct IPv4UdpAddress)) && 1871 if ( (address->address_length != sizeof(struct IPv4UdpAddress)) &&
1819 (address->address_length != sizeof(struct IPv6UdpAddress)) ) 1872 (address->address_length != sizeof(struct IPv6UdpAddress)) )
1873 {
1874 GNUNET_break_op (0);
1820 return NULL; 1875 return NULL;
1876 }
1821 if (NULL != (s = udp_plugin_lookup_session (cls, 1877 if (NULL != (s = udp_plugin_lookup_session (cls,
1822 address))) 1878 address)))
1823 return s; 1879 return s;
1824 1880
1881 /* need to create new session */
1825 if (sizeof (struct IPv4UdpAddress) == address->address_length) 1882 if (sizeof (struct IPv4UdpAddress) == address->address_length)
1826 { 1883 {
1827 struct sockaddr_in v4; 1884 struct sockaddr_in v4;
@@ -1838,7 +1895,7 @@ udp_plugin_get_session (void *cls,
1838 (const struct sockaddr *) &v4, 1895 (const struct sockaddr *) &v4,
1839 sizeof (v4)); 1896 sizeof (v4));
1840 } 1897 }
1841 else if (sizeof (struct IPv6UdpAddress) == address->address_length) 1898 if (sizeof (struct IPv6UdpAddress) == address->address_length)
1842 { 1899 {
1843 struct sockaddr_in6 v6; 1900 struct sockaddr_in6 v6;
1844 1901
@@ -1854,9 +1911,9 @@ udp_plugin_get_session (void *cls,
1854 (const struct sockaddr *) &v6, 1911 (const struct sockaddr *) &v6,
1855 sizeof (v6)); 1912 sizeof (v6));
1856 } 1913 }
1857 1914 return udp_plugin_create_session (cls,
1858 /* otherwise create new */ 1915 address,
1859 return udp_plugin_create_session (cls, address, network_type); 1916 network_type);
1860} 1917}
1861 1918
1862 1919
@@ -2007,8 +2064,6 @@ udp_plugin_send (void *cls,
2007 struct UDP_MessageWrapper * udpw; 2064 struct UDP_MessageWrapper * udpw;
2008 struct UDPMessage *udp; 2065 struct UDPMessage *udp;
2009 char mbuf[udpmlen]; 2066 char mbuf[udpmlen];
2010 GNUNET_assert(plugin != NULL);
2011 GNUNET_assert(s != NULL);
2012 2067
2013 if ( (s->address->address_length == sizeof(struct IPv6UdpAddress)) && 2068 if ( (s->address->address_length == sizeof(struct IPv6UdpAddress)) &&
2014 (plugin->sockv6 == NULL) ) 2069 (plugin->sockv6 == NULL) )
@@ -2239,6 +2294,7 @@ process_udp_message (struct Plugin *plugin,
2239 struct Session *s; 2294 struct Session *s;
2240 struct GNUNET_HELLO_Address *address; 2295 struct GNUNET_HELLO_Address *address;
2241 2296
2297 GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != network_type);
2242 if (0 != ntohl (msg->reserved)) 2298 if (0 != ntohl (msg->reserved))
2243 { 2299 {
2244 GNUNET_break_op(0); 2300 GNUNET_break_op(0);
@@ -2486,7 +2542,6 @@ read_process_ack (struct Plugin *plugin,
2486 udp_addr, 2542 udp_addr,
2487 udp_addr_len)); 2543 udp_addr_len));
2488 2544
2489
2490 /* Remove fragmented message after successful sending */ 2545 /* Remove fragmented message after successful sending */
2491 fragmented_message_done (s->frag_ctx, 2546 fragmented_message_done (s->frag_ctx,
2492 GNUNET_OK); 2547 GNUNET_OK);
@@ -2734,24 +2789,30 @@ udp_select_read (struct Plugin *plugin,
2734 2789
2735 2790
2736/** 2791/**
2737 * FIXME. 2792 * Removes messages from the transmission queue that have
2793 * timed out, and then selects a message that should be
2794 * transmitted next.
2795 *
2796 * @param plugin the UDP plugin
2797 * @param sock which socket should we process the queue for (v4 or v6)
2798 * @return message selected for transmission, or NULL for none
2738 */ 2799 */
2739static struct UDP_MessageWrapper * 2800static struct UDP_MessageWrapper *
2740remove_timeout_messages_and_select (struct UDP_MessageWrapper *head, 2801remove_timeout_messages_and_select (struct Plugin *plugin,
2741 struct GNUNET_NETWORK_Handle *sock) 2802 struct GNUNET_NETWORK_Handle *sock)
2742{ 2803{
2743 struct UDP_MessageWrapper *udpw = NULL; 2804 struct UDP_MessageWrapper *udpw = NULL;
2744 struct GNUNET_TIME_Relative remaining; 2805 struct GNUNET_TIME_Relative remaining;
2745 struct Session *session; 2806 struct Session *session;
2746 struct Plugin *plugin;
2747 int removed; 2807 int removed;
2748 2808
2749 removed = GNUNET_NO; 2809 removed = GNUNET_NO;
2750 udpw = head; 2810 udpw = (sock == plugin->sockv4)
2811 ? plugin->ipv4_queue_head
2812 : plugin->ipv6_queue_head;
2751 while (NULL != udpw) 2813 while (NULL != udpw)
2752 { 2814 {
2753 session = udpw->session; 2815 session = udpw->session;
2754 plugin = session->plugin;
2755 /* Find messages with timeout */ 2816 /* Find messages with timeout */
2756 remaining = GNUNET_TIME_absolute_get_remaining (udpw->timeout); 2817 remaining = GNUNET_TIME_absolute_get_remaining (udpw->timeout);
2757 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us) 2818 if (GNUNET_TIME_UNIT_ZERO.rel_value_us == remaining.rel_value_us)
@@ -2797,12 +2858,13 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2797 "# UDP, total, messages, sent, timeout", 2858 "# UDP, total, messages, sent, timeout",
2798 1, 2859 1,
2799 GNUNET_NO); 2860 GNUNET_NO);
2800 call_continuation (udpw, GNUNET_SYSERR); 2861 call_continuation (udpw,
2862 GNUNET_SYSERR);
2801 LOG (GNUNET_ERROR_TYPE_DEBUG, 2863 LOG (GNUNET_ERROR_TYPE_DEBUG,
2802 "Fragment for message for peer `%s' with size %u timed out\n", 2864 "Fragment for message for peer `%s' with size %u timed out\n",
2803 GNUNET_i2s (&udpw->session->target), 2865 GNUNET_i2s (&udpw->session->target),
2804 udpw->frag_ctx->payload_size); 2866 udpw->frag_ctx->payload_size);
2805 2867
2806 GNUNET_STATISTICS_update (plugin->env->stats, 2868 GNUNET_STATISTICS_update (plugin->env->stats,
2807 "# UDP, fragmented msgs, messages, sent, timeout", 2869 "# UDP, fragmented msgs, messages, sent, timeout",
2808 1, 2870 1,
@@ -2812,7 +2874,8 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2812 udpw->frag_ctx->payload_size, 2874 udpw->frag_ctx->payload_size,
2813 GNUNET_NO); 2875 GNUNET_NO);
2814 /* Remove fragmented message due to timeout */ 2876 /* Remove fragmented message due to timeout */
2815 fragmented_message_done (udpw->frag_ctx, GNUNET_SYSERR); 2877 fragmented_message_done (udpw->frag_ctx,
2878 GNUNET_SYSERR);
2816 break; 2879 break;
2817 case UMT_MSG_ACK: 2880 case UMT_MSG_ACK:
2818 GNUNET_STATISTICS_update (plugin->env->stats, 2881 GNUNET_STATISTICS_update (plugin->env->stats,
@@ -2827,10 +2890,12 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2827 "ACK Message for peer `%s' with size %u timed out\n", 2890 "ACK Message for peer `%s' with size %u timed out\n",
2828 GNUNET_i2s (&udpw->session->target), 2891 GNUNET_i2s (&udpw->session->target),
2829 udpw->payload_size); 2892 udpw->payload_size);
2830 call_continuation (udpw, GNUNET_SYSERR); 2893 call_continuation (udpw,
2894 GNUNET_SYSERR);
2831 removed = GNUNET_YES; 2895 removed = GNUNET_YES;
2832 dequeue (plugin, udpw); 2896 dequeue (plugin,
2833 GNUNET_free(udpw); 2897 udpw);
2898 GNUNET_free (udpw);
2834 break; 2899 break;
2835 default: 2900 default:
2836 break; 2901 break;
@@ -2867,8 +2932,10 @@ remove_timeout_messages_and_select (struct UDP_MessageWrapper *head,
2867 /* Message is delayed, try next */ 2932 /* Message is delayed, try next */
2868 LOG (GNUNET_ERROR_TYPE_DEBUG, 2933 LOG (GNUNET_ERROR_TYPE_DEBUG,
2869 "Message for peer `%s' (%u bytes) is delayed for %s\n", 2934 "Message for peer `%s' (%u bytes) is delayed for %s\n",
2870 GNUNET_i2s (&udpw->session->target), udpw->payload_size, 2935 GNUNET_i2s (&udpw->session->target),
2871 GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES)); 2936 udpw->payload_size,
2937 GNUNET_STRINGS_relative_time_to_string (remaining,
2938 GNUNET_YES));
2872 udpw = udpw->next; 2939 udpw = udpw->next;
2873 } 2940 }
2874 } 2941 }
@@ -2931,7 +2998,12 @@ analyze_send_error (struct Plugin *plugin,
2931 2998
2932 2999
2933/** 3000/**
2934 * FIXME. 3001 * It is time to try to transmit a UDP message. Select one
3002 * and send.
3003 *
3004 * @param plugin the plugin
3005 * @param sock which socket (v4/v6) to send on
3006 * @return number of bytes transmitted, #GNUNET_SYSERR on failure
2935 */ 3007 */
2936static size_t 3008static size_t
2937udp_select_send (struct Plugin *plugin, 3009udp_select_send (struct Plugin *plugin,
@@ -2947,9 +3019,7 @@ udp_select_send (struct Plugin *plugin,
2947 struct UDP_MessageWrapper *udpw; 3019 struct UDP_MessageWrapper *udpw;
2948 3020
2949 /* Find message to send */ 3021 /* Find message to send */
2950 udpw = remove_timeout_messages_and_select ((sock == plugin->sockv4) 3022 udpw = remove_timeout_messages_and_select (plugin,
2951 ? plugin->ipv4_queue_head
2952 : plugin->ipv6_queue_head,
2953 sock); 3023 sock);
2954 if (NULL == udpw) 3024 if (NULL == udpw)
2955 return 0; /* No message to send */ 3025 return 0; /* No message to send */
@@ -2963,7 +3033,9 @@ udp_select_send (struct Plugin *plugin,
2963 a4.sin_len = sizeof (a4); 3033 a4.sin_len = sizeof (a4);
2964#endif 3034#endif
2965 a4.sin_port = u4->u4_port; 3035 a4.sin_port = u4->u4_port;
2966 memcpy (&a4.sin_addr, &u4->ipv4_addr, sizeof(struct in_addr)); 3036 memcpy (&a4.sin_addr,
3037 &u4->ipv4_addr,
3038 sizeof(struct in_addr));
2967 a = (struct sockaddr *) &a4; 3039 a = (struct sockaddr *) &a4;
2968 slen = sizeof (a4); 3040 slen = sizeof (a4);
2969 } 3041 }
@@ -2982,15 +3054,16 @@ udp_select_send (struct Plugin *plugin,
2982 } 3054 }
2983 else 3055 else
2984 { 3056 {
2985 call_continuation (udpw, GNUNET_OK); 3057 call_continuation (udpw,
2986 dequeue (plugin, udpw); 3058 GNUNET_OK);
3059 dequeue (plugin,
3060 udpw);
2987 notify_session_monitor (plugin, 3061 notify_session_monitor (plugin,
2988 udpw->session, 3062 udpw->session,
2989 GNUNET_TRANSPORT_SS_UPDATE); 3063 GNUNET_TRANSPORT_SS_UPDATE);
2990 GNUNET_free (udpw); 3064 GNUNET_free (udpw);
2991 return GNUNET_SYSERR; 3065 return GNUNET_SYSERR;
2992 } 3066 }
2993
2994 sent = GNUNET_NETWORK_socket_sendto (sock, 3067 sent = GNUNET_NETWORK_socket_sendto (sock,
2995 udpw->msg_buf, 3068 udpw->msg_buf,
2996 udpw->msg_size, 3069 udpw->msg_size,
@@ -2999,12 +3072,20 @@ udp_select_send (struct Plugin *plugin,
2999 if (GNUNET_SYSERR == sent) 3072 if (GNUNET_SYSERR == sent)
3000 { 3073 {
3001 /* Failure */ 3074 /* Failure */
3002 analyze_send_error (plugin, a, slen, errno); 3075 analyze_send_error (plugin,
3003 call_continuation (udpw, GNUNET_SYSERR); 3076 a,
3077 slen,
3078 errno);
3079 call_continuation (udpw,
3080 GNUNET_SYSERR);
3004 GNUNET_STATISTICS_update (plugin->env->stats, 3081 GNUNET_STATISTICS_update (plugin->env->stats,
3005 "# UDP, total, bytes, sent, failure", sent, GNUNET_NO); 3082 "# UDP, total, bytes, sent, failure",
3083 sent,
3084 GNUNET_NO);
3006 GNUNET_STATISTICS_update (plugin->env->stats, 3085 GNUNET_STATISTICS_update (plugin->env->stats,
3007 "# UDP, total, messages, sent, failure", 1, GNUNET_NO); 3086 "# UDP, total, messages, sent, failure",
3087 1,
3088 GNUNET_NO);
3008 } 3089 }
3009 else 3090 else
3010 { 3091 {
@@ -3032,7 +3113,7 @@ udp_select_send (struct Plugin *plugin,
3032 notify_session_monitor (plugin, 3113 notify_session_monitor (plugin,
3033 udpw->session, 3114 udpw->session,
3034 GNUNET_TRANSPORT_SS_UPDATE); 3115 GNUNET_TRANSPORT_SS_UPDATE);
3035 GNUNET_free(udpw); 3116 GNUNET_free (udpw);
3036 return sent; 3117 return sent;
3037} 3118}
3038 3119
diff --git a/src/transport/transport_api_monitor_plugins.c b/src/transport/transport_api_monitor_plugins.c
index 7c11194f2..f313bdfe9 100644
--- a/src/transport/transport_api_monitor_plugins.c
+++ b/src/transport/transport_api_monitor_plugins.c
@@ -179,21 +179,6 @@ free_entry (void *cls,
179 179
180 180
181/** 181/**
182 * We got disconnected, remove all existing entries from
183 * the map and notify client.
184 *
185 * @param pm montitor that got disconnected
186 */
187static void
188clear_map (struct GNUNET_TRANSPORT_PluginMonitor *pm)
189{
190 GNUNET_CONTAINER_multihashmap32_iterate (pm->sessions,
191 &free_entry,
192 pm);
193}
194
195
196/**
197 * Cut the existing connection and reconnect. 182 * Cut the existing connection and reconnect.
198 * 183 *
199 * @param pm our context 184 * @param pm our context
@@ -203,7 +188,9 @@ reconnect_plugin_ctx (struct GNUNET_TRANSPORT_PluginMonitor *pm)
203{ 188{
204 GNUNET_CLIENT_disconnect (pm->client); 189 GNUNET_CLIENT_disconnect (pm->client);
205 pm->client = NULL; 190 pm->client = NULL;
206 clear_map (pm); 191 GNUNET_CONTAINER_multihashmap32_iterate (pm->sessions,
192 &free_entry,
193 pm);
207 pm->backoff = GNUNET_TIME_STD_BACKOFF (pm->backoff); 194 pm->backoff = GNUNET_TIME_STD_BACKOFF (pm->backoff);
208 pm->reconnect_task = GNUNET_SCHEDULER_add_delayed (pm->backoff, 195 pm->reconnect_task = GNUNET_SCHEDULER_add_delayed (pm->backoff,
209 &do_plugin_connect, 196 &do_plugin_connect,
@@ -447,7 +434,9 @@ GNUNET_TRANSPORT_monitor_plugins_cancel (struct GNUNET_TRANSPORT_PluginMonitor *
447 GNUNET_SCHEDULER_cancel (pm->reconnect_task); 434 GNUNET_SCHEDULER_cancel (pm->reconnect_task);
448 pm->reconnect_task = NULL; 435 pm->reconnect_task = NULL;
449 } 436 }
450 clear_map (pm); 437 GNUNET_CONTAINER_multihashmap32_iterate (pm->sessions,
438 &free_entry,
439 pm);
451 GNUNET_CONTAINER_multihashmap32_destroy (pm->sessions); 440 GNUNET_CONTAINER_multihashmap32_destroy (pm->sessions);
452 GNUNET_free (pm); 441 GNUNET_free (pm);
453} 442}