[Olsr-cvs] olsrd-current/lib/httpinfo/src olsrd_httpinfo.c, 1.81, 1.82 admin_interface.c, 1.10, 1.11

Bernd Petrovitsch (spam-protected)
Mon Nov 5 16:32:57 CET 2007


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

Modified Files:
	olsrd_httpinfo.c admin_interface.c 
Log Message:
Cleanup:
* Merged "struct hna4_entry" and "struct hna6_entry" into
  "struct local_hna_entry" (as "struct hna_entry" is a different thing)
  Both have almost the same data (IP address + netmask/prefix) so we use
  the quite new "struct olsr_ip_prefix" to store it.
  Also merged the "hna4" and "hna6" pointer in "struct olsr_config" -
  look at the global "olsr_cnf->ip_version".
* const'ified here and there
* added a olsr_ip_prefix_to_string() function


Index: olsrd_httpinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -C2 -d -r1.81 -r1.82
*** olsrd_httpinfo.c	2 Nov 2007 20:58:07 -0000	1.81
--- olsrd_httpinfo.c	5 Nov 2007 15:32:55 -0000	1.82
***************
*** 844,856 ****
          size += snprintf(&buf[size], bufsize-size, "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
        }
- 
      size += snprintf(&buf[size], bufsize-size, "</tr></table>\n");
  
      size += snprintf(&buf[size], bufsize-size, "<h2>Interfaces</h2>\n");
- 
- 
      size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" border=\"0\">\n");
- 
- 
      for(ifs = olsr_cnf->interfaces; ifs; ifs = ifs->next)
        {
--- 844,851 ----
***************
*** 866,878 ****
  	if(olsr_cnf->ip_version == AF_INET)
  	  {
! 	    size += snprintf(&buf[size], bufsize-size, "<tr><td>IP: %s</td>\n", 
! 			    sockaddr_to_string(&rifs->int_addr));
! 	    size += snprintf(&buf[size], bufsize-size, "<td>MASK: %s</td>\n", 
! 			    sockaddr_to_string(&rifs->int_netmask));
! 	    size += snprintf(&buf[size], bufsize-size, "<td>BCAST: %s</td></tr>\n",
! 			    sockaddr_to_string(&rifs->int_broadaddr));
! 	    size += snprintf(&buf[size], bufsize-size, "<tr><td>MTU: %d</td>\n", rifs->int_mtu);
! 	    size += snprintf(&buf[size], bufsize-size, "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
! 	    size += snprintf(&buf[size], bufsize-size, "<td>STATUS: UP</td></tr>\n");
  	  }
  	else
--- 861,867 ----
  	if(olsr_cnf->ip_version == AF_INET)
  	  {
! 	    size += snprintf(&buf[size], bufsize-size, "<tr><td>IP: %s</td>\n", sockaddr_to_string(&rifs->int_addr));
! 	    size += snprintf(&buf[size], bufsize-size, "<td>MASK: %s</td>\n", sockaddr_to_string(&rifs->int_netmask));
! 	    size += snprintf(&buf[size], bufsize-size, "<td>BCAST: %s</td></tr>\n", sockaddr_to_string(&rifs->int_broadaddr));
  	  }
  	else
***************
*** 881,953 ****
  	    size += snprintf(&buf[size], bufsize-size, "<td>MCAST: %s</td>\n", olsr_ip_to_string((union olsr_ip_addr *)&rifs->int6_multaddr.sin6_addr));
  	    size += snprintf(&buf[size], bufsize-size, "<td></td></tr>\n");
- 	    size += snprintf(&buf[size], bufsize-size, "<tr><td>MTU: %d</td>\n", rifs->int_mtu);
- 	    size += snprintf(&buf[size], bufsize-size, "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
- 	    size += snprintf(&buf[size], bufsize-size, "<td>STATUS: UP</td></tr>\n");
  	  }	    
        }
- 
      size += snprintf(&buf[size], bufsize-size, "</table>\n");
  
!     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");
- 
      size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" border=\"0\"><tr><th>Name</th><th>Parameters</th></tr>\n");
