Changeset 24220
- Timestamp:
- 2010-12-02T23:42:16+01:00 (7 years ago)
- Location:
- branches/backfire/package/6to4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/backfire/package/6to4/Makefile
r24023 r24220 9 9 10 10 PKG_NAME:=6to4 11 PKG_VERSION:= 211 PKG_VERSION:=3 12 12 PKG_RELEASE:=1 13 13 -
branches/backfire/package/6to4/files/6to4.sh
r24023 r24220 18 18 printf "2002:%02x%02x:%02x%02x\n" $1 $2 $3 $4 19 19 } 20 21 set_6to4_radvd_interface() { 22 local cfgid="$1" 23 local lanif="${2:-lan}" 24 local ifsection="" 25 26 find_ifsection() { 27 local net 28 local cfg="$1" 29 config_get net "$cfg" interface 30 31 [ "$net" = "$lanif" ] && { 32 ifsection="$cfg" 33 return 1 34 } 35 } 36 37 config_foreach find_ifsection interface 38 39 [ -z "$ifsection" ] && { 40 ifsection="iface_$sid" 41 uci_set_state radvd "$ifsection" "" interface 42 uci_set_state radvd "$ifsection" interface "$lanif" 43 } 44 45 uci_set_state radvd "$ifsection" ignore 0 46 uci_set_state radvd "$ifsection" IgnoreIfMissing 1 47 uci_set_state radvd "$ifsection" AdvSendAdvert 1 48 uci_set_state radvd "$ifsection" MaxRtrAdvInterval 30 49 } 50 51 set_6to4_radvd_prefix() { 52 local cfgid="$1" 53 local lanif="${2:-lan}" 54 local wanif="${3:-wan}" 55 local prefix="${4:-0:0:0:1::/64}" 56 local pfxsection="" 57 58 find_pfxsection() { 59 local net base 60 local cfg="$1" 61 config_get net "$cfg" interface 62 config_get base "$cfg" Base6to4Interface 63 64 [ "$net" = "$lanif" ] && [ "$base" = "$wanif" ] && { 65 pfxsection="$cfg" 66 return 1 67 } 68 } 69 70 config_foreach find_pfxsection prefix 71 72 [ -z "$pfxsection" ] && { 73 pfxsection="prefix_${sid}_${lanif}" 74 uci_set_state radvd "$pfxsection" "" prefix 75 uci_set_state radvd "$pfxsection" ignore 0 76 uci_set_state radvd "$pfxsection" interface "$lanif" 77 uci_set_state radvd "$pfxsection" prefix "$prefix" 78 uci_set_state radvd "$pfxsection" AdvOnLink 1 79 uci_set_state radvd "$pfxsection" AdvAutonomous 1 80 uci_set_state radvd "$pfxsection" AdvValidLifetime 300 81 uci_set_state radvd "$pfxsection" AdvPreferredLifetime 120 82 uci_set_state radvd "$pfxsection" Base6to4Interface "$wanif" 83 } 84 } 85 20 86 21 87 # Hook into scan_interfaces() to synthesize a .device option … … 99 165 } 100 166 101 # find delegation target 102 local adv_interface 103 config_get adv_interface "$cfg" adv_interface 104 105 local adv_ifname 106 config_get adv_ifname "${adv_interface:-lan}" ifname 107 108 local adv_subnet=$(uci_get network "$cfg" adv_subnet) 109 110 grep -qs "^ *$adv_ifname:" /proc/net/dev && { 111 local subnet6="$prefix6:${adv_subnet:-1}::1/64" 112 113 logger -t "$link" " * Advertising IPv6 subnet $subnet6 on ${adv_interface:-lan} ($adv_ifname)" 114 ip -6 addr add $subnet6 dev $adv_ifname 115 uci_set_state network "$cfg" adv_subnet "$subnet6" 116 uci_set_state network "$cfg" adv_ifname "$adv_ifname" 117 118 [ -f /etc/config/radvd ] && /etc/init.d/radvd enabled && { 119 local sid="6to4_$cfg" 120 121 uci -q batch <<-EOF 122 revert radvd.iface_$sid 123 revert radvd.prefix_$sid 124 set radvd.iface_$sid=interface 125 set radvd.iface_$sid.ignore=0 126 set radvd.iface_$sid.interface=${adv_interface:-lan} 127 set radvd.iface_$sid.IgnoreIfMissing=1 128 set radvd.iface_$sid.AdvSendAdvert=1 129 set radvd.iface_$sid.MaxRtrAdvInterval=30 130 set radvd.prefix_$sid=prefix 131 set radvd.prefix_$sid.ignore=0 132 set radvd.prefix_$sid.interface=${adv_interface:-lan} 133 set radvd.prefix_$sid.prefix=0:0:0:${adv_subnet:-1}::/64 134 set radvd.prefix_$sid.AdvOnLink=1 135 set radvd.prefix_$sid.AdvAutonomous=1 136 set radvd.prefix_$sid.AdvValidLifetime=300 137 set radvd.prefix_$sid.AdvPreferredLifetime=120 138 set radvd.prefix_$sid.Base6to4Interface=$wancfg 139 EOF 140 141 /etc/init.d/radvd restart 142 } 167 [ -f /etc/config/radvd ] && /etc/init.d/radvd enabled && { 168 local sid="6to4_$cfg" 169 170 uci_revert_state radvd 171 config_load radvd 172 173 # find delegation target 174 local adv_interface 175 config_get adv_interface "$cfg" adv_interface 176 177 local adv_subnet=$(uci_get network "$cfg" adv_subnet) 178 adv_subnet=$((0x${adv_subnet:-1})) 179 180 local adv_subnets="" 181 182 for adv_interface in ${adv_interface:-lan}; do 183 local adv_ifname 184 config_get adv_ifname "${adv_interface:-lan}" ifname 185 186 grep -qs "^ *$adv_ifname:" /proc/net/dev && { 187 local subnet6="$(printf "%s:%x::1/64" "$prefix6" $adv_subnet)" 188 189 logger -t "$link" " * Advertising IPv6 subnet $subnet6 on ${adv_interface:-lan} ($adv_ifname)" 190 ip -6 addr add $subnet6 dev $adv_ifname 191 192 set_6to4_radvd_interface "$sid" "$adv_interface" 193 set_6to4_radvd_prefix "$sid" "$adv_interface" \ 194 "$wancfg" "$(printf "0:0:0:%x::/64" $adv_subnet)" 195 196 adv_subnets="${adv_subnets:+$adv_subnets }$adv_ifname:$subnet6" 197 adv_subnet=$(($adv_subnet + 1)) 198 } 199 done 200 201 uci_set_state network "$cfg" adv_subnets "$adv_subnets" 202 203 /etc/init.d/radvd restart 143 204 } 144 205 … … 158 219 local defaultroute=$(uci_get_state network "$cfg" defaultroute) 159 220 160 local adv_subnet=$(uci_get_state network "$cfg" adv_subnet) 161 local adv_ifname=$(uci_get_state network "$cfg" adv_ifname) 221 local adv_subnets=$(uci_get_state network "$cfg" adv_subnets) 162 222 163 223 grep -qs "^ *$link:" /proc/net/dev && { … … 165 225 env -i ACTION="ifdown" INTERFACE="$cfg" DEVICE="$link" PROTO=6to4 /sbin/hotplug-call "iface" & 166 226 167 [ -n "$adv_subnet" ] && [ -n "$adv_ifname" ] && { 168 local sid="6to4_$cfg" 169 170 uci -q batch <<-EOF 171 revert radvd.iface_$sid 172 revert radvd.prefix_$sid 173 EOF 174 227 [ -n "$adv_subnets" ] && { 228 uci_revert_state radvd 175 229 /etc/init.d/radvd enabled && /etc/init.d/radvd restart 176 230 177 ip -6 addr del $adv_subnet dev $adv_ifname 231 local adv_subnet 232 for adv_subnet in $adv_subnets; do 233 local ifname="${adv_subnet%%:*}" 234 local subnet="${adv_subnet#*:}" 235 236 logger -t "$link" " * Removing IPv6 subnet $subnet from interface $ifname" 237 ip -6 addr del $subnet dev $ifname 238 done 178 239 } 179 240
Note: See TracChangeset
for help on using the changeset viewer.