Commit | Line | Data |
---|---|---|
9d3a4132 SE |
1 | #ifndef netlink_h |
2 | #define netlink_h | |
3 | ||
7138d0c5 SE |
4 | #include "ipaddr.h" |
5 | ||
9d3a4132 SE |
6 | #define DEFAULT_BUFSIZE 2048 |
7 | #define DEFAULT_MTU 1000 | |
8 | #define ICMP_BUFSIZE 1024 | |
9 | ||
469fd1d9 SE |
10 | struct netlink; |
11 | ||
9d3a4132 | 12 | struct netlink_client { |
469fd1d9 SE |
13 | closure_t cl; |
14 | struct netlink_if ops; | |
15 | struct netlink *nst; | |
794f2398 SE |
16 | struct ipset *networks; |
17 | struct subnet_list *subnets; /* Same information as 'networks' */ | |
d3fe100d SE |
18 | uint32_t priority; /* Higher priority clients have their networks |
19 | checked first during routing. This allows | |
20 | things like laptops to supersede whole | |
21 | networks. */ | |
9d3a4132 SE |
22 | netlink_deliver_fn *deliver; |
23 | void *dst; | |
24 | string_t name; | |
25 | uint32_t link_quality; | |
d3fe100d | 26 | uint32_t mtu; |
3454dce4 | 27 | uint32_t options; |
469fd1d9 | 28 | uint32_t outcount; |
d3fe100d SE |
29 | bool_t up; /* Should these routes exist in the kernel? */ |
30 | bool_t kup; /* Do these routes exist in the kernel? */ | |
31 | struct netlink_client *next; | |
9d3a4132 SE |
32 | }; |
33 | ||
d3fe100d | 34 | typedef bool_t netlink_route_fn(void *cst, struct netlink_client *routes); |
9d3a4132 SE |
35 | |
36 | /* Netlink provides one function to the device driver, to call to deliver | |
37 | a packet from the device. The device driver provides one function to | |
38 | netlink, for it to call to deliver a packet to the device. */ | |
39 | ||
40 | struct netlink { | |
41 | closure_t cl; | |
9d3a4132 | 42 | void *dst; /* Pointer to host interface state */ |
fe5e9cc4 | 43 | cstring_t name; |
9d3a4132 SE |
44 | uint32_t max_start_pad; |
45 | uint32_t max_end_pad; | |
794f2398 | 46 | struct ipset *networks; /* Local networks */ |
d3fe100d | 47 | struct subnet_list *subnets; /* Same as networks, for display */ |
794f2398 | 48 | struct ipset *remote_networks; /* Allowable remote networks */ |
469fd1d9 SE |
49 | uint32_t secnet_address; /* our own address, or the address of the |
50 | other end of a point-to-point link */ | |
c6f79b17 | 51 | bool_t ptp; |
9d3a4132 | 52 | uint32_t mtu; |
d3fe100d SE |
53 | struct netlink_client *clients; /* Linked list of clients */ |
54 | struct netlink_client **routes; /* Array of clients, sorted by priority */ | |
55 | uint32_t n_clients; | |
9d3a4132 | 56 | netlink_deliver_fn *deliver_to_host; /* Provided by driver */ |
d3fe100d | 57 | netlink_route_fn *set_routes; /* Provided by driver */ |
9d3a4132 | 58 | struct buffer_if icmp; /* Buffer for assembly of outgoing ICMP */ |
469fd1d9 SE |
59 | uint32_t outcount; /* Packets sent to host */ |
60 | uint32_t localcount; /* Packets sent to secnet */ | |
9d3a4132 SE |
61 | }; |
62 | ||
63 | extern netlink_deliver_fn *netlink_init(struct netlink *st, | |
64 | void *dst, struct cloc loc, | |
fe5e9cc4 | 65 | dict_t *dict, cstring_t description, |
d3fe100d | 66 | netlink_route_fn *set_routes, |
9d3a4132 SE |
67 | netlink_deliver_fn *to_host); |
68 | ||
69 | #endif /* netlink_h */ |