proto-shell: Model config parameter "no-proto-task" as a proto flag
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 11 Aug 2016 13:53:26 +0000 (15:53 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 11 Aug 2016 17:34:34 +0000 (19:34 +0200)
Export the config parameter "no-proto-task" as a proto flag so it's available for other
other netifd modules

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
proto-shell.c
proto.h

index 4391cdd0cd2ca6e2b4a8c42e5e8d2630600ecb88..998a44c55f7d4ee3f42d2fd7e84e63b439819d5d 100644 (file)
@@ -44,7 +44,6 @@ struct proto_shell_handler {
        char *config_buf;
        char *script_name;
        bool init_available;
-       bool no_proto_task;
 
        struct uci_blob_param_list config;
 };
@@ -306,7 +305,7 @@ proto_shell_task_finish(struct proto_shell_state *state,
                        if (state->renew_pending)
                                proto_shell_handler(&state->proto,
                                                    PROTO_CMD_RENEW, false);
-                       else if (!state->handler->no_proto_task &&
+                       else if (!(state->handler->proto.flags & PROTO_FLAG_NO_TASK) &&
                                 !state->proto_task.uloop.pending &&
                                 state->sm == S_SETUP)
                                proto_shell_handler(&state->proto,
@@ -892,7 +891,8 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj)
                handler->proto.flags |= PROTO_FLAG_NODEV;
 
        tmp = json_get_field(obj, "no-proto-task", json_type_boolean);
-       handler->no_proto_task = tmp && json_object_get_boolean(tmp);
+       if (tmp && json_object_get_boolean(tmp))
+               handler->proto.flags |= PROTO_FLAG_NO_TASK;
 
        tmp = json_get_field(obj, "available", json_type_boolean);
        if (tmp && json_object_get_boolean(tmp))
diff --git a/proto.h b/proto.h
index 8f50fdc21f2ee3e9eca52e6440edcc3758255c8c..26a54bd19d4458f08c24b848eb6c22d357e82a30 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -39,6 +39,7 @@ enum {
        PROTO_FLAG_FORCE_LINK_DEFAULT = (1 << 4),
        PROTO_FLAG_LASTERROR = (1 << 5),
        PROTO_FLAG_TEARDOWN_ON_L3_LINK_DOWN = (1 << 6),
+       PROTO_FLAG_NO_TASK = (1 << 7),
 };
 
 struct interface_proto_state {