3 [ -x /usr/sbin/pppd ] || exit 0
5 [ -n "$INCLUDE_ONLY" ] || {
11 ppp_generic_init_config() {
12 proto_config_add_string "username"
13 proto_config_add_string "password"
14 proto_config_add_string "keepalive"
15 proto_config_add_int "demand"
16 proto_config_add_string "pppd_options"
17 proto_config_add_string "connect"
18 proto_config_add_string "disconnect"
19 proto_config_add_boolean "ipv6"
20 proto_config_add_boolean "authfail"
21 proto_config_add_int "mtu"
25 local config="$1"; shift
27 json_get_vars ipv6 demand keepalive username password pppd_options
28 [ "$ipv6" = 1 ] || ipv6=""
29 if [ "${demand:-0}" -gt 0 ]; then
30 demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
35 [ -n "$mtu" ] || json_get_var mtu mtu
37 local interval="${keepalive##*[, ]}"
38 [ "$interval" != "$keepalive" ] || interval=5
39 [ -n "$connect" ] || json_get_var connect connect
40 [ -n "$disconnect" ] || json_get_var disconnect disconnect
42 proto_run_command "$config" /usr/sbin/pppd \
43 nodetach ipparam "$config" \
44 ifname "${proto:-ppp}-$config" \
45 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
50 ${username:+user "$username" password "$password"} \
51 ${connect:+connect "$connect"} \
52 ${disconnect:+disconnect "$disconnect"} \
53 ip-up-script /lib/netifd/ppp-up \
54 ipv6-up-script /lib/netifd/ppp-up \
55 ip-down-script /lib/netifd/ppp-down \
56 ipv6-down-script /lib/netifd/ppp-down \
57 ${mtu:+mtu $mtu mru $mtu} \
61 ppp_generic_teardown() {
66 proto_notify_error "$interface" AUTH_FAILED
67 json_get_var authfail authfail
68 if [ "${authfail:-0}" -gt 0 ]; then
69 proto_block_restart "$interface"
73 proto_notify_error "$interface" INVALID_OPTIONS
74 proto_block_restart "$interface"
77 proto_kill_command "$interface"
80 # PPP on serial device
82 proto_ppp_init_config() {
83 proto_config_add_string "device"
84 ppp_generic_init_config
92 json_get_var device device
93 ppp_generic_setup "$config" "$device"
96 proto_ppp_teardown() {
97 ppp_generic_teardown "$@"
100 proto_pppoe_init_config() {
101 ppp_generic_init_config
102 proto_config_add_string "ac"
103 proto_config_add_string "service"
106 proto_pppoe_setup() {
110 for module in slhc ppp_generic pppox pppoe; do
111 /sbin/insmod $module 2>&- >&-
118 json_get_var service service
120 ppp_generic_setup "$config" \
122 ${ac:+rp_pppoe_ac "$ac"} \
123 ${service:+rp_pppoe_service "$service"} \
127 proto_pppoe_teardown() {
128 ppp_generic_teardown "$@"
131 proto_pppoa_init_config() {
132 ppp_generic_init_config
133 proto_config_add_int "atmdev"
134 proto_config_add_int "vci"
135 proto_config_add_int "vpi"
136 proto_config_add_string "encaps"
141 proto_pppoa_setup() {
145 for module in slhc ppp_generic pppox pppoatm; do
146 /sbin/insmod $module 2>&- >&-
149 json_get_vars atmdev vci vpi encaps
152 1|vc) encaps="vc-encaps" ;;
153 *) encaps="llc-encaps" ;;
156 ppp_generic_setup "$config" \
158 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
162 proto_pppoa_teardown() {
163 ppp_generic_teardown "$@"
166 proto_pptp_init_config() {
167 ppp_generic_init_config
168 proto_config_add_string "server"
177 local ip serv_addr server
178 json_get_var server server && {
179 for ip in $(resolveip -t 5 "$server"); do
180 ( proto_add_host_dependency "$config" "$ip" )
184 [ -n "$serv_addr" ] || {
185 echo "Could not resolve server address"
187 proto_setup_failed "$config"
192 for module in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp; do
193 grep -q "$module" /proc/modules && continue
194 /sbin/insmod $module 2>&- >&-
197 [ "$load" = "1" ] && sleep 1
199 ppp_generic_setup "$config" \
201 pptp_server $server \
202 file /etc/ppp/options.pptp
205 proto_pptp_teardown() {
206 ppp_generic_teardown "$@"
209 [ -n "$INCLUDE_ONLY" ] || {
211 [ -f /usr/lib/pppd/*/rp-pppoe.so ] && add_protocol pppoe
212 [ -f /usr/lib/pppd/*/pppoatm.so ] && add_protocol pppoa
213 [ -f /usr/lib/pppd/*/pptp.so ] && add_protocol pptp