Merge branch 'master' into 1.1
authorGuus Sliepen <guus@tinc-vpn.org>
Fri, 11 Dec 2009 21:31:27 +0000 (22:31 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Fri, 11 Dec 2009 21:31:27 +0000 (22:31 +0100)
Conflicts:
src/subnet.c

1  2 
src/graph.c
src/route.c
src/subnet.c
src/subnet.h

diff --cc src/graph.c
Simple merge
diff --cc src/route.c
@@@ -102,46 -99,12 +102,46 @@@ static void swap_mac_addresses(vpn_pack
        memcpy(&packet->data[6], &tmp, sizeof tmp);
  }
        
 +static void age_subnets(int fd, short events, void *data) {
 +      subnet_t *s;
 +      connection_t *c;
 +      splay_node_t *node, *next, *node2;
 +      bool left = false;
 +      time_t now = time(NULL);
 +
 +      for(node = myself->subnet_tree->head; node; node = next) {
 +              next = node->next;
 +              s = node->data;
 +              if(s->expires && s->expires < now) {
 +                      ifdebug(TRAFFIC) {
 +                              char netstr[MAXNETSTR];
 +                              if(net2str(netstr, sizeof netstr, s))
 +                                      logger(LOG_INFO, "Subnet %s expired", netstr);
 +                      }
 +
 +                      for(node2 = connection_tree->head; node2; node2 = node2->next) {
 +                              c = node2->data;
 +                              if(c->status.active)
 +                                      send_del_subnet(c, s);
 +                      }
 +
 +                      subnet_del(myself, s);
 +              } else {
 +                      if(s->expires)
 +                              left = true;
 +              }
 +      }
 +
 +      if(left)
 +              event_add(&age_subnets_event, &(struct timeval){10, 0});
 +}
 +
  static void learn_mac(mac_t *address) {
        subnet_t *subnet;
 -      avl_node_t *node;
 +      splay_node_t *node;
        connection_t *c;
  
-       subnet = lookup_subnet_mac(address);
+       subnet = lookup_subnet_mac(myself, address);
  
        /* If we don't know this MAC address yet, store it */
  
diff --cc src/subnet.c
@@@ -327,12 -326,12 +327,12 @@@ bool net2str(char *netstr, int len, con
  /* Subnet lookup routines */
  
  subnet_t *lookup_subnet(const node_t *owner, const subnet_t *subnet) {
 -      return avl_search(owner->subnet_tree, subnet);
 +      return splay_search(owner->subnet_tree, subnet);
  }
  
- subnet_t *lookup_subnet_mac(const mac_t *address) {
-       subnet_t *p, *r = NULL, subnet = {0};
+ subnet_t *lookup_subnet_mac(const node_t *owner, const mac_t *address) {
+       subnet_t *p, *r = NULL;
 -      avl_node_t *n;
 +      splay_node_t *n;
        int i;
  
        // Check if this address is cached
  }
  
  subnet_t *lookup_subnet_ipv4(const ipv4_t *address) {
-       subnet_t *p, *r = NULL, subnet = {0};
+       subnet_t *p, *r = NULL;
 -      avl_node_t *n;
 +      splay_node_t *n;
        int i;
  
        // Check if this address is cached
  }
  
  subnet_t *lookup_subnet_ipv6(const ipv6_t *address) {
-       subnet_t *p, *r = NULL, subnet = {0};
+       subnet_t *p, *r = NULL;
 -      avl_node_t *n;
 +      splay_node_t *n;
        int i;
  
        // Check if this address is cached
diff --cc src/subnet.h
@@@ -77,10 -77,10 +77,10 @@@ extern void subnet_update(struct node_
  extern bool net2str(char *, int, const subnet_t *);
  extern bool str2net(subnet_t *, const char *);
  extern subnet_t *lookup_subnet(const struct node_t *, const subnet_t *);
- extern subnet_t *lookup_subnet_mac(const mac_t *);
+ extern subnet_t *lookup_subnet_mac(const struct node_t *, const mac_t *);
  extern subnet_t *lookup_subnet_ipv4(const ipv4_t *);
  extern subnet_t *lookup_subnet_ipv6(const ipv6_t *);
 -extern void dump_subnets(void);
 +extern bool dump_subnets(struct connection_t *);
  extern void subnet_cache_flush(void);
  
  #endif                                                        /* __TINC_SUBNET_H__ */