[Olsr-cvs] olsrd-current/lib/txtinfo/src olsrd_plugin.c, 1.3, 1.4 olsrd_txtinfo.c, 1.14, 1.15
Bernd Petrovitsch
(spam-protected)
Thu Nov 8 23:47:43 CET 2007
Update of /cvsroot/olsrd/olsrd-current/lib/txtinfo/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28726/lib/txtinfo/src
Modified Files:
olsrd_plugin.c olsrd_txtinfo.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_txtinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/txtinfo/src/olsrd_txtinfo.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** olsrd_txtinfo.c 5 Nov 2007 15:32:55 -0000 1.14
--- olsrd_txtinfo.c 8 Nov 2007 22:47:41 -0000 1.15
***************
*** 76,79 ****
--- 76,80 ----
#include "link_set.h"
#include "socket_parser.h"
+ #include "net_olsr.h"
#include "olsrd_txtinfo.h"
***************
*** 250,254 ****
INET6_ADDRSTRLEN) == NULL)
addr[0] = '\0';
! if (!COMP_IP(&sin4->sin_addr, &ipc_accept_ip.v4)) {
olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n", addr);
close(ipc_connection);
--- 251,255 ----
INET6_ADDRSTRLEN) == NULL)
addr[0] = '\0';
! if (!ip4equal(&sin4->sin_addr, &ipc_accept_ip.v4)) {
olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n", addr);
close(ipc_connection);
***************
*** 261,266 ****
addr[0] = '\0';
/* Use in6addr_any (::) in olsr.conf to allow anybody. */
! if (!COMP_IP(&in6addr_any, &ipc_accept_ip.v6) &&
! !COMP_IP(&sin6->sin6_addr, &ipc_accept_ip.v6)) {
olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n", addr);
close(ipc_connection);
--- 262,267 ----
addr[0] = '\0';
/* Use in6addr_any (::) in olsr.conf to allow anybody. */
! if (!ip6equal(&in6addr_any, &ipc_accept_ip.v6) &&
! !ip6equal(&sin6->sin6_addr, &ipc_accept_ip.v6)) {
olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n", addr);
close(ipc_connection);
***************
*** 297,300 ****
--- 298,302 ----
static void ipc_print_neigh_link(void)
{
+ struct ipaddr_str buf;
struct neighbor_entry *neigh;
struct neighbor_2_list_entry *list_2;
***************
*** 308,313 ****
while(link) {
ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%d\t%d\t%0.2f\t%0.2f\t\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,
--- 310,315 ----
while(link) {
ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%d\t%d\t%0.2f\t%0.2f\t\n",
! olsr_ip_to_string(&buf, &link->local_iface_addr),
! olsr_ip_to_string(&buf, &link->neighbor_iface_addr),
link->L_link_quality,
link->loss_link_quality,
***************
*** 326,330 ****
neigh = neigh->next) {
ipc_sendf("%s\t%s\t%s\t%s\t%d\t",
! olsr_ip_to_string(&neigh->neighbor_main_addr),
(neigh->status == SYM) ? "YES" : "NO",
neigh->is_mpr ? "YES" : "NO",
--- 328,332 ----
neigh = neigh->next) {
ipc_sendf("%s\t%s\t%s\t%s\t%d\t",
! olsr_ip_to_string(&buf, &neigh->neighbor_main_addr),
(neigh->status == SYM) ? "YES" : "NO",
neigh->is_mpr ? "YES" : "NO",
***************
*** 337,341 ****
list_2 = list_2->next)
{
! //size += sprintf(&buf[size], "<option>%s</option>\n", olsr_ip_to_string(&list_2->neighbor_2->neighbor_2_addr));
thop_cnt ++;
}
--- 339,343 ----
list_2 = list_2->next)
{
! //size += sprintf(&buf[size], "<option>%s</option>\n", olsr_ip_to_string(&buf, &list_2->neighbor_2->neighbor_2_addr));
thop_cnt ++;
}
***************
*** 348,351 ****
--- 350,354 ----
static void ipc_print_routes(void)
{
+ struct ipaddr_str buf;
struct rt_entry *rt;
struct avl_node *rt_tree_node;
***************
*** 361,371 ****
ipc_sendf( "%s/%d\t%s\t%d\t%.3f\t%s\t\n",
! olsr_ip_to_string(&rt->rt_dst.prefix),
rt->rt_dst.prefix_len,
! olsr_ip_to_string(&rt->rt_best->rtp_nexthop.gateway),
rt->rt_best->rtp_metric.hops,
rt->rt_best->rtp_metric.etx,
if_ifwithindex_name(rt->rt_best->rtp_nexthop.iif_index));
-
}
ipc_sendf("\n");
--- 364,373 ----
ipc_sendf( "%s/%d\t%s\t%d\t%.3f\t%s\t\n",
! olsr_ip_to_string(&buf, &rt->rt_dst.prefix),
rt->rt_dst.prefix_len,
! olsr_ip_to_string(&buf, &rt->rt_best->rtp_nexthop.gateway),
rt->rt_best->rtp_metric.hops,
rt->rt_best->rtp_metric.etx,
if_ifwithindex_name(rt->rt_best->rtp_nexthop.iif_index));
}
ipc_sendf("\n");
***************
*** 376,389 ****
{
struct tc_entry *tc;
! struct tc_edge_entry *tc_edge;
!
ipc_sendf("Table: Topology\nDestination IP\tLast hop IP\tLQ\tILQ\tETX\n");
/* Topology */
OLSR_FOR_ALL_TC_ENTRIES(tc) {
OLSR_FOR_ALL_TC_EDGE_ENTRIES(tc, tc_edge) {
ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%0.2f\n",
! olsr_ip_to_string(&tc_edge->T_dest_addr),
! olsr_ip_to_string(&tc->addr),
tc_edge->link_quality,
tc_edge->inverse_link_quality,
--- 378,392 ----
{
struct tc_entry *tc;
!
ipc_sendf("Table: Topology\nDestination IP\tLast hop IP\tLQ\tILQ\tETX\n");
/* Topology */
OLSR_FOR_ALL_TC_ENTRIES(tc) {
+ struct tc_edge_entry *tc_edge;
OLSR_FOR_ALL_TC_EDGE_ENTRIES(tc, tc_edge) {
+ struct ipaddr_str dstbuf, addrbuf;
ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%0.2f\n",
! olsr_ip_to_string(&dstbuf, &tc_edge->T_dest_addr),
! olsr_ip_to_string(&addrbuf, &tc->addr),
tc_edge->link_quality,
tc_edge->inverse_link_quality,
***************
*** 399,405 ****
{
int size;
! olsr_u8_t index;
! struct hna_entry *tmp_hna;
! struct hna_net *tmp_net;
struct local_hna_entry *hna;
--- 402,406 ----
{
int size;
! int index;
struct local_hna_entry *hna;
***************
*** 410,427 ****
/* Announced HNA entries */
if (olsr_cnf->ip_version == AF_INET) {
! for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
union olsr_ip_addr netmask;
olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
ipc_sendf("%s\t%s\t%s\n",
! olsr_ip_to_string(&hna->net.prefix),
! olsr_ip_to_string(&netmask),
! olsr_ip_to_string(&olsr_cnf->main_addr));
}
} else {
! for(hna = olsr_cnf->hna_entries; hna; hna = hna->next) {
ipc_sendf("%s\t%d\t%s\n",
! olsr_ip_to_string(&hna->net.prefix),
hna->net.prefix_len,
! olsr_ip_to_string(&olsr_cnf->main_addr));
}
}
--- 411,430 ----
/* Announced HNA entries */
if (olsr_cnf->ip_version == AF_INET) {
! for(hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
! struct ipaddr_str addrbuf, maskbuf, mainaddrbuf;
union olsr_ip_addr netmask;
olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
ipc_sendf("%s\t%s\t%s\n",
! olsr_ip_to_string(&addrbuf, &hna->net.prefix),
! olsr_ip_to_string(&maskbuf, &netmask),
! olsr_ip_to_string(&mainaddrbuf, &olsr_cnf->main_addr));
}
} else {
! for(hna = olsr_cnf->hna_entries; hna != NULL; hna = hna->next) {
! struct ipaddr_str addrbuf, mainaddrbuf;
ipc_sendf("%s\t%d\t%s\n",
! olsr_ip_to_string(&addrbuf, &hna->net.prefix),
hna->net.prefix_len,
! olsr_ip_to_string(&mainaddrbuf, &olsr_cnf->main_addr));
}
}
***************
*** 429,458 ****
/* HNA entries */
for(index = 0; index < HASHSIZE; index++) {
! tmp_hna = hna_set[index].next;
/* Check all entrys */
! while(tmp_hna != &hna_set[index]) {
/* Check all networks */
! tmp_net = tmp_hna->networks.next;
!
! while(tmp_net != &tmp_hna->networks) {
! if (AF_INET == olsr_cnf->ip_version) {
ipc_sendf("%s\t%s\t%s\n",
! olsr_ip_to_string(&tmp_net->A_network_addr),
! olsr_ip_to_string((union olsr_ip_addr *)&tmp_net->A_netmask.v4),
! olsr_ip_to_string(&tmp_hna->A_gateway_addr));
} else {
ipc_sendf("%s\t%d\t%s\n",
! olsr_ip_to_string(&tmp_net->A_network_addr),
tmp_net->A_netmask.v6,
! olsr_ip_to_string(&tmp_hna->A_gateway_addr));
}
! tmp_net = tmp_net->next;
! }
!
! tmp_hna = tmp_hna->next;
}
}
ipc_sendf("\n");
-
}
--- 432,459 ----
/* HNA entries */
for(index = 0; index < HASHSIZE; index++) {
! struct hna_entry *tmp_hna;
/* Check all entrys */
! for (tmp_hna = hna_set[index].next; tmp_hna != &hna_set[index]; tmp_hna = tmp_hna->next) {
/* Check all networks */
! struct hna_net *tmp_net;
! for (tmp_net = tmp_hna->networks.next; tmp_net != &tmp_hna->networks; tmp_net = tmp_net->next) {
! if (olsr_cnf->ip_version == AF_INET) {
! struct ipaddr_str addrbuf, maskbuf, mainaddrbuf;
! const union olsr_ip_addr netmask = { .v4 = { .s_addr = tmp_net->A_netmask.v4 } };
ipc_sendf("%s\t%s\t%s\n",
! olsr_ip_to_string(&addrbuf, &tmp_net->A_network_addr),
! olsr_ip_to_string(&maskbuf, &netmask),
! olsr_ip_to_string(&mainaddrbuf, &tmp_hna->A_gateway_addr));
} else {
+ struct ipaddr_str addrbuf, mainaddrbuf;
ipc_sendf("%s\t%d\t%s\n",
! olsr_ip_to_string(&addrbuf, &tmp_net->A_network_addr),
tmp_net->A_netmask.v6,
! olsr_ip_to_string(&mainaddrbuf, &tmp_hna->A_gateway_addr));
}
! }
}
}
ipc_sendf("\n");
}
***************
*** 471,475 ****
while( entry != &mid_set[index] ) {
! ipc_sendf( olsr_ip_to_string( &entry->main_addr ) );
alias = entry->aliases;
is_first = 1;
--- 472,477 ----
while( entry != &mid_set[index] ) {
! struct ipaddr_str buf;
! ipc_sendf( olsr_ip_to_string(&buf, &entry->main_addr ) );
alias = entry->aliases;
is_first = 1;
***************
*** 478,482 ****
ipc_sendf( "%s%s",
( is_first ? "\t" : ";" ),
! olsr_ip_to_string( &alias->alias )
);
--- 480,484 ----
ipc_sendf( "%s%s",
( is_first ? "\t" : ";" ),
! olsr_ip_to_string(&buf, &alias->alias )
);
Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/txtinfo/src/olsrd_plugin.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** olsrd_plugin.c 15 Jul 2007 17:41:33 -0000 1.3
--- olsrd_plugin.c 8 Nov 2007 22:47:41 -0000 1.4
***************
*** 82,86 ****
ipc_port = 2006;
if (olsr_cnf->ip_version == AF_INET) {
! ipc_accept_ip.v4 = htonl(INADDR_LOOPBACK);
} else {
ipc_accept_ip.v6 = in6addr_loopback;
--- 82,86 ----
ipc_port = 2006;
if (olsr_cnf->ip_version == AF_INET) {
! ipc_accept_ip.v4.s_addr = htonl(INADDR_LOOPBACK);
} else {
ipc_accept_ip.v6 = in6addr_loopback;
More information about the Olsr-cvs
mailing list