aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-transport.c102
1 files changed, 68 insertions, 34 deletions
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index f4895e154..e07ae78dc 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -1540,10 +1540,70 @@ struct PluginMonitorAddress
1540 * Resolved address as string. 1540 * Resolved address as string.
1541 */ 1541 */
1542 char *str; 1542 char *str;
1543
1544 /**
1545 * Last event we got and did not yet print because
1546 * @e str was NULL (address not yet resolved).
1547 */
1548 struct GNUNET_TRANSPORT_SessionInfo si;
1543}; 1549};
1544 1550
1545 1551
1546/** 1552/**
1553 * Print information about a plugin monitoring event.
1554 *
1555 * @param addr out internal context
1556 * @param info the monitoring information
1557 */
1558static void
1559print_plugin_event_info (struct PluginMonitorAddress *addr,
1560 const struct GNUNET_TRANSPORT_SessionInfo *info)
1561{
1562 const char *state;
1563
1564 switch (info->state)
1565 {
1566 case GNUNET_TRANSPORT_SS_INIT:
1567 state = "INIT";
1568 break;
1569 case GNUNET_TRANSPORT_SS_HANDSHAKE:
1570 state = "HANDSHAKE";
1571 break;
1572 case GNUNET_TRANSPORT_SS_UP:
1573 state = "UP";
1574 break;
1575 case GNUNET_TRANSPORT_SS_UPDATE:
1576 state = "UPDATE";
1577 break;
1578 case GNUNET_TRANSPORT_SS_DONE:
1579 state = "DONE";
1580 break;
1581 default:
1582 state = "UNKNOWN";
1583 break;
1584 }
1585 fprintf (stdout,
1586 "%s: state %s timeout in %s @ %s%s\n",
1587 GNUNET_i2s (&info->address->peer),
1588 state,
1589 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (info->session_timeout),
1590 GNUNET_YES),
1591 addr->str,
1592 (info->is_inbound == GNUNET_YES) ? " (INBOUND)" : "");
1593 fprintf (stdout,
1594 "%s: queue has %3u messages and %6u bytes\n",
1595 GNUNET_i2s (&info->address->peer),
1596 info->num_msg_pending,
1597 info->num_bytes_pending);
1598 if (0 != GNUNET_TIME_absolute_get_remaining (info->receive_delay).rel_value_us)
1599 fprintf (stdout,
1600 "%s: receiving blocked until %s\n",
1601 GNUNET_i2s (&info->address->peer),
1602 GNUNET_STRINGS_absolute_time_to_string (info->receive_delay));
1603}
1604
1605
1606/**
1547 * Function called with a textual representation of an address. This 1607 * Function called with a textual representation of an address. This
1548 * function will be called several times with different possible 1608 * function will be called several times with different possible
1549 * textual representations, and a last time with @a address being NULL 1609 * textual representations, and a last time with @a address being NULL
@@ -1574,6 +1634,8 @@ address_cb (void *cls,
1574 if (NULL != addr->str) 1634 if (NULL != addr->str)
1575 return; 1635 return;
1576 addr->str = GNUNET_strdup (address); 1636 addr->str = GNUNET_strdup (address);
1637 print_plugin_event_info (addr,
1638 &addr->si);
1577} 1639}
1578 1640
1579 1641
@@ -1600,7 +1662,6 @@ plugin_monitoring_cb (void *cls,
1600 void **session_ctx, 1662 void **session_ctx,
1601 const struct GNUNET_TRANSPORT_SessionInfo *info) 1663 const struct GNUNET_TRANSPORT_SessionInfo *info)
1602{ 1664{
1603 const char *state;
1604 struct PluginMonitorAddress *addr; 1665 struct PluginMonitorAddress *addr;
1605 1666
1606 if ( (NULL == info) && 1667 if ( (NULL == info) &&
@@ -1632,44 +1693,17 @@ plugin_monitoring_cb (void *cls,
1632 addr = GNUNET_new (struct PluginMonitorAddress); 1693 addr = GNUNET_new (struct PluginMonitorAddress);
1633 addr->asc = GNUNET_TRANSPORT_address_to_string (cfg, 1694 addr->asc = GNUNET_TRANSPORT_address_to_string (cfg,
1634 info->address, 1695 info->address,
1635 GNUNET_NO, 1696 numeric,
1636 GNUNET_TIME_UNIT_FOREVER_REL, 1697 GNUNET_TIME_UNIT_FOREVER_REL,
1637 &address_cb, 1698 &address_cb,
1638 addr); 1699 addr);
1639 *session_ctx = addr; 1700 *session_ctx = addr;
1640 } 1701 }
1641 switch (info->state) 1702 if (NULL == addr->str)
1642 { 1703 addr->si = *info;
1643 case GNUNET_TRANSPORT_SS_INIT: 1704 else
1644 state = "INIT"; 1705 print_plugin_event_info (addr,
1645 break; 1706 info);
1646 case GNUNET_TRANSPORT_SS_HANDSHAKE:
1647 state = "HANDSHAKE";
1648 break;
1649 case GNUNET_TRANSPORT_SS_UP:
1650 state = "UP";
1651 break;
1652 case GNUNET_TRANSPORT_SS_UPDATE:
1653 state = "UPDATE";
1654 break;
1655 case GNUNET_TRANSPORT_SS_DONE:
1656 state = "DONE";
1657 break;
1658 default:
1659 state = "UNKNOWN";
1660 break;
1661 }
1662 fprintf (stdout,
1663 "%s: %s %s (# %u/%u b) blocked until %s timeout in %s [%s]\n",
1664 GNUNET_i2s (&info->address->peer),
1665 addr->str,
1666 (info->is_inbound == GNUNET_YES) ? "<-" : ((info->is_inbound == GNUNET_NO) ? "->" : "<>"),
1667 info->num_msg_pending,
1668 info->num_bytes_pending,
1669 GNUNET_STRINGS_absolute_time_to_string (info->receive_delay),
1670 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (info->session_timeout),
1671 GNUNET_YES),
1672 state);
1673 if (GNUNET_TRANSPORT_SS_DONE == info->state) 1707 if (GNUNET_TRANSPORT_SS_DONE == info->state)
1674 { 1708 {
1675 if (NULL != addr->asc) 1709 if (NULL != addr->asc)