[Olsr-dev] txtinfo patch
Markus Kittenberger
(spam-protected)
Mon Mar 3 16:58:02 CET 2008
Hi
Follwing patch makes the txtinfo more useable,..
it is competely backward compatilbe, but adds some more HTTP parameters
original txtinfo only handles /neighbours HTTP parameter
You may have a look at
http://193.238.156.38/status.html (standalone)
http://193.238.156.38/cgi-bin-state.html (embedded)
where you see it in action in combination with my ajax-state-gui.ipk
(still experimental - Opera will work, Firefox may work, IE is
buggy, without js you should get traditional status page)
http://texas.funkfeuer.at/~markus/ajax-state-gui/
Markus
--- olsrd_txtinfo.orig 2008-03-03 16:36:34.000000000 +0100
+++ olsrd_txtinfo.c 2008-03-03 16:54:26.000000000 +0100
@@ -95,11 +95,13 @@
/* IPC initialization function */
static int plugin_ipc_init(void);
-static void send_info(int neighonly);
+static void send_info(int send_what);
static void ipc_action(int);
-static void ipc_print_neigh_link(void);
+static void ipc_print_neigh(void);
+
+static void ipc_print_link(void);
static void ipc_print_routes(void);
@@ -110,6 +112,16 @@
static void ipc_print_mid(void);
#define TXT_IPC_BUFSIZE 256
+
+#define SIW_ALL 0
+#define SIW_NEIGH 1
+#define SIW_LINK 2
+#define SIW_ROUTE 3
+#define SIW_HNA 4
+#define SIW_MID 5
+#define SIW_TOPO 6
+#define SIW_NEIGHLINK 7
+
static int ipc_sendf(const char* format, ...) __attribute__((format(printf,
1, 2)));
/**
@@ -230,7 +242,7 @@
char addr[INET6_ADDRSTRLEN];
fd_set rfds;
struct timeval tv;
- int neighonly = 0;
+ int send_what = 0;
socklen_t addrlen = sizeof(struct sockaddr_storage);
@@ -285,40 +297,29 @@
* page the normal output is somewhat lengthy. The
* header parsing is sufficient for standard wget.
*/
- neighonly = (0 != strstr(requ, "/neighbours"));
+ if (0 != strstr(requ, "/neighbours")) send_what=SIW_NEIGHLINK;
+ else if (0 != strstr(requ, "/neigh")) send_what=SIW_NEIGH;
+ else if (0 != strstr(requ, "/link")) send_what=SIW_LINK;
+ else if (0 != strstr(requ, "/route")) send_what=SIW_ROUTE;
+ else if (0 != strstr(requ, "/hna")) send_what=SIW_HNA;
+ else if (0 != strstr(requ, "/mid")) send_what=SIW_MID;
+ else if (0 != strstr(requ, "/topo")) send_what=SIW_TOPO;
}
}
- send_info(neighonly);
+ send_info(send_what);
close(ipc_connection);
ipc_open = 0;
}
-static void ipc_print_neigh_link(void)
+static void ipc_print_neigh(void)
{
- struct ipaddr_str buf1, buf2;
+ struct ipaddr_str buf1;
struct neighbor_entry *neigh;
struct neighbor_2_list_entry *list_2;
- struct link_entry *link = NULL;
int index, thop_cnt;
- ipc_sendf("Table: Links\nLocal IP\tremote
IP\tHysteresis\tLinkQuality\tlost\ttotal\tNLQ\tETX\n");
-
- /* Link set */
- link = link_set;
- while(link) {
- ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%d\t%d\t%0.2f\t%0.2f\t\n",
- olsr_ip_to_string(&buf1, &link->local_iface_addr),
- olsr_ip_to_string(&buf2, &link->neighbor_iface_addr),
- link->L_link_quality,
- link->loss_link_quality,
- link->lost_packets,
- link->total_packets,
- link->neigh_link_quality,
- olsr_calc_link_etx(link));
- link = link->next;
- }
ipc_sendf("\nTable: Neighbors\nIP address\tSYM\tMPR\tMPRS\tWillingness\t2
Hop Neighbors\n");
/* Neighbors */
@@ -347,6 +348,31 @@
ipc_sendf("\n");
}
+static void ipc_print_link(void)
+{
+ struct ipaddr_str buf1, buf2;
+ struct link_entry *link = NULL;
+
+ ipc_sendf("Table: Links\nLocal IP\tremote
IP\tHysteresis\tLinkQuality\tlost\ttotal\tNLQ\tETX\n");
+
+ /* Link set */
+ link = link_set;
+ while(link) {
+ ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%d\t%d\t%0.2f\t%0.2f\t\n",
+ olsr_ip_to_string(&buf1, &link->local_iface_addr),
+ olsr_ip_to_string(&buf2, &link->neighbor_iface_addr),
+ link->L_link_quality,
+ link->loss_link_quality,
+ link->lost_packets,
+ link->total_packets,
+ link->neigh_link_quality,
+ olsr_calc_link_etx(link));
+ link = link->next;
+ }
+
+ ipc_sendf("\n");
+}
+
static void ipc_print_routes(void)
{
struct ipaddr_str buf1, buf2;
@@ -482,7 +508,7 @@
}
-static void send_info(int neighonly)
+static void send_info(int send_what)
{
/* Print minimal http header */
ipc_sendf("HTTP/1.0 200 OK\n");
@@ -491,19 +517,21 @@
/* Print tables to IPC socket */
/* links + Neighbors */
- ipc_print_neigh_link();
+ if
((send_what==SIW_ALL)||(send_what==SIW_NEIGHLINK)||(send_what==SIW_LINK))
ipc_print_link();
+
+ if
((send_what==SIW_ALL)||(send_what==SIW_NEIGHLINK)||(send_what==SIW_NEIGH))
ipc_print_neigh();
/* topology */
- if (!neighonly) ipc_print_topology();
+ if ((send_what==SIW_ALL)||(send_what==SIW_TOPO)) ipc_print_topology();
/* hna */
- if (!neighonly) ipc_print_hna();
+ if ((send_what==SIW_ALL)||(send_what==SIW_HNA)) ipc_print_hna();
/* mid */
- if (!neighonly) ipc_print_mid();
+ if ((send_what==SIW_ALL)||(send_what==SIW_MID)) ipc_print_mid();
/* routes */
- if (!neighonly) ipc_print_routes();
+ if ((send_what==SIW_ALL)||(send_what==SIW_ROUTE)) ipc_print_routes();
}
/*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20080303/5a4a2fe9/attachment.html>
More information about the Olsr-dev
mailing list