[Olsr-cvs] olsrd-current/lib/bmf/src Address.c, 1.1, 1.2 Address.h, 1.1, 1.2 Bmf.c, 1.1, 1.2 Bmf.h, 1.1, 1.2 DropList.c, 1.1, 1.2 DropList.h, 1.1, 1.2 NetworkInterfaces.c, 1.1, 1.2 NetworkInterfaces.h, 1.1, 1.2 Packet.c, 1.2, 1.3 Packet.h, 1.1, 1.2 PacketHistory.c, 1.1, 1.2 PacketHistory.h, 1.1, 1.2 olsrd_plugin.c, 1.1, 1.2
Bernd Petrovitsch
(spam-protected)
Sat Feb 10 18:05:58 CET 2007
Update of /cvsroot/olsrd/olsrd-current/lib/bmf/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14934/src
Modified Files:
Address.c Address.h Bmf.c Bmf.h DropList.c DropList.h
NetworkInterfaces.c NetworkInterfaces.h Packet.c Packet.h
PacketHistory.c PacketHistory.h olsrd_plugin.c
Log Message:
* replaced the bmf plugin with the most recent 1.3 from sf.net with the
following changes:
- We had a globally declared ioctl_s variable which is used exactly
once in NetworkInterfaces.c.
Sven-Ola proposed a global "extern" decalaretion but I inserted it
there locally.
Main reason: Where does this variable actually come from?
I can only find one in the olsr_cnf struct. But since the compiler/linker finds
one, there must be one somewhere.
- I #if 0 ... #endif out the IsNullMacAddress() function since it is not used
AFAICS (and the compiler actually).
Index: Packet.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Packet.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Packet.h 3 May 2006 08:59:04 -0000 1.1
--- Packet.h 10 Feb 2007 17:05:56 -0000 1.2
***************
*** 34,38 ****
*/
! /* $Id$ */
/* System includes */
--- 34,44 ----
*/
! /* -------------------------------------------------------------------------
! * File : Packet.h
! * Description: BMF and IP packet processing functions
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
/* System includes */
***************
*** 50,63 ****
#define IPV4_TYPE 0x0800
struct TSaveTtl
{
u_int8_t ttl;
u_int16_t check;
! };
int GetIpTtl(unsigned char* buffer);
void SaveTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl);
void RestoreTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl);
! void PacketDecreaseTtlAndUpdateHeaderChecksum(unsigned char* buffer);
#endif /* _BMF_PACKET_H */
--- 56,85 ----
#define IPV4_TYPE 0x0800
+ /* BMF-encapsulated packets are Ethernet-IP-UDP packets, which start
+ * with a 16-bytes BMF header (struct TEncapHeader), followed by the
+ * encapsulated Ethernet-IP packet itself */
+
+ struct TEncapHeader
+ {
+ u_int32_t crc32;
+ u_int32_t futureExpansion1;
+ u_int32_t futureExpansion2;
+ u_int32_t futureExpansion3;
+ } __attribute__((__packed__));
+
+ #define ENCAP_HDR_LEN (sizeof(struct TEncapHeader))
+
struct TSaveTtl
{
u_int8_t ttl;
u_int16_t check;
! } __attribute__((__packed__));
+ int GetIpPacketLength(unsigned char* buffer);
+ int GetIpHeaderLength(unsigned char* buffer);
int GetIpTtl(unsigned char* buffer);
void SaveTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl);
void RestoreTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl);
! void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* buffer);
#endif /* _BMF_PACKET_H */
Index: Address.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Address.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Address.h 3 May 2006 08:59:04 -0000 1.1
--- Address.h 10 Feb 2007 17:05:55 -0000 1.2
***************
*** 34,45 ****
*/
! /* $Id$ */
#include "olsr_types.h" /* olsr_ip_addr */
#include "interfaces.h" /* struct interface */
int IsMulticast(union olsr_ip_addr* ipAddress);
! int IsLocalBroadcast(union olsr_ip_addr* destIp, struct interface* ifFrom);
! int IsOlsrOrBmfPacket(unsigned char* buffer, ssize_t len);
#endif /* _BMF_ADDRESS_H */
--- 34,56 ----
*/
! /* -------------------------------------------------------------------------
! * File : Address.h
! * Description: IP packet characterization functions
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
#include "olsr_types.h" /* olsr_ip_addr */
#include "interfaces.h" /* struct interface */
+ struct TBmfInterface;
+
+ extern int EnableLocalBroadcast;
+
+ int DoLocalBroadcast(const char* enable);
int IsMulticast(union olsr_ip_addr* ipAddress);
! int IsLocalBroadcast(union olsr_ip_addr* destIp, struct sockaddr* broadAddr);
! int IsOlsrOrBmfPacket(struct TBmfInterface* intf, unsigned char* ethPkt, size_t len);
#endif /* _BMF_ADDRESS_H */
Index: DropList.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/DropList.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DropList.h 3 May 2006 08:59:04 -0000 1.1
--- DropList.h 10 Feb 2007 17:05:56 -0000 1.2
***************
*** 34,38 ****
*/
! /* $Id$ */
struct TMacAddress
--- 34,44 ----
*/
! /* -------------------------------------------------------------------------
! * File : DropList.h
! * Description: List of MAC addresses of hosts from which all packets are dropped.
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
struct TMacAddress
Index: Packet.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Packet.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Packet.c 8 Feb 2007 10:31:43 -0000 1.2
--- Packet.c 10 Feb 2007 17:05:56 -0000 1.3
***************
*** 31,35 ****
*/
! /* $Id$ */
#include "Packet.h"
--- 31,41 ----
*/
! /* -------------------------------------------------------------------------
! * File : Packet.c
! * Description: BMF and IP packet processing functions
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
#include "Packet.h"
***************
*** 39,47 ****
#include <sys/types.h> /* u_int32_t */
#include <netinet/in.h> /* ntohs(), htons() */
! #include <asm/byteorder.h>
! #include <linux/ip.h>
! /* Retrieve the TTL (Time To Live) value from the IP header of the
! * passed ethernet packet */
int GetIpTtl(unsigned char* buffer)
{
--- 45,98 ----
#include <sys/types.h> /* u_int32_t */
#include <netinet/in.h> /* ntohs(), htons() */
! #include <netinet/ip.h> /* struct iphdr */
! #include <stdio.h>
! /* -------------------------------------------------------------------------
! * Function : GetIpPacketLength
! * Description: Retrieve the IP packet length (in bytes) of the passed
! * ethernet-IP packet
! * Input : buffer - the ethernet-IP packet
! * Output : none
! * Return : IP packet length
! * Data Used : none
! * ------------------------------------------------------------------------- */
! int GetIpPacketLength(unsigned char* buffer)
! {
! struct iphdr* iph;
!
! assert(buffer != NULL);
!
! iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
! return ntohs(iph->tot_len);
! }
!
! /* -------------------------------------------------------------------------
! * Function : GetIpHeaderLength
! * Description: Retrieve the IP header length (in bytes) of the passed
! * ethernet-IP packet
! * Input : buffer - the ethernet-IP packet
! * Output : none
! * Return : IP header length
! * Data Used : none
! * ------------------------------------------------------------------------- */
! int GetIpHeaderLength(unsigned char* buffer)
! {
! struct iphdr* iph;
!
! assert(buffer != NULL);
!
! iph = (struct iphdr*) (buffer + IP_HDR_OFFSET);
! return iph->ihl << 2;
! }
!
! /* -------------------------------------------------------------------------
! * Function : GetIpTtl
! * Description: Retrieve the TTL (Time To Live) value from the IP header of
! * the passed ethernet-IP packet
! * Input : buffer - the ethernet-IP packet
! * Output : none
! * Return : TTL value
! * Data Used : none
! * ------------------------------------------------------------------------- */
int GetIpTtl(unsigned char* buffer)
{
***************
*** 54,57 ****
--- 105,117 ----
}
+ /* -------------------------------------------------------------------------
+ * Function : SaveTtlAndChecksum
+ * Description: Save the TTL (Time To Live) value and IP checksum as found in
+ * the IP header of the passed ethernet-IP packet
+ * Input : buffer - the ethernet-IP packet
+ * Output : sttl - the TTL and checksum values
+ * Return : none
+ * Data Used : none
+ * ------------------------------------------------------------------------- */
void SaveTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl)
{
***************
*** 65,68 ****
--- 125,138 ----
}
+ /* -------------------------------------------------------------------------
+ * Function : RestoreTtlAndChecksum
+ * Description: Restore the TTL (Time To Live) value and IP checksum in
+ * the IP header of the passed ethernet-IP packet
+ * Input : buffer - the ethernet-IP packet
+ * sttl - the TTL and checksum values
+ * Output : none
+ * Return : none
+ * Data Used : none
+ * ------------------------------------------------------------------------- */
void RestoreTtlAndChecksum(unsigned char* buffer, struct TSaveTtl* sttl)
{
***************
*** 76,82 ****
}
! /* For an IP packet, decrement the TTL value and update the IP header
! * checksum accordingly. See also RFC1141. */
! void PacketDecreaseTtlAndUpdateHeaderChecksum(unsigned char* buffer)
{
struct iphdr* iph;
--- 146,160 ----
}
! /* -------------------------------------------------------------------------
! * Function : DecreaseTtlAndUpdateHeaderChecksum
! * Description: For an IP packet, decrement the TTL value and update the IP header
! * checksum accordingly.
! * Input : buffer - the ethernet-IP packet
! * Output : none
! * Return : none
! * Data Used : none
! * Notes : See also RFC1141
! * ------------------------------------------------------------------------- */
! void DecreaseTtlAndUpdateHeaderChecksum(unsigned char* buffer)
{
struct iphdr* iph;
Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/olsrd_plugin.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** olsrd_plugin.c 3 May 2006 08:59:04 -0000 1.1
--- olsrd_plugin.c 10 Feb 2007 17:05:56 -0000 1.2
***************
*** 31,39 ****
*/
! /* $Id$ */
!
! /*
! * Dynamic linked library for olsr.org olsrd
! */
/* System includes */
--- 31,41 ----
*/
! /* -------------------------------------------------------------------------
! * File : olsrd_plugin.c
! * Description: Interface to the OLSRD plugin system
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
/* System includes */
***************
*** 43,49 ****
--- 45,54 ----
/* OLSRD includes */
#include "olsrd_plugin.h"
+ #include "defs.h" /* olsr_u8_t, olsr_cnf */
+ #include "scheduler.h" /* olsr_register_scheduler_event */
/* BMF includes */
#include "Bmf.h" /* InitBmf(), CloseBmf(), RegisterBmfParameter() */
+ #include "PacketHistory.h" /* InitPacketHistory() */
static void __attribute__ ((constructor)) my_init(void);
***************
*** 52,57 ****
void olsr_plugin_exit(void);
! /* Plugin interface version
! * Used by main olsrd to check plugin interface version */
int olsrd_plugin_interface_version()
{
--- 57,70 ----
void olsr_plugin_exit(void);
! /* -------------------------------------------------------------------------
! * Function : olsrd_plugin_interface_version
! * Description: Plugin interface version
! * Input : none
! * Output : none
! * Return : BMF plugin interface version number
! * Data Used : none
! * Notes : Called by main OLSRD (olsr_load_dl) to check plugin interface
! * version
! * ------------------------------------------------------------------------- */
int olsrd_plugin_interface_version()
{
***************
*** 59,68 ****
}
int olsrd_plugin_init()
{
! return InitBmf();
}
! /* destructor - called at unload */
void olsr_plugin_exit()
{
--- 72,114 ----
}
+ /* -------------------------------------------------------------------------
+ * Function : olsrd_plugin_init
+ * Description: Plugin initialisation
+ * Input : none
+ * Output : none
+ * Return : fail (0) or success (1)
+ * Data Used : olsr_cnf
+ * Notes : Called by main OLSRD (init_olsr_plugin) to initialize plugin
+ * ------------------------------------------------------------------------- */
int olsrd_plugin_init()
{
! /* Check validity */
! if (olsr_cnf->ip_version != AF_INET)
! {
! fprintf(stderr, PLUGIN_NAME ": This plugin only supports IPv4!\n");
! return 0;
! }
!
! /* Clear the packet history */
! InitPacketHistory();
!
! /* Register ifchange function */
! add_ifchgf(&InterfaceChange);
!
! /* Register the duplicate registration pruning process */
! olsr_register_scheduler_event(&PrunePacketHistory, NULL, 3.0, 2.0, NULL);
!
! return InitBmf(NULL);
}
! /* -------------------------------------------------------------------------
! * Function : olsr_plugin_exit
! * Description: Plugin cleanup
! * Input : none
! * Output : none
! * Return : none
! * Data Used : none
! * Notes : Called by my_fini() at unload of shared object
! * ------------------------------------------------------------------------- */
void olsr_plugin_exit()
{
***************
*** 70,75 ****
}
! /* Register parameters from config file
! * Called for all plugin parameters */
int olsrd_plugin_register_param(char* key, char* value)
{
--- 116,129 ----
}
! /* -------------------------------------------------------------------------
! * 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)
{
***************
*** 79,82 ****
--- 133,145 ----
}
+ /* -------------------------------------------------------------------------
+ * Function : my_init
+ * Description: Plugin constructor
+ * Input : none
+ * Output : none
+ * Return : none
+ * Data Used : none
+ * Notes : Called at load of shared object
+ * ------------------------------------------------------------------------- */
static void my_init()
{
***************
*** 87,90 ****
--- 150,162 ----
}
+ /* -------------------------------------------------------------------------
+ * Function : my_fini
+ * Description: Plugin destructor
+ * Input : none
+ * Output : none
+ * Return : none
+ * Data Used : none
+ * Notes : Called at unload of shared object
+ * ------------------------------------------------------------------------- */
static void my_fini()
{
Index: DropList.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/DropList.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DropList.c 3 May 2006 08:59:04 -0000 1.1
--- DropList.c 10 Feb 2007 17:05:55 -0000 1.2
***************
*** 31,35 ****
*/
! /* $Id$ */
--- 31,42 ----
*/
! /* -------------------------------------------------------------------------
! * File : DropList.c
! * Description: List of MAC addresses of hosts from which received multicast
! * and local broadcast packets are dropped.
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
***************
*** 51,63 ****
static struct TMacAddress* DroppedMacAddresses = NULL;
! /* Register a MAC address in the drop list. The registered MAC address will be matched
! * to the source MAC address of incoming multicast packets. If matched, the multicast
! * packet will be silently dropped.
! * The drop list is needed only in lab environments, where hidden nodes are simulated
! * by using iptables with the -m mac --mac-source option (as in:
! * "iptables -A INPUT -m mac --mac-source 00:0C:29:EE:C9:D0 -j DROP")
! * The drop list is needed because network interfaces in promiscuous mode will still
! * capture packets even if they are specified to be dropped by iptables.
! */
int DropMac(const char* macStr)
{
--- 58,79 ----
static struct TMacAddress* DroppedMacAddresses = NULL;
! /* -------------------------------------------------------------------------
! * Function : DropMac
! * Description: Register a MAC address in the drop list
! * Input : macStr - MAC address as string
! * Output : none
! * Return : fail (0) or success (1)
! * Data Used : DroppedMacAddresses
! * Notes : The registered MAC address will be matched to the source MAC
! * address of incoming multicast packets. If matched, the multicast
! * packet will be dropped.
! * The drop list is needed only in lab environments, where hidden
! * nodes are simulated by using iptables with the
! * -m mac helper and --mac-source option (as in:
! * "iptables -A INPUT -m mac --mac-source 00:0C:29:EE:C9:D0 -j DROP")
! * The drop list is needed because network interfaces in promiscuous
! * mode will still capture packets even if they are specified to
! * be dropped by iptables.
! * ------------------------------------------------------------------------- */
int DropMac(const char* macStr)
{
***************
*** 87,91 ****
}
! /* Return 1 if macAddress is in the drop list, else 0 */
int IsInDropList(const unsigned char* macAddress)
{
--- 103,114 ----
}
! /* -------------------------------------------------------------------------
! * Function : IsInDropList
! * Description: Check if a MAC address is in the drop list
! * Input : macAddress
! * Output : none
! * Return : true (1) or false (0)
! * Data Used : DroppedMacAddresses
! * ------------------------------------------------------------------------- */
int IsInDropList(const unsigned char* macAddress)
{
Index: Address.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Address.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Address.c 3 May 2006 08:59:04 -0000 1.1
--- Address.c 10 Feb 2007 17:05:55 -0000 1.2
***************
*** 30,40 ****
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
!
! /* $Id$ */
!
#include "Address.h"
/* System includes */
#include <assert.h> /* assert() */
/* OLSRD includes */
--- 30,48 ----
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
!
! /* -------------------------------------------------------------------------
! * File : Address.c
! * Description: IP packet characterization functions
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
!
#include "Address.h"
/* System includes */
#include <assert.h> /* assert() */
+ #include <netinet/ip.h> /* struct ip */
+ #include <netinet/udp.h> /* struct udphdr */
/* OLSRD includes */
***************
*** 43,47 ****
--- 51,95 ----
/* Plugin includes */
#include "Bmf.h" /* BMF_ENCAP_PORT */
+ #include "NetworkInterfaces.h" /* TBmfInterface */
+
+ /* Whether or not to flood local broadcast packets (e.g. packets with IP
+ * destination 192.168.1.255). May be overruled by setting the plugin
+ * parameter "DoLocalBroadcast" to "no" */
+ int EnableLocalBroadcast = 1;
+
+ /* -------------------------------------------------------------------------
+ * Function : DoLocalBroadcast
+ * Description: Overrule the default setting, enabling or disabling the
+ * 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;
+ }
+ /* -------------------------------------------------------------------------
+ * Function : IsMulticast
+ * Description: Check if an IP address is a multicast address
+ * Input : ipAddress
+ * Output : none
+ * Return : true (1) or false (0)
+ * Data Used : none
+ * ------------------------------------------------------------------------- */
int IsMulticast(union olsr_ip_addr* ipAddress)
{
***************
*** 51,92 ****
}
! int IsLocalBroadcast(union olsr_ip_addr* destIp, struct interface* ifFrom)
{
struct sockaddr_in* sin;
! assert(destIp != NULL);
!
! /* Protect ourselves against bogus input */
! if (ifFrom == NULL) return 0;
/* Cast down to correct sockaddr subtype */
! sin = (struct sockaddr_in*)&(ifFrom->int_broadaddr);
!
! /* Just in case OLSR does not have int_broadaddr filled in for this
! * interface. */
! if (sin == NULL) return 0;
return COMP_IP(&(sin->sin_addr.s_addr), destIp);
}
! int IsOlsrOrBmfPacket(unsigned char* buffer, ssize_t len)
{
! u_int16_t port;
! assert(buffer != NULL);
/* Consider OLSR and BMF packets not to be local broadcast
* OLSR packets are UDP - port 698
! * BMF packets are UDP - port 50505 */
! memcpy(&port, buffer + 0x24, 2);
! port = ntohs(port);
! if (len > 0x25 &&
! buffer[0x17] == 0x11 && /* UDP */
! (port == OLSRPORT || port == BMF_ENCAP_PORT))
{
return 1;
}
return 0;
}
--- 99,230 ----
}
! /* -------------------------------------------------------------------------
! * Function : IsLocalBroadcast
! * Description: Check if an IP address is a local broadcast address for a
! * given network interface
! * Input : destIp, broadAddr
! * Output : none
! * Return : true (1) or false (0)
! * Data Used : none
! * ------------------------------------------------------------------------- */
! int IsLocalBroadcast(union olsr_ip_addr* destIp, struct sockaddr* broadAddr)
{
struct sockaddr_in* sin;
! assert(destIp != NULL && broadAddr != NULL);
/* Cast down to correct sockaddr subtype */
! sin = (struct sockaddr_in*)broadAddr;
return COMP_IP(&(sin->sin_addr.s_addr), destIp);
}
! /* -------------------------------------------------------------------------
! * Function : IsOlsrOrBmfPacket
! * Description: Check if an ethernet packet is an OLSR packet or a BMF packet
! * Input : intf, ethPkt, len
! * Output : none
! * Return : true (1) or false (0)
! * Data Used : none
! * Assumption : len >= IP_HDR_OFFSET + GetIpHeaderLength(ethPkt)
! * ------------------------------------------------------------------------- */
! int IsOlsrOrBmfPacket(struct TBmfInterface* intf, unsigned char* ethPkt, size_t len)
{
! struct ip* ipData;
! unsigned int ipHeaderLen;
! struct udphdr* udpData;
! u_int16_t destPort;
! assert(ethPkt != NULL);
/* Consider OLSR and BMF packets not to be local broadcast
* OLSR packets are UDP - port 698
! * OLSR-BMF packets are UDP - port 50698
! * OLSR-Autodetect probe packets are UDP - port 51698
! * Fragments of the above packets are also not local broadcast */
! ipData = (struct ip*) (ethPkt + IP_HDR_OFFSET);
! if (ipData->ip_p != SOL_UDP)
! {
! return 0;
! }
! /* Check if the packet is an IP-fragment */
! if ((ntohs(ipData->ip_off) & IP_OFFMASK) != 0)
{
+ #if 0
+ int i;
+ for (i = 0; i < FRAGMENT_HISTORY_SIZE; i++)
+ {
+ /* Quick-access pointer */
+ struct TFragmentHistory* entry = &intf->fragmentHistory[i];
+
+ /* Match */
+ if (entry->ipId == ntohs(ipData->ip_id) &&
+ entry->ipProto == ipData->ip_p &&
+ entry->ipSrc.s_addr == ntohl(ipData->ip_src.s_addr) &&
+ entry->ipDst.s_addr == ntohl(ipData->ip_dst.s_addr))
+ {
+ /* Found matching history entry, so packet is assumed to be a fragment
+ * of an earlier OLSR/OLSR-BMF/OLSR-Autodetect packet */
+
+ /* More fragments? If not, invalidate entry */
+ if (((ntohs(ipData->ip_off) & IP_MF) == 0))
+ {
+ memset(entry, 0, sizeof(struct TFragmentHistory));
+ }
+
+ return 1;
+ }
+ }
+
+ /* Matching history entry not found, so packet is not assumed to be a fragment
+ * of an earlier OLSR/OLSR-BMF/OLSR-Autodetect packet */
+ #endif
+ /* OOPS! IP-fragments may come in earlier than their main packet. In that case,
+ * their relation with the main packet is not detected by the above code, resulting
+ * in stray fragments being forwarded all ove the network. Solution for now is to
+ * not forward any IP-fragments at all. */
+ /*return 0;*/
return 1;
}
+
+ /* The packet is the first (or only) IP-fragment */
+
+ /* Check length first */
+ ipHeaderLen = ipData->ip_hl << 2;
+ if (len < IP_HDR_OFFSET + ipHeaderLen + sizeof(struct udphdr))
+ {
+ return 0;
+ }
+
+ /* Go into the UDP header and check port number */
+ udpData = (struct udphdr*) (ethPkt + IP_HDR_OFFSET + ipHeaderLen);
+ destPort = ntohs(udpData->dest);
+
+ if (destPort == OLSRPORT || destPort == BMF_ENCAP_PORT || destPort == 51698)
+ /* TODO: #define for 51698 */
+ {
+ #if 0
+ /* If more fragments are expected, keep a record in the fragment history */
+ if ((ntohs(ipData->ip_off) & IP_MF) != 0)
+ {
+ /* Quick-access pointer */
+ struct TFragmentHistory* entry = &intf->fragmentHistory[intf->nextFragmentHistoryEntry];
+
+ /* Store in fragment history */
+ entry->ipId = ntohs(ipData->ip_id);
+ entry->ipProto = ipData->ip_p;
+ entry->ipSrc.s_addr = ntohl(ipData->ip_src.s_addr);
+ entry->ipDst.s_addr = ntohl(ipData->ip_dst.s_addr);
+
+ /* Advance to next entry */
+ intf->nextFragmentHistoryEntry++;
+ intf->nextFragmentHistoryEntry %= FRAGMENT_HISTORY_SIZE;
+ }
+ #endif
+ return 1;
+ }
+
return 0;
}
Index: Bmf.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Bmf.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Bmf.h 3 May 2006 08:59:04 -0000 1.1
--- Bmf.h 10 Feb 2007 17:05:55 -0000 1.2
***************
*** 34,50 ****
*/
! /* $Id$ */
/* BMF plugin data */
! #define PLUGIN_NAME "OLSRD Basic Multicast Forwarding plugin"
! #define PLUGIN_VERSION "1.0.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
/* UDP-Port on which multicast packets are encapsulated */
! #define BMF_ENCAP_PORT 50505
! int InitBmf(void);
void CloseBmf(void);
int RegisterBmfParameter(char* key, char* value);
--- 34,60 ----
*/
! /* -------------------------------------------------------------------------
! * File : Bmf.h
! * Description: Multicast forwarding functions
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
/* BMF plugin data */
! #define PLUGIN_NAME "OLSRD Basic Multicast Forwarding (BMF) plugin"
! #define PLUGIN_NAME_SHORT "OLSRD BMF"
! #define PLUGIN_VERSION "1.3 (" __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 */
! #define BMF_ENCAP_PORT 50698
! struct interface;
!
! int InterfaceChange(struct interface* interf, int action);
! int InitBmf(struct interface* skipThisIntf);
void CloseBmf(void);
int RegisterBmfParameter(char* key, char* value);
Index: PacketHistory.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/PacketHistory.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PacketHistory.c 3 May 2006 08:59:04 -0000 1.1
--- PacketHistory.c 10 Feb 2007 17:05:56 -0000 1.2
***************
*** 31,35 ****
*/
! /* $Id$ */
#include "PacketHistory.h"
--- 31,42 ----
*/
! /* -------------------------------------------------------------------------
! * File : PacketHistory.c
! * Description: Functions for keeping and accessing the history of processed
! * multicast IP packets.
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
#include "PacketHistory.h"
***************
*** 37,42 ****
/* System includes */
#include <assert.h> /* assert() */
- #include <sys/types.h> /* u_int16_t, u_int32_t */
#include <string.h> /* memset */
/* OLSRD includes */
--- 44,50 ----
/* System includes */
#include <assert.h> /* assert() */
#include <string.h> /* memset */
+ #include <sys/types.h> /* u_int16_t, u_int32_t */
+ #include <netinet/ip.h> /* struct iphdr */
/* OLSRD includes */
***************
*** 48,53 ****
static u_int32_t PacketHistory[HISTORY_TABLE_SIZE];
! /* Calculate 16-bits CRC according to CRC-CCITT specification, modified
! * to leave out some parts of the packet. */
static u_int16_t CalcCrcCcitt(unsigned char* buffer, ssize_t len)
{
--- 56,71 ----
static u_int32_t PacketHistory[HISTORY_TABLE_SIZE];
! #define CRC_UPTO_NBYTES 256
!
! #if 0
! /* -------------------------------------------------------------------------
! * Function : CalcCrcCcitt
! * Description: Calculate 16-bits CRC according to CRC-CCITT specification
! * Input : buffer - the bytes to calculate the CRC value over
! * len - the number of bytes to calculate the CRC value over
! * Output : none
! * Return : CRC-16 value
! * Data Used : none
! * ------------------------------------------------------------------------- */
static u_int16_t CalcCrcCcitt(unsigned char* buffer, ssize_t len)
{
***************
*** 61,68 ****
for (i = 0; i < len; i++)
{
- /* Skip IP header checksum; we want to avoid as much as possible
- * calculating a checksum over data containing a checksum */
- if (i >= 12 && i < 14) continue;
-
crc = (unsigned char)(crc >> 8) | (crc << 8);
crc ^= buffer[i];
--- 79,82 ----
***************
*** 72,118 ****
}
return crc;
!
! #if 0
! /* Alternative, simpler and perhaps just as good: add source IP address,
! * destination IP address and IP identification, in 16-bit */
! return
! ((buffer[0x0E] << 8) + buffer[0x0F]) + ((buffer[0x10] << 8) + buffer[0x11]) +
! ((buffer[0x12] << 8) + buffer[0x13]) + ((buffer[0x14] << 8) + buffer[0x15]) +
! ((buffer[0x06] << 8) + buffer[0x07]);
#endif
}
void InitPacketHistory()
{
memset(PacketHistory, 0, sizeof(PacketHistory));
}
! /* Record the fact that this packet was seen recently */
! void MarkRecentPacket(unsigned char* buffer, ssize_t len)
{
- u_int16_t crc;
u_int32_t index;
uint offset;
! assert(buffer != NULL);
!
! /* Start CRC calculation at ethertype; skip source and destination MAC
! * addresses */
! crc = CalcCrcCcitt(buffer + ETH_TYPE_OFFSET, len - ETH_TYPE_OFFSET);
!
! index = crc / NPACKETS_PER_ENTRY;
assert(index < HISTORY_TABLE_SIZE);
! offset = (crc % NPACKETS_PER_ENTRY) * NBITS_PER_PACKET;
assert(offset <= NBITS_IN_UINT32 - NBITS_PER_PACKET);
! /* Mark "seen recently" */
PacketHistory[index] = PacketHistory[index] | (0x3u << offset);
}
! /* Check if this packet was seen recently */
! int CheckMarkRecentPacket(unsigned char* buffer, ssize_t len)
{
- u_int16_t crc;
u_int32_t index;
uint offset;
--- 86,253 ----
}
return crc;
! }
#endif
+
+ /* -------------------------------------------------------------------------
+ * Function : GenerateCrc32Table
+ * Description: Generate the table of CRC remainders for all possible bytes,
+ * according to CRC-32-IEEE 802.3
+ * Input : none
+ * Output : none
+ * Return : none
+ * Data Used : none
+ * ------------------------------------------------------------------------- */
+ #define CRC32_POLYNOMIAL 0xedb88320UL /* bit-inverse of 0x04c11db7UL */
+
+ static unsigned long CrcTable[256];
+
+ static void GenerateCrc32Table(void)
+ {
+ int i, j;
+ u_int32_t crc;
+ for (i = 0; i < 256; i++)
+ {
+ crc = (u_int32_t) i;
+ for (j = 0; j < 8; j++)
+ {
+ if (crc & 1)
+ {
+ crc = (crc >> 1) ^ CRC32_POLYNOMIAL;
+ }
+ else
+ {
+ crc = (crc >> 1);
+ }
+ }
+ CrcTable[i] = crc;
+ }
+ }
+
+ /* -------------------------------------------------------------------------
+ * Function : CalcCrc32
+ * Description: Calculate CRC-32 according to CRC-32-IEEE 802.3
+ * Input : buffer - the bytes to calculate the CRC value over
+ * len - the number of bytes to calculate the CRC value over
+ * Output : none
+ * Return : CRC-32 value
+ * Data Used : none
+ * ------------------------------------------------------------------------- */
+ static u_int32_t CalcCrc32(unsigned char* buffer, ssize_t len)
+ {
+ int i, j;
+ u_int32_t crc = 0xffffffffUL;
+ for (i = 0; i < len; i++)
+ {
+ j = ((int) (crc & 0xFF) ^ *buffer++);
+ crc = (crc >> 8) ^ CrcTable[j];
+ }
+ return crc ^ 0xffffffffUL;
}
+ /* -------------------------------------------------------------------------
+ * Function : PacketCrc32
+ * Description: Calculates the CRC-32 value for an Ethernet packet
+ * Input : ethPkt - the Ethernet packet
+ * len - the number of octets in the Ethernet packet
+ * Output : none
+ * Return : 32-bits hash value
+ * Data Used : none
+ * Notes : The source and destination MAC address are not taken into account
+ * in the CRC calculation.
+ * ------------------------------------------------------------------------- */
+ u_int32_t PacketCrc32(unsigned char* ethPkt, ssize_t len)
+ {
+ ssize_t nCrcBytes;
+ struct TSaveTtl sttl;
+ struct iphdr* iph;
+ u_int32_t result;
+
+ assert(ethPkt != NULL);
+
+ /* Start CRC calculation at ethertype; skip source and destination MAC
+ * addresses, and ethertype.
+ *
+ * Also skip TTL: in a multi-homed OLSR-network, the same multicast packet
+ * may enter the network multiple times, each copy differing only in its
+ * TTL value. BMF must not calculate a different CRC for packets that
+ * differ only in TTL. Skip also the IP-header checksum, because it changes
+ * along with TTL. Besides, it is not a good idea to calculate a CRC over
+ * data that already contains a checksum.
+ *
+ * Clip number of bytes over which CRC is calculated to prevent
+ * long packets from possibly claiming too much CPU resources. */
+ nCrcBytes = len - IP_HDR_OFFSET;
+ assert(nCrcBytes > 0);
+ if (nCrcBytes > CRC_UPTO_NBYTES)
+ {
+ nCrcBytes = CRC_UPTO_NBYTES;
+ }
+
+ SaveTtlAndChecksum(ethPkt, &sttl);
+
+ iph = (struct iphdr*) (ethPkt + IP_HDR_OFFSET);
+ iph->ttl = 0xFF; /* fixed value of TTL for CRC-32 calculation */
+ iph->check = 0x5A5A; /* fixed value of IP header checksum for CRC-32 calculation */
+
+ result = CalcCrc32(ethPkt + IP_HDR_OFFSET, nCrcBytes);
+
+ RestoreTtlAndChecksum(ethPkt, &sttl);
+ return result;
+ }
+
+ /* Calculates a 16-bit hash value from a 32-bit hash value */
+ u_int16_t Hash16(u_int32_t hash32)
+ {
+ return ((hash32 >> 16) + hash32) & 0xFFFFU;
+ }
+
+ /* -------------------------------------------------------------------------
+ * Function : InitPacketHistory
+ * Description: Initialize the packet history table and CRC-32 table
+ * Input : none
+ * Output : none
+ * Return : none
+ * Data Used : PacketHistory
+ * ------------------------------------------------------------------------- */
void InitPacketHistory()
{
memset(PacketHistory, 0, sizeof(PacketHistory));
+ GenerateCrc32Table();
}
! /* -------------------------------------------------------------------------
! * Function : MarkRecentPacket
! * Description: Record the fact that this packet was seen recently
! * Input : hash16
! * Output : none
! * Return : none
! * Data Used : PacketHistory
! * ------------------------------------------------------------------------- */
! void MarkRecentPacket(u_int16_t hash16)
{
u_int32_t index;
uint offset;
! index = hash16 / NPACKETS_PER_ENTRY;
assert(index < HISTORY_TABLE_SIZE);
! offset = (hash16 % NPACKETS_PER_ENTRY) * NBITS_PER_PACKET;
assert(offset <= NBITS_IN_UINT32 - NBITS_PER_PACKET);
! /* Mark as "seen recently" */
PacketHistory[index] = PacketHistory[index] | (0x3u << offset);
}
! /* -------------------------------------------------------------------------
! * Function : CheckAndMarkRecentPacket
! * Description: Check if this packet was seen recently, then record the fact
! * that this packet was seen recently.
! * Input : hash16
! * Output : none
! * Return : not recently seen (0), recently seen (1)
! * Data Used : PacketHistory
! * ------------------------------------------------------------------------- */
! int CheckAndMarkRecentPacket(u_int16_t hash16)
{
u_int32_t index;
uint offset;
***************
*** 120,133 ****
int result;
! assert(buffer != NULL);
!
! /* Start CRC calculation at ethertype; skip source and destination MAC
! * addresses */
! crc = CalcCrcCcitt(buffer + ETH_TYPE_OFFSET, len - ETH_TYPE_OFFSET);
!
! index = crc / NPACKETS_PER_ENTRY;
assert(index < HISTORY_TABLE_SIZE);
! offset = (crc % NPACKETS_PER_ENTRY) * NBITS_PER_PACKET;
assert(offset <= NBITS_IN_UINT32 - NBITS_PER_PACKET);
--- 255,262 ----
int result;
! index = hash16 / NPACKETS_PER_ENTRY;
assert(index < HISTORY_TABLE_SIZE);
! offset = (hash16 % NPACKETS_PER_ENTRY) * NBITS_PER_PACKET;
assert(offset <= NBITS_IN_UINT32 - NBITS_PER_PACKET);
***************
*** 135,139 ****
result = ((PacketHistory[index] & bitMask) == bitMask);
! /* Always mark "seen recently" */
PacketHistory[index] = PacketHistory[index] | (0x3u << offset);
--- 264,268 ----
result = ((PacketHistory[index] & bitMask) == bitMask);
! /* Always mark as "seen recently" */
PacketHistory[index] = PacketHistory[index] | (0x3u << offset);
***************
*** 141,144 ****
--- 270,281 ----
}
+ /* -------------------------------------------------------------------------
+ * Function : PrunePacketHistory
+ * Description: Prune the packet history table.
+ * Input : useless - not used
+ * Output : none
+ * Return : none
+ * Data Used : PacketHistory
+ * ------------------------------------------------------------------------- */
void PrunePacketHistory(void* useless)
{
Index: NetworkInterfaces.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/NetworkInterfaces.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NetworkInterfaces.h 3 May 2006 08:59:04 -0000 1.1
--- NetworkInterfaces.h 10 Feb 2007 17:05:56 -0000 1.2
***************
*** 34,42 ****
*/
! /* $Id$ */
/* Plugin includes */
#include "Packet.h" /* IFHWADDRLEN */
struct TBmfInterface
{
--- 34,54 ----
*/
! /* -------------------------------------------------------------------------
! * File : NetworkInterfaces.h
! * Description: Functions to open and close sockets
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
!
! /* System includes */
! #include <netinet/in.h> /* struct in_addr */
/* Plugin includes */
#include "Packet.h" /* IFHWADDRLEN */
+ /* Size of buffer in which packets are received */
+ #define BMF_BUFFER_SIZE 2048
+
struct TBmfInterface
{
***************
*** 45,49 ****
/* File descriptor of UDP (datagram) socket for encapsulated multicast packets.
! * Set to -1 if interface is not OLSR-enabled. */
int encapsulatingSkfd;
--- 57,61 ----
/* File descriptor of UDP (datagram) socket for encapsulated multicast packets.
! * Only used for OLSR-enabled interfaces; set to -1 if interface is not OLSR-enabled. */
int encapsulatingSkfd;
***************
*** 56,62 ****
struct interface* olsrIntf;
! /* Kernels index of this network interface */
! int ifIndex;
!
/* Next element in list */
struct TBmfInterface* next;
--- 68,88 ----
struct interface* olsrIntf;
! /* IP address of this network interface */
! struct sockaddr intAddr;
!
! /* Broadcast address of this network interface */
! struct sockaddr broadAddr;
!
! #define FRAGMENT_HISTORY_SIZE 10
! struct TFragmentHistory
! {
! u_int16_t ipId;
! u_int8_t ipProto;
! struct in_addr ipSrc;
! struct in_addr ipDst;
! } fragmentHistory [FRAGMENT_HISTORY_SIZE];
!
! int nextFragmentHistoryEntry;
!
/* Next element in list */
struct TBmfInterface* next;
***************
*** 65,79 ****
extern struct TBmfInterface* BmfInterfaces;
extern int EtherTunTapFd;
! extern const char* EtherTunTapIfName;
enum TTunOrTap { TT_TUN = 0, TT_TAP };
extern enum TTunOrTap TunOrTap;
! int CreateBmfNetworkInterfaces(void);
void CloseBmfNetworkInterfaces(void);
int AddNonOlsrBmfIf(const char* ifName);
int IsNonOlsrBmfIf(const char* ifName);
#endif /* _BMF_NETWORKINTERFACES_H */
--- 91,120 ----
extern struct TBmfInterface* BmfInterfaces;
+ extern int HighestSkfd;
+ extern fd_set InputSet;
+
extern int EtherTunTapFd;
! extern char EtherTunTapIfName[];
!
! extern u_int32_t EtherTunTapIp;
! extern u_int32_t EtherTunTapIpMask;
! extern u_int32_t EtherTunTapIpBroadcast;
!
! extern int CapturePacketsOnOlsrInterfaces;
enum TTunOrTap { TT_TUN = 0, TT_TAP };
extern enum TTunOrTap TunOrTap;
! int SetBmfInterfaceName(const char* ifname);
! int SetBmfInterfaceType(const char* iftype);
! int SetBmfInterfaceIp(const char* ip);
! int SetCapturePacketsOnOlsrInterfaces(const char* enable);
! int CreateBmfNetworkInterfaces(struct interface* skipThisIntf);
! void AddInterface(struct interface* newIntf);
void CloseBmfNetworkInterfaces(void);
int AddNonOlsrBmfIf(const char* ifName);
int IsNonOlsrBmfIf(const char* ifName);
+ void CheckAndUpdateLocalBroadcast(unsigned char* buffer, struct sockaddr* broadAddr);
#endif /* _BMF_NETWORKINTERFACES_H */
Index: Bmf.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/Bmf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Bmf.c 3 May 2006 08:59:04 -0000 1.1
--- Bmf.c 10 Feb 2007 17:05:55 -0000 1.2
***************
*** 31,35 ****
*/
! /* $Id$ */
#define _MULTI_THREADED
--- 31,41 ----
*/
! /* -------------------------------------------------------------------------
! * File : Bmf.c
[...1837 lines suppressed...]
+ else if (strcmp(key, "BmfInterface") == 0)
+ {
+ return SetBmfInterfaceName(value);
+ }
+ else if (strcmp(key, "BmfInterfaceType") == 0)
+ {
+ return SetBmfInterfaceType(value);
+ }
+ else if (strcmp(key, "BmfInterfaceIp") == 0)
+ {
+ return SetBmfInterfaceIp(value);
+ }
+ else if (strcmp(key, "CapturePacketsOnOlsrInterfaces") == 0)
+ {
+ return SetCapturePacketsOnOlsrInterfaces(value);
+ }
+ /* Key not recognized */
return 0;
}
Index: NetworkInterfaces.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/NetworkInterfaces.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NetworkInterfaces.c 3 May 2006 08:59:04 -0000 1.1
--- NetworkInterfaces.c 10 Feb 2007 17:05:56 -0000 1.2
***************
*** 31,35 ****
*/
! /* $Id$ */
#include "NetworkInterfaces.h"
--- 31,41 ----
*/
! /* -------------------------------------------------------------------------
! * File : NetworkInterfaces.c
[...1628 lines suppressed...]
+ /* Re-calculate UDP/IP checksum for new destination */
+
+ int ipHeaderLen = GetIpHeaderLength(buffer);
+ struct udphdr* udph = (struct udphdr*) (buffer + IP_HDR_OFFSET + ipHeaderLen);
+
+ /* RFC 1624, Eq. 3: HC' = ~(~HC - m + m') */
+
+ check = ntohs(udph->check);
+
+ check = ~ (~ check - ((origDaddr >> 16) & 0xFFFF) + ((newDaddr >> 16) & 0xFFFF));
+ check = ~ (~ check - (origDaddr & 0xFFFF) + (newDaddr & 0xFFFF));
+
+ /* Add carry */
+ check = check + (check >> 16);
+
+ udph->check = htons(check);
+ }
+ }
+ }
+
Index: PacketHistory.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/bmf/src/PacketHistory.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PacketHistory.h 3 May 2006 08:59:04 -0000 1.1
--- PacketHistory.h 10 Feb 2007 17:05:56 -0000 1.2
***************
*** 34,42 ****
*/
! /* $Id$ */
#include <sys/types.h> /* ssize_t */
! /* 2 bits per seen packet fingerping:
* 11 = "seen recently",
* 01 = "timing out"
--- 34,49 ----
*/
! /* -------------------------------------------------------------------------
! * File : PacketHistory.h
! * Description: Functions for keeping and accessing the history of processed
! * multicast IP packets.
! * Created : 29 Jun 2006
! *
! * $Id$
! * ------------------------------------------------------------------------- */
#include <sys/types.h> /* ssize_t */
! /* 2 bits per seen packet:
* 11 = "seen recently",
* 01 = "timing out"
***************
*** 50,55 ****
void InitPacketHistory(void);
! void MarkRecentPacket(unsigned char* buffer, ssize_t len);
! int CheckMarkRecentPacket(unsigned char* buffer, ssize_t len);
void PrunePacketHistory(void*);
--- 57,64 ----
void InitPacketHistory(void);
! u_int32_t PacketCrc32(unsigned char* ethPkt, ssize_t len);
! u_int16_t Hash16(u_int32_t hash32);
! void MarkRecentPacket(u_int16_t hash16);
! int CheckAndMarkRecentPacket(u_int16_t hash16);
void PrunePacketHistory(void*);
More information about the Olsr-cvs
mailing list