[Olsr-cvs] olsrd-current/lib/bmf/src Address.c, 1.5, 1.6 Address.h, 1.4, 1.5 Bmf.c, 1.7, 1.8 Bmf.h, 1.4, 1.5 NetworkInterfaces.c, 1.6, 1.7 NetworkInterfaces.h, 1.4, 1.5 Packet.h, 1.4, 1.5 olsrd_plugin.c, 1.6, 1.7 DropList.c, 1.3, NONE DropList.h, 1.3, NONE

Bernd Petrovitsch (spam-protected)
Wed Sep 12 01:08:22 CEST 2007


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

Modified Files:
	Address.c Address.h Bmf.c Bmf.h NetworkInterfaces.c 
	NetworkInterfaces.h Packet.h olsrd_plugin.c 
Removed Files:
	DropList.c DropList.h 
Log Message:
* updated bmf plugin to 1.5.1

Index: Packet.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Packet.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Packet.h	30 Jun 2007 20:07:47 -0000	1.4
--- Packet.h	11 Sep 2007 23:08:20 -0000	1.5
***************
*** 45,58 ****
  #include <sys/types.h> /* u_int8_t, u_int16_t */
  
- /* Offsets and sizes into IP-ethernet packets */
- #define IPV4_ADDR_SIZE 4
- #define ETH_TYPE_OFFSET (2*IFHWADDRLEN)
- #define ETH_TYPE_LEN 2
- #define IP_HDR_OFFSET (ETH_TYPE_OFFSET + ETH_TYPE_LEN)
- #define IPV4_OFFSET_SRCIP 12
- #define IPV4_OFFSET_DSTIP (IPV4_OFFSET_SRCIP + IPV4_ADDR_SIZE)
- 
- #define IPV4_TYPE 0x0800
- 
  /* BMF-encapsulated packets are Ethernet-IP-UDP packets, which start
   * with a 8-bytes BMF header (struct TEncapHeader), followed by the
--- 45,48 ----
***************
*** 68,72 ****
  } __attribute__((__packed__));
  
! #define	ENCAP_HDR_LEN ((int)sizeof(struct TEncapHeader))
  #define BMF_ENCAP_TYPE 1
  #define BMF_ENCAP_LEN 6
--- 58,62 ----
  } __attribute__((__packed__));
  
! #define ENCAP_HDR_LEN ((int)sizeof(struct TEncapHeader))
  #define BMF_ENCAP_TYPE 1
  #define BMF_ENCAP_LEN 6

Index: Address.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Address.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Address.h	30 Jun 2007 20:07:47 -0000	1.4
--- Address.h	11 Sep 2007 23:08:20 -0000	1.5
***************
*** 48,52 ****
  extern int EnableLocalBroadcast;
  
! int DoLocalBroadcast(const char* enable);
  int IsMulticast(union olsr_ip_addr* ipAddress);
  int IsOlsrOrBmfPacket(unsigned char* ipPacket);
--- 48,52 ----
  extern int EnableLocalBroadcast;
  
! int DoLocalBroadcast(const char* enable, void* data);
  int IsMulticast(union olsr_ip_addr* ipAddress);
  int IsOlsrOrBmfPacket(unsigned char* ipPacket);

--- DropList.h DELETED ---

Index: Bmf.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Bmf.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Bmf.h	30 Jun 2007 20:07:47 -0000	1.4
--- Bmf.h	11 Sep 2007 23:08:20 -0000	1.5
***************
*** 44,51 ****
  #define PLUGIN_NAME "OLSRD Basic Multicast Forwarding (BMF) plugin"
  #define PLUGIN_NAME_SHORT "OLSRD BMF"
! #define PLUGIN_VERSION "1.5 (" __DATE__ " " __TIME__ ")"
  #define PLUGIN_COPYRIGHT "  (C) Thales Communications Huizen, Netherlands"
  #define PLUGIN_AUTHOR "  Erik Tromp ((spam-protected))"
  #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION "\n" PLUGIN_COPYRIGHT "\n" PLUGIN_AUTHOR
  
  /* UDP-Port on which multicast packets are encapsulated */
