-scan_ppp() {
- config_get ifname "$1" ifname
- pppdev="${pppdev:-0}"
- config_set "$1" ifname "ppp$pppdev"
- config_set "$1" unit "$pppdev"
-}
-
-start_pppd() {
- local cfg="$1"; shift
-
- # make sure only one pppd process is started
- lock "/var/lock/ppp-${cfg}"
- local pid="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
- [ -d "/proc/$pid" ] && grep pppd "/proc/$pid/cmdline" 2>/dev/null >/dev/null && {
- lock -u "/var/lock/ppp-${cfg}"
- return 0
- }
-
- config_get device "$cfg" device
- config_get unit "$cfg" unit
- config_get username "$cfg" username
- config_get password "$cfg" password
- config_get keepalive "$cfg" keepalive
-
- config_get connect "$cfg" connect
- config_get disconnect "$cfg" disconnect
-
- interval="${keepalive##*[, ]}"
+#!/bin/sh
+
+[ -x /usr/sbin/pppd ] || exit 0
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /etc/functions.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+ppp_generic_init_config() {
+ proto_config_add_string "username"
+ proto_config_add_string "password"
+ proto_config_add_string "keepalive"
+ proto_config_add_int "demand"
+ proto_config_add_string "pppd_options"
+ proto_config_add_string "connect"
+ proto_config_add_string "disconnect"
+ proto_config_add_boolean "defaultroute"
+ proto_config_add_boolean "peerdns"
+ proto_config_add_boolean "ipv6"
+ proto_config_add_int "mtu"
+}
+
+ppp_generic_setup() {
+ local config="$1"; shift
+
+ json_get_var ipv6 ipv6
+ [ "$ipv6" = 1 ] || ipv6=""
+
+ json_get_var peerdns peerdns
+ [ "$peerdns" = 0 ] && peerdns="" || peerdns="1"
+
+ json_get_var defaultroute defaultroute
+ if [ "$defaultroute" = 1 ]; then
+ defaultroute="defaultroute replacedefaultroute";
+ else
+ defaultroute="nodefaultroute"
+ fi
+
+ json_get_var demand demand
+ if [ "${demand:-0}" -gt 0 ]; then
+ demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
+ else
+ demand="persist"
+ fi
+
+ [ -n "$mtu" ] || json_get_var mtu mtu
+
+ json_get_var keepalive keepalive
+ local interval="${keepalive##*[, ]}"