map: make tunnel encapsulation limit support configurable (FS#1501)
[openwrt/openwrt.git] / package / network / ipv6 / map / files / map.sh
index 42050183ce6cb328aee335df99b528593e1a4a32..5f4add36eb80210b41375ac865aadbc79804903f 100755 (executable)
@@ -28,9 +28,9 @@ proto_map_setup() {
        # uncomment for legacy MAP0 mode
        #export LEGACY=1
 
-       local type mtu ttl tunlink zone
+       local type mtu ttl tunlink zone encaplimit
        local rule ipaddr ip4prefixlen ip6prefix ip6prefixlen peeraddr ealen psidlen psid offset
-       json_get_vars type mtu ttl tunlink zone
+       json_get_vars type mtu ttl tunlink zone encaplimit
        json_get_vars rule ipaddr ip4prefixlen ip6prefix ip6prefixlen peeraddr ealen psidlen psid offset
 
        [ -z "$zone" ] && zone="wan"
@@ -84,9 +84,9 @@ proto_map_setup() {
                json_add_string local $(eval "echo \$RULE_${k}_IPV6ADDR")
                json_add_string remote $(eval "echo \$RULE_${k}_BR")
                json_add_string link $(eval "echo \$RULE_${k}_PD6IFACE")
-
-               if [ "$type" = "map-e" ]; then
-                       json_add_object "data"
+               json_add_object "data"
+                       json_add_string encaplimit "${encaplimit:-4}"
+                       if [ "$type" = "map-e" ]; then
                                json_add_array "fmrs"
                                for i in $(seq $RULE_COUNT); do
                                        [ "$(eval "echo \$RULE_${i}_FMR")" != 1 ] && continue
@@ -98,8 +98,9 @@ proto_map_setup() {
                                        json_close_object
                                done
                                json_close_array
-                       json_close_object
-               fi
+                       fi
+               json_close_object
+
 
                proto_close_tunnel
        elif [ "$type" = "map-t" -a -f "/proc/net/nat46/control" ]; then
@@ -229,6 +230,7 @@ proto_map_init_config() {
        proto_config_add_int "mtu"
        proto_config_add_int "ttl"
        proto_config_add_string "zone"
+       proto_config_add_string "encaplimit"
 }
 
 [ -n "$INCLUDE_ONLY" ] || {