Ticket #1260: cidr+aliases.2.patch
File cidr+aliases.2.patch, 3.0 KB (added by me@…, 10 years ago) |
---|
-
package/base-files/files/bin/ipcalc.sh
old new 2 2 3 3 awk -f /usr/lib/common.awk -f - $* <<EOF 4 4 BEGIN { 5 ipaddr=ip2int(ARGV[1]) 6 netmask=ip2int(ARGV[2]) 5 slpos=index(ARGV[1],"/") 6 if (slpos == 0) { 7 ipaddr=ip2int(ARGV[1]) 8 netmask=ip2int(ARGV[2]) 9 } else { 10 ipaddr=ip2int(substr(ARGV[1],0,slpos-1)) 11 netmask=compl(2**(32-int(substr(ARGV[1],slpos+1)))-1) 12 ARGV[4]=ARGV[3] 13 ARGV[3]=ARGV[2] 14 } 7 15 network=and(ipaddr,netmask) 8 16 broadcast=or(network,compl(netmask)) 9 17 -
package/base-files/files/lib/network/config.sh
old new 142 142 static) 143 143 config_get ipaddr "$config" ipaddr 144 144 config_get netmask "$config" netmask 145 [ -z "$ipaddr" -o -z "$netmask" ] && return 1 145 [ -z "$ipaddr" ] && return 1 146 local IP NETMASK BROADCAST NETWORK PREFIX 147 eval $(ipcalc "$ipaddr" "$netmask") 146 148 147 149 config_get ip6addr "$config" ip6addr 148 150 config_get gateway "$config" gateway 149 151 config_get dns "$config" dns 150 152 config_get bcast "$config" broadcast 153 config_get aliases "$config" aliases 151 154 152 [ -z "$ipaddr" ] || $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask" broadcast "${bcast:-+}"155 $DEBUG ifconfig "$iface" "$IP" netmask "$NETMASK" broadcast "${bcast:-+}" 153 156 [ -z "$ip6addr" ] || $DEBUG ifconfig "$iface" add "$ip6addr" 154 157 [ -z "$gateway" ] || $DEBUG route add default gw "$gateway" 155 158 [ -z "$dns" ] || { … … 159 162 } 160 163 done 161 164 } 165 [ -z "$aliases" ] || { 166 i=1 167 for al in $aliases; do 168 eval $(ipcalc "$al") 169 $DEBUG ifconfig "$iface":$i "$IP" netmask "$NETMASK" broadcast "$BROADCAST" 170 ((i++)) 171 done 172 } 162 173 163 174 env -i ACTION="ifup" INTERFACE="$config" DEVICE="$iface" PROTO=static /sbin/hotplug-call "iface" & 164 175 ;;