ln -svf ip-updown $(DESTDIR)/etc/ppp/ip-pre-up
ln -svf ip-updown $(DESTDIR)/etc/ppp/ip-up
ln -svf ip-updown $(DESTDIR)/etc/ppp/ip-down
+ ln -svf ip-updown ${DESTDIR}/etc/ppp/ipv6-up
+ ln -svf ip-updown ${DESTDIR}/etc/ppp/ipv6-down
install -m 755 -v ppp/dialer $(DESTDIR)/etc/ppp
dist:
return ${EXIT_ERROR}
fi
- # XXX protocol hardcoded
routing_db_from_ppp ${zone} ipv4
# Request firewall reload
return ${EXIT_ERROR}
fi
- # XXX protocol is hardcoded
routing_db_set ${zone} ipv4 active 1
routing_update ${zone} ipv4
return ${EXIT_ERROR}
fi
+ # Remove the information about this zone from the routing database
+ # and update the routing table.
+ routing_db_remove ${zone} ipv4
+ routing_update ${zone} ipv4
+
+ # Save accounting information
+ ppp_accounting ${zone}
+
+ # Emit interface-up event
+ event_interface_down ${zone}
+
+ return ${EXIT_OK}
+}
+
+function ppp_common_ipv6_up() {
+ local zone=${1}
+ shift
+
+ if ! zone_exists ${zone}; then
+ error "Zone '${zone}' does not exist."
+ return ${EXIT_ERROR}
+ fi
+
+ # Add information about this zone to the routing database.
+ routing_db_from_ppp ${zone} ipv6
+
+ routing_db_set ${zone} ipv6 active 1
+ routing_update ${zone} ipv6
+
+ # Emit interface-up event
+ event_interface_up ${zone}
+
+ return ${EXIT_OK}
+}
+
+function ppp_common_ipv6_down() {
+ local zone=${1}
+ shift
+
+ if ! zone_exists ${zone}; then
+ error "Zone '${zone}' does not exist."
+ return ${EXIT_ERROR}
+ fi
+
+ # Remove the information about this zone from the routing database
+ # and update the routing table.
+ routing_db_remove ${zone} ipv6
+ routing_update ${zone} ipv6
+
# Save accounting information
ppp_accounting ${zone}
fi
local gateway
+ local proto
local weight
local zone
- local proto="ipv4"
+ for proto in ${IP_SUPPORTED_PROTOCOLS}; do
+ # Clear routes
+ routes=""
- for zone in ${zones}; do
- # Skip if zone is not up
- routing_db_exists ${zone} ${proto} || continue
+ for zone in ${zones}; do
+ # Skip if zone is not up
+ routing_db_exists ${zone} ${proto} || continue
- if [ "$(routing_db_get ${zone} ${proto} active)" = "1" ]; then
- gateway=$(routing_db_get ${zone} ${proto} remote-ip-address)
- weight=$(routing_db_get ${zone} ${proto} weight)
+ if [ "$(routing_db_get ${zone} ${proto} active)" = "1" ]; then
+ gateway=$(routing_db_get ${zone} ${proto} remote-ip-address)
+ weight=$(routing_db_get ${zone} ${proto} weight)
- routes="${routes} nexthop via ${gateway}"
+ routes="${routes} nexthop via ${gateway}"
- if [ -n "${weight}" ]; then
- routes="${routes} weight ${weight}"
+ if [ -n "${weight}" ]; then
+ routes="${routes} weight ${weight}"
+ fi
+ else
+ log DEBUG "Ignoring zone '${zone}' which is not active."
fi
- else
- log DEBUG "Ignoring zone '${zone}' which is not active."
- fi
- done
+ done
- if [ -z "${routes}" ]; then
- log INFO "Removing default route."
+ if [ -z "${routes}" ]; then
+ log INFO "Removing default route for ${proto}."
- if routing_has_default; then
- ip route del default
+ if routing_has_default; then
+ ip route del default
+ fi
+ return ${EXIT_OK}
fi
- return ${EXIT_OK}
- fi
- # Remove too much spaces.
- routes=$(echo ${routes})
+ # Remove too much spaces.
+ routes=$(echo ${routes})
- log INFO "Setting default route: ${routes}"
+ log INFO "Setting default route for ${proto}: ${routes}"
- ip route replace default ${routes}
+ ip $([ "${proto}" = "ipv6" ] && echo "-6") route replace default ${routes}
+ assert [ $? -eq 0 ]
+ done
}
function routing_table_exists() {
# Save ppp configuration
routing_db_set ${zone} ${proto} type "ppp"
- routing_db_set ${zone} ${proto} local-ip-address ${PPP_IPLOCAL}
- routing_db_set ${zone} ${proto} remote-ip-address ${PPP_IPREMOTE}
+
+ if [ "${proto}" = "ipv6" ]; then
+ routing_db_set ${zone} ${proto} local-ip-address ${PPP_LLLOCAL}
+ routing_db_set ${zone} ${proto} remote-ip-address ${PPP_LLREMOTE}
+ elif [ "${proto}" = "ipv4" ]; then
+ routing_db_set ${zone} ${proto} local-ip-address ${PPP_IPLOCAL}
+ routing_db_set ${zone} ${proto} remote-ip-address ${PPP_IPREMOTE}
+ fi
routing_db_set ${zone} ${proto} dns ${PPP_DNS1} ${PPP_DNS2}
exit $?
}
+function _ppp-ipv6-up() {
+ local zone=${1}
+ shift
+
+ if ! zone_exists ${zone}; then
+ error "Zone '${zone}' does not exist."
+ exit ${EXIT_ERROR}
+ fi
+
+ ppp_common_ipv6_up ${zone} $@
+
+ exit $?
+}
+
+function _ppp-ipv6-down() {
+ local zone=${1}
+ shift
+
+ if ! zone_exists ${zone}; then
+ error "Zone '${zone}' does not exist."
+ exit ${EXIT_ERROR}
+ fi
+
+ ppp_common_ipv6_down ${zone} $@
+
+ exit $?
+}
+
function run() {
# Replace all dashes by an underscore
#action=${action//-/_}
;;
# ppp daemon callbacks
- ppp-ip-pre-up|ppp-ip-up|ppp-ip-down)
+ ppp-ip-pre-up|ppp-ip-up|ppp-ip-down|ppp-ipv6-up|ppp-ipv6-down)
_${action} $@
;;
AUTH=
DEFAULTROUTE=1
+IPV6=1
LINKNAME="$(uuid)"
MTU=1492
PEERDNS=1
#assert isset DEVICE_TYPE
assert isbool DEFAULTROUTE
+ assert isbool IPV6
assert isbool PEERDNS
#assert ismac DEVICE
#assert isoneof DEVICE_TYPE real virtual
--auth=*)
AUTH=${1#--auth=}
;;
+ --ipv6=*)
+ IPV6=${1#--ipv6=}
+ ;;
*)
echo "Unknown option: $1" >&2
exit ${EXIT_ERROR}
plugin ${PPPOE_PLUGIN} ${port}
+# Enable/disable IPv6
+$(enabled IPV6 && echo "+" || echo "-")ipv6
+
# User configuration
user ${USER}
printf "${DEVICE_PRINT_LINE1}" "Secret:" "<hidden>"
echo
printf "${DEVICE_PRINT_LINE1}" "MTU:" "${MTU}"
+ printf "${DEVICE_PRINT_LINE1}" "IPv6:" "$(enabled IPV6 && echo "enabled" || echo "disabled")"
printf "${DEVICE_PRINT_LINE1}" "Use default route?" "$(enabled DEFAULTROUTE && echo "enabled" || echo "disabled")"
printf "${DEVICE_PRINT_LINE1}" "Use peer DNS?" "$(enabled PEERDNS && echo "enabled" || echo "disabled")"
echo
# XXX display time since connection started
cli_headline " Point-to-Point-over-Ethernet protocol:"
- echo " IP-Address : $(routing_db_get ${zone} local-ip-address)"
- echo " Gateway : $(routing_db_get ${zone} remote-ip-address)"
- echo " DNS-Server : $(routing_db_get ${zone} dns)"
- echo
- echo " MAC-Remote : $(routing_db_get ${zone} remote-address)"
- echo
+ local proto
+ for proto in ${IP_SUPPORTED_PROTOCOLS}; do
+ routing_db_exists ${zone} ${proto} || continue
+ if [ "${proto}" = "ipv6" ]; then
+ echo " Internet Protocol Version 6:"
+ elif [ "${proto}" = "ipv4" ]; then
+ echo " Internet Protocol Version 4:"
+ fi
+ echo " IP-Address : $(routing_db_get ${zone} ${proto} local-ip-address)"
+ echo " Gateway : $(routing_db_get ${zone} ${proto} remote-ip-address)"
+ echo " DNS-Server : $(routing_db_get ${zone} ${proto} dns)"
+ echo
+ echo " MAC-Remote : $(routing_db_get ${zone} ${proto} remote-address)"
+ echo
+ done
echo " MTU : $(device_get_mtu ${zone})"
echo # Empty line
exit ${EXIT_OK}
export PATH=/usr/sbin:/sbin:/usr/bin:/bin
# Give the variables we get passed by pppd an own namespace
-for i in IFNAME IPLOCAL IPREMOTE DNS1 DNS2 MACREMOTE; do
+for i in IFNAME IPLOCAL IPREMOTE DNS1 DNS2 MACREMOTE LLLOCAL LLREMOTE; do
export PPP_${i}=${!i}
unset ${i}
done
assert isset HOOK
assert hook_zone_exists ${HOOK}
-hook_zone_exec ${HOOK} ppp-$(basename ${0}) ${ZONE}
+PROGNAME=$(basename ${0})
+assert isset PROGNAME
+
+log DEBUG "${PROGNAME} was called with the following parameters:"
+log DEBUG " $@"
+
+hook_zone_exec ${HOOK} ppp-${PROGNAME} ${ZONE}