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' */ | |
9d3a4132 SE |
18 | netlink_deliver_fn *deliver; |
19 | void *dst; | |
20 | string_t name; | |
21 | uint32_t link_quality; | |
3454dce4 | 22 | uint32_t options; |
9d3a4132 SE |
23 | struct netlink_client *next; |
24 | }; | |
25 | ||
26 | struct netlink_route { | |
27 | struct subnet net; | |
28 | bool_t hard; | |
3454dce4 | 29 | bool_t allow_route; |
9d3a4132 SE |
30 | bool_t up; |
31 | bool_t kup; | |
042a8da9 | 32 | uint32_t quality; /* provided by client */ |
469fd1d9 | 33 | uint32_t outcount; |
9d3a4132 SE |
34 | struct netlink_client *c; |
35 | }; | |
36 | ||
37 | typedef bool_t netlink_route_fn(void *cst, struct netlink_route *route); | |
38 | ||
39 | /* Netlink provides one function to the device driver, to call to deliver | |
40 | a packet from the device. The device driver provides one function to | |
41 | netlink, for it to call to deliver a packet to the device. */ | |
42 | ||
43 | struct netlink { | |
44 | closure_t cl; | |
9d3a4132 SE |
45 | void *dst; /* Pointer to host interface state */ |
46 | string_t name; | |
47 | uint32_t max_start_pad; | |
48 | uint32_t max_end_pad; | |
794f2398 SE |
49 | struct ipset *networks; /* Local networks */ |
50 | struct subnet_list *subnets; /* Same information as networks */ | |
51 | struct ipset *remote_networks; /* Allowable remote networks */ | |
469fd1d9 SE |
52 | uint32_t secnet_address; /* our own address, or the address of the |
53 | other end of a point-to-point link */ | |
c6f79b17 | 54 | bool_t ptp; |
9d3a4132 SE |
55 | uint32_t mtu; |
56 | struct netlink_client *clients; | |
57 | netlink_deliver_fn *deliver_to_host; /* Provided by driver */ | |
58 | netlink_route_fn *set_route; /* Provided by driver */ | |
59 | struct buffer_if icmp; /* Buffer for assembly of outgoing ICMP */ | |
60 | uint32_t n_routes; /* How many routes do we know about? */ | |
61 | struct netlink_route *routes; | |
469fd1d9 SE |
62 | uint32_t outcount; /* Packets sent to host */ |
63 | uint32_t localcount; /* Packets sent to secnet */ | |
9d3a4132 SE |
64 | }; |
65 | ||
66 | extern netlink_deliver_fn *netlink_init(struct netlink *st, | |
67 | void *dst, struct cloc loc, | |
68 | dict_t *dict, string_t description, | |
69 | netlink_route_fn *set_route, | |
70 | netlink_deliver_fn *to_host); | |
71 | ||
72 | #endif /* netlink_h */ |