[Olsr-cvs] olsrd-current/lib/httpinfo/src html.h, 1.7, 1.8 olsrd_httpinfo.c, 1.76, 1.77

Bernd Petrovitsch (spam-protected)
Sun Sep 16 23:20:09 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/lib/httpinfo/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv8566/lib/httpinfo/src

Modified Files:
	html.h olsrd_httpinfo.c 
Log Message:
* creating builddata.c containing build time information as date+time,
  host and version
  and using it througout
* activated links in the httpinfo plugin again if we have host links
  other minor HTML cleanups there
* replaced the olsr_host_rt_maxplen() function with a field in
  "struct olsr_cfg" similar to "ipsize"


Index: olsrd_httpinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -C2 -d -r1.76 -r1.77
*** olsrd_httpinfo.c	13 Sep 2007 16:08:12 -0000	1.76
--- olsrd_httpinfo.c	16 Sep 2007 21:20:07 -0000	1.77
***************
*** 88,92 ****
  #endif
  
! static char copyright_string[] = "olsr.org HTTPINFO plugin Copyright (c) 2004, Andreas Tønnesen((spam-protected)) All rights reserved.";
  
  #define MAX_CLIENTS 3
--- 88,92 ----
  #endif
  
! static char copyright_string[] __attribute__((unused)) = "olsr.org HTTPINFO plugin Copyright (c) 2004, Andreas Tønnesen((spam-protected)) All rights reserved.";
  
  #define MAX_CLIENTS 3
***************
*** 96,100 ****
  #define DEFAULT_TCP_PORT 1978
  
! #define HTML_BUFSIZE (1024 * 400)
  
  #define FRAMEWIDTH 800
--- 96,100 ----
  #define DEFAULT_TCP_PORT 1978
  
! #define HTML_BUFSIZE (1024 * 4000)
  
  #define FRAMEWIDTH 800
***************
*** 232,236 ****
  olsrd_plugin_init(void)
  {
-   (void)copyright_string;
    /* Get start time */
    gettimeofday(&start_time, NULL);
--- 232,235 ----
***************
*** 679,692 ****
  }
  
! static int build_ip_txt(char *buf, const olsr_u32_t bufsize, const olsr_bool want_link,
!                         const union olsr_ip_addr * const ipaddr, const int prefix_len)
  {
    int size = 0;
!   if (want_link && prefix_len == -1) { /* Print the link only if there is no prefix_len */
!     size += snprintf(&buf[size],
!                      bufsize-size,
!                      "<a href=\"http://%s:%d/all\">",
!                      olsr_ip_to_string(ipaddr),
!                      http_port);
    }
  
--- 678,701 ----
  }
  
! static int fmt_href(char *buf,
!                     const olsr_u32_t bufsize,
!                     const union olsr_ip_addr * const ipaddr)
! {
!   return snprintf(buf, bufsize,
!                   "<a href=\"http://%s:%d/all\">",
!                   olsr_ip_to_string(ipaddr),
!                   http_port);
! 
! }
! 
! static int build_ip_txt(char *buf,
!                         const olsr_u32_t bufsize,
!                         const olsr_bool print_link,
!                         const union olsr_ip_addr * const ipaddr,
!                         const int prefix_len)
  {
    int size = 0;
!   if (print_link) { /* Print the link only if there is no prefix_len */
!     size += fmt_href(&buf[size], bufsize-size, ipaddr);
    }
  
***************
*** 699,703 ****
    }
    
!   if (want_link && prefix_len == -1) { /* Print the link only if there is no prefix_len */
      size += snprintf(&buf[size], bufsize-size, "</a>");
    }
--- 708,712 ----
    }
    
!   if (print_link) { /* Print the link only if there is no prefix_len */
      size += snprintf(&buf[size], bufsize-size, "</a>");
    }
***************
*** 716,722 ****
  #endif
        NULL;
  
    size += snprintf(&buf[size], bufsize-size, "<td>");
!   size += build_ip_txt(&buf[size], bufsize-size, want_link, ipaddr, prefix_len);
    size += snprintf(&buf[size], bufsize-size, "</td>");
  
--- 725,732 ----
  #endif
        NULL;
+   const int print_link = want_link && (prefix_len == -1 || prefix_len == olsr_cnf->maxplen);
  
    size += snprintf(&buf[size], bufsize-size, "<td>");
