X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=proto.c;h=5126107b53c2cb98c467fc4a01447929c4599b42;hp=ea6e138e71e82dbbfd71e01e45c2d9f40f32a7e9;hb=3e22e5b6bddce74aa7b3ca92ff0f089ac9b59ccb;hpb=71427e54fa17dacd1ace6077bffb9f9b9d456ebb diff --git a/proto.c b/proto.c index ea6e138..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,15 +83,13 @@ 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; } - state = proto->attach(proto, iface); + state = proto->attach(proto, iface, s); error: if (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;