blob: d9d650dc21633269a04a5ee4baabf75ab3aaa2fd [file] [log] [blame]
Paul Jakma57345092011-12-25 17:52:09 +01001/*
2 * This file is free software: you may copy, redistribute and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation, either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * This file is distributed in the hope that it will be useful, but
8 * WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *
15 * This file incorporates work covered by the following copyright and
16 * permission notice:
17 *
18Copyright (c) 2007, 2008 by Juliusz Chroboczek
19
20Permission is hereby granted, free of charge, to any person obtaining a copy
21of this software and associated documentation files (the "Software"), to deal
22in the Software without restriction, including without limitation the rights
23to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24copies of the Software, and to permit persons to whom the Software is
25furnished to do so, subject to the following conditions:
26
27The above copyright notice and this permission notice shall be included in
28all copies or substantial portions of the Software.
29
30THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36THE SOFTWARE.
37*/
38
39#include <netinet/in.h>
40#include "babel_main.h"
41#include "if.h"
42
43#define KERNEL_INFINITY 0xFFFF
44
45struct kernel_route {
46 unsigned char prefix[16];
47 int plen;
48 int metric;
49 unsigned int ifindex;
50 int proto;
51 unsigned char gw[16];
52};
53
54#define ROUTE_FLUSH 0
55#define ROUTE_ADD 1
56#define ROUTE_MODIFY 2
57
58#define CHANGE_LINK (1 << 0)
59#define CHANGE_ROUTE (1 << 1)
60#define CHANGE_ADDR (1 << 2)
61
62extern int export_table, import_table;
63
64int kernel_setup(int setup);
65int kernel_setup_socket(int setup);
66int kernel_setup_interface(int setup, struct interface *interface);
67int kernel_interface_operational(struct interface *interface);
68int kernel_interface_ipv4(struct interface *interface,
69 unsigned char *addr_r);
70int kernel_interface_mtu(struct interface *interface);
71int kernel_interface_wireless(struct interface *interface);
72int kernel_route(int operation, const unsigned char *dest, unsigned short plen,
73 const unsigned char *gate, int ifindex, unsigned int metric,
74 const unsigned char *newgate, int newifindex,
75 unsigned int newmetric);
76int kernel_routes(struct kernel_route *routes, int maxroutes);
77int kernel_callback(int (*fn)(int, void*), void *closure);
78int kernel_addresses(struct interface *interface, int ll,
79 struct kernel_route *routes, int maxroutes);
80int if_eui64(char *ifname, int ifindex, unsigned char *eui);
81int gettime(struct timeval *tv);
82int read_random_bytes(void *buf, size_t len);