summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-10-27 10:39:13 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-10-27 10:39:13 +0200
commit4ff6bcbee05983037f6a629b114beace5d98bdbe (patch)
tree05a59174b352d319534c9e86b07cc9605c49f017
parent10741b4974b85c825036eb0717ddc7112f96f5fb (diff)
downloadnetifd-4ff6bcbee05983037f6a629b114beace5d98bdbe.tar.gz
proto-shell: add a notify command for setting interface availability
-rwxr-xr-xdummy/netifd-proto.sh9
-rw-r--r--proto-shell.c14
2 files changed, 23 insertions, 0 deletions
diff --git a/dummy/netifd-proto.sh b/dummy/netifd-proto.sh
index e61de46..11337c2 100755
--- a/dummy/netifd-proto.sh
+++ b/dummy/netifd-proto.sh
@@ -206,6 +206,15 @@ proto_block_restart() {
_proto_notify "$interface"
}
+proto_set_available() {
+ local interface="$1"
+ local state="$2"
+ json_init
+ json_add_int action 5
+ json_add_boolean available "$state"
+ _proto_notify "$interface"
+}
+
init_proto() {
proto="$1"; shift
cmd="$1"; shift
diff --git a/proto-shell.c b/proto-shell.c
index 3582319..b40b456 100644
--- a/proto-shell.c
+++ b/proto-shell.c
@@ -220,6 +220,7 @@ enum {
NOTIFY_COMMAND,
NOTIFY_ENV,
NOTIFY_SIGNAL,
+ NOTIFY_AVAILABLE,
NOTIFY_LINK_UP,
NOTIFY_IFNAME,
NOTIFY_ADDR_EXT,
@@ -238,6 +239,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 +429,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 +461,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;
}