* applied hunks from Erik Tromps patch at http://home.tiscali.nl/levab001/olsrd-0...
authorBernd Petrovitsch <bernd@firmix.at>
Sun, 4 Feb 2007 22:37:36 +0000 (22:37 +0000)
committerBernd Petrovitsch <bernd@firmix.at>
Sun, 4 Feb 2007 22:37:36 +0000 (22:37 +0000)
lib/httpinfo/src/html.h
lib/httpinfo/src/olsrd_httpinfo.c
lib/httpinfo/src/olsrd_plugin.c
lib/httpinfo/src/olsrd_plugin.h
src/cfgparser/cfgfile_gen.c
src/unix/ifnet.c

index cb33209..25c5b8c 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: html.h,v 1.6 2005/03/14 21:28:15 kattemat Exp $
+ * $Id: html.h,v 1.7 2007/02/04 22:37:36 bernd67 Exp $
  */
 
 /*
@@ -48,7 +48,7 @@
 
 static const char *httpinfo_css[] =
 {
-  "A {text-decoration: none}\n",
+  "#A {text-decoration: none}\n",
   "TH{text-align: left}\n",
   "H1, H3, TD, TH {font-family: Helvetica; font-size: 80%%}\n",
   "h2\n {\nfont-family: Helvetica;\n font-size: 14px;text-align: center;\n",
index ef0576d..654b7c7 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_httpinfo.c,v 1.60 2006/11/05 23:03:56 bernd67 Exp $
+ * $Id: olsrd_httpinfo.c,v 1.61 2007/02/04 22:37:36 bernd67 Exp $
  */
 
 /*
@@ -715,7 +715,10 @@ build_routes_body(char *buf, olsr_u32_t bufsize)
 
   size += sprintf(&buf[size], "<h2>OLSR routes in kernel</h2>\n");
 
-  size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination</th><th>Gateway</th><th>Metric</th><th>ETX</th><th>Interface</th><th>Type</th></tr>\n");
+  size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination</th><th>Gateway</th><th>Metric</th>");
+  if (olsr_cnf->lq_level > 0)
+    size += sprintf(&buf[size], "<th>ETX</th>");
+  size += sprintf(&buf[size], "<th>Interface</th><th>Type</th></tr>\n");
 
   /* Neighbors */
   for(index = 0;index < HASHSIZE;index++)
@@ -724,12 +727,23 @@ build_routes_body(char *buf, olsr_u32_t bufsize)
          routes != &routingtable[index];
          routes = routes->next)
        {
-         size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%d</td><td>%.2f</td><td>%s</td><td>HOST</td></tr>\n",
-                         olsr_ip_to_string(&routes->rt_dst),
-                         olsr_ip_to_string(&routes->rt_router),
-                         routes->rt_metric,
-                         routes->rt_etx,
-                         routes->rt_if->int_name);
+         size += sprintf(&buf[size],
+                         "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
+                         "<td><a href=\"http://%s:%d/all\">%s</a></td>"
+                         "<td>%d</td>",
+                         olsr_ip_to_string(&routes->rt_dst),
+                         http_port,
+                         olsr_ip_to_string(&routes->rt_dst),
+                         olsr_ip_to_string(&routes->rt_router),
+                         http_port,
+                         olsr_ip_to_string(&routes->rt_router),
+                         routes->rt_metric);
+          if (olsr_cnf->lq_level > 0)
+           size += sprintf(&buf[size], "<td>%.2f</td>", routes->rt_etx);
+         size += sprintf(&buf[size],
+                         "<td>%s</td>"
+                         "<td>HOST</td></tr>\n",
+                         routes->rt_if->int_name);
        }
     }
 
