3 Copyright (C) 2000 Ivo Timmermans <itimmermans@bigfoot.com>,
4 2000 Guus Sliepen <guus@sliepen.warande.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 $Id: route.c,v 1.1.2.1 2000/10/23 13:52:54 guus Exp $
33 int routing_mode = 0; /* Will be used to determine if we route by MAC or by payload's protocol */
35 conn_list_t *route_packet(vpn_packet_t *packet)
39 type = ntohs(*((unsigned short*)(&packet.data[12])))
44 return route_ipv4(packet);
46 return route_ipv6(packet);
49 return route_ipx(packet);
51 return route_arp(packet);
54 /* TODO: try MAC as last resort? */
55 if(debug_lvl >= DEBUG_TRAFFIC)
57 syslog(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
63 conn_list_t *route_ipv4(vpn_packet_t *packet)
68 dest = ntohl(*((unsigned long*)(&packet.data[30]);
70 cl = lookup_conn_list_ipv4(dest);
72 if(debug_lvl >= DEBUG_TRAFFIC)
74 syslog(LOG_WARNING, _("Cannot route packet: unknown destination address %d.%d.%d.%d"),
75 packet.data[30], packet.data[31], packet.data[32], packet.data[33]);
82 conn_list_t *route_ipv6(vpn_packet_t *packet)
85 syslog(LOG_WARNING, _("Cannot route packet: IPv6 routing not implemented yet"));