- 
      for(pentry = olsr_cnf->plugins; pentry; pentry = pentry->next)
        {
! 	size += snprintf(&buf[size], bufsize-size, "<tr><td>%s</td>\n", pentry->name);
! 
! 	size += snprintf(&buf[size], bufsize-size, "<td><select>\n");
! 	size += snprintf(&buf[size], bufsize-size, "<option>KEY, VALUE</option>\n");
  
  	for(pparam = pentry->params; pparam; pparam = pparam->next)
  	  {
! 	    size += snprintf(&buf[size], bufsize-size, "<option>\"%s\", \"%s\"</option>\n",
! 			    pparam->key,
! 			    pparam->value);
  	  }
  	size += snprintf(&buf[size], bufsize-size, "</select></td></tr>\n");
  
        }
- 
      size += snprintf(&buf[size], bufsize-size, "</table>\n");
  
      size += section_title(&buf[size], bufsize-size, "Announced HNA entries");
! 
!     if((olsr_cnf->ip_version == AF_INET) && (olsr_cnf->hna4_entries))
!       {
! 	struct hna4_entry *hna4;
! 	
! 	size += snprintf(&buf[size], bufsize-size,
!                          "<tr><th>Network</th><th>Netmask</th></tr>\n");
! 	
! 	for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
! 	  {
! 	    size += snprintf(&buf[size], bufsize-size, "<tr><td>%s</td><td>%s</td></tr>\n", 
! 			    olsr_ip_to_string(&hna4->net),
! 			    olsr_ip_to_string(&hna4->netmask));
! 	  }
!       } 
!    else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries))
!       {
! 	struct hna6_entry *hna6;
! 	
! 	size += snprintf(&buf[size], bufsize-size,
!                          "<tr><th>Network</th><th>Prefix length</th></tr>\n");
! 	
! 	for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
! 	  {
! 	    size += snprintf(&buf[size], bufsize-size, "<tr><td>%s</td><td>%d</td></tr>\n", 
! 			    olsr_ip_to_string(&hna6->net),
! 			    hna6->prefix_len);
! 	  }
! 	
        }
      size += snprintf(&buf[size], bufsize-size, "</table>\n");
- 
      return size;
  }
--- 870,927 ----
  	    size += snprintf(&buf[size], bufsize-size, "<td>MCAST: %s</td>\n", olsr_ip_to_string((union olsr_ip_addr *)&rifs->int6_multaddr.sin6_addr));
  	    size += snprintf(&buf[size], bufsize-size, "<td></td></tr>\n");
  	  }	    
+         size += snprintf(&buf[size], bufsize-size, "<tr><td>MTU: %d</td>\n", rifs->int_mtu);
+         size += snprintf(&buf[size], bufsize-size, "<td>WLAN: %s</td>\n", rifs->is_wireless ? "Yes" : "No");
+         size += snprintf(&buf[size], bufsize-size, "<td>STATUS: UP</td></tr>\n");
        }
      size += snprintf(&buf[size], bufsize-size, "</table>\n");
  
!     size += snprintf(&buf[size], bufsize-size,
!                      "<em>Olsrd is configured to %s if no interfaces are available</em><br>\n",
!                      olsr_cnf->allow_no_interfaces ? "run even" : "halt");
  
      size += snprintf(&buf[size], bufsize-size, "<h2>Plugins</h2>\n");
      size += snprintf(&buf[size], bufsize-size, "<table width=\"100%%\" border=\"0\"><tr><th>Name</th><th>Parameters</th></tr>\n");
      for(pentry = olsr_cnf->plugins; pentry; pentry = pentry->next)
        {
! 	size += snprintf(&buf[size], bufsize-size,
!                          "<tr><td>%s</td>\n"
!                          "<td><select>\n"
!                          "<option>KEY, VALUE</option>\n",
!                          pentry->name);
  
  	for(pparam = pentry->params; pparam; pparam = pparam->next)
  	  {
! 	    size += snprintf(&buf[size], bufsize-size, "<option>\"%s\", \"%s\"</option>\n", pparam->key, pparam->value);
  	  }
  	size += snprintf(&buf[size], bufsize-size, "</select></td></tr>\n");
  
        }
      size += snprintf(&buf[size], bufsize-size, "</table>\n");
  
      size += section_title(&buf[size], bufsize-size, "Announced HNA entries");
