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_boolean keepalive_adaptive
16 proto_config_add_int demand
17 proto_config_add_string pppd_options
18 proto_config_add_string
'connect:file'
19 proto_config_add_string
'disconnect:file'
20 proto_config_add_string ipv6
21 proto_config_add_boolean authfail
22 proto_config_add_int mtu
23 proto_config_add_string pppname
27 local config
="$1"; shift
29 json_get_vars ipv6 demand keepalive keepalive_adaptive username password pppd_options pppname
30 if [ "$ipv6" = 0 ]; then
32 elif [ -z "$ipv6" -o "$ipv6" = auto
]; then
34 proto_export
"AUTOIPV6=1"
37 if [ "${demand:-0}" -gt 0 ]; then
38 demand
="precompiled-active-filter /etc/ppp/filter demand idle $demand"
42 [ -n "$mtu" ] || json_get_var mtu mtu
43 [ -n "$pppname" ] || pppname
="${proto:-ppp}-$config"
45 local lcp_failure
="${keepalive%%[, ]*}"
46 local lcp_interval
="${keepalive##*[, ]}"
47 local lcp_adaptive
="lcp-echo-adaptive"
48 [ "${lcp_failure:-0}" -lt 1 ] && lcp_failure
=""
49 [ "$lcp_interval" != "$keepalive" ] || lcp_interval
=5
50 [ "${keepalive_adaptive:-1}" -lt 1 ] && lcp_adaptive
=""
51 [ -n "$connect" ] || json_get_var connect connect
52 [ -n "$disconnect" ] || json_get_var disconnect disconnect
54 proto_run_command
"$config" /usr
/sbin
/pppd \
55 nodetach ipparam
"$config" \
57 ${lcp_failure:+lcp-echo-interval $lcp_interval lcp-echo-failure $lcp_failure $lcp_adaptive} \
62 ${username:+user "$username" password "$password"} \
63 ${connect:+connect "$connect"} \
64 ${disconnect:+disconnect "$disconnect"} \
65 ip-up-script
/lib
/netifd
/ppp-up \
66 ipv6-up-script
/lib
/netifd
/ppp-up \
67 ip-down-script
/lib
/netifd
/ppp-down \
68 ipv6-down-script
/lib
/netifd
/ppp-down \
69 ${mtu:+mtu $mtu mru $mtu} \
73 ppp_generic_teardown
() {
78 proto_notify_error
"$interface" AUTH_FAILED
79 json_get_var authfail authfail
80 if [ "${authfail:-0}" -gt 0 ]; then
81 proto_block_restart
"$interface"
85 proto_notify_error
"$interface" INVALID_OPTIONS
86 proto_block_restart
"$interface"
89 proto_kill_command
"$interface"
92 # PPP on serial device
94 proto_ppp_init_config
() {
95 proto_config_add_string
"device"
96 ppp_generic_init_config
104 json_get_var device device
105 ppp_generic_setup
"$config" "$device"
108 proto_ppp_teardown
() {
109 ppp_generic_teardown
"$@"
112 proto_pppoe_init_config
() {
113 ppp_generic_init_config
114 proto_config_add_string
"ac"
115 proto_config_add_string
"service"
118 proto_pppoe_setup
() {
122 for module
in slhc ppp_generic pppox pppoe
; do
123 /sbin
/insmod
$module 2>&- >&-
130 json_get_var service service
132 ppp_generic_setup
"$config" \
134 ${ac:+rp_pppoe_ac "$ac"} \
135 ${service:+rp_pppoe_service "$service"} \
139 proto_pppoe_teardown
() {
140 ppp_generic_teardown
"$@"
143 proto_pppoa_init_config
() {
144 ppp_generic_init_config
145 proto_config_add_int
"atmdev"
146 proto_config_add_int
"vci"
147 proto_config_add_int
"vpi"
148 proto_config_add_string
"encaps"
153 proto_pppoa_setup
() {
157 for module
in slhc ppp_generic pppox pppoatm
; do
158 /sbin
/insmod
$module 2>&- >&-
161 json_get_vars atmdev vci vpi encaps
164 1|vc
) encaps
="vc-encaps" ;;
165 *) encaps
="llc-encaps" ;;
168 ppp_generic_setup
"$config" \
170 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
174 proto_pppoa_teardown
() {
175 ppp_generic_teardown
"$@"
178 proto_pptp_init_config
() {
179 ppp_generic_init_config
180 proto_config_add_string
"server"
189 local ip serv_addr server
190 json_get_var server server
&& {
191 for ip
in $
(resolveip
-t 5 "$server"); do
192 ( proto_add_host_dependency
"$config" "$ip" )
196 [ -n "$serv_addr" ] ||
{
197 echo "Could not resolve server address"
199 proto_setup_failed
"$config"
204 for module
in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp
; do
205 grep -q "^$module " /proc
/modules
&& continue
206 /sbin
/insmod
$module 2>&- >&-
209 [ "$load" = "1" ] && sleep 1
211 ppp_generic_setup
"$config" \
213 pptp_server
$server \
214 file /etc
/ppp
/options.pptp
217 proto_pptp_teardown
() {
218 ppp_generic_teardown
"$@"
221 [ -n "$INCLUDE_ONLY" ] ||
{
223 [ -f /usr
/lib
/pppd
/*/rp-pppoe.so
] && add_protocol pppoe
224 [ -f /usr
/lib
/pppd
/*/pppoatm.so
] && add_protocol pppoa
225 [ -f /usr
/lib
/pppd
/*/pptp.so
] && add_protocol pptp