proto-shell: add a notify command for setting interface availability
[project/netifd.git] / dummy / netifd-proto.sh
index 2a6a393..11337c2 100755 (executable)
@@ -48,6 +48,8 @@ proto_init_update() {
        PROTO_IP6ADDR=
        PROTO_ROUTE=
        PROTO_ROUTE6=
+       PROTO_DNS=
+       PROTO_DNS_SEARCH=
        json_init
        json_add_int action 0
        [ -n "$ifname" -a "*" != "$ifname" ] && json_add_string "ifname" "$ifname"
@@ -110,7 +112,7 @@ _proto_push_route() {
 
        json_add_object ""
        json_add_string target "$target"
-       json_add_string mask "$mask"
+       json_add_string netmask "$mask"
        json_add_string gateway "$gw"
        json_close_object
 }
@@ -182,6 +184,37 @@ proto_kill_command() {
        _proto_notify "$interface"
 }
 
+proto_notify_error() {
+       local interface="$1"; shift
+
+       json_init
+       json_add_int action 3
+       json_add_array error
+       while [ $# -gt 0 ]; do
+               json_add_string "" "$1"
+               shift
+       done
+       json_close_array
+       _proto_notify "$interface"
+}
+
+proto_block_restart() {
+       local interface="$1"; shift
+
+       json_init
+       json_add_int action 4
+       _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