]> git.ipfire.org Git - network.git/blobdiff - ppp/ip-updown
Merge branch 'master' into 6rd-new
[network.git] / ppp / ip-updown
index cc746a13f7032718203f962e48124fd731b32cb1..9c1ac7e1d1a6a82b0cce0acb27c03a1d16d169d7 100755 (executable)
 #                                                                             #
 ###############################################################################
 
+LOG_FACILITY=$(basename ${0})
+
 umask 022
-export PATH=/usr/sbin:/sbin:/usr/bin:/bin
 
-exec &>/tmp/network.$(basename $0)
+PPP_VARIABLES="IFNAME IPLOCAL IPREMOTE DNS1 DNS2 MACREMOTE LLLOCAL LLREMOTE"
 
 # Give the variables we get passed by pppd an own namespace
-for i in IFNAME IPLOCAL IPREMOTE DNS1 DNS2 MACREMOTE; do
+for i in ${PPP_VARIABLES}; do
        export PPP_${i}=${!i}
        unset ${i}
 done
 
-. /lib/network/functions
+. /usr/lib/network/functions
+
+log DEBUG "Called."
+for i in ${PPP_VARIABLES}; do
+       i="PPP_${i}"
+       log DEBUG "  ${i} = ${!i}"
+done
 
 # Zone equals IFNAME
 ZONE=${PPP_IFNAME}
 
-assert isset ZONE
+# If the given device is a known zone, we will call the required
+# hook methods. If we don't know about any zone with name ${ZONE},
+# we do nothing.
 
-if ! zone_exists ${ZONE}; then
-       error "Zone '${ZONE}' does not exist."
-       exit ${EXIT_ERROR}
-fi
+if isset ZONE && zone_exists ${ZONE}; then
+       HOOK=$(zone_get_hook ${ZONE})
+
+       assert isset HOOK
+       assert hook_zone_exists ${HOOK}
 
-HOOK=$(zone_get_hook ${ZONE})
+       PROGNAME=$(basename ${0})
+       METHOD=""
+       case "${PROGNAME}" in
+               ip-pre-up)
+                       METHOD="ppp_ip_pre_up"
+                       ;;
+               ipv6-down)
+                       METHOD="ppp_ipv6_down"
+                       ;;
+               ipv6-up)
+                       METHOD="ppp_ipv6_up"
+                       ;;
+               ip-down)
+                       METHOD="ppp_ipv4_down"
+                       ;;
+               ip-up)
+                       METHOD="ppp_ipv4_up"
+                       ;;
+       esac
+       assert isset METHOD
 
-assert isset HOOK
+       log DEBUG "${PROGNAME}/${METHOD} was called with the following parameters:"
+       log DEBUG "  $@"
 
-if ! hook_zone_exists ${HOOK}; then
-       error "Hook '${HOOK}' does not exist."
-       exit ${EXIT_ERROR}
+       hook_zone_exec "${HOOK}" "${METHOD}" "${ZONE}"
+       exit $?
 fi
 
-hook_zone_exec ${HOOK} ppp-$(basename ${0}) ${ZONE}
+exit ${EXIT_OK}