-#include "protocol.h"
-#include "device.h"
-
-#include "system.h"
-
-int routing_mode = RMODE_ROUTER;
-subnet_t mymac;
-
-void learn_mac(mac_t *address)
-{
- subnet_t *subnet;
- avl_node_t *node;
- connection_t *c;
-cp
- subnet = lookup_subnet_mac(address);
-
- /* If we don't know this MAC address yet, store it */
-
- if(!subnet || subnet->owner!=myself)
- {
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_INFO, _("Learned new MAC address %hx:%hx:%hx:%hx:%hx:%hx"),
- address->x[0], address->x[1], address->x[2], address->x[3], address->x[4], address->x[5]);
-
- subnet = new_subnet();
- subnet->type = SUBNET_MAC;
- memcpy(&subnet->net.mac.address, address, sizeof(mac_t));
- subnet_add(myself, subnet);
-
- /* And tell all other tinc daemons it's our MAC */
-
- for(node = connection_tree->head; node; node = node->next)
- {
- c = (connection_t *)node->data;
- if(c->status.active)
- send_add_subnet(c, subnet);
- }
- }
-}
-
-node_t *route_mac(vpn_packet_t *packet)
-{
- subnet_t *subnet;
-cp
- /* Learn source address */
-
- learn_mac((mac_t *)(&packet->data[6]));
-
- /* Lookup destination address */
-
- subnet = lookup_subnet_mac((mac_t *)(&packet->data[0]));
-
- if(subnet)
- return subnet->owner;
- else
- return NULL;
-}