dhclient - Stray '$medium' missed in last commit.
[dragonfly.git] / sbin / dhclient / dhclient-script
index a7a203f..4f175c6 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/sh
 #
-# $OpenBSD: dhclient-script,v 1.12 2007/08/11 17:58:55 krw Exp $
-# $DragonFly: src/sbin/dhclient/dhclient-script,v 1.1 2008/08/30 16:07:58 hasso Exp $
+# $OpenBSD: src/sbin/dhclient/dhclient-script,v 1.20 2011/04/04 11:29:51 krw Exp $
 #
 # Copyright (c) 2003 Kenneth R Westerback <krw@openbsd.org>
 #
@@ -25,8 +24,8 @@
 
 delete_old_address() {
        if [ -n "$old_ip_address" ]; then
-               ifconfig $interface inet $old_ip_address delete $medium
-               route delete "$old_ip_address" 127.0.0.1 >/dev/null 2>&1
+               ifconfig $interface inet $old_ip_address delete
+               #route delete "$old_ip_address" 127.0.0.1 >/dev/null 2>&1
        fi
 }
 
@@ -34,33 +33,13 @@ add_new_address() {
        ifconfig $interface \
                inet $new_ip_address \
                netmask $new_subnet_mask \
-               broadcast $new_broadcast_address \
-               $medium
+               broadcast $new_broadcast_address
 
        # XXX Original TIMEOUT code did not do this unless $new_routers was set?
-       route add $new_ip_address 127.0.0.1 >/dev/null 2>&1
-}
-
-delete_old_alias() {
-       if [ -n "$alias_ip_address" ]; then
-               ifconfig $interface inet $alias_ip_address delete > /dev/null 2>&1
-               route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
-       fi
-}
-
-add_new_alias() {
-       if [ -n "$alias_ip_address" ]; then
-               ifconfig $interface inet $alias_ip_address alias netmask \
-                   $alias_subnet_mask
-               route add $alias_ip_address 127.0.0.1
-       fi
+       #route add $new_ip_address 127.0.0.1 >/dev/null 2>&1
 }
 
 delete_old_routes() {
-       # Delete existing default route. We only allow one, so no need to
-       # process $old_routers list.
-       route delete default >/dev/null 2>&1
-
        if [ -n "$old_static_routes" ]; then
                set $old_static_routes
                while [ $# -gt 1 ]; do
@@ -73,12 +52,12 @@ delete_old_routes() {
 }
 
 add_new_routes() {
-       route delete default >/dev/null 2>&1
        for router in $new_routers; do
+               route -q delete default
                if [ "$new_ip_address" = "$router" ]; then
-                       route add default -iface $router >/dev/null 2>&1
+                       route -q add default -iface $router
                else
-                       route add default $router >/dev/null 2>&1
+                       route -q add default $router
                fi
                # 2nd and subsequent default routers error out, so explicitly
                # stop processing the list after the first one.
@@ -95,11 +74,9 @@ add_new_routes() {
 }
 
 add_new_resolv_conf() {
-       # XXX Old code did not create/update resolv.conf unless both
-       # $new_domain_name and $new_domain_name_servers were provided.  PR
-       # #3135 reported some ISPs only provide $new_domain_name_servers and
-       # thus broke the script. This code creates the resolv.conf if either
-       # are provided.
+       # Create resolv.conf when either $new_domain_name_servers or
+       # $new_domain_name are provided. As reported in PR#3135, some ISPs
+       # provide only $new_domain_name_servers.
 
        rm -f /etc/resolv.conf.std
 
@@ -144,23 +121,25 @@ add_new_resolv_conf() {
 
 case $reason in
 MEDIUM)
-       ifconfig $interface $medium
-       sleep 1
+       # Not called by OpenBSD dhclient(8).
        ;;
 
 PREINIT)
-       delete_old_alias
-       ifconfig $interface up
+       # Not called by OpenBSD dhclient(8).
+       ;;
+
+ARPSEND)
+       # Not called by OpenBSD dhclient(8).
+       exit 1
        ;;
 
-ARPCHECK|ARPSEND)
+ARPCHECK)
+       # Not called by OpenBSD dhclient(8).
+       # Always succeed. i.e. accept lease.
        ;;
 
 BOUND|RENEW|REBIND|REBOOT)
        if [ -n "$old_ip_address" ]; then
-               if [ "$old_ip_address" != "$alias_ip_address" ]; then
-                       delete_old_alias
-               fi
                if [ "$old_ip_address" != "$new_ip_address" ]; then
                        delete_old_address
                        delete_old_routes
@@ -173,42 +152,32 @@ BOUND|RENEW|REBIND|REBOOT)
                add_new_address
                add_new_routes
        fi
-       if [ "$new_ip_address" != "$alias_ip_address" ]; then
-               add_new_alias
-       fi
        add_new_resolv_conf
        ;;
 
 EXPIRE|FAIL)
-       delete_old_alias
        if [ -n "$old_ip_address" ]; then
                delete_old_address
                delete_old_routes
        fi
-       # XXX Why add alias we just deleted above?
-       add_new_alias
        if [ -f /etc/resolv.conf.save ]; then
                cat /etc/resolv.conf.save > /etc/resolv.conf
        fi
        ;;
 
 TIMEOUT)
-       delete_old_alias
        add_new_address
        sleep 1
        if [ -n "$new_routers" ]; then
                set "$new_routers"
                if ping -q -c 1 -w 1 "$1"; then
-                       if [ "$new_ip_address" != "$alias_ip_address" ]; then
-                               add_new_alias
-                       fi
                        add_new_routes
                        if add_new_resolv_conf; then
                                exit 0
                        fi
                fi
        fi
-       ifconfig $interface inet $new_ip_address delete $medium
+       ifconfig $interface inet $new_ip_address delete
        # XXX Why not a delete_old_address as before all other invocations of
        #     delete_old_routes?
        delete_old_routes