+ /* FIXME: multicast? */
+
+ switch(routing_mode)
+ {
+ case RMODE_ROUTER:
+ type = ntohs(*((unsigned short*)(&packet->data[12])));
+ switch(type)
+ {
+ case 0x0800:
+ cl = route_ipv4(packet);
+ break;
+ case 0x86DD:
+ cl = route_ipv6(packet);
+ break;
+ default:
+ if(debug_lvl >= DEBUG_TRAFFIC)
+ {
+ syslog(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
+ }
+ return;
+ }
+ if(cl)
+ send_packet(cl, packet);
+ break;
+
+ case RMODE_SWITCH:
+ cl = route_mac(myself, packet);
+ if(cl)
+ send_packet(cl, packet);
+ break;
+
+ case RMODE_HUB:
+ for(node = connection_tree->head; node; node = node->next)
+ {
+ cl = (connection_t *)node->data;
+ if(cl->status.active)
+ send_packet(cl, packet);
+ }
+ break;
+ }
+}
+
+void route_incoming(connection_t *source, vpn_packet_t *packet)
+{
+ switch(routing_mode)
+ {
+ case RMODE_ROUTER:
+ memcpy(packet->data, mymac.net.mac.address.x, 6);
+ break;
+ case RMODE_SWITCH:
+ learn_mac(source, (mac_t *)(&packet->data[0]));
+ break;
+ }
+
+ accept_packet(packet);