projects
/
project
/
netifd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
39dbd09
)
export a function to look up a protocol handler
author
Felix Fietkau
<nbd@openwrt.org>
Wed, 13 Apr 2011 21:30:51 +0000
(23:30 +0200)
committer
Felix Fietkau
<nbd@openwrt.org>
Wed, 13 Apr 2011 21:30:51 +0000
(23:30 +0200)
proto.c
patch
|
blob
|
history
proto.h
patch
|
blob
|
history
diff --git
a/proto.c
b/proto.c
index
3161e01
..
5126107
100644
(file)
--- a/
proto.c
+++ b/
proto.c
@@
-40,7
+40,8
@@
no_proto_handler(struct interface_proto_state *proto,
return 0;
}
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;
{
struct interface_proto_state *proto;
@@
-51,7
+52,19
@@
static struct interface_proto_state *get_default_proto(void)
return proto;
}
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;
{
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;
}
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;
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;
{
enum interface_event ev;
int ret;
diff --git
a/proto.h
b/proto.h
index
aeb2f24
..
fd9a0f8
100644
(file)
--- a/
proto.h
+++ b/
proto.h
@@
-43,6
+43,7
@@
struct proto_handler {
};
void add_proto_handler(struct proto_handler *p);
};
void add_proto_handler(struct proto_handler *p);
+struct proto_handler *get_proto_handler(const char *name);
void proto_attach_interface(struct interface *iface, struct uci_section *s);
int interface_proto_event(struct interface_proto_state *proto,
enum interface_proto_cmd cmd, bool force);
void proto_attach_interface(struct interface *iface, struct uci_section *s);
int interface_proto_event(struct interface_proto_state *proto,
enum interface_proto_cmd cmd, bool force);