- 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:
- /* TODO: try MAC as last resort? */
- if(debug_lvl >= DEBUG_TRAFFIC)
- {
- syslog(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
- }
- return NULL;
- }
+ 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->address.x[0],
+ address->address.x[1],
+ address->address.x[2],
+ address->address.x[3],
+ address->address.x[4],
+ address->address.x[5],
+ cl->name, cl->hostname);
+ }
+ }
+}
+
+connection_t *route_mac(connection_t *source, vpn_packet_t *packet)
+{
+ connection_t *oldsrc, *dst;
+ subnet_t *subnet;
+cp
+ /* Learn source address */
+
+ learn_mac(source, (mac_t *)(&packet->data[0]));
+
+ /* Lookup destination address */
+
+ dst = lookup_subnet_mac((mac_t *)(&packet->data[6]))->owner;
+
+ if(!dst)
+ 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 dst;