!     if(olsr_cnf->hna_entries) {
!       struct local_hna_entry *hna;
!       if(olsr_cnf->ip_version == AF_INET) {
! 	size += snprintf(&buf[size], bufsize-size, "<tr><th>Network</th><th>Netmask</th></tr>\n");
! 	for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
!             union olsr_ip_addr netmask;
!             olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
! 	    size += snprintf(&buf[size], bufsize-size,
!                              "<tr><td>%s</td><td>%s</td></tr>\n", 
! 			    olsr_ip_to_string(&hna->net.prefix),
! 			    olsr_ip_to_string(&netmask));
!         }
!       } else {
! 	size += snprintf(&buf[size], bufsize-size, "<tr><th>Network</th><th>Prefix length</th></tr>\n");
! 	for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
!           size += snprintf(&buf[size], bufsize-size,
!                            "<tr><td>%s</td><td>%d</td></tr>\n", 
!                            olsr_ip_to_string(&hna->net.prefix),
!                            hna->net.prefix_len);
!         }
        }
+     }
      size += snprintf(&buf[size], bufsize-size, "</table>\n");
      return size;
  }

Index: admin_interface.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/admin_interface.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** admin_interface.c	20 Oct 2007 20:41:04 -0000	1.10
--- admin_interface.c	5 Nov 2007 15:32:55 -0000	1.11
***************
*** 78,83 ****
  		  "TOS:", "tos", 6, "TBD");
  
!   size += snprintf(&buf[size], bufsize-size, "</tr>\n");
!   size += snprintf(&buf[size], bufsize-size, "<tr>\n");
  
    size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
--- 78,83 ----
  		  "TOS:", "tos", 6, "TBD");
  
!   size += snprintf(&buf[size], bufsize-size, "</tr>\n"
!                                              "<tr>\n");
  
    size += snprintf(&buf[size], bufsize-size, admin_basic_setting_int,
***************
*** 121,146 ****
    size += snprintf(&buf[size], bufsize-size, admin_frame_mid);
  
!   if(olsr_cnf->ip_version == AF_INET) {
!     struct hna4_entry *hna4;      
!     for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)	{
!       const char * const net = olsr_ip_to_string((union olsr_ip_addr *)&hna4->net);
!       const char * const mask = olsr_ip_to_string((union olsr_ip_addr *)&hna4->netmask);
!       size += snprintf(&buf[size], bufsize-size,
!                        "<tr><td halign=\"middle\"><input type=\"checkbox\" name=\"del_hna%s*%s\" class=\"input_checkbox\"></td><td>%s</td><td>%s</td></tr>\n", 
!                        net,
!                        mask,
!                        net,
!                        mask);
!     }
!   } else {
!     struct hna6_entry *hna6;
!     for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next) {
!       const char * const net = olsr_ip_to_string((union olsr_ip_addr *)&hna6->net);
!       size += snprintf(&buf[size], bufsize-size,
!                        "<tr><td halign=\"middle\"><input type=\"checkbox\" name=\"del_hna%s*%d\" class=\"input_checkbox\"></td><td>%s</td><td>%d</td></tr>\n", 
!                        net,
!                        hna6->prefix_len,
!                        net,
!                        hna6->prefix_len);
      }
    }
--- 121,144 ----
    size += snprintf(&buf[size], bufsize-size, admin_frame_mid);
  
!   if(olsr_cnf->hna_entries) {
!     if(olsr_cnf->ip_version == AF_INET) {
!       struct local_hna_entry *hna;
!       
!       for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
!         union olsr_ip_addr netmask;
!         olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
!         size += snprintf(&buf[size], bufsize-size,
!                          "<tr><td halign=\"middle\"><input type=\"checkbox\" name=\"del_hna%1$s*%2$s\" class=\"input_checkbox\"></td><td>%1$s</td><td>%2$s</td></tr>\n",
!                          olsr_ip_to_string(&hna->net.prefix),
!                          olsr_ip_to_string(&netmask));
!       }
!     } else {
!       struct local_hna_entry *hna;
!       for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
!         size += snprintf(&buf[size], bufsize-size,
!                          "<tr><td halign=\"middle\"><input type=\"checkbox\" name=\"del_hna%1$s*%2$d\" class=\"input_checkbox\"></td><td>%1$s</td><td>%2$d</td></tr>\n",
!                          olsr_ip_to_string(&hna->net.prefix),
!                          hna->net.prefix_len);
!       }
      }
    }





More information about the Olsr-cvs mailing list