--- 44,52 ----
  #define PLUGIN_NAME "OLSRD Basic Multicast Forwarding (BMF) plugin"
  #define PLUGIN_NAME_SHORT "OLSRD BMF"
! #define PLUGIN_VERSION "1.5.1 (" __DATE__ " " __TIME__ ")"
  #define PLUGIN_COPYRIGHT "  (C) Thales Communications Huizen, Netherlands"
  #define PLUGIN_AUTHOR "  Erik Tromp ((spam-protected))"
  #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION "\n" PLUGIN_COPYRIGHT "\n" PLUGIN_AUTHOR
+ #define PLUGIN_INTERFACE_VERSION 5
  
  /* UDP-Port on which multicast packets are encapsulated */

Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/olsrd_plugin.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** olsrd_plugin.c	15 Jul 2007 17:41:33 -0000	1.6
--- olsrd_plugin.c	11 Sep 2007 23:08:20 -0000	1.7
***************
*** 50,55 ****
  #include "Bmf.h" /* InitBmf(), CloseBmf(), RegisterBmfParameter() */
  #include "PacketHistory.h" /* InitPacketHistory() */
! 
! #define PLUGIN_INTERFACE_VERSION 4
  
  static void __attribute__ ((constructor)) my_init(void);
--- 50,55 ----
  #include "Bmf.h" /* InitBmf(), CloseBmf(), RegisterBmfParameter() */
  #include "PacketHistory.h" /* InitPacketHistory() */
! #include "NetworkInterfaces.h" /* AddNonOlsrBmfIf(), SetBmfInterfaceIp(), ... */
! #include "Address.h" /* DoLocalBroadcast() */
  
  static void __attribute__ ((constructor)) my_init(void);
***************
*** 117,137 ****
  }
  
  /* -------------------------------------------------------------------------
!  * Function   : olsrd_plugin_register_param
!  * Description: Register parameters from config file
!  * Input      : key - the parameter name
!  *              value - the parameter value
!  * Output     : none
!  * Return     : fatal error (<0), minor error (0) or success (>0)
!  * Data Used  : none
!  * Notes      : Called by main OLSR (init_olsr_plugin) for all plugin parameters
   * ------------------------------------------------------------------------- */
! int olsrd_plugin_register_param(char* key, char* value)
  {
!   assert(key != NULL && value != NULL);
! 
!   return RegisterBmfParameter(key, value);
  }
!  
  /* -------------------------------------------------------------------------
   * Function   : my_init
--- 117,145 ----
  }
  
+ static const struct olsrd_plugin_parameters plugin_parameters[] = {
+     { .name = "NonOlsrIf", .set_plugin_parameter = &AddNonOlsrBmfIf, .data = NULL },
+     { .name = "DoLocalBroadcast", .set_plugin_parameter = &DoLocalBroadcast, .data = NULL },
+     { .name = "BmfInterface", .set_plugin_parameter = &SetBmfInterfaceName, .data = NULL },
+     { .name = "BmfInterfaceIp", .set_plugin_parameter = &SetBmfInterfaceIp, .data = NULL },
+     { .name = "CapturePacketsOnOlsrInterfaces", .set_plugin_parameter = &SetCapturePacketsOnOlsrInterfaces, .data = NULL },
+     { .name = "BmfMechanism", .set_plugin_parameter = &SetBmfMechanism, .data = NULL },
+ };
+ 
  /* -------------------------------------------------------------------------
!  * Function   : olsrd_get_plugin_parameters
!  * Description: Return the parameter table and its size
!  * Input      : none
!  * Output     : params - the parameter table
!  *              size - its size in no. of entries
!  * Return     : none
!  * Data Used  : plugin_parameters
!  * Notes      : Called by main OLSR (init_olsr_plugin) for all plugins
   * ------------------------------------------------------------------------- */
! void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
  {
!     *params = plugin_parameters;
!     *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
  }
