From 24ccfe7d353ceb0ee4f8d4967604585de92fc9d0 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 27 Oct 2011 21:09:47 +0200 Subject: [PATCH 1/1] proto-shell: handle the "available" config flag --- interface.c | 4 +++- proto-shell.c | 5 +++++ proto.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/interface.c b/interface.c index a8f7b8f..787d7d9 100644 --- a/interface.c +++ b/interface.c @@ -184,6 +184,8 @@ interface_claim_device(struct interface *iface) if (dev) device_add_user(&iface->main_dev, dev); } + if (iface->proto_handler->flags & PROTO_FLAG_INIT_AVAILABLE) + interface_set_available(iface, true); } @@ -517,8 +519,8 @@ interface_update(struct vlist_tree *tree, struct vlist_node *node_new, set_config_state(if_old, IFC_REMOVE); } else if (node_new) { D(INTERFACE, "Create interface '%s'\n", if_new->name); - interface_claim_device(if_new); proto_init_interface(if_new, if_new->config); + interface_claim_device(if_new); netifd_ubus_add_interface(if_new); } } diff --git a/proto-shell.c b/proto-shell.c index b40b456..51a6dac 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -25,6 +25,7 @@ struct proto_shell_handler { struct proto_handler proto; struct config_param_list config; char *config_buf; + bool init_available; char script_name[]; }; @@ -615,6 +616,10 @@ proto_shell_add_handler(const char *script, json_object *obj) if (tmp && json_object_get_boolean(tmp)) handler->proto.flags |= PROTO_FLAG_NODEV; + tmp = get_field(obj, "available", json_type_boolean); + if (tmp && json_object_get_boolean(tmp)) + handler->proto.flags |= PROTO_FLAG_INIT_AVAILABLE; + config = get_field(obj, "config", json_type_array); if (config) handler->config_buf = proto_shell_parse_config(&handler->config, config); diff --git a/proto.h b/proto.h index 57426bd..c401d6f 100644 --- a/proto.h +++ b/proto.h @@ -19,6 +19,7 @@ enum interface_proto_cmd { enum { PROTO_FLAG_IMMEDIATE = (1 << 0), PROTO_FLAG_NODEV = (1 << 1), + PROTO_FLAG_INIT_AVAILABLE = (1 << 2), }; struct interface_proto_state { -- 2.11.0