[Olsr-cvs] olsrd-current/src/linux apm.c, 1.19, 1.20 kernel_routes.c, 1.29, 1.30 net.c, 1.34, 1.35

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


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

Modified Files:
	apm.c kernel_routes.c net.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: apm.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/apm.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** apm.c	24 Oct 2007 13:44:26 -0000	1.19
--- apm.c	8 Nov 2007 22:47:42 -0000	1.20
***************
*** 141,145 ****
  
  void
! apm_printinfo(struct olsr_apm_info *ainfo)
  {
    OLSR_PRINTF(5, "APM info:\n\tAC status %d\n\tBattery percentage %d%%\n\tBattery time left %d mins\n\n",
--- 141,145 ----
  
  void
! apm_printinfo(struct olsr_apm_info *ainfo __attribute__((unused)))
  {
    OLSR_PRINTF(5, "APM info:\n\tAC status %d\n\tBattery percentage %d%%\n\tBattery time left %d mins\n\n",
***************
*** 153,165 ****
  apm_read(struct olsr_apm_info *ainfo)
  {
!   switch(method)
!     {
!     case(USE_APM):
!       return apm_read_apm(ainfo);
!     case(USE_ACPI):
!       return apm_read_acpi(ainfo);
!     default:
!       break;
!     }
    return 0;
  }
--- 153,161 ----
  apm_read(struct olsr_apm_info *ainfo)
  {
!   switch(method) {
!   case USE_APM:  return apm_read_apm(ainfo);
!   case USE_ACPI: return apm_read_acpi(ainfo);
!   default:       break;
!   }
    return 0;
  }

Index: net.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/net.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** net.c	25 Apr 2007 22:08:18 -0000	1.34
--- net.c	8 Nov 2007 22:47:42 -0000	1.35
***************
*** 49,52 ****
--- 49,53 ----
  #include "../net_os.h"
  #include "../parser.h"
+ #include "../net_olsr.h"
  
  
***************
*** 559,570 ****
  {
    /* See linux/in6.h */
! 
    struct ipv6_mreq mcastreq;
  
!   COPY_IP(&mcastreq.ipv6mr_multiaddr, &ifs->int6_multaddr.sin6_addr);
    mcastreq.ipv6mr_interface = ifs->if_index;
  
  #if !defined __FreeBSD__ && !defined __MacOSX__ && !defined __NetBSD__
!   OLSR_PRINTF(3, "Interface %s joining multicast %s...",	ifs->int_name, olsr_ip_to_string((union olsr_ip_addr *)&ifs->int6_multaddr.sin6_addr));
    /* Send multicast */
    if(setsockopt(sock, 
--- 560,573 ----
  {
    /* See linux/in6.h */
! #ifndef NODEBUG
!   struct ipaddr_str buf;
! #endif
    struct ipv6_mreq mcastreq;
  
!   mcastreq.ipv6mr_multiaddr = ifs->int6_multaddr.sin6_addr;
    mcastreq.ipv6mr_interface = ifs->if_index;
  
  #if !defined __FreeBSD__ && !defined __MacOSX__ && !defined __NetBSD__
!   OLSR_PRINTF(3, "Interface %s joining multicast %s...", ifs->int_name, ip6_to_string(&buf, &ifs->int6_multaddr.sin6_addr));
    /* Send multicast */
    if(setsockopt(sock, 

Index: kernel_routes.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/linux/kernel_routes.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** kernel_routes.c	13 Oct 2007 12:31:04 -0000	1.29
--- kernel_routes.c	8 Nov 2007 22:47:42 -0000	1.30
***************
*** 105,109 ****
  	if (AF_INET == family)
  	{
! 		if (rt->rt_dst.prefix.v4 != nexthop->gateway.v4)
  		{
  			olsr_netlink_addreq(&req, RTA_GATEWAY, &nexthop->gateway.v4, sizeof(nexthop->gateway.v4));
--- 105,109 ----
  	if (AF_INET == family)
  	{
! 		if (rt->rt_dst.prefix.v4.s_addr != nexthop->gateway.v4.s_addr)
  		{
  			olsr_netlink_addreq(&req, RTA_GATEWAY, &nexthop->gateway.v4, sizeof(nexthop->gateway.v4));
***************
*** 191,204 ****
    ((struct sockaddr_in*)&kernel_route.rt_genmask)->sin_family = AF_INET;
  
!   ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_addr.s_addr =
!     rt->rt_dst.prefix.v4;
  
    if (!olsr_prefix_to_netmask(&mask, rt->rt_dst.prefix_len)) {
      return -1;
    }
!   ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_addr.s_addr = mask.v4;
  
!   if (rt->rt_dst.prefix.v4 != rt->rt_best->rtp_nexthop.gateway.v4) {
!     ((struct sockaddr_in *)&kernel_route.rt_gateway)->sin_addr.s_addr =
        rt->rt_best->rtp_nexthop.gateway.v4;
    }
--- 191,203 ----
    ((struct sockaddr_in*)&kernel_route.rt_genmask)->sin_family = AF_INET;
  
!   ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_addr = rt->rt_dst.prefix.v4;
  
    if (!olsr_prefix_to_netmask(&mask, rt->rt_dst.prefix_len)) {
      return -1;
    }
!   ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_addr = mask.v4;
  
!   if (rt->rt_dst.prefix.v4.s_addr != rt->rt_best->rtp_nexthop.gateway.v4.s_addr) {
!     ((struct sockaddr_in *)&kernel_route.rt_gateway)->sin_addr =
        rt->rt_best->rtp_nexthop.gateway.v4;
    }
***************
*** 214,218 ****
    /* delete existing default route before ? */
    if((olsr_cnf->del_gws) &&
!      (rt->rt_dst.prefix.v4 == INADDR_ANY) &&
       (rt->rt_dst.prefix_len == INADDR_ANY)) {
      delete_all_inet_gws();
--- 213,217 ----
    /* delete existing default route before ? */
    if((olsr_cnf->del_gws) &&
!      (rt->rt_dst.prefix.v4.s_addr == INADDR_ANY) &&
       (rt->rt_dst.prefix_len == INADDR_ANY)) {
      delete_all_inet_gws();
***************
*** 264,271 ****
    memset(&kernel_route, 0, sizeof(struct in6_rtmsg));
  
!   COPY_IP(&kernel_route.rtmsg_dst, &rt->rt_dst.prefix);
    kernel_route.rtmsg_dst_len = rt->rt_dst.prefix_len;
  
!   COPY_IP(&kernel_route.rtmsg_gateway, &rt->rt_best->rtp_nexthop.gateway);
  
    kernel_route.rtmsg_flags = olsr_rt_flags(rt);
--- 263,272 ----
    memset(&kernel_route, 0, sizeof(struct in6_rtmsg));
  
!   //COPY_IP(&kernel_route.rtmsg_dst, &rt->rt_dst.prefix);
!   kernel_route.rtmsg_dst     = rt->rt_dst.prefix.v6;
    kernel_route.rtmsg_dst_len = rt->rt_dst.prefix_len;
  
!   //COPY_IP(&kernel_route.rtmsg_gateway, &rt->rt_best->rtp_nexthop.gateway);
!   kernel_route.rtmsg_gateway = rt->rt_best->rtp_nexthop.gateway.v6;
  
    kernel_route.rtmsg_flags = olsr_rt_flags(rt);
***************
*** 321,330 ****
    ((struct sockaddr_in*)&kernel_route.rt_genmask)->sin_family = AF_INET;
  
!   ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_addr.s_addr =
!     rt->rt_dst.prefix.v4;
  
!   if (rt->rt_dst.prefix.v4 != rt->rt_nexthop.gateway.v4) {
!     ((struct sockaddr_in *)&kernel_route.rt_gateway)->sin_addr.s_addr =
!       rt->rt_nexthop.gateway.v4;
    }
  
--- 322,329 ----
    ((struct sockaddr_in*)&kernel_route.rt_genmask)->sin_family = AF_INET;
  
!   ((struct sockaddr_in *)&kernel_route.rt_dst)->sin_addr = rt->rt_dst.prefix.v4;
  
!   if (rt->rt_dst.prefix.v4.s_addr != rt->rt_nexthop.gateway.v4.s_addr) {
!     ((struct sockaddr_in *)&kernel_route.rt_gateway)->sin_addr = rt->rt_nexthop.gateway.v4;
    }
  
***************
*** 332,336 ****
      return -1;
    } else {
!     ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_addr.s_addr = mask.v4;
    }
  
--- 331,335 ----
      return -1;
    } else {
!     ((struct sockaddr_in *)&kernel_route.rt_genmask)->sin_addr = mask.v4;
    }
  
***************
*** 385,392 ****
    memset(&kernel_route,0,sizeof(struct in6_rtmsg));
  
!   COPY_IP(&kernel_route.rtmsg_dst, &rt->rt_dst.prefix);
    kernel_route.rtmsg_dst_len = rt->rt_dst.prefix_len;
  
!   COPY_IP(&kernel_route.rtmsg_gateway, &rt->rt_best->rtp_nexthop.gateway);
  
    kernel_route.rtmsg_flags = olsr_rt_flags(rt);
--- 384,394 ----
    memset(&kernel_route,0,sizeof(struct in6_rtmsg));
  
! 
!   //COPY_IP(&kernel_route.rtmsg_dst, &rt->rt_dst.prefix);
!   kernel_route.rtmsg_dst     = rt->rt_dst.prefix.v6;
    kernel_route.rtmsg_dst_len = rt->rt_dst.prefix_len;
  
!   //COPY_IP(&kernel_route.rtmsg_gateway, &rt->rt_best->rtp_nexthop.gateway);
!   kernel_route.rtmsg_gateway = rt->rt_best->rtp_nexthop.gateway.v6;
  
    kernel_route.rtmsg_flags = olsr_rt_flags(rt);





More information about the Olsr-cvs mailing list