- if(packet->len < ether_size) {
- ifdebug(TRAFFIC) logger(LOG_WARNING, _("Read too short packet"));
- return;
- }
-
- /* FIXME: multicast? */
-
- switch (routing_mode) {
- case RMODE_ROUTER:
- type = ntohs(*((uint16_t *)(&packet->data[12])));
- switch (type) {
- case ETH_P_IP:
- if(packet->len < ether_size + ip_size) {
- ifdebug(TRAFFIC) logger(LOG_WARNING, _("Read too short packet"));
- return;
- }
-
- n = route_ipv4(packet);
- break;
-
- case ETH_P_IPV6:
- if(packet->len < ether_size + ip6_size) {
- ifdebug(TRAFFIC) logger(LOG_WARNING, _("Read too short packet"));
- return;
- }
-
- if(packet->data[20] == IPPROTO_ICMPV6 && packet->len >= ether_size + ip6_size + ns_size && packet->data[54] == ND_NEIGHBOR_SOLICIT) {
- route_neighborsol(packet);
- return;
- }
- n = route_ipv6(packet);
- break;
-
- case ETH_P_ARP:
- if(packet->len < ether_size + arp_size) {
- ifdebug(TRAFFIC) logger(LOG_WARNING, _("Read too short packet"));
- return;
- }
-
- route_arp(packet);
- return;
-
- default:
- ifdebug(TRAFFIC) logger(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
- return;
- }
- if(n)
- send_packet(n, packet);
- break;
-
- case RMODE_SWITCH:
- n = route_mac(packet);
- if(n)
- send_packet(n, packet);
- else
- broadcast_packet(myself, packet);
- break;
-
- case RMODE_HUB:
- broadcast_packet(myself, packet);
- break;
- }
-}
-
-void route_incoming(node_t *source, vpn_packet_t *packet)
-{
- if(packet->len < ether_size) {
- ifdebug(TRAFFIC) logger(LOG_WARNING, _("Read too short packet"));