View | Details | Raw Unified
Collapse All | Expand All

(-) dhclient-script.orig (-1 / +70 lines)
 Lines 135-140    Link Here 
  exit_with_hooks 0
  exit_with_hooks 0
fi
fi
  
  
# simple IP arithmetic functions:
function quad2num()
{
    if [ $# -eq 4 ]; then
       let n="$1<<24|$2<<16|$3<<8|$4"
       echo $n;
       return 0;
    fi
    echo '0';
    return 1;
}
function ip2num()
{
    IFS='.' quad2num $1;
}
function num2ip()
{
    let n="$1";
    let o1='(n>>24)&0xff';
    let o2='(n>>16)&0xff';
    let o3='(n>>8)&0xff';
    let o4='n & 0xff';
    echo $o1.$o2.$o3.$o4;
}
function mask()
{   
    ip=$1
    m=$2
    let ip=`IFS='.' ip2num $ip`;
    let m=`IFS='.' ip2num $m`;
    let n='ip&m';
    num2ip $n;
}
function routerReachable()
{ # Handle silly DHCP servers that give us a router not on our subnet:    
    router=$1
    routerSubnet=`mask $router $new_subnet_mask`
    mySubnet=`mask $new_ip_address $new_subnet_mask`
    unreachable=0
    if [ "$routerSubnet" != "$mySubnet" ]; then
	unreachable=1
	if /sbin/arping -f -q -I $interface -w2 $router; then
	    /sbin/route add ${router}/32 dev $interface
	    if [ $? -eq 0 ]; then
		unreachable=0
	    fi
	else
	    unreachable=1
	fi;
    fi;
    return $unreachable;
}
function add_default_gateway()
{
    router=$1
    metric=$2
    if routerReachable $router ; then
	/sbin/route add default gw $router $metric dev $interface;
	return $?;
    fi;
    return 1;
}
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
   [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
  current_hostname=`hostname`
  current_hostname=`hostname`
 Lines 172-178    Link Here 
      	dev $interface
      	dev $interface
    fi
    fi
    for router in $new_routers; do
    for router in $new_routers; do
      route add default gw $router $metric_arg dev $interface
      add_default_gateway $router $metric_arg
    done
    done
  fi
  fi
  if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];
  if [ x$new_ip_address != x$alias_ip_address ] && [ x$alias_ip_address != x ];