+proto_shell_block_restart(struct proto_shell_state *state, struct blob_attr **tb)
+{
+ state->proto.iface->autostart = false;
+ return 0;
+}
+
+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_add_host_dependency(struct proto_shell_state *state, struct blob_attr **tb)
+{
+ struct proto_shell_dependency *dep;
+ const char *ifname = tb[NOTIFY_IFNAME] ? blobmsg_data(tb[NOTIFY_IFNAME]) : "";
+ const char *host = tb[NOTIFY_HOST] ? blobmsg_data(tb[NOTIFY_HOST]) : "";
+
+ if (state->sm == S_TEARDOWN || state->sm == S_SETUP_ABORT)
+ return UBUS_STATUS_PERMISSION_DENIED;
+
+ dep = calloc(1, sizeof(*dep) + strlen(ifname) + 1);
+
+ if (!host[0] && ifname[0]) {
+ dep->any = true;
+ } else if (inet_pton(AF_INET, host, &dep->host) < 1) {
+ if (inet_pton(AF_INET6, host, &dep->host) < 1) {
+ free(dep);
+ return UBUS_STATUS_INVALID_ARGUMENT;
+ } else {
+ dep->v6 = true;
+ }
+ }
+
+ dep->proto = state;
+ strcpy(dep->interface, ifname);
+
+ dep->dep.cb = proto_shell_if_up_cb;
+ interface_add_user(&dep->dep, NULL);
+ list_add(&dep->list, &state->deps);
+ proto_shell_update_host_dep(dep);
+ if (!dep->dep.iface)
+ return UBUS_STATUS_NOT_FOUND;
+
+ return 0;
+}
+
+static int
+proto_shell_setup_failed(struct proto_shell_state *state)
+{
+ int ret = 0;
+
+ switch (state->sm) {
+ case S_IDLE:
+ state->proto.proto_event(&state->proto, IFPEV_LINK_LOST);
+ /* fall through */
+ case S_SETUP:
+ proto_shell_handler(&state->proto, PROTO_CMD_TEARDOWN, false);
+ break;
+ case S_SETUP_ABORT:
+ case S_TEARDOWN:
+ default:
+ ret = UBUS_STATUS_PERMISSION_DENIED;
+ break;
+ }
+ return ret;
+}
+
+static int