X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=proto-shell.c;h=51a6dac17f797f0c895200607fa3ebb85402eff5;hb=b8f0ce8319a43d629c8de86df6951892b7e8d813;hp=3582319cb39ebb52f8e952f8f76d50a63acb9017;hpb=986c4a1434cc61d2de560690ecc0d532a157d40a;p=project%2Fnetifd.git diff --git a/proto-shell.c b/proto-shell.c index 3582319..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[]; }; @@ -220,6 +221,7 @@ enum { NOTIFY_COMMAND, NOTIFY_ENV, NOTIFY_SIGNAL, + NOTIFY_AVAILABLE, NOTIFY_LINK_UP, NOTIFY_IFNAME, NOTIFY_ADDR_EXT, @@ -238,6 +240,7 @@ static const struct blobmsg_policy notify_attr[__NOTIFY_LAST] = { [NOTIFY_COMMAND] = { .name = "command", .type = BLOBMSG_TYPE_ARRAY }, [NOTIFY_ENV] = { .name = "env", .type = BLOBMSG_TYPE_ARRAY }, [NOTIFY_SIGNAL] = { .name = "signal", .type = BLOBMSG_TYPE_INT32 }, + [NOTIFY_AVAILABLE] = { .name = "available", .type = BLOBMSG_TYPE_BOOL }, [NOTIFY_LINK_UP] = { .name = "link-up", .type = BLOBMSG_TYPE_BOOL }, [NOTIFY_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING }, [NOTIFY_ADDR_EXT] = { .name = "address-external", .type = BLOBMSG_TYPE_BOOL }, @@ -427,6 +430,16 @@ proto_shell_block_restart(struct proto_shell_state *state, struct blob_attr **tb } static int +proto_shell_set_available(struct proto_shell_state *state, struct blob_attr **tb) +{ + if (!tb[NOTIFY_AVAILABLE]) + return UBUS_STATUS_INVALID_ARGUMENT; + + interface_set_available(state->proto.iface, blobmsg_get_bool(tb[NOTIFY_AVAILABLE])); + return 0; +} + +static int proto_shell_notify(struct interface_proto_state *proto, struct blob_attr *attr) { struct proto_shell_state *state; @@ -449,6 +462,8 @@ proto_shell_notify(struct interface_proto_state *proto, struct blob_attr *attr) return proto_shell_notify_error(state, tb); case 4: return proto_shell_block_restart(state, tb); + case 5: + return proto_shell_set_available(state, tb); default: return UBUS_STATUS_INVALID_ARGUMENT; } @@ -601,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);