chiark / gitweb /
Import release 0.1.2
[secnet.git] / netlink.h
1 #ifndef netlink_h
2 #define netlink_h
3
4 #define DEFAULT_BUFSIZE 2048
5 #define DEFAULT_MTU 1000
6 #define ICMP_BUFSIZE 1024
7
8 struct netlink_client {
9     struct subnet_list *networks;
10     netlink_deliver_fn *deliver;
11     void *dst;
12     string_t name;
13     uint32_t link_quality;
14     bool_t hard_routes;
15     struct netlink_client *next;
16 };
17
18 struct netlink_route {
19     struct subnet net;
20     bool_t hard;
21     bool_t up;
22     bool_t kup;
23     struct netlink_client *c;
24 };
25
26 typedef bool_t netlink_route_fn(void *cst, struct netlink_route *route);
27
28 /* Netlink provides one function to the device driver, to call to deliver
29    a packet from the device. The device driver provides one function to
30    netlink, for it to call to deliver a packet to the device. */
31
32 struct netlink {
33     closure_t cl;
34     struct netlink_if ops;
35     void *dst; /* Pointer to host interface state */
36     string_t name;
37     uint32_t max_start_pad;
38     uint32_t max_end_pad;
39     struct subnet_list networks;
40     struct subnet_list exclude_remote_networks;
41     uint32_t local_address; /* host interface address */
42     uint32_t secnet_address; /* our own address */
43     uint32_t mtu;
44     struct netlink_client *clients;
45     netlink_deliver_fn *deliver_to_host; /* Provided by driver */
46     netlink_route_fn *set_route; /* Provided by driver */
47     struct buffer_if icmp; /* Buffer for assembly of outgoing ICMP */
48     uint32_t n_routes; /* How many routes do we know about? */
49     struct netlink_route *routes;
50 };
51
52 extern netlink_deliver_fn *netlink_init(struct netlink *st,
53                                         void *dst, struct cloc loc,
54                                         dict_t *dict, string_t description,
55                                         netlink_route_fn *set_route,
56                                         netlink_deliver_fn *to_host);
57
58 #endif /* netlink_h */