summaryrefslogtreecommitdiffhomepage
path: root/proto.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-04-03 19:05:48 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-04-03 19:05:51 +0200
commit56b7cadaeb51a60afa5666e190906d332840d5a1 (patch)
tree8f4872ec8739f7d8802f1e1a2e8000ea3a3510ba /proto.c
parentfe105ac00422a8ea2250e921e76b801a3d23aa8c (diff)
move immediate protocol state transitions to a wrapper function
Diffstat (limited to 'proto.c')
-rw-r--r--proto.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/proto.c b/proto.c
index 287eae5..b16600c 100644
--- a/proto.c
+++ b/proto.c
@@ -16,7 +16,30 @@ static int
default_proto_handler(struct interface_proto_state *proto,
enum interface_proto_cmd cmd, bool force)
{
+ return 0;
+}
+
+struct interface_proto_state *get_default_proto(void)
+{
+ struct interface_proto_state *proto;
+
+ proto = calloc(1, sizeof(*proto));
+ proto->handler = default_proto_handler;
+ proto->free = default_proto_free;
+ proto->flags = PROTO_FLAG_IMMEDIATE;
+
+ return proto;
+}
+
+int interface_proto_event(struct interface_proto_state *proto,
+ enum interface_proto_cmd cmd, bool force)
+{
enum interface_event ev;
+ int ret;
+
+ ret = proto->handler(proto, cmd, force);
+ if (ret || !(proto->flags & PROTO_FLAG_IMMEDIATE))
+ goto out;
switch(cmd) {
case PROTO_CMD_SETUP:
@@ -29,15 +52,7 @@ default_proto_handler(struct interface_proto_state *proto,
return -EINVAL;
}
proto->proto_event(proto, ev);
- return 0;
-}
-struct interface_proto_state *get_default_proto(void)
-{
- struct interface_proto_state *proto;
-
- proto = calloc(1, sizeof(*proto));
- proto->handler = default_proto_handler;
- proto->free = default_proto_free;
- return proto;
+out:
+ return ret;
}