! 
  /* -------------------------------------------------------------------------
   * Function   : my_init

--- DropList.c DELETED ---

Index: Address.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Address.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Address.c	30 Jun 2007 20:07:47 -0000	1.5
--- Address.c	11 Sep 2007 23:08:20 -0000	1.6
***************
*** 63,85 ****
   *              flooding of local broadcast packets
   * Input      : enable - either "yes" or "no"
   * Output     : none
!  * Return     : fail (0) or success (1)
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! int DoLocalBroadcast(const char* enable)
  {
    if (strcmp(enable, "yes") == 0)
    {
      EnableLocalBroadcast = 1;
!     return 1;
    }
    else if (strcmp(enable, "no") == 0)
    {
      EnableLocalBroadcast = 0;
!     return 1;
    }
  
    /* Value not recognized */
!   return 0;
  }
  
--- 63,86 ----
   *              flooding of local broadcast packets
   * Input      : enable - either "yes" or "no"
+  *              data - not used
   * Output     : none
!  * Return     : success (0) or fail (1)
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! int DoLocalBroadcast(const char* enable, void* data)
  {
    if (strcmp(enable, "yes") == 0)
    {
      EnableLocalBroadcast = 1;
!     return 0;
    }
    else if (strcmp(enable, "no") == 0)
    {
      EnableLocalBroadcast = 0;
!     return 0;
    }
  
    /* Value not recognized */
!   return 1;
  }
  

Index: NetworkInterfaces.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/NetworkInterfaces.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** NetworkInterfaces.h	30 Jun 2007 20:07:47 -0000	1.4
--- NetworkInterfaces.h	11 Sep 2007 23:08:20 -0000	1.5
***************
*** 121,128 ****
  extern enum TBmfMechanism BmfMechanism;
  
! int SetBmfInterfaceName(const char* ifname);
! int SetBmfInterfaceIp(const char* ip);
! int SetCapturePacketsOnOlsrInterfaces(const char* enable);
! int SetBmfMechanism(const char* mechanism);
  int DeactivateSpoofFilter(void);
  void RestoreSpoofFilter(void);
--- 121,128 ----
  extern enum TBmfMechanism BmfMechanism;
  
! int SetBmfInterfaceName(const char* ifname, void* data);
! int SetBmfInterfaceIp(const char* ip, void* data);
! int SetCapturePacketsOnOlsrInterfaces(const char* enable, void* data);
! int SetBmfMechanism(const char* mechanism, void* data);
  int DeactivateSpoofFilter(void);
  void RestoreSpoofFilter(void);
***************
*** 133,137 ****
  };
  
! struct TBestNeighbors GetBestTwoNeighbors(
    struct TBmfInterface* intf,
    union olsr_ip_addr* source,
--- 133,138 ----
  };
  
