[Olsr-cvs] olsrd-current/lib/bmf/src Address.c, 1.8, 1.9 Bmf.c, 1.8, 1.9 NetworkInterfaces.c, 1.10, 1.11

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


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

Modified Files:
	Address.c Bmf.c NetworkInterfaces.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: Address.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Address.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Address.c	17 Sep 2007 21:57:05 -0000	1.8
--- Address.c	8 Nov 2007 22:47:39 -0000	1.9
***************
*** 47,51 ****
  
  /* OLSRD includes */
! #include "defs.h" /* COMP_IP */
  
  /* Plugin includes */
--- 47,51 ----
  
  /* OLSRD includes */
! #include "defs.h" /* ipequal */
  
  /* Plugin includes */
***************
*** 98,102 ****
    assert(ipAddress != NULL);
  
!   return (ntohl(ipAddress->v4) & 0xF0000000) == 0xE0000000;
  }
  
--- 98,102 ----
    assert(ipAddress != NULL);
  
!   return (ntohl(ipAddress->v4.s_addr) & 0xF0000000) == 0xE0000000;
  }
  

Index: NetworkInterfaces.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/NetworkInterfaces.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** NetworkInterfaces.c	17 Sep 2007 21:57:05 -0000	1.10
--- NetworkInterfaces.c	8 Nov 2007 22:47:39 -0000	1.11
***************
*** 64,67 ****
--- 64,68 ----
  #include "lq_route.h" /* MIN_LINK_QUALITY */
  #include "tc_set.h" /* olsr_lookup_tc_entry(), olsr_tc_lookup_dst() */
+ #include "net_olsr.h" /* ipequal */
  
  /* Plugin includes */
