6to4: Tos support
[openwrt/staging/chunkeey.git] / package / network / ipv6 / 6to4 / files / 6to4.sh
index 145f78a23987e14d2f94a9a182683b2b120ddf41..ce1de53ea851d405bdf2303ee00d0ddb3d2c919e 100755 (executable)
@@ -34,8 +34,8 @@ proto_6to4_setup() {
        local iface="$2"
        local link="6to4-$cfg"
 
-       local mtu ttl ipaddr
-       json_get_vars mtu ttl ipaddr
+       local mtu ttl tos ipaddr sourcerouting
+       json_get_vars mtu ttl tos ipaddr sourcerouting
 
        ( proto_add_host_dependency "$cfg" 0.0.0.0 )
 
@@ -63,12 +63,21 @@ proto_6to4_setup() {
 
        proto_init_update "$link" 1
        proto_add_ipv6_address "$local6" 16
-       proto_add_ipv6_route "::" 0 "::192.88.99.1"
+       proto_add_ipv6_prefix "$prefix6::/48"
+
+       if [ "$sourcerouting" != "0" ]; then
+               proto_add_ipv6_route "::" 0 "::192.88.99.1" "" "" "::/128"
+               proto_add_ipv6_route "::" 0 "::192.88.99.1" "" "" "$local6/16"
+               proto_add_ipv6_route "::" 0 "::192.88.99.1" "" "" "$prefix6::/48"
+       else
+               proto_add_ipv6_route "::" 0 "::192.88.99.1"
+       fi
 
        proto_add_tunnel
        json_add_string mode sit
        json_add_int mtu "${mtu:-1280}"
        json_add_int ttl "${ttl:-64}"
+       [ -n "$tos" ] && json_add_string tos "$tos"
        json_add_string local "$ipaddr"
        proto_close_tunnel
 
@@ -86,6 +95,8 @@ proto_6to4_init_config() {
        proto_config_add_string "ipaddr"
        proto_config_add_int "mtu"
        proto_config_add_int "ttl"
+       proto_config_add_string "tos"
+       proto_config_add_boolean "sourcerouting"
 }
 
 [ -n "$INCLUDE_ONLY" ] || {