! void GetBestTwoNeighbors(
!   struct TBestNeighbors* result,
    struct TBmfInterface* intf,
    union olsr_ip_addr* source,
***************
*** 143,147 ****
  void AddInterface(struct interface* newIntf);
  void CloseBmfNetworkInterfaces(void);
! int AddNonOlsrBmfIf(const char* ifName);
  int IsNonOlsrBmfIf(const char* ifName);
  void CheckAndUpdateLocalBroadcast(unsigned char* ipPacket, union olsr_ip_addr* broadAddr);
--- 144,148 ----
  void AddInterface(struct interface* newIntf);
  void CloseBmfNetworkInterfaces(void);
! int AddNonOlsrBmfIf(const char* ifName, void* data);
  int IsNonOlsrBmfIf(const char* ifName);
  void CheckAndUpdateLocalBroadcast(unsigned char* ipPacket, union olsr_ip_addr* broadAddr);

Index: Bmf.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Bmf.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Bmf.c	31 Jul 2007 12:02:18 -0000	1.7
--- Bmf.c	11 Sep 2007 23:08:20 -0000	1.8
***************
*** 64,71 ****
  #include "link_set.h" /* get_best_link_to_neighbor() */
  
! /* Plugin includes */
  #include "NetworkInterfaces.h" /* TBmfInterface, CreateBmfNetworkInterfaces(), CloseBmfNetworkInterfaces() */
  #include "Address.h" /* IsMulticast() */
! #include "Packet.h" /* ETH_TYPE_OFFSET, IFHWADDRLEN etc. */
  #include "PacketHistory.h" /* InitPacketHistory() */
  
--- 64,71 ----
  #include "link_set.h" /* get_best_link_to_neighbor() */
  
! /* BMF includes */
  #include "NetworkInterfaces.h" /* TBmfInterface, CreateBmfNetworkInterfaces(), CloseBmfNetworkInterfaces() */
  #include "Address.h" /* IsMulticast() */
! #include "Packet.h" /* ENCAP_HDR_LEN, BMF_ENCAP_TYPE, BMF_ENCAP_LEN etc. */
  #include "PacketHistory.h" /* InitPacketHistory() */
  
***************
*** 159,163 ****
  
    /* Retrieve at most two best neigbors to forward the packet to */
!   bestNeighborLinks = GetBestTwoNeighbors(intf, NULL, NULL, NULL, &nPossibleNeighbors);
  
    if (nPossibleNeighbors <= 0)
--- 159,163 ----
  
    /* Retrieve at most two best neigbors to forward the packet to */
!   GetBestTwoNeighbors(&bestNeighborLinks, intf, NULL, NULL, NULL, &nPossibleNeighbors);
  
    if (nPossibleNeighbors <= 0)
***************
*** 760,770 ****
  
        /* Retrieve at most two best neigbors to forward the packet to */
!       bestNeighborLinks =
!         GetBestTwoNeighbors(
!           walker,
!           &mcSrc,
!           forwardedBy,
!           forwardedTo,
!           &nPossibleNeighbors);
  
        if (nPossibleNeighbors <= 0)
--- 760,770 ----
  
        /* Retrieve at most two best neigbors to forward the packet to */
!       GetBestTwoNeighbors(
!         &bestNeighborLinks,
!         walker,
!         &mcSrc,
!         forwardedBy,
!         forwardedTo,
!         &nPossibleNeighbors);
  
        if (nPossibleNeighbors <= 0)
***************
*** 1153,1157 ****
           * - the UDP header of the encapsulation IP packet
           * - the encapsulation header
-          * - the Ethernet header in the encapsulated Ethernet packet
           * - a minimum IP header inside the encapsulated packet
           * Note: on a VLAN interface, the value returned by 'recvfrom' may (but need
--- 1153,1156 ----
***************
*** 1162,1166 ****
            sizeof(struct udphdr) +
            ENCAP_HDR_LEN +
-           IP_HDR_OFFSET +
            sizeof(struct ip);
          if (nBytes < minimumLength)
--- 1161,1164 ----
***************
*** 1197,1200 ****
--- 1195,1199 ----
          socklen_t fromLen = sizeof(from);
          int nBytes;
+         int minimumLength;
          union olsr_ip_addr forwardedBy;
  
***************
*** 1222,1228 ****
           * encapsulation packet, at least:
           * - the encapsulation header
-          * - the Ethernet header in the encapsulated Ethernet packet
           * - a minimum IP header inside the encapsulated packet */
!         if (nBytes < ENCAP_HDR_LEN + IP_HDR_OFFSET + (int)sizeof(struct ip))
          {
            olsr_printf(
--- 1221,1229 ----
           * encapsulation packet, at least:
           * - the encapsulation header
           * - a minimum IP header inside the encapsulated packet */
!         minimumLength =
!           ENCAP_HDR_LEN +
!           sizeof(struct ip);
!         if (nBytes < minimumLength)
          {
            olsr_printf(
***************
*** 1474,1515 ****
  } /* CloseBmf */
  
- /* -------------------------------------------------------------------------
-  * Function   : RegisterBmfParameter
-  * Description: Register a configuration parameter with the BMF process
-  * Input      : key - the parameter name, e.g. "DropMac" or "NonOlsrIf"
-  *              value - the parameter value
-  * Output     : none
-  * Return     : fatal error (<0), minor error (0) or success (>0)
-  * Data Used  : none
-  * ------------------------------------------------------------------------- */
- int RegisterBmfParameter(char* key, char* value)
- {
-   if (strcmp(key, "NonOlsrIf") == 0)
-   {
-     return AddNonOlsrBmfIf(value);
-   }
-   else if (strcmp(key, "DoLocalBroadcast") == 0)
-   {
-     return DoLocalBroadcast(value);
-   }
-   else if (strcmp(key, "BmfInterface") == 0)
-   {
-     return SetBmfInterfaceName(value);
-   }
-   else if (strcmp(key, "BmfInterfaceIp") == 0)
-   {
-     return SetBmfInterfaceIp(value);
-   }
-   else if (strcmp(key, "CapturePacketsOnOlsrInterfaces") == 0)
-   {
-     return SetCapturePacketsOnOlsrInterfaces(value);
-   }
-   else if (strcmp(key, "BmfMechanism") == 0)
-   {
-     return SetBmfMechanism(value);
-   }
- 
-   /* Key not recognized */
-   return 0;
- } /* RegisterBmfParameter */
- 
--- 1475,1476 ----

Index: NetworkInterfaces.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/NetworkInterfaces.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** NetworkInterfaces.c	30 Jun 2007 20:07:47 -0000	1.6
--- NetworkInterfaces.c	11 Sep 2007 23:08:20 -0000	1.7
***************
*** 122,134 ****
   *              EtherTunTap interface
   * Input      : ifname - network interface name (e.g. "mybmf0")
   * Output     : none
!  * Return     : fail (0) or success (1)
   * Data Used  : EtherTunTapIfName
   * ------------------------------------------------------------------------- */
! int SetBmfInterfaceName(const char* ifname)
  {
    strncpy(EtherTunTapIfName, ifname, IFNAMSIZ - 1);
    EtherTunTapIfName[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
!   return 1;
  } /* SetBmfInterfaceName */
  
--- 122,135 ----
   *              EtherTunTap interface
   * Input      : ifname - network interface name (e.g. "mybmf0")
+  *              data - not used
   * Output     : none
!  * Return     : success (0) or fail (1)
   * Data Used  : EtherTunTapIfName
   * ------------------------------------------------------------------------- */
! int SetBmfInterfaceName(const char* ifname, void* data)
  {
    strncpy(EtherTunTapIfName, ifname, IFNAMSIZ - 1);
    EtherTunTapIfName[IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
!   return 0;
  } /* SetBmfInterfaceName */
  
***************
*** 138,147 ****
   *              ("10.255.255.253/30") of the EtherTunTap interface
   * Input      : ip - IP address string, followed by '/' and prefix length
   * Output     : none
!  * Return     : fail (0) or success (1)
   * Data Used  : EtherTunTapIp, EtherTunTapIpMask, EtherTunTapIpBroadcast,
   *              TunTapIpOverruled
   * ------------------------------------------------------------------------- */
! int SetBmfInterfaceIp(const char* ip)
  {
  #define IPV4_MAX_ADDRLEN 16
--- 139,149 ----
   *              ("10.255.255.253/30") of the EtherTunTap interface
   * Input      : ip - IP address string, followed by '/' and prefix length
+  *              data - not used
   * Output     : none
!  * Return     : success (0) or fail (1)
   * Data Used  : EtherTunTapIp, EtherTunTapIpMask, EtherTunTapIpBroadcast,
   *              TunTapIpOverruled
   * ------------------------------------------------------------------------- */
! int SetBmfInterfaceIp(const char* ip, void* data)
  {
  #define IPV4_MAX_ADDRLEN 16
***************
*** 163,167 ****
    {
      /* No prefix length specified, or IP address too long */
!     return 0;
    }
  
--- 165,169 ----
    {
      /* No prefix length specified, or IP address too long */
!     return 1;
    }
  
***************
*** 171,175 ****
    {
      /* Invalid address passed */
!     return 0;
    }
  
--- 173,177 ----
    {
      /* Invalid address passed */
!     return 1;
    }
  
***************
*** 180,185 ****
    if (prefixLen <= 0 || prefixLen > IPV4_MAX_PREFIXLEN)
    {
! 	  return 0;
! 	}
  
    /* Compose IP subnet mask in host byte order */
--- 182,187 ----
    if (prefixLen <= 0 || prefixLen > IPV4_MAX_PREFIXLEN)
    {
!     return 1;
!   }
  
    /* Compose IP subnet mask in host byte order */
***************
*** 199,203 ****
    TunTapIpOverruled = 1;
  
!   return 1;
  } /* SetBmfInterfaceIp */
  
--- 201,205 ----
    TunTapIpOverruled = 1;
  
!   return 0;
  } /* SetBmfInterfaceIp */
  
***************
*** 207,229 ****
   *              capturing of packets on OLSR-enabled interfaces.
   * Input      : enable - either "yes" or "no"
   * Output     : none
!  * Return     : fail (0) or success (1)
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! int SetCapturePacketsOnOlsrInterfaces(const char* enable)
  {
    if (strcmp(enable, "yes") == 0)
    {
      CapturePacketsOnOlsrInterfaces = 1;
!     return 1;
    }
    else if (strcmp(enable, "no") == 0)
    {
      CapturePacketsOnOlsrInterfaces = 0;
!     return 1;
    }
  
    /* Value not recognized */
!   return 0;
  } /* SetCapturePacketsOnOlsrInterfaces */
  
--- 209,232 ----
   *              capturing of packets on OLSR-enabled interfaces.
   * Input      : enable - either "yes" or "no"
+  *              data - not used
   * Output     : none
!  * Return     : success (0) or fail (1)
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! int SetCapturePacketsOnOlsrInterfaces(const char* enable, void* data)
  {
    if (strcmp(enable, "yes") == 0)
    {
      CapturePacketsOnOlsrInterfaces = 1;
!     return 0;
    }
    else if (strcmp(enable, "no") == 0)
    {
      CapturePacketsOnOlsrInterfaces = 0;
!     return 0;
    }
  
    /* Value not recognized */
!   return 1;
  } /* SetCapturePacketsOnOlsrInterfaces */
  
***************
*** 233,255 ****
   *              BM_UNICAST_PROMISCUOUS.
   * Input      : mechanism - either "Broadcast" or "UnicastPromiscuous"
   * Output     : none
!  * Return     : fail (0) or success (1)
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! int SetBmfMechanism(const char* mechanism)
  {
    if (strcmp(mechanism, "Broadcast") == 0)
    {
      BmfMechanism = BM_BROADCAST;
!     return 1;
    }
    else if (strcmp(mechanism, "UnicastPromiscuous") == 0)
    {
      BmfMechanism = BM_UNICAST_PROMISCUOUS;
!     return 1;
    }
  
    /* Value not recognized */
!   return 0;
  } /* SetBmfMechanism */
  
--- 236,259 ----
   *              BM_UNICAST_PROMISCUOUS.
   * Input      : mechanism - either "Broadcast" or "UnicastPromiscuous"
+  *              data - not used
   * Output     : none
!  * Return     : success (0) or fail (1)
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! int SetBmfMechanism(const char* mechanism, void* data)
  {
    if (strcmp(mechanism, "Broadcast") == 0)
    {
      BmfMechanism = BM_BROADCAST;
!     return 0;
    }
    else if (strcmp(mechanism, "UnicastPromiscuous") == 0)
    {
      BmfMechanism = BM_UNICAST_PROMISCUOUS;
!     return 0;
    }
  
    /* Value not recognized */
!   return 1;
  } /* SetBmfMechanism */
  
***************
*** 403,413 ****
   *              forwardedTo - the IP address of the node to which the BMF packet
   *                was directed
!  * Output     : nPossibleNeighbors - number of found possible neighbors
!  * Return     : The list of the two best neighbors. If only one best neighbor is
!  *              found, the second list entry is NULL. If no neigbors are found,
!  *              the first and second list entries are both NULL.
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! struct TBestNeighbors GetBestTwoNeighbors(
    struct TBmfInterface* intf,
    union olsr_ip_addr* source,
--- 407,418 ----
   *              forwardedTo - the IP address of the node to which the BMF packet
   *                was directed
!  * Output     : result - the list of the two best neighbors. If only one best
!  *                neighbor is found, the second list entry is NULL. If no neigbors
!  *                are found, the first and second list entries are both NULL.
!  *              nPossibleNeighbors - number of found possible neighbors
   * Data Used  : none
   * ------------------------------------------------------------------------- */
! void GetBestTwoNeighbors(
!   struct TBestNeighbors* result,
    struct TBmfInterface* intf,
    union olsr_ip_addr* source,
***************
*** 416,422 ****
    int* nPossibleNeighbors)
  {
!   struct TBestNeighbors result;
!   result.links[0] = NULL;
!   result.links[1] = NULL;
  
    /* handle the non-LQ case */
--- 421,426 ----
    int* nPossibleNeighbors)
  {
!   result->links[0] = NULL;
!   result->links[1] = NULL;
  
    /* handle the non-LQ case */
***************
*** 490,500 ****
        /* In the non-LQ case, it is not possible to select neigbors
         * by quality or cost. So just remember the first two found links. */
!       if (result.links[0] == NULL)
        {
!         result.links[0] = walker;
        }
!       else if (result.links[1] == NULL)
        {
!         result.links[1] = walker;
        } /* if */
      } /* for */
--- 494,504 ----
        /* In the non-LQ case, it is not possible to select neigbors
         * by quality or cost. So just remember the first two found links. */
!       if (result->links[0] == NULL)
        {
!         result->links[0] = walker;
        }
!       else if (result->links[1] == NULL)
        {
!         result->links[1] = walker;
        } /* if */
      } /* for */
***************
*** 507,513 ****
  
      struct link_entry* walker;
!     float previousLinkCost = INFINITE_COST;
!     float bestLinkCost = INFINITE_COST;
!     float oneButBestLinkCost = INFINITE_COST;
      *nPossibleNeighbors = 0;
  
--- 511,517 ----
  
      struct link_entry* walker;
!     float previousLinkCost = 2 * INFINITE_COST;
!     float bestLinkCost = 2 * INFINITE_COST;
!     float oneButBestLinkCost = 2 * INFINITE_COST;
      *nPossibleNeighbors = 0;
  
***************
*** 583,586 ****
--- 587,601 ----
        /* Found a candidate neighbor to direct our packet to */
  
+       if (walker->link_cost >= INFINITE_COST)
+       {
+         OLSR_PRINTF(
+           9,
+           "%s: ----> Not forwarding to %s: link is timing out\n",
+           PLUGIN_NAME_SHORT,
+           olsr_ip_to_string(&walker->neighbor_iface_addr));
+ 
+         continue; /* for */
+       }
+ 
        /* Compare costs to check if the candidate neighbor is best reached via 'intf' */
        OLSR_PRINTF(
***************
*** 671,681 ****
        if (walker->link_cost < bestLinkCost)
        {
!         result.links[1] = result.links[0];
!         result.links[0] = walker;
          bestLinkCost = walker->link_cost;
        }
        else if (walker->link_cost < oneButBestLinkCost)
        {
!         result.links[1] = walker;
          oneButBestLinkCost = walker->link_cost;
        } /* if */
--- 686,696 ----
        if (walker->link_cost < bestLinkCost)
        {
!         result->links[1] = result->links[0];
!         result->links[0] = walker;
          bestLinkCost = walker->link_cost;
        }
        else if (walker->link_cost < oneButBestLinkCost)
        {
!         result->links[1] = walker;
          oneButBestLinkCost = walker->link_cost;
        } /* if */
***************
*** 685,691 ****
          
      struct link_entry* walker;
!     float previousLinkEtx = INFINITE_ETX;
!     float bestEtx = INFINITE_ETX; 
!     float oneButBestEtx = INFINITE_ETX; 
      *nPossibleNeighbors = 0;
  
--- 700,706 ----
          
      struct link_entry* walker;
!     float previousLinkEtx = 2 * INFINITE_ETX;
!     float bestEtx = 2 * INFINITE_ETX; 
!     float oneButBestEtx = 2 * INFINITE_ETX;
      *nPossibleNeighbors = 0;
  
***************
*** 770,773 ****
--- 785,799 ----
          walker->neigh_link_quality);
   
+       if (currEtx >= INFINITE_ETX)
+       {
+         OLSR_PRINTF(
+           9,
+           "%s: ----> Not forwarding to %s: link is timing out\n",
+           PLUGIN_NAME_SHORT,
+           olsr_ip_to_string(&walker->neighbor_iface_addr));
+ 
+         continue; /* for */
+       }
+ 
        /* Compare costs to check if the candidate neighbor is best reached via 'intf' */
        OLSR_PRINTF(
***************
*** 866,876 ****
        if (currEtx < bestEtx)
        {
!         result.links[1] = result.links[0];
!         result.links[0] = walker;
          bestEtx = currEtx;
        }
        else if (currEtx < oneButBestEtx)
        {
!         result.links[1] = walker;
          oneButBestEtx = currEtx;
        } /* if */
--- 892,902 ----
        if (currEtx < bestEtx)
        {
!         result->links[1] = result->links[0];
!         result->links[0] = walker;
          bestEtx = currEtx;
        }
        else if (currEtx < oneButBestEtx)
        {
!         result->links[1] = walker;
          oneButBestEtx = currEtx;
        } /* if */
***************
*** 882,886 ****
  
    /* Display the result of the neighbor search */
!   if (result.links[0] == NULL)
    {
      OLSR_PRINTF(
--- 908,912 ----
  
    /* Display the result of the neighbor search */
!   if (result->links[0] == NULL)
    {
      OLSR_PRINTF(
***************
*** 902,913 ****
        9,
        "%s",
!       olsr_ip_to_string(&result.links[0]->neighbor_iface_addr));
  
!     if (result.links[1] != NULL)
      {
        OLSR_PRINTF(
          9,
          ", %s",
!         olsr_ip_to_string(&result.links[1]->neighbor_iface_addr));
      } /* if */
  
--- 928,939 ----
        9,
        "%s",
!       olsr_ip_to_string(&result->links[0]->neighbor_iface_addr));
  
!     if (result->links[1] != NULL)
      {
        OLSR_PRINTF(
          9,
          ", %s",
!         olsr_ip_to_string(&result->links[1]->neighbor_iface_addr));
      } /* if */
  
***************
*** 915,919 ****
    } /* if */
  
-   return result;
  } /* GetBestTwoNeighbors */
  
--- 941,944 ----
***************
*** 1735,1743 ****
   *              network interfaces
   * Input      : ifName - network interface (e.g. "eth0")
   * Output     : none
!  * Return     : fail (0) or success (1)
   * Data Used  : NonOlsrIfNames
   * ------------------------------------------------------------------------- */
! int AddNonOlsrBmfIf(const char* ifName)
  {
    assert(ifName != NULL);
--- 1760,1769 ----
   *              network interfaces
   * Input      : ifName - network interface (e.g. "eth0")
+  *              data - not used
   * Output     : none
!  * Return     : success (0) or fail (1)
   * Data Used  : NonOlsrIfNames
   * ------------------------------------------------------------------------- */
! int AddNonOlsrBmfIf(const char* ifName, void* data)
  {
    assert(ifName != NULL);
***************
*** 1750,1754 ****
        PLUGIN_NAME,
        MAX_NON_OLSR_IFS);
!     return 0;
    }
  
--- 1776,1780 ----
        PLUGIN_NAME,
        MAX_NON_OLSR_IFS);
!     return 1;
    }
  
***************
*** 1756,1760 ****
    NonOlsrIfNames[nNonOlsrIfs][IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
    nNonOlsrIfs++;
!   return 1;
  } /* AddNonOlsrBmfIf */
  
--- 1782,1786 ----
    NonOlsrIfNames[nNonOlsrIfs][IFNAMSIZ - 1] = '\0'; /* Ensures null termination */
    nNonOlsrIfs++;
!   return 0;
  } /* AddNonOlsrBmfIf */
  





More information about the Olsr-cvs mailing list