!   size += build_ip_txt(&buf[size], bufsize-size, print_link, ipaddr, prefix_len);
    size += snprintf(&buf[size], bufsize-size, "</td>");
  
***************
*** 724,728 ****
--- 734,744 ----
      if (hp) {
        size += snprintf(&buf[size], bufsize-size, "<td>(");
+       if (print_link) {
+         size += fmt_href(&buf[size], bufsize-size, ipaddr);
+       }
        size += snprintf(&buf[size], bufsize-size, "%s", hp->h_name);
+       if (print_link) {
+         size += snprintf(&buf[size], bufsize-size, "</a>");
+       }
        size += snprintf(&buf[size], bufsize-size, ")</td>");
      } else {
***************
*** 782,819 ****
  static int build_config_body(char *buf, olsr_u32_t bufsize)
  {
-     char systime[100];
-     time_t currtime;
      int size = 0;
      struct olsr_if *ifs;
      struct plugin_entry *pentry;
      struct plugin_param *pparam;
-     struct timeval now, uptime;
-     int hours, mins, days;
  
!     gettimeofday(&now, NULL);
!     timersub(&now, &start_time, &uptime);
!     days = uptime.tv_sec/86400;
!     uptime.tv_sec -= days*86400;
!     hours = uptime.tv_sec/3600;
!     uptime.tv_sec -= hours*3600;
!     mins = uptime.tv_sec/60;
!     uptime.tv_sec -= mins*60;
! 
!     time(&currtime);
!     strftime(systime, 100, "System time: <i>%a, %d %b %Y %H:%M:%S</i><br>", localtime(&currtime));
  
  
!     size += snprintf(&buf[size], bufsize-size, "OS: %s\n<br>", OS);
  
!     size += snprintf(&buf[size], bufsize-size, "%s\n", systime);
  
!     if(days)
!       size += snprintf(&buf[size], bufsize-size, "Olsrd uptime: <i>%d day(s) %02d hours %02d minutes %02d seconds</i><br>\n", days, hours, mins, (int)uptime.tv_sec);
!     else
!       size += snprintf(&buf[size], bufsize-size, "Olsrd uptime: <i>%02d hours %02d minutes %02d seconds</i><br>\n", hours, mins, (int)uptime.tv_sec);
  
!     size += snprintf(&buf[size], bufsize-size, "HTTP stats(ok/dyn/error/illegal): <i>%d/%d/%d/%d</i><br>\n", stats.ok_hits, stats.dyn_hits, stats.err_hits, stats.ill_hits);
  
!     size += snprintf(&buf[size], bufsize-size, "Click <a href=\"/cfgfile\">here</a> to <i>generate a configuration file for this node</i>.\n");
  
      size += snprintf(&buf[size], bufsize-size, "<h2>Variables</h2>\n");
--- 798,840 ----
  static int build_config_body(char *buf, olsr_u32_t bufsize)
  {
      int size = 0;
      struct olsr_if *ifs;
      struct plugin_entry *pentry;
      struct plugin_param *pparam;
  
!     size += snprintf(&buf[size], bufsize-size, "Version: %s (built on %s on %s)\n<br>", olsrd_version, build_date, build_host);
!     size += snprintf(&buf[size], bufsize-size, "OS: %s\n<br>", OS);
  
+     { 
+       time_t currtime = time(NULL);
+       int rc = strftime(&buf[size], bufsize-size, "System time: <em>%a, %d %b %Y %H:%M:%S</em><br>", localtime(&currtime));
+       if (rc > 0) {
+         size += rc;
+       }
+     }
  
!     {
!       struct timeval now, uptime;
!       int hours, mins, days;
!       gettimeofday(&now, NULL);
!       timersub(&now, &start_time, &uptime);
  
!       days = uptime.tv_sec/86400;
!       uptime.tv_sec %= 86400;
!       hours = uptime.tv_sec/3600;
!       uptime.tv_sec %= 3600;
!       mins = uptime.tv_sec/60;
!       uptime.tv_sec %= 60;
  
!       size += snprintf(&buf[size], bufsize-size, "Olsrd uptime: <em>");
!       if (days) {
!         size += snprintf(&buf[size], bufsize-size, "%d day(s) ", days);
!       }
!       size += snprintf(&buf[size], bufsize-size, "%02d hours %02d minutes %02d seconds</em><br/>\n", hours, mins, (int)uptime.tv_sec);
!     }
  
!     size += snprintf(&buf[size], bufsize-size, "HTTP stats(ok/dyn/error/illegal): <em>%d/%d/%d/%d</em><br>\n", stats.ok_hits, stats.dyn_hits, stats.err_hits, stats.ill_hits);
  
!     size += snprintf(&buf[size], bufsize-size, "Click <a href=\"/cfgfile\">here</a> to <em>generate a configuration file for this node</em>.\n");
  
      size += snprintf(&buf[size], bufsize-size, "<h2>Variables</h2>\n");
***************
*** 910,916 ****
  
      if(olsr_cnf->allow_no_interfaces)
!       size += snprintf(&buf[size], bufsize-size, "<i>Olsrd is configured to run even if no interfaces are available</i><br>\n");
      else
!       size += snprintf(&buf[size], bufsize-size, "<i>Olsrd is configured to halt if no interfaces are available</i><br>\n");
  
      size += snprintf(&buf[size], bufsize-size, "<h2>Plugins</h2>\n");
--- 931,937 ----
  
      if(olsr_cnf->allow_no_interfaces)
!       size += snprintf(&buf[size], bufsize-size, "<em>Olsrd is configured to run even if no interfaces are available</em><br>\n");
      else
!       size += snprintf(&buf[size], bufsize-size, "<em>Olsrd is configured to halt if no interfaces are available</em><br>\n");
  
      size += snprintf(&buf[size], bufsize-size, "<h2>Plugins</h2>\n");
***************
*** 1166,1176 ****
  static int build_about_body(char *buf, olsr_u32_t bufsize)
  {
!   int size = 0, i = 0;
! 
!   while(about_frame[i]) {
!       size += snprintf(&buf[size], bufsize-size, about_frame[i]);
!       i++;
!   }
!   return size;
  }
  
--- 1187,1191 ----
  static int build_about_body(char *buf, olsr_u32_t bufsize)
  {
!   return snprintf(buf, bufsize, about_frame, build_date, build_host);
  }
  

Index: html.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/html.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** html.h	4 Feb 2007 22:37:36 -0000	1.7
--- html.h	16 Sep 2007 21:20:07 -0000	1.8
***************
*** 126,131 ****
  
  
- 
- 
  static const char *http_ok_tail[] =
  {
--- 126,129 ----
***************
*** 133,137 ****
      "<div id=\"footer\">\n\n",
      "<p><center>\n",
!     "(C)2005 Andreas Tønnesen<br>\n",
      "<a href=\"http://www.olsr.org/\">http://www.olsr.org</a>\n",
      "</center>\n",
--- 131,135 ----
      "<div id=\"footer\">\n\n",
      "<p><center>\n",
!     "(C)2005 Andreas Tønnesen<br/>\n",
      "<a href=\"http://www.olsr.org/\">http://www.olsr.org</a>\n",
      "</center>\n",
***************
*** 144,199 ****
  {
      "\n\n",
!     "<b>This is a automatically generated configuration\n",
!     "file based on the current olsrd configuration of this node.<br>\n",
!     "<hr>\n",
      "<pre>\n",
      "<!-- CFGFILE -->",
!     "</pre>\n<hr>\n",
      NULL
  };
  
  
! static const char *about_frame[] =
  {
!     "<b>" PLUGIN_NAME " version " PLUGIN_VERSION "</b><br>\n"
!     "by Andreas Tønnesen (C)2005.<br>\n",
  #ifdef ADMIN_INTERFACE
!     "Compiled <i>with experimental admin interface</i> " __DATE__ "<hr>\n"
! #else
!     "Compiled " __DATE__ "<hr>\n"
  #endif
!     "This plugin implements a HTTP server that supplies\n",
!     "the client with various dynamic web pages representing\n",
!     "the current olsrd status.<br>The different pages include:\n",
!     "<ul>\n<li><b>Configuration</b> - This page displays information\n",
!     "about the current olsrd configuration. This includes various\n",
!     "olsr settings such as IP version, MID/TC redundancy, hysteresis\n",
!     "etc. Information about the current status of the interfaces on\n",
!     "which olsrd is configured to run is also displayed. Loaded olsrd\n",
!     "plugins are shown with their plugin parameters. Finally all local\n",
!     "HNA entries are shown. These are the networks that the local host\n",
!     "will anounce itself as a gateway to.</li>\n",
!     "<li><b>Routes</b> - This page displays all routes currently set in\n",
!     "the kernel <i>by olsrd</i>. The type of route is also displayed(host\n",
!     "or HNA).</li>\n",
!     "<li><b>Links/Topology</b> - This page displays all information about\n",
!     "links, neighbors, topology, MID and HNA entries.</li>\n",
!     "<li><b>All</b> - Here all the previous pages are displayed as one.\n",
!     "This is to make all information available as easy as possible(for example\n",
!     "for a script) and using as few resources as possible.</li>\n",
  #ifdef ADMIN_INTERFACE
!     "<li><b>Admin</b> - This page is highly experimental(and unsecure)!\n",
!     "As of now it is not working at all but it provides a impression of\n",
!     "the future possibilities of httpinfo. This is to be a interface to\n",
      "changing olsrd settings in realtime. These settings include various\n"
!     "\"basic\" settings and local HNA settings.\n",
  #endif
!     "<li><b>About</b> - this help page.</li>\n</ul>",
!     "<hr>\n",
!     "Send questions or comments to\n",
!     "<a href=\"mailto:(spam-protected)\">(spam-protected)</a> or\n",
!     "<a href=\"mailto:andreto-at-olsr.org\">andreto-at-olsr.org</a><br>\n"
!     "Official olsrd homepage: <a href=\"http://www.olsr.org/\">http://www.olsr.org</a><br>\n",
!     NULL
  };
  
--- 142,196 ----
  {
      "\n\n",
!     "<strong>This is a automatically generated configuration\n",
!     "file based on the current olsrd configuration of this node.<br/>\n",
!     "<hr/>\n",
      "<pre>\n",
      "<!-- CFGFILE -->",
!     "</pre>\n<hr/>\n",
      NULL
  };
  
  
! static const char about_frame[] =
  {
!     "<strong>" PLUGIN_NAME " version " PLUGIN_VERSION "</strong><br/>\n"
!     "by Andreas Tønnesen (C)2005.<br/>\n"
!     "Compiled "
  #ifdef ADMIN_INTERFACE
!               "<em>with experimental admin interface</em> "
  #endif
!                                                            "%s at %s<hr/>\n"
!     "This plugin implements a HTTP server that supplies\n"
!     "the client with various dynamic web pages representing\n"
!     "the current olsrd status.<br/>The different pages include:\n"
!     "<ul>\n<li><strong>Configuration</strong> - This page displays information\n"
!     "about the current olsrd configuration. This includes various\n"
!     "olsr settings such as IP version, MID/TC redundancy, hysteresis\n"
!     "etc. Information about the current status of the interfaces on\n"
!     "which olsrd is configured to run is also displayed. Loaded olsrd\n"
!     "plugins are shown with their plugin parameters. Finally all local\n"
!     "HNA entries are shown. These are the networks that the local host\n"
!     "will anounce itself as a gateway to.</li>\n"
!     "<li><strong>Routes</strong> - This page displays all routes currently set in\n"
!     "the kernel <em>by olsrd</em>. The type of route is also displayed(host\n"
!     "or HNA).</li>\n"
!     "<li><strong>Links/Topology</strong> - This page displays all information about\n"
!     "links, neighbors, topology, MID and HNA entries.</li>\n"
!     "<li><strong>All</strong> - Here all the previous pages are displayed as one.\n"
!     "This is to make all information available as easy as possible(for example\n"
!     "for a script) and using as few resources as possible.</li>\n"
  #ifdef ADMIN_INTERFACE
!     "<li><strong>Admin</strong> - This page is highly experimental(and unsecure)!\n"
!     "As of now it is not working at all but it provides a impression of\n"
!     "the future possibilities of httpinfo. This is to be a interface to\n"
      "changing olsrd settings in realtime. These settings include various\n"
!     "\"basic\" settings and local HNA settings.</li>\n"
  #endif
!     "<li><strong>About</strong> - this help page.</li>\n</ul>"
!     "<hr/>\n"
!     "Send questions or comments to\n"
!     "<a href=\"mailto:(spam-protected)\">(spam-protected)</a> or\n"
!     "<a href=\"mailto:andreto-at-olsr.org\">andreto-at-olsr.org</a><br/>\n"
!     "Official olsrd homepage: <a href=\"http://www.olsr.org/\">http://www.olsr.org</a><br/>\n"
  };
  





More information about the Olsr-cvs mailing list