[Olsr-cvs] olsrd-current/lib/httpinfo/src admin_interface.c, 1.11, 1.12 olsrd_httpinfo.c, 1.82, 1.83 olsrd_plugin.c, 1.20, 1.21
Bernd Petrovitsch
(spam-protected)
Thu Nov 8 23:47:42 CET 2007
Update of /cvsroot/olsrd/olsrd-current/lib/httpinfo/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28726/lib/httpinfo/src
Modified Files:
admin_interface.c olsrd_httpinfo.c olsrd_plugin.c
Log Message:
Another fat commit:
The main target was:
- Fixed the misleading definition of "v4" in "struct olsr_ip_addr" fom
"olsr_u32_t" (in network-byteorder!) to "struct in_addr". Lots of
temporary variables to call inet_ntoa()/inet_ptoa() vanished .....
- declare "int_addr", "int_netmask" and "int_broadaddr" in "struct interface"
as "struct sockaddr_in" since it is that what we actually want there (and
it is similar to the IPv6 code).
To get that thoroughly via compiler errors, we get:
- We have now ip4_to_string(), ip6_to_string() and olsr_ip_to_string()
to print a "struct in_addr", "struct in6_addr" and "union olsr_ip_addr"
into a string buffer.
Alas, this also annoyed me since ages:
- cleanup: olsr_ip_to_string() and similar non-reentrant functions now must
get a target buffer. To ease that, there is the "struct ipaddr_str"
which is large enough for all of them (read: for an IPv6 address). This
also removes the cyclic buffer there.
All of these function return a "const char *" which can be directly used
for printf(3) and friends.
And some cleanups:
- const'ified more functions
- converted the source to UTF-8.
- "struct sig_msg" uses an olsr_u8_t for a byte array (and not "char")
- force the few inline function to always be inlined.
- #ifdef the body of the olsr_print_hna_set() and olsr_print_neighbor_table()
if nothing is done
- use "inline_avl_comp_ipv4()" in "avl_comp_ipv4()"
- clean up the routes on more signals. Basically we want to do this on all
signals which terminate the program.
- killed a superflous global buffer in src/main.c
This version was breing since weeks and running for severa day in Vienna's
FunkFeuer net without any noticably problem!
Please report anything that broke!
Index: olsrd_httpinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -C2 -d -r1.82 -r1.83
*** olsrd_httpinfo.c 5 Nov 2007 15:32:55 -0000 1.82
--- olsrd_httpinfo.c 8 Nov 2007 22:47:40 -0000 1.83
***************
*** 162,166 ****
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);
static int build_ipaddr_link(char *buf, const olsr_u32_t bufsize, const olsr_bool want_link,
--- 162,166 ----
static int build_ip_txt(char *buf, const olsr_u32_t bufsize, const olsr_bool want_link,
! const char * const ipaddrstr, const int prefix_len);
[...1191 lines suppressed...]
size = snprintf(buf, size, "ERROR GENERATING CONFIGFILE!\n");
}
i++;
! while (cfgfile_body[i]) {
size += snprintf(&buf[size], bufsize-size, cfgfile_body[i]);
i++;
***************
*** 1164,1168 ****
const struct allowed_net *alln;
for (alln = allowed_nets; alln != NULL; alln = alln->next) {
! if((addr->v4 & alln->mask.v4) == (alln->net.v4 & alln->mask.v4)) {
return 1;
}
--- 1136,1140 ----
const struct allowed_net *alln;
for (alln = allowed_nets; alln != NULL; alln = alln->next) {
! if ((addr->v4.s_addr & alln->mask.v4.s_addr) == (alln->net.v4.s_addr & alln->mask.v4.s_addr)) {
return 1;
}
Index: admin_interface.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/admin_interface.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** admin_interface.c 5 Nov 2007 15:32:55 -0000 1.11
--- admin_interface.c 8 Nov 2007 22:47:40 -0000 1.12
***************
*** 52,55 ****
--- 52,56 ----
#include "admin_interface.h"
#include "local_hna_set.h" /* add_local_hna4_entry() */
+ #include "net_olsr.h"
#include <stdio.h>
***************
*** 124,128 ****
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;
--- 125,129 ----
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) {
union olsr_ip_addr netmask;
***************
*** 130,142 ****
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);
}
--- 131,144 ----
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(&netbuf, &hna->net.prefix),
! olsr_ip_to_string(&maskbuf, &netmask));
}
} else {
struct local_hna_entry *hna;
for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
+ struct ipaddr_str netbuf;
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(&netbuf, &hna->net.prefix),
hna->net.prefix_len);
}
Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_plugin.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** olsrd_plugin.c 17 Sep 2007 21:57:05 -0000 1.20
--- olsrd_plugin.c 8 Nov 2007 22:47:40 -0000 1.21
***************
*** 118,131 ****
static int insert_plugin_ipnet(const char *sz_net, const char *sz_mask, struct allowed_net **allowed_nets)
{
- struct in_addr net, mask;
struct allowed_net *an;
- if(inet_aton(sz_net, &net) == 0) {
- return 1;
- }
- if(inet_aton(sz_mask, &mask) == 0) {
- return 1;
- }
-
an = olsr_malloc(sizeof(*an), __func__);
if (an == NULL) {
--- 118,123 ----
***************
*** 134,139 ****
}
! an->net.v4 = net.s_addr;
! an->mask.v4 = mask.s_addr;
an->next = *allowed_nets;
*allowed_nets = an;
--- 126,134 ----
}
! if(inet_aton(sz_net, &an->net.v4) == 0 ||
! inet_aton(sz_mask, &an->mask.v4) == 0) {
! free(an);
! return 1;
! }
an->next = *allowed_nets;
*allowed_nets = an;
More information about the Olsr-cvs
mailing list