summaryrefslogtreecommitdiffhomepage
path: root/dummy/netifd-proto.sh
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-03-23 15:45:43 +0200
committerFelix Fietkau <nbd@openwrt.org>2012-03-23 15:45:43 +0200
commit9b40d469c858d9ce4cacfa0aca37ba2ac69d2f96 (patch)
tree59281a24e69559c30f7ec5a2b6968e06b71d9a42 /dummy/netifd-proto.sh
parent76d5b041afff56375bb88a18eff33e50acceb1d8 (diff)
allow proto handlers to attach data items in notify
Diffstat (limited to 'dummy/netifd-proto.sh')
-rwxr-xr-xdummy/netifd-proto.sh29
1 files changed, 21 insertions, 8 deletions
diff --git a/dummy/netifd-proto.sh b/dummy/netifd-proto.sh
index 7482a83..f1ddd1a 100755
--- a/dummy/netifd-proto.sh
+++ b/dummy/netifd-proto.sh
@@ -58,17 +58,30 @@ proto_init_update() {
[ -n "$3" ] && json_add_boolean "address-external" "$external"
}
-proto_add_tunnel() {
- proto_close_tunnel
+proto_close_nested() {
+ [ -n "$PROTO_NESTED_OPEN" ] && json_close_object
+ PROTO_NESTED_OPEN=
+}
+
+proto_add_nested() {
+ PROTO_NESTED_OPEN=1
+ json_add_object "$1"
+}
- PROTO_TUNNEL_OPEN=1
- json_add_object "tunnel"
+proto_add_tunnel() {
+ proto_add_nested "tunnel"
}
proto_close_tunnel() {
- [ -n "$PROTO_TUNNEL_OPEN" ] || return
- json_close_object
- PROTO_TUNNEL_OPEN=
+ proto_close_nested
+}
+
+proto_add_data() {
+ proto_add_nested "data"
+}
+
+proto_close_data() {
+ proto_close_nested
}
proto_add_dns_server() {
@@ -152,7 +165,7 @@ _proto_notify() {
proto_send_update() {
local interface="$1"
- proto_close_tunnel
+ proto_close_nested
_proto_push_array "ipaddr" "$PROTO_IPADDR" _proto_push_ip
_proto_push_array "ip6addr" "$PROTO_IP6ADDR" _proto_push_ip
_proto_push_array "routes" "$PROTO_ROUTE" _proto_push_route