X-Git-Url: http://git.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=proto-shell.c;h=bac57e03176c8876ffa53d948b709a83986cf077;hp=977cdbceedc8d69639dd79082838610a325cf0bc;hb=c68587663ef18fa87841be0a5281264361fab411;hpb=3c4a49e215379ea207c38c08e990a89b31be3f36 diff --git a/proto-shell.c b/proto-shell.c index 977cdbc..bac57e0 100644 --- a/proto-shell.c +++ b/proto-shell.c @@ -44,6 +44,7 @@ struct proto_shell_handler { char *config_buf; char *script_name; bool init_available; + bool no_proto_task; struct uci_blob_param_list config; }; @@ -284,9 +285,17 @@ proto_shell_task_finish(struct proto_shell_state *state, if (task == &state->proto_task) proto_shell_handler(&state->proto, PROTO_CMD_TEARDOWN, false); - if (task == &state->script_task && state->renew_pending) - proto_shell_handler(&state->proto, PROTO_CMD_RENEW, - false); + else if (task == &state->script_task) { + if (state->renew_pending) + proto_shell_handler(&state->proto, + PROTO_CMD_RENEW, false); + else if (!state->handler->no_proto_task && + !state->proto_task.uloop.pending && + state->sm == S_SETUP) + proto_shell_handler(&state->proto, + PROTO_CMD_TEARDOWN, + false); + } break; case S_SETUP_ABORT: @@ -811,6 +820,9 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj) if (tmp && json_object_get_boolean(tmp)) 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); + tmp = json_get_field(obj, "available", json_type_boolean); if (tmp && json_object_get_boolean(tmp)) handler->proto.flags |= PROTO_FLAG_INIT_AVAILABLE; @@ -819,6 +831,10 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj) if (tmp && json_object_get_boolean(tmp)) handler->proto.flags |= PROTO_FLAG_RENEW_AVAILABLE; + tmp = json_get_field(obj, "lasterror", json_type_boolean); + if (tmp && json_object_get_boolean(tmp)) + handler->proto.flags |= PROTO_FLAG_LASTERROR; + config = json_get_field(obj, "config", json_type_array); if (config) handler->config_buf = netifd_handler_parse_config(&handler->config, config);