-int routing_mode = 0; /* Will be used to determine if we route by MAC or by payload's protocol */
-
-conn_list_t *route_packet(vpn_packet_t *packet)
-{
- unsigned short type;
-cp
- type = ntohs(*((unsigned short*)(&packet.data[12])))
-
- if(routing_mode)
- {
- return route_mac(packet);
- }
-
- switch(type)
- {
- case 0x0800:
- return route_ipv4(packet);
- case 0x86DD:
- return route_ipv6(packet);
-/*
- case 0x8137:
- return route_ipx(packet);
- case 0x0806:
- return route_arp(packet);
-*/
- default:
- if(debug_lvl >= DEBUG_TRAFFIC)
- {
- syslog(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
- }
- return NULL;
- }
-}
-
-conn_list_t *route_mac(vpn_packet_t *packet)
-{
- conn_list_t *cl;
-cp
- cl = lookup_subnet_mac((mac_t *)(&packet.data[6]));
- if(!cl)
- 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 cl;
+#include "logger.h"
+#include "net.h"
+#include "route.h"
+#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;