[Olsr-cvs] olsrd-current/lib/pgraph/src olsrd_pgraph.c,1.9,1.10

Bernd Petrovitsch (spam-protected)
Thu Nov 8 23:47:42 CET 2007


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

Modified Files:
	olsrd_pgraph.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_pgraph.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/pgraph/src/olsrd_pgraph.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** olsrd_pgraph.c	2 Nov 2007 20:58:07 -0000	1.9
--- olsrd_pgraph.c	8 Nov 2007 22:47:40 -0000	1.10
***************
*** 49,52 ****
--- 49,53 ----
  #include "olsrd_plugin.h"
  #include "plugin_util.h"
+ #include "net_olsr.h"
  
  #include <stdio.h>
***************
*** 99,103 ****
    ipc_port = 2004;
    if (olsr_cnf->ip_version == AF_INET) {
!     ipc_accept_ip.v4 = htonl(INADDR_LOOPBACK);
    } else {
      ipc_accept_ip.v6 = in6addr_loopback;
--- 100,104 ----
    ipc_port = 2004;
    if (olsr_cnf->ip_version == AF_INET) {
!     ipc_accept_ip.v4.s_addr = htonl(INADDR_LOOPBACK);
    } else {
      ipc_accept_ip.v6 = in6addr_loopback;
***************
*** 163,175 ****
    char buf[256];
    int len;
!   const char* main_adr;
!   const char* adr;
  //  double etx=0.0;
  //  char* style = "solid";
  //  struct link_entry* link;
  
!   main_adr = olsr_ip_to_string(&olsr_cnf->main_addr);
!   adr = olsr_ip_to_string(&neighbor->neighbor_main_addr);
!   len = sprintf( buf, "add link %s %s\n", main_adr, adr );
    ipc_send(buf, len);
    
--- 164,176 ----
    char buf[256];
    int len;
!   struct ipaddr_str main_adr, adr;
  //  double etx=0.0;
  //  char* style = "solid";
  //  struct link_entry* link;
  
!   len = sprintf(buf,
!                 "add link %s %s\n",
!                 olsr_ip_to_string(&main_adr, &olsr_cnf->main_addr),
!                 olsr_ip_to_string(&adr, &neighbor->neighbor_main_addr));
    ipc_send(buf, len);
    
***************
*** 292,295 ****
--- 293,297 ----
    else
      {
+       struct ipaddr_str main_addr;
        addr = inet_ntoa(pin.sin_addr);
  /*
***************
*** 304,308 ****
  */
  	  olsr_printf(1, "(DOT DRAW)IPC: Connection from %s\n",addr);
!           len = sprintf(buf, "add node %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
    	  ipc_send(buf, len);
  	  pcf_event(1, 1, 1);
--- 306,310 ----
  */
  	  olsr_printf(1, "(DOT DRAW)IPC: Connection from %s\n",addr);
!           len = sprintf(buf, "add node %s\n", olsr_ip_to_string(&main_addr, &olsr_cnf->main_addr));
    	  ipc_send(buf, len);
  	  pcf_event(1, 1, 1);
***************
*** 404,414 ****
    char buf[256];
    int len;
!   const char* main_adr;
!   const char* adr;
  //  double etx = olsr_calc_tc_etx(dst_entry);
  
!   main_adr = olsr_ip_to_string(&entry->addr);
!   adr = olsr_ip_to_string(&dst_entry->T_dest_addr);
!   len = sprintf( buf, "add link %s %s\n", main_adr, adr );
    ipc_send(buf, len);
  }
--- 406,415 ----
    char buf[256];
    int len;
!   struct ipaddr_str main_adr, adr;
  //  double etx = olsr_calc_tc_etx(dst_entry);
  
!   len = sprintf( buf, "add link %s %s\n",
!                  olsr_ip_to_string(&main_adr, &entry->addr),
!                  olsr_ip_to_string(&adr, &dst_entry->T_dest_addr));
    ipc_send(buf, len);
  }
***************
*** 477,481 ****
      // check whether it's a link to the requested neighbor and
      // whether the link's quality is better than what we have
!     if(COMP_IP(main, &walker->neighbor->neighbor_main_addr))
      {
        curr = walker->loss_link_quality * walker->neigh_link_quality;
--- 478,482 ----
      // check whether it's a link to the requested neighbor and
      // whether the link's quality is better than what we have
!     if(ipequal(main, &walker->neighbor->neighbor_main_addr))
      {
        curr = walker->loss_link_quality * walker->neigh_link_quality;





More information about the Olsr-cvs mailing list