add forced shell proto setup kill (timeout: 1 second)
[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 PROTO_FLAG_NODEV = (1 << 1),
21 };
22
23 struct interface_proto_state {
24 const struct proto_handler *handler;
25 struct interface *iface;
26
27 /* filled in by the protocol user */
28 void (*proto_event)(struct interface_proto_state *, enum interface_proto_event ev);
29
30 /* filled in by the protocol handler */
31 int (*notify)(struct interface_proto_state *, struct blob_attr *data);
32 int (*cb)(struct interface_proto_state *, enum interface_proto_cmd cmd, bool force);
33 void (*free)(struct interface_proto_state *);
34 };
35
36
37 struct proto_handler {
38 struct avl_node avl;
39
40 unsigned int flags;
41
42 const char *name;
43 const struct config_param_list *config_params;
44
45 struct interface_proto_state *(*attach)(const struct proto_handler *h,
46 struct interface *iface, struct blob_attr *attr);
47 };
48
49 void add_proto_handler(struct proto_handler *p);
50 void proto_init_interface(struct interface *iface, struct blob_attr *attr);
51 void proto_attach_interface(struct interface *iface, const char *proto_name);
52 int interface_proto_event(struct interface_proto_state *proto,
53 enum interface_proto_cmd cmd, bool force);
54 int proto_apply_static_settings(struct interface_proto_state *state,
55 struct blob_attr *attr);
56
57 #endif