summaryrefslogtreecommitdiff
path: root/proto.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-04-13 23:30:51 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-04-13 23:30:51 +0200
commit6b7accf51072d883a7692d7a4bb1d7d1a2e7242b (patch)
tree3653ed33d4c58cbb641d3563c3f5c605f6e16826 /proto.c
parent39dbd09f5845311a41300655ffd83f0b2d7ee7e4 (diff)
downloadnetifd-6b7accf51072d883a7692d7a4bb1d7d1a2e7242b.tar.gz
export a function to look up a protocol handler
Diffstat (limited to 'proto.c')
-rw-r--r--proto.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/proto.c b/proto.c
index 3161e01..5126107 100644
--- a/proto.c
+++ b/proto.c
@@ -40,7 +40,8 @@ no_proto_handler(struct interface_proto_state *proto,
return 0;
}
-static struct interface_proto_state *get_default_proto(void)
+static struct interface_proto_state *
+get_default_proto(void)
{
struct interface_proto_state *proto;
@@ -51,7 +52,19 @@ static struct interface_proto_state *get_default_proto(void)
return proto;
}
-void proto_attach_interface(struct interface *iface, struct uci_section *s)
+struct proto_handler *
+get_proto_handler(const char *name)
+{
+ struct proto_handler *proto;
+
+ if (!handlers.comp)
+ return NULL;
+
+ return avl_find_element(&handlers, name, proto, avl);
+}
+
+void
+proto_attach_interface(struct interface *iface, struct uci_section *s)
{
struct interface_proto_state *state = NULL;
struct proto_handler *proto = NULL;
@@ -70,9 +83,7 @@ void proto_attach_interface(struct interface *iface, struct uci_section *s)
goto out;
}
- if (handlers.comp)
- proto = avl_find_element(&handlers, proto_name, proto, avl);
-
+ proto = get_proto_handler(proto_name);
if (!proto) {
error = "INVALID_PROTO";
goto error;
@@ -92,8 +103,9 @@ out:
}
-int interface_proto_event(struct interface_proto_state *proto,
- enum interface_proto_cmd cmd, bool force)
+int
+interface_proto_event(struct interface_proto_state *proto,
+ enum interface_proto_cmd cmd, bool force)
{
enum interface_event ev;
int ret;