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