+static void
+proto_shell_checkup_timeout_cb(struct uloop_timeout *timeout)
+{
+ struct proto_shell_state *state = container_of(timeout, struct
+ proto_shell_state, checkup_timeout);
+ struct interface_proto_state *proto = &state->proto;
+ struct interface *iface = proto->iface;
+
+ if (!iface->autostart)
+ return;
+
+ if (iface->state == IFS_UP)
+ return;
+
+ D(INTERFACE, "Interface '%s' is not up after %d sec\n",
+ iface->name, state->checkup_interval);
+ proto_shell_handler(proto, PROTO_CMD_TEARDOWN, false);
+}
+
+static void
+proto_shell_checkup_attach(struct proto_shell_state *state,
+ const struct blob_attr *attr)
+{
+ struct blob_attr *tb;
+ struct blobmsg_policy checkup_policy = {
+ .name = "checkup_interval",
+ .type = BLOBMSG_TYPE_INT32
+ };
+
+ blobmsg_parse(&checkup_policy, 1, &tb, blob_data(attr), blob_len(attr));
+ if (!tb) {
+ state->checkup_interval = -1;
+ state->checkup_timeout.cb = NULL;
+ } else {
+ state->checkup_interval = blobmsg_get_u32(tb);
+ state->checkup_timeout.cb = proto_shell_checkup_timeout_cb;
+ }
+}
+