add shell functions for adding tunnel data in proto notify
authorFelix Fietkau <nbd@openwrt.org>
Thu, 15 Mar 2012 00:54:09 +0000 (01:54 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 15 Mar 2012 00:54:09 +0000 (01:54 +0100)
dummy/netifd-proto.sh

index b04bc89a4d26d227349594aff8a5fb382863d4a5..69aa27d4eda34b7eee940691f74f57d2559c008b 100755 (executable)
@@ -44,6 +44,7 @@ proto_init_update() {
        local external="$3"
 
        PROTO_INIT=1
+       PROTO_TUNNEL_OPEN=
        PROTO_IPADDR=
        PROTO_IP6ADDR=
        PROTO_ROUTE=
@@ -57,6 +58,19 @@ proto_init_update() {
        [ -n "$3" ] && json_add_boolean "address-external" "$external"
 }
 
+proto_add_tunnel() {
+       proto_close_tunnel
+
+       PROTO_TUNNEL_OPEN=1
+       json_add_object "tunnel"
+}
+
+proto_close_tunnel() {
+       [ -n "$PROTO_TUNNEL_OPEN" ] || return
+       json_close_object
+       PROTO_TUNNEL_OPEN=
+}
+
 proto_add_dns_server() {
        local address="$1"
 
@@ -138,6 +152,7 @@ _proto_notify() {
 proto_send_update() {
        local interface="$1"
 
+       proto_close_tunnel
        _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