@@ -740,11 +754,21 @@ build_routes_body(char *buf, olsr_u32_t bufsize)
          routes != &hna_routes[index];
          routes = routes->next)
        {
-         size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%d</td><td>%s</td><td>HNA</td></tr>\n",
-                         olsr_ip_to_string(&routes->rt_dst),
-                         olsr_ip_to_string(&routes->rt_router),
-                         routes->rt_metric,
-                         routes->rt_if->int_name);
+         size += sprintf(&buf[size],
+                         "<tr><td>%s</td>"
+                         "<td><a href=\"http://%s:%d/all\">%s</a></td>"
+                         "<td>%d</td>",
+                         olsr_ip_to_string(&routes->rt_dst),
+                         olsr_ip_to_string(&routes->rt_router),
+                         http_port,
+                         olsr_ip_to_string(&routes->rt_router),
+                         routes->rt_metric);
+          if (olsr_cnf->lq_level > 0)
+           size += sprintf(&buf[size], "<td>%.2f</td>", routes->rt_etx);
+         size += sprintf(&buf[size],
+                         "<td>%s</td>"
+                         "<td>HNA</td></tr>\n",
+                         routes->rt_if->int_name);
        }
     }
 
@@ -818,17 +842,24 @@ build_config_body(char *buf, olsr_u32_t bufsize)
     
     size += sprintf(&buf[size], "</tr>\n<tr>\n");
 
