]> git.meshlink.io Git - meshlink/blob - src/route.c
fabb90ff54f9626ee1bd196a93b8edf3516f25ea
[meshlink] / src / route.c
1 /*
2     route.c -- routing
3     Copyright (C) 2000-2005 Ivo Timmermans,
4                   2000-2013 Guus Sliepen <guus@meshlink.io>
5
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.
10
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.
15
16     You should have received a copy of the GNU General Public License along
17     with this program; if not, write to the Free Software Foundation, Inc.,
18     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "system.h"
22
23 #include "logger.h"
24 #include "net.h"
25 #include "route.h"
26 #include "utils.h"
27
28 rmode_t routing_mode = RMODE_ROUTER;
29 fmode_t forwarding_mode = FMODE_INTERNAL;
30 bmode_t broadcast_mode = BMODE_MST;
31 bool decrement_ttl = false;
32 bool directonly = false;
33 bool priorityinheritance = false;
34 int macexpire = 600;
35 bool overwrite_mac = false;
36 mac_t mymac = {{0xFE, 0xFD, 0, 0, 0, 0}};
37 bool pcap = false;
38
39 static bool ratelimit(int frequency) {
40         static time_t lasttime = 0;
41         static int count = 0;
42
43         if(lasttime == now.tv_sec) {
44                 if(count >= frequency)
45                         return true;
46         } else {
47                 lasttime = now.tv_sec;
48                 count = 0;
49         }
50
51         count++;
52         return false;
53 }
54
55 static bool checklength(node_t *source, vpn_packet_t *packet, length_t length) {
56         if(packet->len < length) {
57                 logger(DEBUG_TRAFFIC, LOG_WARNING, "Got too short packet from %s (%s)", source->name, source->hostname);
58                 return false;
59         } else
60                 return true;
61 }
62
63 void route(node_t *source, vpn_packet_t *packet) {
64         // TODO: route on name or key
65 }