-
-#include "system.h"
-
-int routing_mode = RMODE_ROUTER; /* Will be used to determine if we route by MAC or by payload's protocol */
-
-connection_t *route_mac(connection_t *source, vpn_packet_t *packet)
-{
- connection_t *oldsrc, *dst;
- subnet_t *subnet;
-cp
- /* Learn source address */
-
- oldsrc = lookup_subnet_mac((mac_t *)(&packet->data[0]))->owner;
-
- if(!oldsrc)
- {
- subnet = new_subnet();
- subnet->type = SUBNET_MAC;
- memcpy(&subnet->net.mac.address, (mac_t *)(&packet->data[0]), sizeof(mac_t));
- subnet_add(source, subnet);
- }
-
- /* FIXME: do ageing and roaming */
-
- /* Lookup destination address */
-
- dst = lookup_subnet_mac((mac_t *)(&packet->data[6]))->owner;
-
- if(!dst)
- if(debug_lvl >= DEBUG_TRAFFIC)
- {
- syslog(LOG_WARNING, _("Cannot route packet: unknown destination address %x:%x:%x:%x:%x:%x"),
- packet->data[6],
- packet->data[7],
- packet->data[8],
- packet->data[9],
- packet->data[10],
- packet->data[11]);
- }
-cp
- return dst;
+#include "utils.h"
+
+rmode_t routing_mode = RMODE_ROUTER;
+fmode_t forwarding_mode = FMODE_INTERNAL;
+bmode_t broadcast_mode = BMODE_MST;
+bool decrement_ttl = false;
+bool directonly = false;
+bool priorityinheritance = false;
+int macexpire = 600;
+bool overwrite_mac = false;
+mac_t mymac = {{0xFE, 0xFD, 0, 0, 0, 0}};
+bool pcap = false;
+
+static bool ratelimit(int frequency) {
+ static time_t lasttime = 0;
+ static int count = 0;
+
+ if(lasttime == now.tv_sec) {
+ if(count >= frequency)
+ return true;
+ } else {
+ lasttime = now.tv_sec;
+ count = 0;
+ }
+
+ count++;
+ return false;