e83e32726312d6b09f690841cb6290ce854c4d40
[project/netifd.git] / interface-ip.h
1 #ifndef __INTERFACE_IP_H
2 #define __INTERFACE_IP_H
3
4 enum device_addr_flags {
5         /* address family for routes and addresses */
6         DEVADDR_INET4   = (0 << 0),
7         DEVADDR_INET6   = (1 << 0),
8         DEVADDR_FAMILY  = DEVADDR_INET4 | DEVADDR_INET6,
9
10         /* device route (no gateway) */
11         DEVADDR_DEVICE  = (1 << 1),
12 };
13
14 union if_addr {
15         struct in_addr in;
16         struct in6_addr in6;
17 };
18
19 struct device_addr {
20         struct list_head list;
21         void *ctx;
22
23         enum device_addr_flags flags;
24
25         unsigned int mask;
26         union if_addr addr;
27 };
28
29 struct device_route {
30         struct list_head list;
31         void *ctx;
32
33         enum device_addr_flags flags;
34         bool keep;
35
36         unsigned int mask;
37         union if_addr addr;
38         union if_addr nexthop;
39 };
40
41 int interface_add_address(struct interface *iface, struct device_addr *addr);
42 void interface_del_address(struct interface *iface, struct device_addr *addr);
43 void interface_del_ctx_addr(struct interface *iface, void *ctx);
44
45 int interface_add_route(struct interface *iface, struct device_route *route);
46 void interface_del_route(struct interface *iface, struct device_route *route);
47 void interface_del_all_routes(struct interface *iface);
48
49 #endif