summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--proto-shell.c2
-rw-r--r--proto-static.c4
-rw-r--r--proto.c11
-rw-r--r--proto.h7
4 files changed, 14 insertions, 10 deletions
diff --git a/proto-shell.c b/proto-shell.c
index 281debc..d014b43 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -111,7 +111,7 @@ proto_shell_attach(const struct proto_handler *h, struct interface *iface,
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;
diff --git a/proto-static.c b/proto-static.c
index 3734f09..bbe304b 100644
--- a/proto-static.c
+++ b/proto-static.c
@@ -241,8 +241,7 @@ static_attach(const struct proto_handler *h, struct interface *iface,
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;
@@ -253,6 +252,7 @@ error:
static struct proto_handler static_proto = {
.name = "static",
+ .flags = PROTO_FLAG_IMMEDIATE,
.config_params = &static_attr_list,
.attach = static_attach,
};
diff --git a/proto.c b/proto.c
index 278fb0c..d8f16b3 100644
--- a/proto.c
+++ b/proto.c
@@ -48,14 +48,14 @@ default_proto_attach(const struct proto_handler *h,
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,
};
@@ -84,9 +84,10 @@ proto_init_interface(struct interface *iface, struct blob_attr *attr)
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);
}
@@ -114,8 +115,8 @@ interface_proto_event(struct interface_proto_state *proto,
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) {
diff --git a/proto.h b/proto.h
index 273ec94..e066b43 100644
--- a/proto.h
+++ b/proto.h
@@ -17,17 +17,18 @@ enum interface_proto_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 *);
};
@@ -35,6 +36,8 @@ struct interface_proto_state {
struct proto_handler {
struct avl_node avl;
+ unsigned int flags;
+
const char *name;
const struct config_param_list *config_params;