-#include "system.h"
-
-int routing_mode = RMODE_ROUTER;
-subnet_t mymac;
-
-void learn_mac(connection_t *source, mac_t *address)
-{
- subnet_t *subnet;
-cp
- subnet = lookup_subnet_mac(address);
-
- if(!subnet)
- {
- subnet = new_subnet();
- subnet->type = SUBNET_MAC;
-// subnet->lasttime = gettimeofday();
- memcpy(&subnet->net.mac.address, address, sizeof(mac_t));
- subnet_add(source, subnet);
-
- if(debug_lvl >= DEBUG_TRAFFIC)
- {
- syslog(LOG_DEBUG, _("Learned new MAC address %x:%x:%x:%x:%x:%x from %s (%s)"),
- address->x[0],
- address->x[1],
- address->x[2],
- address->x[3],
- address->x[4],
- address->x[5],
- source->name, source->hostname);
- }
- }
-}
-
-connection_t *route_mac(connection_t *source, vpn_packet_t *packet)
-{
- subnet_t *subnet;
-cp
- /* Learn source address */
-
- learn_mac(source, (mac_t *)(&packet->data[0]));
-
- /* Lookup destination address */
-
- subnet = lookup_subnet_mac((mac_t *)(&packet->data[6]));
-
- if(!subnet)
- {
- 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]);
- }
- return NULL;
- }
-cp
- return subnet->owner;
-}
-
-connection_t *route_ipv4(vpn_packet_t *packet)
-{
- ipv4_t dest;
- subnet_t *subnet;
-cp
- dest = ntohl(*((unsigned long*)(&packet->data[30])));
-
- subnet = lookup_subnet_ipv4(&dest);
-
- if(!subnet)
- {
- if(debug_lvl >= DEBUG_TRAFFIC)
- {
- syslog(LOG_WARNING, _("Cannot route packet: unknown destination address %d.%d.%d.%d"),
- packet->data[30], packet->data[31], packet->data[32], packet->data[33]);
- }
-
- return NULL;
- }
-cp
- return subnet->owner;
-}
-
-connection_t *route_ipv6(vpn_packet_t *packet)
-{
-cp
- if(debug_lvl > DEBUG_NOTHING)
- {
- syslog(LOG_WARNING, _("Cannot route packet: IPv6 routing not yet implemented"));
- }
-cp
- return NULL;
-}
-
-void route_outgoing(vpn_packet_t *packet)
-{
- unsigned short int type;
- avl_node_t *node;
- connection_t *cl;
-cp
- /* FIXME: multicast? */