aboutsummaryrefslogtreecommitdiffstats
path: root/gg_map
diff options
context:
space:
mode:
Diffstat (limited to 'gg_map')
-rw-r--r--gg_map/Makefile2
-rw-r--r--gg_map/README.txt9
-rw-r--r--gg_map/gg_map.c95
-rwxr-xr-xgg_map/glouglou_localsniff.sh23
4 files changed, 100 insertions, 29 deletions
diff --git a/gg_map/Makefile b/gg_map/Makefile
index 17040af..2722e39 100644
--- a/gg_map/Makefile
+++ b/gg_map/Makefile
@@ -4,6 +4,7 @@ LIBS += $(shell pkg-config --libs elementary evas ecore) -levent -lglouglou -leg
CFLAGS += -Wall -g
BINARY=gg_map
+WRAPPER=glouglou_localsniff.sh
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
@@ -15,6 +16,7 @@ install: $(BINARY)
@echo "installation of $(BINARY)"
mkdir -p $(BINDIR)
install -m 0755 $(BINARY) $(BINDIR)
+ install -m 0755 $(WRAPPER) $(BINDIR)
clean:
rm -f $(BINARY) $(BINARY).o
diff --git a/gg_map/README.txt b/gg_map/README.txt
index 5b5146e..4a92b49 100644
--- a/gg_map/README.txt
+++ b/gg_map/README.txt
@@ -6,12 +6,11 @@ WARNING: Work in progress, don't expect this to work !
* libglouglou
-* egraph
+* egraph (git clone git://git.enlightenment.org/devs/kiwi/egraph.git)
-* Enlightenment Foundation Libraries
-http://www.enlightenment.org
- * evas
- * elementary
+* Enlightenment Foundation Libraries - http://www.enlightenment.org
+ * efl (git clone git://git.enlightenment.org/core/efl.git)
+ * elementary (git clone git://git.enlightenment.org/core/elementary.git)
TODO
====
diff --git a/gg_map/gg_map.c b/gg_map/gg_map.c
index dda280c..48c68f0 100644
--- a/gg_map/gg_map.c
+++ b/gg_map/gg_map.c
@@ -6,13 +6,26 @@
#include <libglouglou.h>
#include <libggnet.h>
-int _debug = 0;
+int _loglevel = 0;
Evas_Object *_mainwin;
Evas_Object *_egraph = NULL;
struct ggnet *_ggnet;
struct event_base *_ev_base;
+#if defined(__OpenBSD__)
+void __dead
+#else
+void
+#endif
+usage(void)
+{
+ extern char *__progname;
+
+ fprintf(stderr, "usage: %s [-hv] [ip [port]]\n", __progname);
+ exit(1);
+}
+
/* link between ecore loop and libevent loop */
static Eina_Bool
_cb_ecore_libevent(void *data) {
@@ -117,7 +130,7 @@ _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)
+ if (_loglevel >= 2)
printf("_conn_add\n");
if (response > 0) /* cannot have a new connection that is a response */
return;
@@ -131,7 +144,7 @@ _conn_add(u_int id, u_int src, u_int dst, u_int proto, u_int8_t pktsize)
va = _node_to_vertice(a);
vb = _node_to_vertice(b);
e = egraph_edge_find(_egraph, va, vb);
- if (_debug)
+ if (_loglevel >= 2)
printf("_conn_add: a %d b %d e %x id %d\n", va->id, vb->id, e, id);
if (!e) {
if (a->group && a->group->conn_count == 1)
@@ -139,7 +152,7 @@ _conn_add(u_int id, u_int src, u_int dst, u_int proto, u_int8_t pktsize)
if (b->group && b->group->conn_count == 1)
_node_detach_parentgroup(b);
e = egraph_edge_add(_egraph, va, vb, conn);
- if (_debug)
+ if (_loglevel >= 2)
printf("_conn_add: egraph edge added %x\n", e);
}
ggnet_conn_usrdata_set(conn, e);
@@ -156,7 +169,7 @@ _conn_del(int id) {
a = ggnet_conn_src_get(conn);
b = ggnet_conn_dst_get(conn);
e = ggnet_conn_usrdata_get(conn);
- if (_debug)
+ if (_loglevel >= 2)
printf("_conn_del: conn id %d\n", id); // XXX
ggnet_conn_del(_ggnet, conn);
/* is there other connections between these peers ? */
@@ -164,7 +177,7 @@ _conn_del(int id) {
if (!otherconn) {
// XXX lets keep the edges, igraph layouting behaves badly when you have
// a vertice without edge ...
- if (_debug)
+ if (_loglevel >= 2)
printf("_conn_del: edge del %x\n", e); // XXX
egraph_edge_del(_egraph, e);
if (a->group && a->group->conn_count == 0)
@@ -172,11 +185,11 @@ _conn_del(int id) {
if (b->group && b->group->conn_count == 0)
_node_attach_parentgroup(b);
} else {
- if (_debug)
+ if (_loglevel >= 2)
printf("_conn_del: not last one, edge %x *not* deleted\n", e);
}
} else {
- if (_debug)
+ if (_loglevel >= 2)
printf("_conn_del: does not exist !\n");
}
}
@@ -222,12 +235,14 @@ _cb_packet(struct gg_client *cli, struct gg_packet *pkt)
{
switch(pkt->type) {
case PACKET_NEWCONN:
- printf(" type PACKET_NEWCONN\n");
- printf(" newconn_id %d\n", pkt->newconn_id);
- printf(" newconn_src %4x\n", pkt->newconn_src);
- printf(" newconn_dst %4x\n", pkt->newconn_dst);
- printf(" newconn_proto %d\n", pkt->newconn_proto);
- printf(" newconn_size %d\n", pkt->newconn_size);
+ if (_loglevel >= 1) {
+ printf(" type PACKET_NEWCONN\n");
+ printf(" newconn_id %d\n", pkt->newconn_id);
+ printf(" newconn_src %4x\n", pkt->newconn_src);
+ printf(" newconn_dst %4x\n", pkt->newconn_dst);
+ printf(" newconn_proto %d\n", pkt->newconn_proto);
+ printf(" newconn_size %d\n", pkt->newconn_size);
+ }
_conn_del(pkt->newconn_id); /* in case we missed a previous del */
_conn_add(pkt->newconn_id, pkt->newconn_src, pkt->newconn_dst,
@@ -235,25 +250,31 @@ _cb_packet(struct gg_client *cli, struct gg_packet *pkt)
break;
case PACKET_DELCONN:
- printf(" type PACKET_DELCONN\n");
- printf(" delconn_id %d\n", pkt->delconn_id);
+ if (_loglevel >= 1) {
+ printf(" type PACKET_DELCONN\n");
+ printf(" delconn_id %d\n", pkt->delconn_id);
+ }
_conn_del(pkt->delconn_id);
break;
case PACKET_DATA:
- //printf(" type PACKET_DATA\n");
- //printf(" data_connid %d\n", pkt->data_connid);
- //printf(" data_size %d\n", pkt->data_size);
+ if (_loglevel >= 1) {
+ //printf(" type PACKET_DATA\n");
+ //printf(" data_connid %d\n", pkt->data_connid);
+ //printf(" data_size %d\n", pkt->data_size);
+ }
_conn_data(pkt->data_connid, pkt->data_size);
break;
case PACKET_NAME:
- printf(" type PACKET_NAME\n");
- printf(" name_addr %4x\n", pkt->name_addr);
- printf(" name_len %d\n", pkt->name_len);
- printf(" name_name_fqdn %s\n", pkt->name_fqdn);
+ if (_loglevel >= 1) {
+ printf(" type PACKET_NAME\n");
+ printf(" name_addr %4x\n", pkt->name_addr);
+ printf(" name_len %d\n", pkt->name_len);
+ printf(" name_name_fqdn %s\n", pkt->name_fqdn);
+ }
_conn_name(pkt->name_addr, pkt->name_len, pkt->name_fqdn);
break;
@@ -333,7 +354,33 @@ elm_main(int argc, char **argv)
Evas_Object *bx, *bx2, *ck, *sc, *seg_it, *lb;
Evas *evas;
struct gg_client *ggcli;
+ char gg_serv_ip[30] = "127.0.0.1";
+ int gg_serv_port = GLOUGLOU_ANALY_DEFAULT_PORT;
int retval = -1;
+ int op;
+
+ while ((op = getopt(argc, argv, "hv")) != -1) {
+ switch (op) {
+ case 'h':
+ usage();
+ /* NOTREACHED */
+ case 'v':
+ _loglevel++;
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+ switch (argc - optind) {
+ case 2: gg_serv_port = atoi(argv[3]);
+ case 1: strncpy(gg_serv_ip, argv[2], sizeof(gg_serv_ip));
+ case 0:
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
win = elm_win_add(NULL, "panes", ELM_WIN_BASIC);
evas = evas_object_evas_get(win);
@@ -437,7 +484,7 @@ elm_main(int argc, char **argv)
_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,
+ ggcli = gg_client_connect(_ev_base, gg_serv_ip, gg_serv_port,
NULL, _cb_packet, NULL);
if (!ggcli)
goto quit;
diff --git a/gg_map/glouglou_localsniff.sh b/gg_map/glouglou_localsniff.sh
new file mode 100755
index 0000000..75d9cdd
--- /dev/null
+++ b/gg_map/glouglou_localsniff.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# Wrapper script to visualize network activity on local machine
+
+PATH="./:$PATH" # for pkg
+
+glougloud=`which glougloud`
+gg_sniff=`which gg_sniff`
+gg_map=`which gg_map`
+iface=${1-"eth0"}
+
+if [ -z "$glougloud" -o -z "$gg_sniff" -o -z "$gg_map" ]; then
+ echo "instalation incomplete (glougloud, gg_sniff, gg_map)"
+ exit 1
+fi
+
+tmux start \;\
+ new-session -d -s glouglou \;\
+ neww -n "glougloud" "sudo $glougloud -v; bash" \;\
+ neww -n "gg_sniff" "sudo $gg_sniff -v -i $iface" \;\
+ neww -n "gg_map" "gg_map" \;\
+ attach-session -t glouglou
+