[Olsr-cvs] olsrd-current/lib/httpinfo/src admin_interface.c, 1.12, 1.13 olsrd_httpinfo.c, 1.87, 1.88 admin_html.h, 1.5, NONE
Bernd Petrovitsch
(spam-protected)
Thu Nov 29 01:49:43 CET 2007
Update of /cvsroot/olsrd/olsrd-current/lib/httpinfo/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16024/lib/httpinfo/src
Modified Files:
admin_interface.c olsrd_httpinfo.c
Removed Files:
admin_html.h
Log Message:
Major Changes:
- renamed "struct local_hna_entry" to "struct ip_prefix_list" since
it is exactly that. Renamed the functions in src/local_hna_set.{c,h}
in the same way.
- each IPv4 and IPv6 function pairs in src/local_hna_set.{c,h} is
called from the same place and have the same signature. So I
condensed each of them.
- Since we have only 3 functions left in src/local_hna_set.{c,h}
and they are used for the configuration, the .h file is now part
of src/olsr_cfg.h and the ,c file of src/cfgparser/olsrd_conf.c.
- replaced "struct ipc_net" with "struct ip_prefix_list" since it
serves the same purpose as the "struct ip_prefix_list"
- replaced "struct ipc_host" with "struct ip_prefix_list" since it
serves the same purpose as the "struct ip_prefix_list" and is
just a special case. No need to duplicate code etc.
- removed "union hna_netmask" from src/olsr_types since we use the
prefix_len everywhere (and that is an olsr_u8_t in several other
struct's).
That implies changes and simplifications in the code handling
them (since the IPv4 is similar to IPv6).
- the config file parser now understands for IPv4 addresses also
"/$prefix".
- On the output side, the patch generates only "/$prefix" which
kills code since it is the same as the IPv6 handling.
- There are some netmask conversions left (mainly in the plugins)
but that be cleaned up afterwards.
- extracted ip{,4,6}{cmp,equal} and formatting functions from
net_olsr.{c,h} into src/ipcalc.{c,h} since net_olsr.h became
IMHO to much of a "put anything in there".
- renamed "sockaddr_to_string()" to "sockaddr4_to_string()"
since it is exactly that (unless I'm missing something).
Minor Changes:
- lib/httpinfo/src/admin_html.h contained just some variable
definitions so it is now integrated in the only user:
admin_interface.c
- olsrd_dot_draw.c got rid of two indicator variables if
a socket is valid or not. Since sockets may use "-1" as the
"not open", "invalid" value, there is no need for two more
ints.
- and the dot_draw plugin is somewhat smaller and easier to read.
- const'ified some functions
Index: olsrd_httpinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** olsrd_httpinfo.c 16 Nov 2007 19:12:55 -0000 1.87
--- olsrd_httpinfo.c 29 Nov 2007 00:49:41 -0000 1.88
***************
*** 63,66 ****
--- 63,67 ----
#include "link_set.h"
#include "socket_parser.h"
+ #include "ipcalc.h"
#include "olsrd_httpinfo.h"
***************
*** 233,245 ****
static const struct static_bin_file_entry static_bin_files[] = {
! #if 0
! {"favicon.ico", favicon_ico, 1406/*favicon_ico_len*/},
! {"logo.gif", logo_gif, 2801/*logo_gif_len*/},
! {"grayline.gif", grayline_gif, 43/*grayline_gif_len*/},
! #else
! {"favicon.ico", favicon_ico, sizeof(favicon_ico)},
! {"logo.gif", logo_gif, sizeof(logo_gif)},
{"grayline.gif", grayline_gif, sizeof(grayline_gif)},
- #endif
{NULL, NULL, 0}
};
--- 234,240 ----
static const struct static_bin_file_entry static_bin_files[] = {
! {"favicon.ico", favicon_ico, sizeof(favicon_ico)},
! {"logo.gif", logo_gif, sizeof(logo_gif)},
{"grayline.gif", grayline_gif, sizeof(grayline_gif)},
{NULL, NULL, 0}
};
***************
*** 259,288 ****
};
- /**
- *Do initialization here
- *
- *This function is called by the my_init
- *function in uolsrd_plugin.c
- */
- int
- olsrd_plugin_init(void)
- {
- /* Get start time */
- gettimeofday(&start_time, NULL);
-
- curr_clients = 0;
- /* set up HTTP socket */
- http_socket = get_http_socket(http_port != 0 ? http_port : DEFAULT_TCP_PORT);
-
- if (http_socket < 0) {
- fprintf(stderr, "(HTTPINFO) could not initialize HTTP socket\n");
- exit(0);
- }
-
- /* Register socket */
- add_olsr_socket(http_socket, &parse_http_request);
-
- return 1;
- }
static int
--- 254,257 ----
***************
*** 330,333 ****
--- 299,328 ----
}
+ /**
+ *Do initialization here
+ *
+ *This function is called by the my_init
+ *function in uolsrd_plugin.c
+ */
+ int
+ olsrd_plugin_init(void)
+ {
+ /* Get start time */
+ gettimeofday(&start_time, NULL);
+
+ curr_clients = 0;
+ /* set up HTTP socket */
+ http_socket = get_http_socket(http_port != 0 ? http_port : DEFAULT_TCP_PORT);
+
+ if (http_socket < 0) {
+ fprintf(stderr, "(HTTPINFO) could not initialize HTTP socket\n");
+ exit(0);
+ }
+
+ /* Register socket */
+ add_olsr_socket(http_socket, &parse_http_request);
+
+ return 1;
+ }
/* Non reentrant - but we are not multithreaded anyway */
***************
*** 489,495 ****
"<tbody><tr bgcolor=\"#ffffff\">\n"
"<td align=\"left\" height=\"69\" valign=\"middle\" width=\"80%%\">\n"
! "<font color=\"black\" face=\"timesroman\" size=\"6\"> olsr.org OLSR daemon</font></td>\n"
"<td align=\"right\" height=\"69\" valign=\"middle\" width=\"20%%\">\n"
! "<img src=\"/logo.gif\" alt=\"olsrd logo\"></td>\n"
"</tr>\n"
"</tbody>\n"
--- 484,490 ----
"<tbody><tr bgcolor=\"#ffffff\">\n"
"<td align=\"left\" height=\"69\" valign=\"middle\" width=\"80%%\">\n"
! "<font color=\"black\" face=\"timesroman\" size=\"6\"> <a href=\"http://www.olsr.org/\">olsr.org OLSR daemon</a></font></td>\n"
"<td align=\"right\" height=\"69\" valign=\"middle\" width=\"20%%\">\n"
! "<a href=\"http://www.olsr.org/\"><img border=\"0\" src=\"/logo.gif\" alt=\"olsrd logo\"></a></td>\n"
"</tr>\n"
"</tbody>\n"
***************
*** 653,658 ****
olsr_plugin_exit(void)
{
! if (http_socket) {
! close(http_socket);
}
}
--- 648,653 ----
olsr_plugin_exit(void)
{
! if (http_socket >= 0) {
! CLOSE(http_socket);
}
}
***************
*** 866,884 ****
size += snprintf(&buf[size], bufsize-size, "<td>Willingness: %d %s</td>\n", olsr_cnf->willingness, olsr_cnf->willingness_auto ? "(auto)" : "");
- size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n");
if (olsr_cnf->lq_level == 0) {
! size += snprintf(&buf[size], bufsize-size, "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
if (olsr_cnf->use_hysteresis) {
size += snprintf(&buf[size], bufsize-size, "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
size += snprintf(&buf[size], bufsize-size, "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
}
- } else {
- size += snprintf(&buf[size], bufsize-size, "<td></td>\n");
}
! size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n");
!
! size += snprintf(&buf[size], bufsize-size, "<td>LQ extension: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
if (olsr_cnf->lq_level) {
size += snprintf(&buf[size], bufsize-size,
--- 861,876 ----
size += snprintf(&buf[size], bufsize-size, "<td>Willingness: %d %s</td>\n", olsr_cnf->willingness, olsr_cnf->willingness_auto ? "(auto)" : "");
if (olsr_cnf->lq_level == 0) {
! size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n"
! "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
if (olsr_cnf->use_hysteresis) {
size += snprintf(&buf[size], bufsize-size, "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
size += snprintf(&buf[size], bufsize-size, "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
}
}
! size += snprintf(&buf[size], bufsize-size, "</tr>\n<tr>\n"
! "<td>LQ extension: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
if (olsr_cnf->lq_level) {
size += snprintf(&buf[size], bufsize-size,
***************
*** 958,962 ****
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");
--- 950,954 ----
size += section_title(&buf[size], bufsize-size, "Announced HNA entries");
if (olsr_cnf->hna_entries) {
! struct ip_prefix_list *hna;
if (olsr_cnf->ip_version == AF_INET) {
size += snprintf(&buf[size], bufsize-size, "<tr><th>Network</th><th>Netmask</th></tr>\n");
Index: admin_interface.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/admin_interface.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** admin_interface.c 8 Nov 2007 22:47:40 -0000 1.12
--- admin_interface.c 29 Nov 2007 00:49:41 -0000 1.13
***************
*** 49,56 ****
#include "olsrd_httpinfo.h"
#include "olsr_cfg.h"
- #include "admin_html.h"
#include "admin_interface.h"
- #include "local_hna_set.h" /* add_local_hna4_entry() */
#include "net_olsr.h"
#include <stdio.h>
--- 49,55 ----
#include "olsrd_httpinfo.h"
#include "olsr_cfg.h"
#include "admin_interface.h"
#include "net_olsr.h"
+ #include "ipcalc.h"
#include <stdio.h>
***************
*** 63,66 ****
--- 62,96 ----
#endif
+ static const char admin_basic_setting_int[] = "<td><strong>%s</strong></td><td><input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%d\"></td>\n";
+ static const char admin_basic_setting_float[] = "<td><strong>%s</strong></td><td><input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%0.2f\"></td>\n";
+ static const char admin_basic_setting_string[] = "<td><strong>%s</strong></td><td><input type=\"text\" name=\"%s\" maxlength=\"%d\" class=\"input_text\" value=\"%s\"></td>\n";
+
+ static const char admin_frame_prolog[] =
+ "<strong>Administrator interface</strong><hr>\n"
+ "<h2>Change basic settings</h2>\n"
+ "<form action=\"set_values\" method=\"post\">\n"
+ "<table width=\"100%%\">\n";
+
+ static const char admin_frame_mid[] =
+ "</table>\n<br>\n"
+ "<center><input type=\"submit\" value=\"Submit\" class=\"input_button\">\n"
+ "<input type=\"reset\" value=\"Reset\" class=\"input_button\"></center>\n"
+ "</form>\n"
+ "<h2>Add/remove local HNA entries</h2>\n"
+ "<form action=\"set_values\" method=\"post\">\n"
+ "<table width=\"100%%\"><tr><td><strong>Network:</strong></td>\n"
+ "<td><input type=\"text\" name=\"hna_new_net\" maxlength=\"16\" class=\"input_text\" value=\"0.0.0.0\"></td>\n"
+ "<td><strong>Netmask/Prefix:</strong></td>\n"
+ "<td><input type=\"text\" name=\"hna_new_netmask\" maxlength=\"16\" class=\"input_text\" value=\"0.0.0.0\"></td>\n"
+ "<td><input type=\"submit\" value=\"Add entry\" class=\"input_button\"></td></form>\n"
+ "</table><hr>\n"
+ "<form action=\"set_values\" method=\"post\">\n"
+ "<table width=\"100%%\">\n"
+ "<tr><th width=50 halign=\"middle\">Delete</th><th>Network</th><th>Netmask</th></tr>\n";
+
+ static const char admin_frame_epilog[] =
+ "</table>\n<br>\n"
+ "<center><input type=\"submit\" value=\"Delete selected\" class=\"input_button\"></center>\n"
+ "</form>\n";
int
***************
*** 124,128 ****
if(olsr_cnf->hna_entries) {
if(olsr_cnf->ip_version == AF_INET) {
! struct local_hna_entry *hna;
struct ipaddr_str netbuf, maskbuf;
for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
--- 154,158 ----
if(olsr_cnf->hna_entries) {
if(olsr_cnf->ip_version == AF_INET) {
! struct ip_prefix_list *hna;
struct ipaddr_str netbuf, maskbuf;
for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
***************
*** 135,139 ****
}
} else {
! struct local_hna_entry *hna;
for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
struct ipaddr_str netbuf;
--- 165,169 ----
}
} else {
! struct ip_prefix_list *hna;
for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
struct ipaddr_str netbuf;
--- admin_html.h DELETED ---
More information about the Olsr-cvs
mailing list