move ip related functions and data structures to a separate header file
[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
35 unsigned int mask;
36 union if_addr addr;
37 union if_addr nexthop;
38 };
39
40 int interface_add_address(struct interface *iface, struct device_addr *addr);
41 void interface_del_address(struct interface *iface, struct device_addr *addr);
42 void interface_del_ctx_addr(struct interface *iface, void *ctx);
43
44 int interface_add_route(struct interface *iface, struct device_route *route);
45 void interface_del_route(struct interface *iface, struct device_route *route);
46 void interface_del_all_routes(struct interface *iface);
47
48 #endif