aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2014-01-06 04:38:54 +0000
committerBart Polot <bart@net.in.tum.de>2014-01-06 04:38:54 +0000
commit54fa2add0f3ed4941e7f7c1d7e9a8d11f4d1c3fc (patch)
tree5138b1b797f5ca857a0dc2e586827398773412bb /src
parent8a63b822c0125f5a5bd0a4ce7113379327f8edfb (diff)
downloadgnunet-54fa2add0f3ed4941e7f7c1d7e9a8d11f4d1c3fc.tar.gz
gnunet-54fa2add0f3ed4941e7f7c1d7e9a8d11f4d1c3fc.zip
- add -i function back to CLI
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-mesh.c55
-rw-r--r--src/mesh/gnunet-service-mesh_local.c22
-rw-r--r--src/mesh/mesh_api.c122
3 files changed, 116 insertions, 83 deletions
diff --git a/src/mesh/gnunet-mesh.c b/src/mesh/gnunet-mesh.c
index 340f03821..eaa9c09fd 100644
--- a/src/mesh/gnunet-mesh.c
+++ b/src/mesh/gnunet-mesh.c
@@ -425,40 +425,52 @@ data_callback (void *cls,
425 425
426 426
427/** 427/**
428 * Method called to retrieve information about each tunnel the mesh peer 428 * Method called to retrieve information about all tunnels in MESH.
429 * is aware of.
430 * 429 *
431 * @param cls Closure. 430 * @param cls Closure.
432 * @param tunnel_number Tunnel number. 431 * @param peer Destination peer.
433 * @param origin that started the tunnel (owner). 432 * @param channels Number of channels.
434 * @param target other endpoint of the tunnel 433 * @param connections Number of connections.
434 * @param estate Encryption state.
435 * @param cstate Connectivity state.
435 */ 436 */
436void /* FIXME static */ 437void
437tunnels_callback (void *cls, 438tunnels_callback (void *cls,
438 uint32_t tunnel_number, 439 const struct GNUNET_PeerIdentity *peer,
439 const struct GNUNET_PeerIdentity *origin, 440 unsigned int channels,
440 const struct GNUNET_PeerIdentity *target) 441 unsigned int connections,
442 unsigned int estate,
443 unsigned int cstate)
441{ 444{
442 FPRINTF (stdout, "Tunnel %s [%u]\n", 445 FPRINTF (stdout, "%s [%u, %u] CH: %u, C: %u\n",
443 GNUNET_i2s_full (origin), tunnel_number); 446 GNUNET_i2s_full (peer), estate, cstate, channels, connections);
444 FPRINTF (stdout, "\n");
445} 447}
446 448
447 449
448/** 450/**
449 * Method called to retrieve information about each tunnel the mesh peer 451 * Method called to retrieve information about a specific tunnel the mesh peer
450 * is aware of. 452 * has established, o`r is trying to establish.
451 * 453 *
452 * @param cls Closure. 454 * @param cls Closure.
453 * @param peer Peer in the tunnel's tree. 455 * @param peer Peer towards whom the tunnel is directed.
454 * @param parent Parent of the current peer. All 0 when peer is root. 456 * @param channels Number of channels.
455 * 457 * @param connections Number of connections.
458 * @param estate Encryption status.
459 * @param cstate Connectivity status.
456 */ 460 */
457void /* FIXME static */ 461void
458tunnel_callback (void *cls, 462tunnel_callback (void *cls,
459 const struct GNUNET_PeerIdentity *peer, 463 const struct GNUNET_PeerIdentity *peer,
460 const struct GNUNET_PeerIdentity *parent) 464 unsigned int channels,
465 unsigned int connections,
466 unsigned int estate,
467 unsigned int cstate)
461{ 468{
469 FPRINTF (stdout, "Tunnel %s\n", GNUNET_i2s_full (peer));
470 FPRINTF (stdout, "- %u channels\n", channels);
471 FPRINTF (stdout, "- %u connections\n", connections);
472 FPRINTF (stdout, "- enc state: %u\n", estate);
473 FPRINTF (stdout, "- con state: %u\n", cstate);
462} 474}
463 475
464 476
@@ -475,7 +487,7 @@ get_tunnels (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
475 { 487 {
476 return; 488 return;
477 } 489 }
478// GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL); 490 GNUNET_MESH_get_tunnels (mh, &tunnels_callback, NULL);
479 if (GNUNET_YES != monitor_connections) 491 if (GNUNET_YES != monitor_connections)
480 { 492 {
481 GNUNET_SCHEDULER_shutdown(); 493 GNUNET_SCHEDULER_shutdown();
@@ -505,7 +517,7 @@ show_tunnel (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
505 GNUNET_SCHEDULER_shutdown(); 517 GNUNET_SCHEDULER_shutdown();
506 return; 518 return;
507 } 519 }
508// GNUNET_MESH_show_tunnel (mh, &pid, 0, tunnel_callback, NULL); 520 GNUNET_MESH_get_tunnel (mh, &pid, tunnel_callback, NULL);
509} 521}
510 522
511 523
@@ -662,6 +674,7 @@ main (int argc, char *const *argv)
662 {'t', "tunnel", "TUNNEL_ID", 674 {'t', "tunnel", "TUNNEL_ID",
663 gettext_noop ("provide information about a particular tunnel"), 675 gettext_noop ("provide information about a particular tunnel"),
664 GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id}, 676 GNUNET_YES, &GNUNET_GETOPT_set_string, &tunnel_id},
677
665 GNUNET_GETOPT_OPTION_END 678 GNUNET_GETOPT_OPTION_END
666 }; 679 };
667 680
diff --git a/src/mesh/gnunet-service-mesh_local.c b/src/mesh/gnunet-service-mesh_local.c
index 82743c892..f6b4b8149 100644
--- a/src/mesh/gnunet-service-mesh_local.c
+++ b/src/mesh/gnunet-service-mesh_local.c
@@ -593,20 +593,22 @@ monitor_all_tunnels_iterator (void *cls,
593 void *value) 593 void *value)
594{ 594{
595 struct GNUNET_SERVER_Client *client = cls; 595 struct GNUNET_SERVER_Client *client = cls;
596 struct MeshChannel *ch = value; 596 struct MeshTunnel3 *t = value;
597 struct GNUNET_MESH_LocalInfo *msg; 597 struct GNUNET_MESH_LocalInfoTunnel msg;
598 598
599 msg = GNUNET_new (struct GNUNET_MESH_LocalInfo); 599 msg.header.size = htons (sizeof (msg));
600 msg->channel_id = htonl (GMCH_get_id (ch)); 600 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS);
601 msg->header.size = htons (sizeof (struct GNUNET_MESH_LocalInfo)); 601 msg.destination = *peer;
602 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS); 602 msg.channels = htons (42);
603 msg.connections = htons (42);
604 msg.cstate = htons (GMT_get_cstate (t));
605 msg.estate = htons (42);
603 606
604 LOG (GNUNET_ERROR_TYPE_INFO, 607 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending info about tunnel ->%s\n",
605 "* sending info about tunnel %s\n", 608 GNUNET_i2s (peer));
606 GNUNET_i2s (&msg->owner));
607 609
608 GNUNET_SERVER_notification_context_unicast (nc, client, 610 GNUNET_SERVER_notification_context_unicast (nc, client,
609 &msg->header, GNUNET_NO); 611 &msg.header, GNUNET_NO);
610 return GNUNET_YES; 612 return GNUNET_YES;
611} 613}
612 614
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 926feb8af..f27e86b71 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -1034,28 +1034,34 @@ static void
1034process_get_tunnels (struct GNUNET_MESH_Handle *h, 1034process_get_tunnels (struct GNUNET_MESH_Handle *h,
1035 const struct GNUNET_MessageHeader *message) 1035 const struct GNUNET_MessageHeader *message)
1036{ 1036{
1037 struct GNUNET_PeerIdentity *id; 1037 struct GNUNET_MESH_LocalInfoTunnel *msg;
1038 uint16_t size; 1038 uint16_t size;
1039 unsigned int i;
1040 1039
1041 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get Tunnels messasge received\n"); 1040 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get Tunnels messasge received\n");
1042 1041
1043 if (NULL == h->tunnels_cb) 1042 if (NULL == h->tunnels_cb)
1044 { 1043 {
1045 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n"); 1044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ignored\n");
1046 return; 1045 return;
1047 } 1046 }
1048 1047
1049 size = ntohs (message->size); 1048 size = ntohs (message->size);
1050 size /= sizeof (struct GNUNET_PeerIdentity); 1049 if (sizeof (struct GNUNET_MESH_LocalInfoTunnel) > size)
1051 id = (struct GNUNET_PeerIdentity *) &message[1]; 1050 {
1051 h->tunnels_cb (h->tunnel_cls, NULL, 0, 0, 0, 0);
1052 h->tunnels_cb = NULL;
1053 h->tunnels_cls = NULL;
1054 return;
1055 }
1052 1056
1053 for (i = 0; i < size; i++) 1057 msg = (struct GNUNET_MESH_LocalInfoTunnel *) message;
1054 h->tunnels_cb (h->tunnels_cls, &id[i]); 1058 h->tunnels_cb (h->tunnel_cls,
1055 h->tunnels_cb (h->tunnels_cls, NULL); 1059 &msg->destination,
1060 ntohl (msg->channels),
1061 ntohl (msg->connections),
1062 ntohl (msg->estate),
1063 ntohl (msg->cstate));
1056 1064
1057 h->tunnels_cb = NULL;
1058 h->tunnels_cls = NULL;
1059} 1065}
1060 1066
1061 1067
@@ -1066,43 +1072,48 @@ process_get_tunnels (struct GNUNET_MESH_Handle *h,
1066 * @param h Mesh handle. 1072 * @param h Mesh handle.
1067 * @param message Message itself. 1073 * @param message Message itself.
1068 */ 1074 */
1069// static void 1075static void
1070// process_show_channel (struct GNUNET_MESH_Handle *h, 1076process_get_tunnel (struct GNUNET_MESH_Handle *h,
1071// const struct GNUNET_MessageHeader *message) 1077 const struct GNUNET_MessageHeader *message)
1072// { 1078{
1073// struct GNUNET_MESH_LocalInfo *msg; 1079 struct GNUNET_MESH_LocalInfoTunnel *msg;
1074// size_t esize; 1080 size_t esize;
1075// 1081
1076// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Show Channel messasge received\n"); 1082 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get Tunnel messasge received\n");
1077// 1083
1078// if (NULL == h->channel_cb) 1084 if (NULL == h->tunnel_cb)
1079// { 1085 {
1080// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n"); 1086 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, " ignored\n");
1081// return; 1087 return;
1082// } 1088 }
1083// 1089
1084// /* Verify message sanity */ 1090 /* Verify message sanity */
1085// msg = (struct GNUNET_MESH_LocalInfo *) message; 1091 msg = (struct GNUNET_MESH_LocalInfoTunnel *) message;
1086// esize = sizeof (struct GNUNET_MESH_LocalInfo); 1092 esize = sizeof (struct GNUNET_MESH_LocalInfo);
1087// if (ntohs (message->size) != esize) 1093 if (ntohs (message->size) != esize)
1088// { 1094 {
1089// GNUNET_break_op (0); 1095 GNUNET_break_op (0);
1090// GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1096 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1091// "Show channel message: size %hu - expected %u\n", 1097 "Get Tunnel message: size %hu - expected %u\n",
1092// ntohs (message->size), 1098 ntohs (message->size),
1093// esize); 1099 esize);
1094// 1100
1095// h->channel_cb (h->channel_cls, NULL, NULL); 1101 h->tunnel_cb (h->tunnel_cls, NULL, 0, 0, 0, 0);
1096// h->channel_cb = NULL; 1102 h->tunnel_cb = NULL;
1097// h->channel_cls = NULL; 1103 h->tunnel_cls = NULL;
1098// 1104
1099// return; 1105 return;
1100// } 1106 }
1101// 1107
1102// h->channel_cb (h->channel_cls, 1108 h->tunnel_cb (h->tunnel_cls,
1103// &msg->destination, 1109 &msg->destination,
1104// &msg->owner); 1110 ntohl (msg->channels),
1105// } 1111 ntohl (msg->connections),
1112 ntohl (msg->estate),
1113 ntohl (msg->cstate));
1114 h->tunnel_cb = NULL;
1115 h->tunnel_cls = NULL;
1116}
1106 1117
1107/** 1118/**
1108 * Function to process all messages received from the service 1119 * Function to process all messages received from the service
@@ -1153,6 +1164,9 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
1153 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS: 1164 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS:
1154 process_get_tunnels (h, msg); 1165 process_get_tunnels (h, msg);
1155 break; 1166 break;
1167 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL:
1168 process_get_tunnel (h, msg);
1169 break;
1156// case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL: 1170// case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL:
1157// process_show_channel (h, msg); 1171// process_show_channel (h, msg);
1158// break; 1172// break;
@@ -1161,7 +1175,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg)
1161 LOG (GNUNET_ERROR_TYPE_WARNING, 1175 LOG (GNUNET_ERROR_TYPE_WARNING,
1162 "unsolicited message form service (type %s)\n", 1176 "unsolicited message form service (type %s)\n",
1163 GM_m2s (ntohs (msg->type))); 1177 GM_m2s (ntohs (msg->type)));
1164 } 1178 } FPRINTF (stdout, "\n");
1165 LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n"); 1179 LOG (GNUNET_ERROR_TYPE_DEBUG, "message processed\n");
1166 if (GNUNET_YES == h->in_receive) 1180 if (GNUNET_YES == h->in_receive)
1167 { 1181 {
@@ -1435,6 +1449,8 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
1435 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: 1449 case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY:
1436 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS: 1450 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNELS:
1437 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL: 1451 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL:
1452 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL:
1453 case GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNELS:
1438 break; 1454 break;
1439 default: 1455 default:
1440 GNUNET_break (0); 1456 GNUNET_break (0);
@@ -1756,7 +1772,7 @@ GNUNET_MESH_get_tunnels_cancel (struct GNUNET_MESH_Handle *h)
1756 h->tunnels_cb = NULL; 1772 h->tunnels_cb = NULL;
1757 cls = h->tunnels_cls; 1773 cls = h->tunnels_cls;
1758 h->tunnels_cls = NULL; 1774 h->tunnels_cls = NULL;
1759 1775
1760 return cls; 1776 return cls;
1761} 1777}
1762 1778
@@ -1780,7 +1796,7 @@ GNUNET_MESH_get_tunnels_cancel (struct GNUNET_MESH_Handle *h)
1780void 1796void
1781GNUNET_MESH_get_tunnel (struct GNUNET_MESH_Handle *h, 1797GNUNET_MESH_get_tunnel (struct GNUNET_MESH_Handle *h,
1782 const struct GNUNET_PeerIdentity *id, 1798 const struct GNUNET_PeerIdentity *id,
1783 GNUNET_MESH_TunnelsCB callback, 1799 GNUNET_MESH_TunnelCB callback,
1784 void *callback_cls) 1800 void *callback_cls)
1785{ 1801{
1786 struct GNUNET_MESH_LocalInfo msg; 1802 struct GNUNET_MESH_LocalInfo msg;
@@ -1790,6 +1806,8 @@ GNUNET_MESH_get_tunnel (struct GNUNET_MESH_Handle *h,
1790 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL); 1806 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_TUNNEL);
1791 msg.destination = *id; 1807 msg.destination = *id;
1792 send_packet (h, &msg.header, NULL); 1808 send_packet (h, &msg.header, NULL);
1809 h->tunnel_cb = callback;
1810 h->tunnel_cls = callback_cls;
1793} 1811}
1794 1812
1795 1813
@@ -1818,7 +1836,7 @@ GNUNET_MESH_show_channel (struct GNUNET_MESH_Handle *h,
1818 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL); 1836 msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_INFO_CHANNEL);
1819 msg.owner = *initiator; 1837 msg.owner = *initiator;
1820 msg.channel_id = htonl (channel_number); 1838 msg.channel_id = htonl (channel_number);
1821 msg.reserved = 0; 1839// msg.reserved = 0;
1822 send_packet (h, &msg.header, NULL); 1840 send_packet (h, &msg.header, NULL);
1823 h->channel_cb = callback; 1841 h->channel_cb = callback;
1824 h->channel_cls = callback_cls; 1842 h->channel_cls = callback_cls;