vlist: fix node version update for tree->keep_old/no_delete
[project/netifd.git] / proto.h
1 #ifndef __NETIFD_PROTO_H
2 #define __NETIFD_PROTO_H
3
4 struct interface;
5 struct interface_proto_state;
6 struct proto_handler;
7
8 enum interface_proto_event {
9         IFPEV_UP,
10         IFPEV_DOWN,
11         IFPEV_LINK_LOST,
12 };
13
14 enum interface_proto_cmd {
15         PROTO_CMD_SETUP,
16         PROTO_CMD_TEARDOWN,
17 };
18
19 enum {
20         PROTO_FLAG_IMMEDIATE = (1 << 0),
21         PROTO_FLAG_NODEV = (1 << 1),
22         PROTO_FLAG_INIT_AVAILABLE = (1 << 2),
23 };
24
25 struct interface_proto_state {
26         const struct proto_handler *handler;
27         struct interface *iface;
28
29         /* filled in by the protocol user */
30         void (*proto_event)(struct interface_proto_state *, enum interface_proto_event ev);
31
32         /* filled in by the protocol handler */
33         int (*notify)(struct interface_proto_state *, struct blob_attr *data);
34         int (*cb)(struct interface_proto_state *, enum interface_proto_cmd cmd, bool force);
35         void (*free)(struct interface_proto_state *);
36 };
37
38
39 struct proto_handler {
40         struct avl_node avl;
41
42         unsigned int flags;
43
44         const char *name;
45         const struct config_param_list *config_params;
46
47         struct interface_proto_state *(*attach)(const struct proto_handler *h,
48                 struct interface *iface, struct blob_attr *attr);
49 };
50
51 void add_proto_handler(struct proto_handler *p);
52 void proto_init_interface(struct interface *iface, struct blob_attr *attr);
53 void proto_attach_interface(struct interface *iface, const char *proto_name);
54 int interface_proto_event(struct interface_proto_state *proto,
55                           enum interface_proto_cmd cmd, bool force);
56 struct device_addr *proto_parse_ip_addr_string(const char *str, bool v6, int mask);
57 unsigned int parse_netmask_string(const char *str, bool v6);
58
59 #endif