constify
[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 };
12
13 enum interface_proto_cmd {
14 PROTO_CMD_SETUP,
15 PROTO_CMD_TEARDOWN,
16 };
17
18 enum {
19 PROTO_FLAG_IMMEDIATE = (1 << 0),
20 };
21
22 struct interface_proto_state {
23 struct interface *iface;
24 unsigned int flags;
25
26 /* filled in by the protocol user */
27 void (*proto_event)(struct interface_proto_state *, enum interface_proto_event ev);
28
29 /* filled in by the protocol handler */
30 int (*handler)(struct interface_proto_state *, enum interface_proto_cmd cmd, bool force);
31 void (*free)(struct interface_proto_state *);
32 };
33
34
35 struct proto_handler {
36 struct avl_node avl;
37
38 const char *name;
39 const struct config_param_list *config_params;
40
41 struct interface_proto_state *(*attach)(const struct proto_handler *h,
42 struct interface *iface, struct blob_attr *attr);
43 };
44
45 void add_proto_handler(struct proto_handler *p);
46 void proto_init_interface(struct interface *iface, struct blob_attr *attr);
47 void proto_attach_interface(struct interface *iface, const char *proto_name);
48 int interface_proto_event(struct interface_proto_state *proto,
49 enum interface_proto_cmd cmd, bool force);
50
51 #endif