memcpy(state->config, attr, blob_pad_len(attr));
state->proto.free = proto_shell_free;
- state->proto.handler = proto_shell_handler;
+ state->proto.cb = proto_shell_handler;
state->handler = container_of(h, struct proto_shell_handler, proto);
return &state->proto;
memcpy(state->config, attr, blob_pad_len(attr));
state->proto.free = static_free;
- state->proto.handler = static_handler;
- state->proto.flags = PROTO_FLAG_IMMEDIATE;
+ state->proto.cb = static_handler;
return &state->proto;
static struct proto_handler static_proto = {
.name = "static",
+ .flags = PROTO_FLAG_IMMEDIATE,
.config_params = &static_attr_list,
.attach = static_attach,
};
proto = calloc(1, sizeof(*proto));
proto->free = default_proto_free;
- proto->flags = PROTO_FLAG_IMMEDIATE;
- proto->handler = no_proto_handler;
+ proto->cb = no_proto_handler;
return proto;
}
static const struct proto_handler no_proto = {
.name = "none",
+ .flags = PROTO_FLAG_IMMEDIATE,
.attach = default_proto_attach,
};
if (!state) {
state = no_proto.attach(&no_proto, iface, attr);
- state->handler = invalid_proto_handler;
+ state->cb = invalid_proto_handler;
}
+ state->handler = proto;
interface_set_proto_state(iface, state);
}
enum interface_event ev;
int ret;
- ret = proto->handler(proto, cmd, force);
- if (ret || !(proto->flags & PROTO_FLAG_IMMEDIATE))
+ ret = proto->cb(proto, cmd, force);
+ if (ret || !(proto->handler->flags & PROTO_FLAG_IMMEDIATE))
goto out;
switch(cmd) {
enum {
PROTO_FLAG_IMMEDIATE = (1 << 0),
+ PROTO_FLAG_NODEV = (1 << 1),
};
struct interface_proto_state {
+ const struct proto_handler *handler;
struct interface *iface;
- unsigned int flags;
/* filled in by the protocol user */
void (*proto_event)(struct interface_proto_state *, enum interface_proto_event ev);
/* filled in by the protocol handler */
- int (*handler)(struct interface_proto_state *, enum interface_proto_cmd cmd, bool force);
+ int (*cb)(struct interface_proto_state *, enum interface_proto_cmd cmd, bool force);
void (*free)(struct interface_proto_state *);
};
struct proto_handler {
struct avl_node avl;
+ unsigned int flags;
+
const char *name;
const struct config_param_list *config_params;