aboutsummaryrefslogtreecommitdiffstats
path: root/gg_map/gg_map.c
diff options
context:
space:
mode:
Diffstat (limited to 'gg_map/gg_map.c')
-rw-r--r--gg_map/gg_map.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/gg_map/gg_map.c b/gg_map/gg_map.c
index 24f3536..4045088 100644
--- a/gg_map/gg_map.c
+++ b/gg_map/gg_map.c
@@ -6,6 +6,8 @@
#include <libglouglou.h>
#include <libggnet.h>
+int _debug = 0;
+
Evas_Object *_mainwin;
Evas_Object *_egraph;
struct ggnet *_ggnet;
@@ -21,7 +23,8 @@ _cb_ecore_libevent(void *data) {
return EINA_TRUE;
}
-const char *ip_to_str(u_int ip)
+const char*
+ip_to_str(u_int ip)
{
unsigned char bytes[4];
static char buf[16];
@@ -35,15 +38,38 @@ const char *ip_to_str(u_int ip)
return buf;
}
+static void
+_cb_ggnet_addgroup(struct ggnet *net, struct ggnet_nodegroup *group)
+{
+ Egraph_Vertice *vgroup;
+
+ vgroup = egraph_group_add(_egraph, ip_to_str(group->addr.s_addr), group);
+ ggnet_nodegroup_usrdata_set(group, vgroup);
+}
+
+static void
+_cb_ggnet_delgroup(struct ggnet *net, struct ggnet_nodegroup *group)
+{
+ Egraph_Vertice *vgroup;
+
+ vgroup = ggnet_nodegroup_usrdata_get(group);
+ egraph_vertice_del(_egraph, vgroup);
+}
+
static Egraph_Vertice *
_node_to_vertice(struct ggnet_node *n)
{
Egraph_Vertice *v;
+ struct ggnet_nodegroup *group;
v = ggnet_node_usrdata_get(n);
if (!v) {
v = egraph_vertice_add(_egraph, ip_to_str(n->addr.s_addr), n);
ggnet_node_usrdata_set(n, v);
+ group = ggnet_node_group_get(n);
+ if (group)
+ egraph_group_vertice_attach(_egraph, v,
+ ggnet_nodegroup_usrdata_get(group));
}
return v;
}
@@ -58,6 +84,8 @@ _conn_add(u_int id, u_int src, u_int dst, u_int proto, u_int8_t pktsize)
int size, response;
GG_PKTDATA_SIZE_DECODE(pktsize, size, response);
+ if (_debug)
+ printf("_conn_add\n");
if (response > 0) /* cannot have a new connection that is a response */
return;
@@ -68,8 +96,13 @@ _conn_add(u_int id, u_int src, u_int dst, u_int proto, u_int8_t pktsize)
a = _node_to_vertice(ggnet_conn_src_get(conn));
b = _node_to_vertice(ggnet_conn_dst_get(conn));
e = egraph_edge_find(_egraph, a, b);
- if (!e)
+ if (_debug)
+ printf("_conn_add: a %d b %d e %x id %d\n", a->id, b->id, e, id);
+ if (!e) {
e = egraph_edge_add(_egraph, a, b, conn);
+ if (_debug)
+ printf("_conn_add: egraph edge added %x\n", e);
+ }
ggnet_conn_usrdata_set(conn, e);
}
@@ -84,19 +117,25 @@ _conn_del(int id) {
a = ggnet_conn_src_get(conn);
b = ggnet_conn_dst_get(conn);
e = ggnet_conn_usrdata_get(conn);
+ if (_debug)
+ printf("_conn_del: conn id %d\n", id); // XXX
ggnet_conn_del(_ggnet, conn);
/* is there other connections between these peers ? */
otherconn = ggnet_conn_find_by_node(_ggnet, a, b);
if (!otherconn) {
// XXX lets keep the edges, igraph layouting behaves badly when you have
// a vertice without edge ...
+ if (_debug)
+ printf("_conn_del: edge del %x\n", e); // XXX
egraph_edge_del(_egraph, e);
//if (ggnet_node_is_connected(
} else {
- printf("not last one\n");
+ if (_debug)
+ printf("_conn_del: not last one, edge %x *not* deleted\n", e);
}
} else {
- printf("does not exist !\n");
+ if (_debug)
+ printf("_conn_del: does not exist !\n");
}
}
@@ -227,6 +266,10 @@ elm_main(int argc, char **argv)
_mainwin = win;
_ggnet = ggnet_new(GGNET_MANAGE_CONNID_FALSE);
+ if (!_ggnet)
+ goto quit;
+ ggnet_grouping_set(_ggnet, GGNET_GROUPING_TRUE,
+ _cb_ggnet_addgroup, _cb_ggnet_delgroup);
_ev_base = event_base_new();
ggcli = gg_client_connect(_ev_base, "127.0.0.1", GLOUGLOU_ANALY_DEFAULT_PORT,