#include "system.h"
-#include "avl_tree.h"
+#include "splay_tree.h"
#include "connection.h"
#include "ethernet.h"
#include "ipv4.h"
static bool ratelimit(int frequency) {
static time_t lasttime = 0;
static int count = 0;
+ time_t now = time(NULL);
if(lasttime == now) {
if(++count > frequency)
{
subnet_t *s;
connection_t *c;
- avl_node_t *node, *next, *node2;
+ splay_node_t *node, *next, *node2;
bool left = false;
+ time_t now = time(NULL);
cp();
static void learn_mac(mac_t *address)
{
subnet_t *subnet;
- avl_node_t *node;
+ splay_node_t *node;
connection_t *c;
cp();
subnet = new_subnet();
subnet->type = SUBNET_MAC;
- subnet->expires = now + macexpire;
+ subnet->expires = time(NULL) + macexpire;
subnet->net.mac.address = *address;
subnet_add(myself, subnet);
if(!timeout_initialized(&age_subnets_event))
timeout_set(&age_subnets_event, age_subnets, NULL);
event_add(&age_subnets_event, &(struct timeval){10, 0});
+ } else {
+ if(subnet->expires)
+ subnet->expires = time(NULL) + macexpire;
}
-
- if(subnet->expires)
- subnet->expires = now + macexpire;
}
static void route_mac(node_t *source, vpn_packet_t *packet)