/[baselayout]/trunk/net-scripts/net.modules.d/ifconfig
Gentoo

Diff of /trunk/net-scripts/net.modules.d/ifconfig

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 871 Revision 872
10 LC_ALL=C /sbin/ifconfig "$@" 10 LC_ALL=C /sbin/ifconfig "$@"
11} 11}
12 12
13ifconfig_tunnel() { 13ifconfig_tunnel() {
14 LC_ALL=C /sbin/iptunnel "$@" 14 LC_ALL=C /sbin/iptunnel "$@"
15}
16
17route() {
18 LC_ALL=C /sbin/route "$@"
15} 19}
16 20
17# void ifconfig_depend(void) 21# void ifconfig_depend(void)
18# 22#
19# Sets up the dependancies for the module 23# Sets up the dependancies for the module
110# void ifconfig_get_address(char *interface) 114# void ifconfig_get_address(char *interface)
111# 115#
112# Fetch the address retrieved by DHCP. If successful, echoes the 116# Fetch the address retrieved by DHCP. If successful, echoes the
113# address on stdout, otherwise echoes nothing. 117# address on stdout, otherwise echoes nothing.
114ifconfig_get_address() { 118ifconfig_get_address() {
115 ifconfig $1 | sed -ne 's/.*inet addr:\([^ ]*\).*/\1/p' 119 local -a x=( $( ifconfig $1 | sed -ne 's/.*inet addr:\([^ ]*\).*Mask:\([^ ]*\).*/\1 \2/p' ) )
120 x[1]=$( netmask2cidr ${x[1]} )
121 echo "${x[0]}/${x[1]}"
116} 122}
117 123
118# void ifconfig_get_mac_address(char *interface) 124# void ifconfig_get_mac_address(char *interface)
119# 125#
120# Fetch the mac address assingned to the network card 126# Fetch the mac address assingned to the network card
272 x=${x//via/gw} 278 x=${x//via/gw}
273 279
274 ebegin "${x}" 280 ebegin "${x}"
275 # Support adding IPv6 addresses easily 281 # Support adding IPv6 addresses easily
276 if [[ ${x} == *:* && ${x} != *'-A inet6'* ]]; then 282 if [[ ${x} == *:* && ${x} != *'-A inet6'* ]]; then
277 /sbin/route add -A inet6 ${x} &>${devnull} 283 route add -A inet6 ${x} &>${devnull}
278 else 284 else
279 /sbin/route add ${x} &>${devnull} 285 route add ${x} &>${devnull}
280 fi 286 fi
281 eend $? 287 eend $?
282 done 288 done
283 eoutdent 289 eoutdent
284 290
315 config=( "${config[@]//brd/broadcast}" ) 321 config=( "${config[@]//brd/broadcast}" )
316 config=( "${config[@]//peer/pointtopoint}" ) 322 config=( "${config[@]//peer/pointtopoint}" )
317 fi 323 fi
318 324
319 ifconfig ${iface} ${config[@]} &>${devnull} 325 ifconfig ${iface} ${config[@]} &>${devnull}
320 eend $?
321 return $? 326 return $?
322} 327}
328
329# void ifconfig_default_route(char* gateway_ip)
330#
331# Force default route to the specified gateway
332ifconfig_default_route() {
333 # Delete any existing default routes
334 while true ; do
335 route del default metric 0 2>/dev/null || break
336 done
337
338 # Then we add our route
339 route add default gw $1 metric 0
340}

Legend:
Removed from v.871  
changed lines
  Added in v.872

  ViewVC Help
Powered by ViewVC 1.1.20