2 * This file is part of secnet.
3 * See README for full list of copyright holders.
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.
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.
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.
25 #define DEFAULT_BUFSIZE 2048
26 #define DEFAULT_MTU 1000
27 #define ICMP_BUFSIZE 1024
31 struct netlink_client
{
33 struct netlink_if ops
;
35 struct ipset
*networks
;
36 struct subnet_list
*subnets
; /* Same information as 'networks' */
37 uint32_t priority
; /* Higher priority clients have their networks
38 checked first during routing. This allows
39 things like laptops to supersede whole
41 netlink_deliver_fn
*deliver
;
44 uint32_t link_quality
;
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
;
53 /* options field in 'struct netlink_client' */
54 #define OPT_SOFTROUTE 1
55 #define OPT_ALLOWROUTE 2
57 typedef bool_t
netlink_route_fn(void *cst
, struct netlink_client
*routes
);
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. */
65 void *dst
; /* Pointer to host interface state */
67 struct ipset
*networks
; /* Local networks */
68 struct subnet_list
*subnets
; /* Same as networks, for display */
69 struct ipset
*remote_networks
; /* Allowable remote networks */
70 uint32_t local_address
; /* host interface address */
71 uint32_t secnet_address
; /* our own address, or the address of the
72 other end of a point-to-point link */
75 struct netlink_client
*clients
; /* Linked list of clients */
76 struct netlink_client
**routes
; /* Array of clients, sorted by priority */
78 netlink_deliver_fn
*deliver_to_host
; /* Provided by driver */
79 netlink_route_fn
*set_routes
; /* Provided by driver */
80 struct buffer_if icmp
; /* Buffer for assembly of outgoing ICMP */
81 uint32_t outcount
; /* Packets sent to host */
82 uint32_t localcount
; /* Packets sent to secnet */
85 extern netlink_deliver_fn
*netlink_init(struct netlink
*st
,
86 void *dst
, struct cloc loc
,
87 dict_t
*dict
, cstring_t description
,
88 netlink_route_fn
*set_routes
,
89 netlink_deliver_fn
*to_host
);
91 #endif /* netlink_h */