Commit | Line | Data |
---|---|---|
c215a4bc IJ |
1 | /* |
2 | * This file is part of secnet. | |
3 | * See README for full list of copyright holders. | |
4 | * | |
5 | * secnet is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version d of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * secnet is distributed in the hope that it will be useful, but | |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * version 3 along with secnet; if not, see | |
17 | * https://www.gnu.org/licenses/gpl.html. | |
18 | */ | |
19 | ||
9d3a4132 SE |
20 | #ifndef netlink_h |
21 | #define netlink_h | |
22 | ||
7138d0c5 SE |
23 | #include "ipaddr.h" |
24 | ||
9d3a4132 SE |
25 | #define DEFAULT_BUFSIZE 2048 |
26 | #define DEFAULT_MTU 1000 | |
27 | #define ICMP_BUFSIZE 1024 | |
28 | ||
469fd1d9 SE |
29 | struct netlink; |
30 | ||
9d3a4132 | 31 | struct netlink_client { |
469fd1d9 SE |
32 | closure_t cl; |
33 | struct netlink_if ops; | |
34 | struct netlink *nst; | |
794f2398 SE |
35 | struct ipset *networks; |
36 | struct subnet_list *subnets; /* Same information as 'networks' */ | |
d3fe100d SE |
37 | uint32_t priority; /* Higher priority clients have their networks |
38 | checked first during routing. This allows | |
39 | things like laptops to supersede whole | |
40 | networks. */ | |
9d3a4132 SE |
41 | netlink_deliver_fn *deliver; |
42 | void *dst; | |
43 | string_t name; | |
44 | uint32_t link_quality; | |
1caa23ff | 45 | int32_t mtu; |
3454dce4 | 46 | uint32_t options; |
469fd1d9 | 47 | uint32_t outcount; |
d3fe100d SE |
48 | bool_t up; /* Should these routes exist in the kernel? */ |
49 | bool_t kup; /* Do these routes exist in the kernel? */ | |
50 | struct netlink_client *next; | |
9d3a4132 SE |
51 | }; |
52 | ||
efacf9e0 ST |
53 | /* options field in 'struct netlink_client' */ |
54 | #define OPT_SOFTROUTE 1 | |
55 | #define OPT_ALLOWROUTE 2 | |
56 | ||
d3fe100d | 57 | typedef bool_t netlink_route_fn(void *cst, struct netlink_client *routes); |
9d3a4132 SE |
58 | |
59 | /* Netlink provides one function to the device driver, to call to deliver | |
60 | a packet from the device. The device driver provides one function to | |
61 | netlink, for it to call to deliver a packet to the device. */ | |
62 | ||
63 | struct netlink { | |
64 | closure_t cl; | |
9d3a4132 | 65 | void *dst; /* Pointer to host interface state */ |
fe5e9cc4 | 66 | cstring_t name; |
794f2398 | 67 | struct ipset *networks; /* Local networks */ |
d3fe100d | 68 | struct subnet_list *subnets; /* Same as networks, for display */ |
794f2398 | 69 | struct ipset *remote_networks; /* Allowable remote networks */ |
091433c6 | 70 | uint32_t local_address; /* host interface address */ |
469fd1d9 SE |
71 | uint32_t secnet_address; /* our own address, or the address of the |
72 | other end of a point-to-point link */ | |
c6f79b17 | 73 | bool_t ptp; |
1caa23ff | 74 | int32_t mtu; |
d3fe100d SE |
75 | struct netlink_client *clients; /* Linked list of clients */ |
76 | struct netlink_client **routes; /* Array of clients, sorted by priority */ | |
1caa23ff | 77 | int32_t n_clients; |
9d3a4132 | 78 | netlink_deliver_fn *deliver_to_host; /* Provided by driver */ |
d3fe100d | 79 | netlink_route_fn *set_routes; /* Provided by driver */ |
9d3a4132 | 80 | struct buffer_if icmp; /* Buffer for assembly of outgoing ICMP */ |
469fd1d9 SE |
81 | uint32_t outcount; /* Packets sent to host */ |
82 | uint32_t localcount; /* Packets sent to secnet */ | |
9d3a4132 SE |
83 | }; |
84 | ||
85 | extern netlink_deliver_fn *netlink_init(struct netlink *st, | |
86 | void *dst, struct cloc loc, | |
fe5e9cc4 | 87 | dict_t *dict, cstring_t description, |
d3fe100d | 88 | netlink_route_fn *set_routes, |
9d3a4132 SE |
89 | netlink_deliver_fn *to_host); |
90 | ||
91 | #endif /* netlink_h */ |