proto-shell: handle the "available" config flag
authorFelix Fietkau <nbd@openwrt.org>
Thu, 27 Oct 2011 19:09:47 +0000 (21:09 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 27 Oct 2011 19:09:47 +0000 (21:09 +0200)
interface.c
proto-shell.c
proto.h

index a8f7b8f01267f9e519d9d52fe978b067879cd126..787d7d9284fc66bfb484835c3153797e84a79867 100644 (file)
@@ -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);
        }
 }
index b40b456987c72744c336db4ac97b38201b127234..51a6dac17f797f0c895200607fa3ebb85402eff5 100644 (file)
@@ -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 57426bd70accdcc8f7542783bb5f3c726bc6f3a8..c401d6f79d601da893c24258a8e2637779465f94 100644 (file)
--- 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 {