-    size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
-       
-    size += sprintf(&buf[size], "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
-    size += sprintf(&buf[size], "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
+    if (olsr_cnf->lq_level == 0)
+      {
+        size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
+       if (olsr_cnf->use_hysteresis)
+          {
+            size += sprintf(&buf[size], "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
+            size += sprintf(&buf[size], "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
+          }
+      }
 
     size += sprintf(&buf[size], "</tr>\n<tr>\n");
 
-    size += sprintf(&buf[size], "<td>LQ extention: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
-    size += sprintf(&buf[size], "<td>LQ level: %d</td>\n", olsr_cnf->lq_level);
-    size += sprintf(&buf[size], "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
-    size += sprintf(&buf[size], "<td></td>\n");
+    size += sprintf(&buf[size], "<td>LQ extension: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
+    if (olsr_cnf->lq_level)
+      {
+        size += sprintf(&buf[size], "<td>LQ level: %d</td>\n", olsr_cnf->lq_level);
+        size += sprintf(&buf[size], "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
+      }
 
     size += sprintf(&buf[size], "</tr></table>\n");
 
@@ -870,7 +901,6 @@ build_config_body(char *buf, olsr_u32_t bufsize)
            size += sprintf(&buf[size], "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
            size += sprintf(&buf[size], "<td>STATUS: UP</td></tr>\n");
          }         
-
       }
 
     size += sprintf(&buf[size], "</table>\n");
@@ -952,21 +982,39 @@ build_neigh_body(char *buf, olsr_u32_t bufsize)
   int size = 0, index, thop_cnt;
 
   size += sprintf(&buf[size], "<h2>Links</h2>\n");
-  size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Local IP</th><th>remote IP</th><th>Hysteresis</th><th>LinkQuality</th><th>lost</th><th>total</th><th>NLQ</th><th>ETX</th></tr>\n");
+  size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Local IP</th><th>remote IP</th><th>Hysteresis</th>\n");
+  if (olsr_cnf->lq_level > 0)
+    size += sprintf(&buf[size], "<th>LinkQuality</th><th>lost</th><th>total</th><th>NLQ</th><th>ETX</th>\n");
+  size += sprintf(&buf[size], "</tr>\n");
 
   /* Link set */
   link = link_set;
     while(link)
       {
-       size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%0.2f</td><td>%0.2f</td><td>%d</td><td>%d</td><td>%0.2f</td><td>%0.2f</td></tr>\n",
-                       olsr_ip_to_string(&link->local_iface_addr),
-                       olsr_ip_to_string(&link->neighbor_iface_addr),
-                       link->L_link_quality, 
-                       link->loss_link_quality,
-                       link->lost_packets, 
-                       link->total_packets,
-                       link->neigh_link_quality, 
-                       (link->loss_link_quality * link->neigh_link_quality) ? 1.0 / (link->loss_link_quality * link->neigh_link_quality) : 0.0);
+       size += sprintf(&buf[size],
+                       "<tr><td>%s</td>"
+                       "<td><a href=\"http://%s:%d/all\">%s</a></td>"
+                       "<td>%0.2f</td>",
+                       olsr_ip_to_string(&link->local_iface_addr),
+                       olsr_ip_to_string(&link->neighbor_iface_addr),
+                       http_port,
+                       olsr_ip_to_string(&link->neighbor_iface_addr),
+                       link->L_link_quality);
+        if (olsr_cnf->lq_level > 0)
+          {
+           size += sprintf(&buf[size],
+                           "<td>%0.2f</td>"
+                           "<td>%d</td>"
+                           "<td>%d</td>"
+                           "<td>%0.2f</td>"
+                           "<td>%0.2f</td></tr>\n",
+                           link->loss_link_quality,
+                           link->lost_packets, 
+                           link->total_packets,
+                           link->neigh_link_quality, 
+                           (link->loss_link_quality * link->neigh_link_quality) ? 1.0 / (link->loss_link_quality * link->neigh_link_quality) : 0.0);
+          }
+       size += sprintf(&buf[size], "</tr>\n");
 
        link = link->next;
       }
@@ -983,7 +1031,13 @@ build_neigh_body(char *buf, olsr_u32_t bufsize)
          neigh = neigh->next)
        {
          size += sprintf(&buf[size], 
-                         "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%d</td>", 
+                         "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
+                         "<td>%s</td>"
+                         "<td>%s</td>"
+                         "<td>%s</td>"
+                         "<td>%d</td>", 
+                         olsr_ip_to_string(&neigh->neighbor_main_addr),
+                          http_port,
                          olsr_ip_to_string(&neigh->neighbor_main_addr),
                          (neigh->status == SYM) ? "YES" : "NO",
                          neigh->is_mpr ? "YES" : "NO",
@@ -1023,7 +1077,10 @@ build_topo_body(char *buf, olsr_u32_t bufsize)
   struct topo_dst *dst_entry;
 
 
-  size += sprintf(&buf[size], "<h2>Topology entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination IP</th><th>Last hop IP</th><th>LQ</th><th>ILQ</th><th>ETX</th></tr>\n");
+  size += sprintf(&buf[size], "<h2>Topology entries</h2>\n<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Destination IP</th><th>Last hop IP</th>");
+  if (olsr_cnf->lq_level > 0)
+    size += sprintf(&buf[size], "<th>LQ</th><th>ILQ</th><th>ETX</th>");
+  size += sprintf(&buf[size], "</tr>\n");
 
 
   /* Topology */  
@@ -1037,12 +1094,26 @@ build_topo_body(char *buf, olsr_u32_t bufsize)
          dst_entry = entry->destinations.next;
          while(dst_entry != &entry->destinations)
            {
-             size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td><td>%0.2f</td><td>%0.2f</td><td>%0.2f</td></tr>\n", 
-                             olsr_ip_to_string(&dst_entry->T_dest_addr),
-                             olsr_ip_to_string(&entry->T_last_addr), 
-                             dst_entry->link_quality,
-                             dst_entry->inverse_link_quality,
-                             (dst_entry->link_quality * dst_entry->inverse_link_quality) ? 1.0 / (dst_entry->link_quality * dst_entry->inverse_link_quality) : 0.0);
+             size += sprintf(&buf[size],
+                             "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>"
+                             "<td><a href=\"http://%s:%d/all\">%s</a></td>",
+                             olsr_ip_to_string(&dst_entry->T_dest_addr),
+                             http_port,
+                             olsr_ip_to_string(&dst_entry->T_dest_addr),
+                             olsr_ip_to_string(&entry->T_last_addr), 
+                             http_port,
+                             olsr_ip_to_string(&entry->T_last_addr));
+              if (olsr_cnf->lq_level > 0)
+                {
+                 size += sprintf(&buf[size],
+                                 "<td>%0.2f</td>"
+                                 "<td>%0.2f</td>"
+                                 "<td>%0.2f</td>\n",
+                                 dst_entry->link_quality,
+                                 dst_entry->inverse_link_quality,
+                                 (dst_entry->link_quality * dst_entry->inverse_link_quality) ? 1.0 / (dst_entry->link_quality * dst_entry->inverse_link_quality) : 0.0);
+                }
+             size += sprintf(&buf[size], "</tr>\n");
 
              dst_entry = dst_entry->next;
            }
@@ -1085,7 +1156,9 @@ build_hna_body(char *buf, olsr_u32_t bufsize)
                              olsr_ip_to_string(&tmp_net->A_network_addr));
              size += sprintf(&buf[size], "<td>%s</td>",
                              olsr_netmask_to_string(&tmp_net->A_netmask));
-             size += sprintf(&buf[size], "<td>%s</td></tr>\n",
+             size += sprintf(&buf[size], "<td><a href=\"http://%s:%d/all\">%s</a></td></tr>\n",
+                              olsr_ip_to_string(&tmp_hna->A_gateway_addr),
+                              http_port,
                               olsr_ip_to_string(&tmp_hna->A_gateway_addr));
              tmp_net = tmp_net->next;
            }
@@ -1103,7 +1176,7 @@ build_hna_body(char *buf, olsr_u32_t bufsize)
 int
 build_mid_body(char *buf, olsr_u32_t bufsize)
 {
-  int size = 0;
+  int size = 0, mid_cnt;
   olsr_u8_t index;
   struct mid_entry *entry;
   struct mid_address *alias;
@@ -1116,18 +1189,21 @@ build_mid_body(char *buf, olsr_u32_t bufsize)
       entry = mid_set[index].next;
       while(entry != &mid_set[index])
        {
-         size += sprintf(&buf[size], "<tr><td>%s</td>\n", olsr_ip_to_string(&entry->main_addr));
+         size += sprintf(&buf[size], "<tr><td><a href=\"http://%s:%d/all\">%s</a></td>\n",
+                         olsr_ip_to_string(&entry->main_addr),
+                          http_port,
+                         olsr_ip_to_string(&entry->main_addr));
          size += sprintf(&buf[size], "<td><select>\n<option>IP ADDRESS</option>\n");
 
          alias = entry->aliases;
+         mid_cnt = 0;
          while(alias)
            {
              size += sprintf(&buf[size], "<option>%s</option>\n", olsr_ip_to_string(&alias->alias));
+             mid_cnt ++;
              alias = alias->next_alias;
            }
-         size += sprintf(&buf[size], "</select>\n");
-
-         size += sprintf(&buf[size], "</tr>\n");
+         size += sprintf(&buf[size], "</select> (%d)</td></tr>\n", mid_cnt);
          entry = entry->next;
        }
     }
index 4868834..3018db4 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.c,v 1.12 2005/05/29 12:47:41 br1 Exp $
+ * $Id: olsrd_plugin.c,v 1.13 2007/02/04 22:37:36 bernd67 Exp $
  */
 
 /*
@@ -51,6 +51,8 @@
 #include <stdlib.h>
 #include "olsrd_httpinfo.h"
 
+int http_port = 0;
+
 static void __attribute__ ((constructor)) 
 my_init(void);
 
index 8aab0cd..6b6ecdb 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: olsrd_plugin.h,v 1.20 2005/05/29 12:47:41 br1 Exp $
+ * $Id: olsrd_plugin.h,v 1.21 2007/02/04 22:37:36 bernd67 Exp $
  */
 
 /*
@@ -71,7 +71,7 @@
 #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
 #define PLUGIN_INTERFACE_VERSION 4
 
-int http_port;
+extern int http_port;
 
 /* Allowed hosts stuff */
 
index a8fa65e..cc1f24a 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: cfgfile_gen.c,v 1.4 2006/12/12 11:22:15 kattemat Exp $
+ * $Id: cfgfile_gen.c,v 1.5 2007/02/04 22:37:36 bernd67 Exp $
  */
 
 
@@ -316,7 +316,17 @@ olsrd_write_cnf(struct olsrd_config *cnf, const char *fname)
                }
            }
 
-         fprintf(fd, "    # When multiple links exist between hosts\n    # the weight of interface is used to determine\n    # the link to use. Normally the weight is\n    # automatically calculated by olsrd based\n    # on the characteristics of the interface,\n    # but here you can specify a fixed value.\n    # Olsrd will choose links with the lowest value.\n");
+         fprintf(fd, "    # When multiple links exist between hosts\n");
+         fprintf(fd, "    # the weight of interface is used to determine\n");
+         fprintf(fd, "    # the link to use. Normally the weight is\n");
+         fprintf(fd, "    # automatically calculated by olsrd based\n");
+         fprintf(fd, "    # on the characteristics of the interface,\n");
+         fprintf(fd, "    # but here you can specify a fixed value.\n");
+         fprintf(fd, "    # Olsrd will choose links with the lowest value.\n");
+         fprintf(fd, "    # Note:\n");
+         fprintf(fd, "    # Interface weight is used only when LinkQualityLevel is 0.\n");
+         fprintf(fd, "    # For any other value of LinkQualityLevel, the interface ETX\n");
+         fprintf(fd, "    # value is used instead.\n\n");
          if(in->cnf->weight.fixed)
            {
              fprintf(fd, "    Weight\t %d\n\n", in->cnf->weight.value);
@@ -621,9 +631,19 @@ olsrd_write_cnf_buf(struct olsrd_config *cnf, char *buf, olsr_u32_t bufsize)
            }
 
          if(first)
-           WRITE_TO_BUF("    # When multiple links exist between hosts\n    # the weight of interface is used to determine\n    # the link to use. Normally the weight is\n")
-          if(first)
-            WRITE_TO_BUF("    # automatically calculated by olsrd based\n    # on the characteristics of the interface,\n    # but here you can specify a fixed value.\n    # Olsrd will choose links with the lowest value.\n")
+           {
+             WRITE_TO_BUF("    # When multiple links exist between hosts\n");
+             WRITE_TO_BUF("    # the weight of interface is used to determine\n");
+             WRITE_TO_BUF("    # the link to use. Normally the weight is\n")
+             WRITE_TO_BUF("    # automatically calculated by olsrd based\n");
+             WRITE_TO_BUF("    # on the characteristics of the interface,\n");
+             WRITE_TO_BUF("    # but here you can specify a fixed value.\n");
+             WRITE_TO_BUF("    # Olsrd will choose links with the lowest value.\n")
+             WRITE_TO_BUF("    # Note:\n");
+             WRITE_TO_BUF("    # Interface weight is used only when LinkQualityLevel is 0.\n");
+             WRITE_TO_BUF("    # For any other value of LinkQualityLevel, the interface ETX\n");
+             WRITE_TO_BUF("    # value is used instead.\n\n");
+            }
          if(in->cnf->weight.fixed)
            {
              WRITE_TO_BUF("    Weight\t %d\n\n", in->cnf->weight.value)
index 46a35f7..6903659 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: ifnet.c,v 1.41 2007/01/31 12:36:50 bernd67 Exp $
+ * $Id: ifnet.c,v 1.42 2007/02/04 22:37:35 bernd67 Exp $
  */
 
 
@@ -882,7 +882,6 @@ chk_if_up(struct olsr_if *iface, int debuglvl)
   
   ifs.if_index = if_nametoindex(ifr.ifr_name);
   
-  /* Set interface metric */
   /* Set interface metric */
   if(iface->cnf->weight.fixed)
     ifs.int_metric = iface->cnf->weight.value;