***************
*** 438,445 ****
      for (walker = get_link_set(); walker != NULL; walker = walker->next) 
      {
        union olsr_ip_addr* neighborMainIp;
  
        /* Consider only links from the specified interface */
!       if (! COMP_IP(&intf->intAddr, &walker->local_iface_addr))
        {
          continue; /* for */
--- 439,449 ----
      for (walker = get_link_set(); walker != NULL; walker = walker->next) 
      {
+ #ifndef NODEBUG
+       struct ipaddr_str buf;
+ #endif
        union olsr_ip_addr* neighborMainIp;
  
        /* Consider only links from the specified interface */
!       if (! ipequal(&intf->intAddr, &walker->local_iface_addr))
        {
          continue; /* for */
***************
*** 451,455 ****
          PLUGIN_NAME_SHORT,
          intf->ifName,
!         olsr_ip_to_string(&walker->neighbor_iface_addr));
  
        neighborMainIp = MainAddressOf(&walker->neighbor_iface_addr);
--- 455,459 ----
          PLUGIN_NAME_SHORT,
          intf->ifName,
!         olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
        neighborMainIp = MainAddressOf(&walker->neighbor_iface_addr);
***************
*** 457,467 ****
        /* Consider only neighbors with an IP address that differs from the
         * passed IP addresses (if passed). Rely on short-circuit boolean evaluation. */
!       if (source != NULL && COMP_IP(neighborMainIp, MainAddressOf(source)))
        {
          OLSR_PRINTF(
            9,
            "%s: ----> Not forwarding to %s: is source of pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&walker->neighbor_iface_addr));
  
          continue; /* for */
--- 461,474 ----
        /* Consider only neighbors with an IP address that differs from the
         * passed IP addresses (if passed). Rely on short-circuit boolean evaluation. */
!       if (source != NULL && ipequal(neighborMainIp, MainAddressOf(source)))
        {
+ #ifndef NODEBUG
+         struct ipaddr_str buf;
+ #endif
          OLSR_PRINTF(
            9,
            "%s: ----> Not forwarding to %s: is source of pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
          continue; /* for */
***************
*** 469,479 ****
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedBy != NULL && COMP_IP(neighborMainIp, MainAddressOf(forwardedBy)))
        {
          OLSR_PRINTF(
            9,
            "%s: ----> Not forwarding to %s: is the node that forwarded the pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&walker->neighbor_iface_addr));
  
          continue; /* for */
--- 476,489 ----
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedBy != NULL && ipequal(neighborMainIp, MainAddressOf(forwardedBy)))
        {
+ #ifndef NODEBUG
+         struct ipaddr_str buf;
+ #endif
          OLSR_PRINTF(
            9,
            "%s: ----> Not forwarding to %s: is the node that forwarded the pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
          continue; /* for */
***************
*** 481,491 ****
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedTo != NULL && COMP_IP(neighborMainIp, MainAddressOf(forwardedTo)))
        {
          OLSR_PRINTF(
            9,
            "%s: ----> Not forwarding to %s: is the node to which the pkt was forwarded\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&walker->neighbor_iface_addr));
  
          continue; /* for */
--- 491,504 ----
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedTo != NULL && ipequal(neighborMainIp, MainAddressOf(forwardedTo)))
        {
+ #ifndef NODEBUG
+         struct ipaddr_str buf;
+ #endif
          OLSR_PRINTF(
            9,
            "%s: ----> Not forwarding to %s: is the node to which the pkt was forwarded\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
          continue; /* for */
***************
*** 538,542 ****
  
        /* Consider only links from the specified interface */
!       if (! COMP_IP(&intf->intAddr, &walker->local_iface_addr))
        {
          continue; /* for */
--- 551,555 ----
  
        /* Consider only links from the specified interface */
!       if (! ipequal(&intf->intAddr, &walker->local_iface_addr))
        {
          continue; /* for */
***************
*** 554,558 ****
        /* Consider only neighbors with an IP address that differs from the
         * passed IP addresses (if passed). Rely on short-circuit boolean evaluation. */
!       if (source != NULL && COMP_IP(neighborMainIp, MainAddressOf(source)))
        {
          OLSR_PRINTF(
--- 567,571 ----
        /* Consider only neighbors with an IP address that differs from the
         * passed IP addresses (if passed). Rely on short-circuit boolean evaluation. */
!       if (source != NULL && ipequal(neighborMainIp, MainAddressOf(source)))
        {
          OLSR_PRINTF(
***************
*** 566,570 ****
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedBy != NULL && COMP_IP(neighborMainIp, MainAddressOf(forwardedBy)))
        {
          OLSR_PRINTF(
--- 579,583 ----
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedBy != NULL && ipequal(neighborMainIp, MainAddressOf(forwardedBy)))
        {
          OLSR_PRINTF(
***************
*** 578,582 ****
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedTo != NULL && COMP_IP(neighborMainIp, MainAddressOf(forwardedTo)))
        {
          OLSR_PRINTF(
--- 591,595 ----
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedTo != NULL && ipequal(neighborMainIp, MainAddressOf(forwardedTo)))
        {
          OLSR_PRINTF(
***************
*** 725,728 ****
--- 738,744 ----
      for (walker = get_link_set(); walker != NULL; walker = walker->next) 
      {
+ #ifndef NODEBUG
+       struct ipaddr_str buf;
+ #endif
        union olsr_ip_addr* neighborMainIp;
        struct link_entry* bestLinkToNeighbor;
***************
*** 731,735 ****
   
        /* Consider only links from the specified interface */
!       if (! COMP_IP(&intf->intAddr, &walker->local_iface_addr))
        {
          continue; /* for */
--- 747,751 ----
   
        /* Consider only links from the specified interface */
!       if (! ipequal(&intf->intAddr, &walker->local_iface_addr))
        {
          continue; /* for */
***************
*** 741,745 ****
          PLUGIN_NAME_SHORT,
          intf->ifName,
!         olsr_ip_to_string(&walker->neighbor_iface_addr));
  
        neighborMainIp = MainAddressOf(&walker->neighbor_iface_addr);
--- 757,761 ----
          PLUGIN_NAME_SHORT,
          intf->ifName,
!         olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
        neighborMainIp = MainAddressOf(&walker->neighbor_iface_addr);
***************
*** 747,751 ****
        /* Consider only neighbors with an IP address that differs from the
         * passed IP addresses (if passed). Rely on short-circuit boolean evaluation. */
!       if (source != NULL && COMP_IP(neighborMainIp, MainAddressOf(source)))
        {
          OLSR_PRINTF(
--- 763,767 ----
        /* Consider only neighbors with an IP address that differs from the
         * passed IP addresses (if passed). Rely on short-circuit boolean evaluation. */
!       if (source != NULL && ipequal(neighborMainIp, MainAddressOf(source)))
        {
          OLSR_PRINTF(
***************
*** 753,757 ****
            "%s: ----> Not forwarding to %s: is source of pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&walker->neighbor_iface_addr));
  
          continue; /* for */
--- 769,773 ----
            "%s: ----> Not forwarding to %s: is source of pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
          continue; /* for */
***************
*** 759,763 ****
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedBy != NULL && COMP_IP(neighborMainIp, MainAddressOf(forwardedBy)))
        {
          OLSR_PRINTF(
--- 775,779 ----
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedBy != NULL && ipequal(neighborMainIp, MainAddressOf(forwardedBy)))
        {
          OLSR_PRINTF(
***************
*** 765,769 ****
            "%s: ----> Not forwarding to %s: is the node that forwarded the pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&walker->neighbor_iface_addr));
  
          continue; /* for */
--- 781,785 ----
            "%s: ----> Not forwarding to %s: is the node that forwarded the pkt\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
          continue; /* for */
***************
*** 771,775 ****
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedTo != NULL && COMP_IP(neighborMainIp, MainAddressOf(forwardedTo)))
        {
          OLSR_PRINTF(
--- 787,791 ----
  
        /* Rely on short-circuit boolean evaluation */
!       if (forwardedTo != NULL && ipequal(neighborMainIp, MainAddressOf(forwardedTo)))
        {
          OLSR_PRINTF(
***************
*** 777,781 ****
            "%s: ----> Not forwarding to %s: is the node to which the pkt was forwarded\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&walker->neighbor_iface_addr));
  
          continue; /* for */
--- 793,797 ----
            "%s: ----> Not forwarding to %s: is the node to which the pkt was forwarded\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
          continue; /* for */
***************
*** 795,799 ****
            "%s: ----> Not forwarding to %s: link is timing out\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&walker->neighbor_iface_addr));
  
          continue; /* for */
--- 811,815 ----
            "%s: ----> Not forwarding to %s: link is timing out\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
  
          continue; /* for */
***************
*** 805,809 ****
          "%s: ----> Forwarding pkt to %s will cost ETX %5.2f\n",
          PLUGIN_NAME_SHORT,
!         olsr_ip_to_string(&walker->neighbor_iface_addr),
          currEtx);
  
--- 821,825 ----
          "%s: ----> Forwarding pkt to %s will cost ETX %5.2f\n",
          PLUGIN_NAME_SHORT,
!         olsr_ip_to_string(&buf, &walker->neighbor_iface_addr),
          currEtx);
  
***************
*** 818,836 ****
          if (bestLinkToNeighbor == NULL)
          {
            OLSR_PRINTF(
              9,
              "%s: ----> Not forwarding to %s: no link found\n",
              PLUGIN_NAME_SHORT,
!             olsr_ip_to_string(&walker->neighbor_iface_addr));
          }
          else
          {
            struct interface* bestIntf = if_ifwithaddr(&bestLinkToNeighbor->local_iface_addr);
! 
            OLSR_PRINTF(
              9,
              "%s: ----> Not forwarding to %s: \"%s\" gives a better link to this neighbor, costing %5.2f\n",
              PLUGIN_NAME_SHORT,
!             olsr_ip_to_string(&walker->neighbor_iface_addr),
              bestIntf->int_name,
              CalcEtx(
--- 834,857 ----
          if (bestLinkToNeighbor == NULL)
          {
+ #ifndef NODEBUG
+           struct ipaddr_str buf;
+ #endif
            OLSR_PRINTF(
              9,
              "%s: ----> Not forwarding to %s: no link found\n",
              PLUGIN_NAME_SHORT,
!             olsr_ip_to_string(&buf, &walker->neighbor_iface_addr));
          }
          else
          {
+ #ifndef NODEBUG
            struct interface* bestIntf = if_ifwithaddr(&bestLinkToNeighbor->local_iface_addr);
!           struct ipaddr_str buf;
! #endif
            OLSR_PRINTF(
              9,
              "%s: ----> Not forwarding to %s: \"%s\" gives a better link to this neighbor, costing %5.2f\n",
              PLUGIN_NAME_SHORT,
!             olsr_ip_to_string(&buf, &walker->neighbor_iface_addr),
              bestIntf->int_name,
              CalcEtx(
***************
*** 838,842 ****
                bestLinkToNeighbor->neigh_link_quality));
          }
! 
          continue; /* for */
        }
--- 859,863 ----
                bestLinkToNeighbor->neigh_link_quality));
          }
!         
          continue; /* for */
        }
***************
*** 844,853 ****
        if (forwardedBy != NULL)
        {
          OLSR_PRINTF(
            9,
            "%s: ----> 2-hop path from %s via me to %s will cost ETX %5.2f\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(forwardedBy),
!           olsr_ip_to_string(&walker->neighbor_iface_addr),
            previousLinkEtx + currEtx);
        }
--- 865,877 ----
        if (forwardedBy != NULL)
        {
+ #ifndef NODEBUG
+         struct ipaddr_str forwardedByBuf, niaBuf;
+ #endif
          OLSR_PRINTF(
            9,
            "%s: ----> 2-hop path from %s via me to %s will cost ETX %5.2f\n",
            PLUGIN_NAME_SHORT,
!           olsr_ip_to_string(&forwardedByBuf, forwardedBy),
!           olsr_ip_to_string(&niaBuf, &walker->neighbor_iface_addr),
            previousLinkEtx + currEtx);
        }
***************
*** 876,886 ****
              if (previousLinkEtx + currEtx > tcEtx)
              {
                OLSR_PRINTF(
                  9,
                  "%s: ----> Not forwarding to %s: I am not an MPR between %s and %s, direct link costs %5.2f\n",
                  PLUGIN_NAME_SHORT,
!                 olsr_ip_to_string(&walker->neighbor_iface_addr),
!                 olsr_ip_to_string(forwardedBy),
!                 olsr_ip_to_string(&walker->neighbor_iface_addr),
                  tcEtx);
  
--- 900,914 ----
              if (previousLinkEtx + currEtx > tcEtx)
              {
+ #ifndef NODEBUG
+               struct ipaddr_str neighbor_iface_buf, forw_buf;
+               olsr_ip_to_string(&neighbor_iface_buf, &walker->neighbor_iface_addr);
+ #endif
                OLSR_PRINTF(
                  9,
                  "%s: ----> Not forwarding to %s: I am not an MPR between %s and %s, direct link costs %5.2f\n",
                  PLUGIN_NAME_SHORT,
!                 neighbor_iface_buf.buf,
!                 olsr_ip_to_string(&forw_buf, forwardedBy),
!                 neighbor_iface_buf.buf,
                  tcEtx);
  
***************
*** 922,925 ****
--- 950,956 ----
    else
    {
+ #ifndef NODEBUG
+     struct ipaddr_str buf;
+ #endif
      OLSR_PRINTF(
        9,
***************
*** 932,936 ****
        9,
        "%s",
!       olsr_ip_to_string(&result->links[0]->neighbor_iface_addr));
  
      if (result->links[1] != NULL)
--- 963,967 ----
        9,
        "%s",
!       olsr_ip_to_string(&buf, &result->links[0]->neighbor_iface_addr));
  
      if (result->links[1] != NULL)
***************
*** 939,943 ****
          9,
          ", %s",
!         olsr_ip_to_string(&result->links[1]->neighbor_iface_addr));
      } /* if */
  
--- 970,974 ----
          9,
          ", %s",
!         olsr_ip_to_string(&buf, &result->links[1]->neighbor_iface_addr));
      } /* if */
  
***************
*** 1238,1242 ****
        if (bmfIf->olsrIntf != NULL)
        {
!         EtherTunTapIp = ntohl(bmfIf->intAddr.v4);
          EtherTunTapIpBroadcast = EtherTunTapIp;
        }
--- 1269,1273 ----
        if (bmfIf->olsrIntf != NULL)
        {
!         EtherTunTapIp = ntohl(bmfIf->intAddr.v4.s_addr);
          EtherTunTapIpBroadcast = EtherTunTapIp;
        }
***************
*** 1327,1332 ****
      union olsr_ip_addr temp_netmask;
  
!     temp_net.v4 = htonl(EtherTunTapIp);
!     temp_netmask.v4 = htonl(0xFFFFFFFF);
      add_local_hna4_entry(&temp_net, &temp_netmask);
    }
--- 1358,1363 ----
      union olsr_ip_addr temp_netmask;
  
!     temp_net.v4.s_addr = htonl(EtherTunTapIp);
!     temp_netmask.v4.s_addr = htonl(0xFFFFFFFF);
      add_local_hna4_entry(&temp_net, &temp_netmask);
    }
***************
*** 1440,1445 ****
       * address from the OLSR interface object. Downcast to correct sockaddr
       * subtype. */
!     COPY_IP(&newIf->intAddr, &((struct sockaddr_in *)&olsrIntf->int_addr)->sin_addr.s_addr);
!     COPY_IP(&newIf->broadAddr, &((struct sockaddr_in *)&olsrIntf->int_broadaddr)->sin_addr.s_addr);
    }
    else
--- 1471,1478 ----
       * address from the OLSR interface object. Downcast to correct sockaddr
       * subtype. */
!     //COPY_IP(&newIf->intAddr, &((struct sockaddr_in *)&olsrIntf->int_addr)->sin_addr.s_addr);
!     newIf->intAddr.v4 = ((struct sockaddr_in *)&olsrIntf->int_addr)->sin_addr;
!     //COPY_IP(&newIf->broadAddr, &((struct sockaddr_in *)&olsrIntf->int_broadaddr)->sin_addr.s_addr);
!     newIf->broadAddr.v4 = ((struct sockaddr_in *)&olsrIntf->int_broadaddr)->sin_addr;
    }
    else
***************
*** 1453,1462 ****
        BmfPError("ioctl(SIOCGIFADDR) error for interface \"%s\"", ifName);
  
!       newIf->intAddr.v4 = inet_addr("0.0.0.0");
  	  }
  	  else
  	  {
        /* Downcast to correct sockaddr subtype */
!       COPY_IP(&newIf->intAddr, &((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);
      }
  
--- 1486,1496 ----
        BmfPError("ioctl(SIOCGIFADDR) error for interface \"%s\"", ifName);
  
!       newIf->intAddr.v4.s_addr = inet_addr("0.0.0.0");
  	  }
  	  else
  	  {
        /* Downcast to correct sockaddr subtype */
!       //COPY_IP(&newIf->intAddr, &((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr);
!       newIf->intAddr.v4 = ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr;
      }
  
***************
*** 1469,1478 ****
        BmfPError("ioctl(SIOCGIFBRDADDR) error for interface \"%s\"", ifName);
  
!       newIf->broadAddr.v4 = inet_addr("0.0.0.0");
  	  }
  	  else
  	  {
        /* Downcast to correct sockaddr subtype */
!       COPY_IP(&newIf->broadAddr, &((struct sockaddr_in *)&ifr.ifr_broadaddr)->sin_addr.s_addr);
      }
    }
--- 1503,1513 ----
        BmfPError("ioctl(SIOCGIFBRDADDR) error for interface \"%s\"", ifName);
  
!       newIf->broadAddr.v4.s_addr = inet_addr("0.0.0.0");
  	  }
  	  else
  	  {
        /* Downcast to correct sockaddr subtype */
!       //COPY_IP(&newIf->broadAddr, &((struct sockaddr_in *)&ifr.ifr_broadaddr)->sin_addr.s_addr);
!       newIf->broadAddr.v4 = ((struct sockaddr_in *)&ifr.ifr_broadaddr)->sin_addr;
      }
    }
***************
*** 1590,1594 ****
  
      /* ...find the OLSR interface structure, if any */
!     COPY_IP(&ipAddr, &((struct sockaddr_in*)&ifr->ifr_addr)->sin_addr.s_addr);
      olsrIntf = if_ifwithaddr(&ipAddr);
  
--- 1625,1630 ----
  
      /* ...find the OLSR interface structure, if any */
!     //COPY_IP(&ipAddr, &((struct sockaddr_in*)&ifr->ifr_addr)->sin_addr.s_addr);
!     ipAddr.v4 =  ((struct sockaddr_in*)&ifr->ifr_addr)->sin_addr;
      olsrIntf = if_ifwithaddr(&ipAddr);
  
***************
*** 1832,1836 ****
  
    iph = (struct iphdr*) ipPacket;
!   COPY_IP(&destIp, &iph->daddr);
    if (! IsMulticast(&destIp))
    {
--- 1868,1873 ----
  
    iph = (struct iphdr*) ipPacket;
!   //COPY_IP(&destIp, &iph->daddr);
!   destIp.v4.s_addr = iph->daddr;
    if (! IsMulticast(&destIp))
    {
***************
*** 1840,1844 ****
      origDaddr = ntohl(iph->daddr);
  
!     COPY_IP(&iph->daddr, broadAddr);
      newDaddr = ntohl(iph->daddr);
  
--- 1877,1882 ----
      origDaddr = ntohl(iph->daddr);
  
!     //COPY_IP(&iph->daddr, broadAddr);
!     iph->daddr = broadAddr->v4.s_addr;
      newDaddr = ntohl(iph->daddr);
  

Index: Bmf.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Bmf.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Bmf.c	11 Sep 2007 23:08:20 -0000	1.8
--- Bmf.c	8 Nov 2007 22:47:39 -0000	1.9
***************
*** 63,66 ****
--- 63,67 ----
  #include "mpr_selector_set.h" /* olsr_lookup_mprs_set() */
  #include "link_set.h" /* get_best_link_to_neighbor() */
+ #include "net_olsr.h" /* ipequal */
  
  /* BMF includes */
***************
*** 178,182 ****
  
    /* Start by filling in the local broadcast address */
!   COPY_IP(&forwardTo.sin_addr.s_addr, &intf->broadAddr);
  
    /* - If the BMF mechanism is BM_UNICAST_PROMISCUOUS, always send just one
--- 179,184 ----
  
    /* Start by filling in the local broadcast address */
!   //COPY_IP(&forwardTo.sin_addr.s_addr, &intf->broadAddr);
!   forwardTo.sin_addr = intf->broadAddr.v4;
  
    /* - If the BMF mechanism is BM_UNICAST_PROMISCUOUS, always send just one
***************
*** 200,204 ****
      if (BmfMechanism == BM_UNICAST_PROMISCUOUS || nPossibleNeighbors <= 2)
      {
!       COPY_IP(&forwardTo.sin_addr.s_addr, &bestNeighborLinks.links[i]->neighbor_iface_addr);
      }
  
--- 202,207 ----
      if (BmfMechanism == BM_UNICAST_PROMISCUOUS || nPossibleNeighbors <= 2)
      {
!       //COPY_IP(&forwardTo.sin_addr.s_addr, &bestNeighborLinks.links[i]->neighbor_iface_addr);
!       forwardTo.sin_addr = bestNeighborLinks.links[i]->neighbor_iface_addr.v4;
      }
  
***************
*** 263,274 ****
    u_int32_t crc32;
    struct TEncapHeader* encapHdr;
! 
    ipHeader = GetIpHeader(encapsulationUdpData);
  
!   COPY_IP(&dst, &ipHeader->ip_dst);
  
    /* Only forward multicast packets. If configured, also forward local broadcast packets */
    if (IsMulticast(&dst) ||
!       (EnableLocalBroadcast != 0 && COMP_IP(&dst, &intf->broadAddr)))
    {
      /* continue */
--- 266,280 ----
    u_int32_t crc32;
    struct TEncapHeader* encapHdr;
! #ifndef NODEBUG
!   struct ipaddr_str srcBuf, dstBuf;
! #endif
    ipHeader = GetIpHeader(encapsulationUdpData);
  
!   //COPY_IP(&dst, &ipHeader->ip_dst);
!   dst.v4 = ipHeader->ip_dst;
  
    /* Only forward multicast packets. If configured, also forward local broadcast packets */
    if (IsMulticast(&dst) ||
!       (EnableLocalBroadcast != 0 && ipequal(&dst, &intf->broadAddr)))
    {
      /* continue */
***************
*** 297,301 ****
    ipPacketLen = GetIpTotalLength(ipPacket);
  
!   COPY_IP(&src, &ipHeader->ip_src);
    OLSR_PRINTF(
      8,
--- 303,309 ----
    ipPacketLen = GetIpTotalLength(ipPacket);
  
!   //COPY_IP(&src, &ipHeader->ip_src);
!   src.v4 = ipHeader->ip_src;
! 
    OLSR_PRINTF(
      8,
***************
*** 306,311 ****
      isFromOlsrIntf ? "OLSR" : "non-OLSR",
      intf->ifName,
!     olsr_ip_to_string(&src),
!     olsr_ip_to_string(&dst));
  
    /* Lookup main address of source in the MID table of OLSR */
--- 314,319 ----
      isFromOlsrIntf ? "OLSR" : "non-OLSR",
      intf->ifName,
!     olsr_ip_to_string(&srcBuf, &src),
!     olsr_ip_to_string(&dstBuf, &dst));
  
    /* Lookup main address of source in the MID table of OLSR */
***************
*** 404,407 ****
--- 412,418 ----
          /* Case 1.1 */
          {
+ #ifndef NODEBUG
+           struct ipaddr_str buf;
+ #endif
            OLSR_PRINTF(
              8,
***************
*** 409,413 ****
              PLUGIN_NAME_SHORT,
              walker->ifName,
!             olsr_ip_to_string(&src));
          }    
        }
--- 420,424 ----
              PLUGIN_NAME_SHORT,
              walker->ifName,
!             olsr_ip_to_string(&buf, &src));
          }    
        }
***************
*** 578,582 ****
    u_int16_t encapsulationUdpDataLen;
    struct TBmfInterface* walker;
! 
    /* Are we talking to ourselves? */
    if (if_ifwithaddr(forwardedBy) != NULL)
--- 589,595 ----
    u_int16_t encapsulationUdpDataLen;
    struct TBmfInterface* walker;
! #ifndef NODEBUG
!   struct ipaddr_str mcSrcBuf, mcDstBuf, forwardedByBuf, forwardedToBuf;
! #endif
    /* Are we talking to ourselves? */
    if (if_ifwithaddr(forwardedBy) != NULL)
***************
*** 596,601 ****
    ipHeader = GetIpHeader(encapsulationUdpData);
  
!   COPY_IP(&mcSrc, &ipHeader->ip_src);
!   COPY_IP(&mcDst, &ipHeader->ip_dst);
  
    /* Increase counter */
--- 609,616 ----
    ipHeader = GetIpHeader(encapsulationUdpData);
  
!   //COPY_IP(&mcSrc, &ipHeader->ip_src);
!   mcSrc.v4 = ipHeader->ip_src;
!   //COPY_IP(&mcDst, &ipHeader->ip_dst);
!   mcDst.v4 = ipHeader->ip_dst;
  
    /* Increase counter */
***************
*** 609,616 ****
      (long)ipPacketLen,
      intf->ifName,
!     olsr_ip_to_string(&mcSrc),
!     olsr_ip_to_string(&mcDst),
!     olsr_ip_to_string(forwardedBy),
!     forwardedTo != NULL ? olsr_ip_to_string(forwardedTo) : "me");
  
    /* Get encapsulation header */
--- 624,631 ----
      (long)ipPacketLen,
      intf->ifName,
!     olsr_ip_to_string(&mcSrcBuf, &mcSrc),
!     olsr_ip_to_string(&mcDstBuf, &mcDst),
!     olsr_ip_to_string(&forwardedByBuf, forwardedBy),
!     forwardedTo != NULL ? olsr_ip_to_string(&forwardedToBuf, forwardedTo) : "me");
  
    /* Get encapsulation header */
***************
*** 654,658 ****
       * update its destination address to match the subnet of the EtherTunTap
       * interface */
!     broadAddr.v4 = htonl(EtherTunTapIpBroadcast);
      CheckAndUpdateLocalBroadcast(ipPacket, &broadAddr);
  
--- 669,673 ----
       * update its destination address to match the subnet of the EtherTunTap
       * interface */
!     broadAddr.v4.s_addr = htonl(EtherTunTapIpBroadcast);
      CheckAndUpdateLocalBroadcast(ipPacket, &broadAddr);
  
***************
*** 781,785 ****
        /* Compose destination of encapsulation packet.
         * Start by filling in the local broadcast address. */
!       COPY_IP(&forwardTo.sin_addr.s_addr, &walker->broadAddr);
  
        /* - If the BMF mechanism is BM_UNICAST_PROMISCUOUS, always send just one
--- 796,801 ----
        /* Compose destination of encapsulation packet.
         * Start by filling in the local broadcast address. */
!       //COPY_IP(&forwardTo.sin_addr.s_addr, &walker->broadAddr);
!       forwardTo.sin_addr = walker->broadAddr.v4;
  
        /* - If the BMF mechanism is BM_UNICAST_PROMISCUOUS, always send just one
***************
*** 805,809 ****
            /* For unicast, overwrite the local broadcast address which was filled in
             * above */
!           COPY_IP(&forwardTo.sin_addr.s_addr, &bestNeighborLinks.links[i]->neighbor_iface_addr);
          }
  
--- 821,826 ----
            /* For unicast, overwrite the local broadcast address which was filled in
             * above */
!           //COPY_IP(&forwardTo.sin_addr.s_addr, &bestNeighborLinks.links[i]->neighbor_iface_addr);
!           forwardTo.sin_addr = bestNeighborLinks.links[i]->neighbor_iface_addr.v4;
          }
  
***************
*** 839,842 ****
--- 856,862 ----
      else /* walker->olsrIntf != NULL && !iAmMpr */
      {
+ #ifndef NODEBUG
+       struct ipaddr_str buf;
+ #endif
        /* 'walker' is an OLSR interface, but I am not selected as MPR. In that
         * case, don't forward. */
***************
*** 846,850 ****
          PLUGIN_NAME_SHORT,
          walker->ifName,
!         olsr_ip_to_string(forwardedBy));
      } /* else */
    } /* for */
--- 866,870 ----
          PLUGIN_NAME_SHORT,
          walker->ifName,
!         olsr_ip_to_string(&buf, forwardedBy));
      } /* else */
    } /* for */
***************
*** 873,877 ****
    u_int32_t crc32;
    struct TEncapHeader* encapHdr;
! 
    ipPacket = GetIpPacket(encapsulationUdpData);
    ipPacketLen = GetIpTotalLength(ipPacket);
--- 893,899 ----
    u_int32_t crc32;
    struct TEncapHeader* encapHdr;
! #ifndef NODEBUG
!   struct ipaddr_str srcIpBuf, dstIpBuf;
! #endif
    ipPacket = GetIpPacket(encapsulationUdpData);
    ipPacketLen = GetIpTotalLength(ipPacket);
***************
*** 879,886 ****
  
    /* Only forward multicast packets. If configured, also forward local broadcast packets */
!   COPY_IP(&dstIp, &ipHeader->ip_dst);
!   broadAddr.v4 = htonl(EtherTunTapIpBroadcast);
    if (IsMulticast(&dstIp) ||
!       (EnableLocalBroadcast != 0 && COMP_IP(&dstIp, &broadAddr)))
    {
      /* continue */
--- 901,910 ----
  
    /* Only forward multicast packets. If configured, also forward local broadcast packets */
!   //COPY_IP(&dstIp, &ipHeader->ip_dst);
!   dstIp.v4 = ipHeader->ip_dst;
! 
!   broadAddr.v4.s_addr = htonl(EtherTunTapIpBroadcast);
    if (IsMulticast(&dstIp) ||
!       (EnableLocalBroadcast != 0 && ipequal(&dstIp, &broadAddr)))
    {
      /* continue */
***************
*** 891,895 ****
    }
  
!   COPY_IP(&srcIp, &ipHeader->ip_src);
    OLSR_PRINTF(
      8,
--- 915,921 ----
    }
  
!   //COPY_IP(&srcIp, &ipHeader->ip_src);
!   srcIp.v4 = ipHeader->ip_src;
! 
    OLSR_PRINTF(
      8,
***************
*** 898,903 ****
      (long)ipPacketLen,
      EtherTunTapIfName,
!     olsr_ip_to_string(&srcIp),
!     olsr_ip_to_string(&dstIp));
  
    /* Calculate packet fingerprint */
--- 924,929 ----
      (long)ipPacketLen,
      EtherTunTapIfName,
!     olsr_ip_to_string(&srcIpBuf, &srcIp),
!     olsr_ip_to_string(&dstIpBuf, &dstIp));
  
    /* Calculate packet fingerprint */
***************
*** 1174,1179 ****
          }
  
!         COPY_IP(&forwardedBy, &ipHeader->ip_src);
!         COPY_IP(&forwardedTo, &ipHeader->ip_dst);
          BmfEncapsulationPacketReceived(
            walker,
--- 1200,1207 ----
          }
  
!         //COPY_IP(&forwardedBy, &ipHeader->ip_src);
!         forwardedBy.v4 = ipHeader->ip_src;
!         //COPY_IP(&forwardedTo, &ipHeader->ip_dst);
!         forwardedTo.v4 = ipHeader->ip_dst;
          BmfEncapsulationPacketReceived(
            walker,
***************
*** 1216,1220 ****
          } /* if (nBytes < 0) */
  
!         COPY_IP(&forwardedBy, &from.sin_addr.s_addr);
  
          /* Check if the number of received bytes is large enough for a minimal BMF
--- 1244,1249 ----
          } /* if (nBytes < 0) */
  
!         //COPY_IP(&forwardedBy, &from.sin_addr.s_addr);
!         forwardedBy.v4 = from.sin_addr;
  
          /* Check if the number of received bytes is large enough for a minimal BMF
***************
*** 1227,1230 ****
--- 1256,1260 ----
          if (nBytes < minimumLength)
          {
+           struct ipaddr_str buf;
            olsr_printf(
              1,
***************
*** 1232,1236 ****
              PLUGIN_NAME,
              nBytes,
!             olsr_ip_to_string(&forwardedBy),
              walker->ifName);
  
--- 1262,1266 ----
              PLUGIN_NAME,
              nBytes,
!             olsr_ip_to_string(&buf, &forwardedBy),
              walker->ifName);
  





More information about the Olsr-cvs mailing list