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