2 * netifd - network interface daemon
3 * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 #ifndef __NETIFD_PROTO_H
15 #define __NETIFD_PROTO_H
18 struct interface_proto_state
;
21 enum interface_proto_event
{
28 enum interface_proto_cmd
{
35 PROTO_FLAG_IMMEDIATE
= (1 << 0),
36 PROTO_FLAG_NODEV
= (1 << 1),
37 PROTO_FLAG_INIT_AVAILABLE
= (1 << 2),
38 PROTO_FLAG_RENEW_AVAILABLE
= (1 << 3),
39 PROTO_FLAG_FORCE_LINK_DEFAULT
= (1 << 4),
40 PROTO_FLAG_LASTERROR
= (1 << 5),
43 struct interface_proto_state
{
44 const struct proto_handler
*handler
;
45 struct interface
*iface
;
47 /* filled in by the protocol user */
48 void (*proto_event
)(struct interface_proto_state
*, enum interface_proto_event ev
);
50 /* filled in by the protocol handler */
51 int (*notify
)(struct interface_proto_state
*, struct blob_attr
*data
);
52 int (*cb
)(struct interface_proto_state
*, enum interface_proto_cmd cmd
, bool force
);
53 void (*free
)(struct interface_proto_state
*);
57 struct proto_handler
{
63 const struct uci_blob_param_list
*config_params
;
65 struct interface_proto_state
*(*attach
)(const struct proto_handler
*h
,
66 struct interface
*iface
, struct blob_attr
*attr
);
69 extern const struct uci_blob_param_list proto_ip_attr
;
71 void add_proto_handler(struct proto_handler
*p
);
72 void proto_init_interface(struct interface
*iface
, struct blob_attr
*attr
);
73 void proto_attach_interface(struct interface
*iface
, const char *proto_name
);
74 int interface_proto_event(struct interface_proto_state
*proto
,
75 enum interface_proto_cmd cmd
, bool force
);
77 unsigned int parse_netmask_string(const char *str
, bool v6
);
78 int proto_apply_static_ip_settings(struct interface
*iface
, struct blob_attr
*attr
);
79 int proto_apply_ip_settings(struct interface
*iface
, struct blob_attr
*attr
, bool ext
);
80 void proto_dump_handlers(struct blob_buf
*b
);
81 void proto_shell_init(void);