[Olsr-cvs] olsrd-current/lib/dot_draw/src olsrd_dot_draw.c, 1.30, 1.31 olsrd_plugin.c, 1.17, 1.18
Bernd Petrovitsch
(spam-protected)
Thu Nov 8 23:47:41 CET 2007
Update of /cvsroot/olsrd/olsrd-current/lib/dot_draw/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28726/lib/dot_draw/src
Modified Files:
olsrd_dot_draw.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_dot_draw.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_dot_draw.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** olsrd_dot_draw.c 5 Nov 2007 15:32:55 -0000 1.30
--- olsrd_dot_draw.c 8 Nov 2007 22:47:39 -0000 1.31
***************
*** 68,71 ****
--- 68,72 ----
#include "link_set.h"
#include "socket_parser.h"
+ #include "net_olsr.h"
#include "olsrd_dot_draw.h"
***************
*** 154,167 ****
{
char buf[256];
! const char* adr;
double etx = 0.0;
char* style = "solid";
struct link_entry* link;
! adr = olsr_ip_to_string(&olsr_cnf->main_addr);
! sprintf( buf, "\"%s\" -> ", adr );
ipc_send_str(buf);
- adr = olsr_ip_to_string(&neighbor->neighbor_main_addr);
-
if (neighbor->status == 0) { // non SYM
style = "dashed";
--- 155,166 ----
{
char buf[256];
! struct ipaddr_str strbuf;
double etx = 0.0;
char* style = "solid";
struct link_entry* link;
!
! sprintf( buf, "\"%s\" -> ", olsr_ip_to_string(&strbuf, &olsr_cnf->main_addr));
ipc_send_str(buf);
if (neighbor->status == 0) { // non SYM
style = "dashed";
***************
*** 174,182 ****
}
! sprintf( buf, "\"%s\"[label=\"%.2f\", style=%s];\n", adr, etx, style );
ipc_send_str(buf);
! if (neighbor->is_mpr) {
! sprintf( buf, "\"%s\"[shape=box];\n", adr );
ipc_send_str(buf);
}
--- 173,181 ----
}
! sprintf( buf, "\"%s\"[label=\"%.2f\", style=%s];\n", olsr_ip_to_string(&strbuf, &neighbor->neighbor_main_addr), etx, style );
ipc_send_str(buf);
! if (neighbor->is_mpr) {
! sprintf( buf, "\"%s\"[shape=box];\n", buf);
ipc_send_str(buf);
}
***************
*** 268,272 ****
else
{
! if(ntohl(pin.sin_addr.s_addr) != ntohl(ipc_accept_ip.v4))
{
olsr_printf(0, "Front end-connection from foreign host (%s) not allowed!\n", inet_ntoa(pin.sin_addr));
--- 267,271 ----
else
{
! if(!ip4equal(&pin.sin_addr, &ipc_accept_ip.v4))
{
olsr_printf(0, "Front end-connection from foreign host (%s) not allowed!\n", inet_ntoa(pin.sin_addr));
***************
*** 293,297 ****
{
int res;
! olsr_u8_t index;
struct neighbor_entry *neighbor_table_tmp;
struct tc_entry *tc;
--- 292,296 ----
{
int res;
! int index;
struct neighbor_entry *neighbor_table_tmp;
struct tc_entry *tc;
***************
*** 308,313 ****
/* Neighbors */
for(index=0;index<HASHSIZE;index++)
! {
!
for(neighbor_table_tmp = neighbortable[index].next;
neighbor_table_tmp != &neighbortable[index];
--- 307,311 ----
/* Neighbors */
for(index=0;index<HASHSIZE;index++)
! {
for(neighbor_table_tmp = neighbortable[index].next;
neighbor_table_tmp != &neighbortable[index];
***************
*** 348,352 ****
//hna_msk.v4 = hna4->netmask.v4;
olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
! hna_msk.v4 = netmask.v4;
ipc_print_net(&olsr_cnf->interfaces->interf->ip_addr,
&hna->net.prefix,
--- 346,350 ----
//hna_msk.v4 = hna4->netmask.v4;
olsr_prefix_to_netmask(&netmask, hna->net.prefix_len);
! hna_msk.v4 = netmask.v4.s_addr;
ipc_print_net(&olsr_cnf->interfaces->interf->ip_addr,
&hna->net.prefix,
***************
*** 371,377 ****
! if(!ipc_socket_up)
plugin_ipc_init();
!
return res;
}
--- 369,375 ----
! if (!ipc_socket_up) {
plugin_ipc_init();
! }
return res;
}
***************
*** 380,389 ****
ipc_print_tc_link(const struct tc_entry *entry, const struct tc_edge_entry *dst_entry)
{
! char buf[256];
! sprintf( buf, "\"%s\" -> ", olsr_ip_to_string(&entry->addr));
! ipc_send_str(buf);
!
! sprintf( buf, "\"%s\"[label=\"%.2f\"];\n", olsr_ip_to_string(&dst_entry->T_dest_addr), olsr_calc_tc_etx(dst_entry));
ipc_send_str(buf);
}
--- 378,388 ----
ipc_print_tc_link(const struct tc_entry *entry, const struct tc_edge_entry *dst_entry)
{
! char buf[512];
! struct ipaddr_str strbuf1, strbuf2;
! sprintf( buf, "\"%s\" -> \"%s\"[label=\"%.2f\"];\n",
! olsr_ip_to_string(&strbuf1, &entry->addr),
! olsr_ip_to_string(&strbuf2, &dst_entry->T_dest_addr),
! olsr_calc_tc_etx(dst_entry));
ipc_send_str(buf);
}
***************
*** 393,416 ****
ipc_print_net(const union olsr_ip_addr *gw, const union olsr_ip_addr *net, const union hna_netmask *mask)
{
! const char *adr;
! adr = olsr_ip_to_string(gw);
! ipc_send_str("\"");
! ipc_send_str(adr);
! ipc_send_str("\" -> \"");
! adr = olsr_ip_to_string(net);
! ipc_send_str(adr);
! ipc_send_str("/");
! adr = olsr_netmask_to_string(mask);
! ipc_send_str(adr);
! ipc_send_str("\"[label=\"HNA\"];\n");
! ipc_send_str("\"");
! adr = olsr_ip_to_string(net);
! ipc_send_str(adr);
! ipc_send_str("/");
! adr = olsr_netmask_to_string(mask);
! ipc_send_str(adr);
! ipc_send_str("\"");
! ipc_send_str("[shape=diamond];\n");
}
--- 392,408 ----
ipc_print_net(const union olsr_ip_addr *gw, const union olsr_ip_addr *net, const union hna_netmask *mask)
{
! char buf[512];
! struct ipaddr_str gwbuf, netbuf;
! sprintf( buf, "\"%s\" -> \"%s/%s\"[label=\"HNA\"];\n",
! olsr_ip_to_string(&gwbuf, gw),
! olsr_ip_to_string(&netbuf, net),
! olsr_netmask_to_string(mask));
! ipc_send_str(buf);
!
! sprintf( buf,"\"%s/%s\"[shape=diamond];\n",
! olsr_ip_to_string(&netbuf, net),
! olsr_netmask_to_string(mask));
! ipc_send_str(buf);
}
Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_plugin.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** olsrd_plugin.c 23 Jul 2007 12:58:38 -0000 1.17
--- olsrd_plugin.c 8 Nov 2007 22:47:39 -0000 1.18
***************
*** 78,82 ****
/* defaults for parameters */
ipc_port = 2004;
! ipc_accept_ip.v4 = htonl(INADDR_LOOPBACK);
}
--- 78,82 ----
/* defaults for parameters */
ipc_port = 2004;
! ipc_accept_ip.v4.s_addr = htonl(INADDR_LOOPBACK);
}
More information about the Olsr-cvs
mailing list