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"
116 proto_config_add_string
"host_uniq"
119 proto_pppoe_setup
() {
123 for module
in slhc ppp_generic pppox pppoe
; do
124 /sbin
/insmod
$module 2>&- >&-
131 json_get_var service service
132 json_get_var host_uniq host_uniq
134 ppp_generic_setup
"$config" \
136 ${ac:+rp_pppoe_ac "$ac"} \
137 ${service:+rp_pppoe_service "$service"} \
138 ${host_uniq:+host-uniq "$host_uniq"} \
142 proto_pppoe_teardown
() {
143 ppp_generic_teardown
"$@"
146 proto_pppoa_init_config
() {
147 ppp_generic_init_config
148 proto_config_add_int
"atmdev"
149 proto_config_add_int
"vci"
150 proto_config_add_int
"vpi"
151 proto_config_add_string
"encaps"
156 proto_pppoa_setup
() {
160 for module
in slhc ppp_generic pppox pppoatm
; do
161 /sbin
/insmod
$module 2>&- >&-
164 json_get_vars atmdev vci vpi encaps
167 1|vc
) encaps
="vc-encaps" ;;
168 *) encaps
="llc-encaps" ;;
171 ppp_generic_setup
"$config" \
173 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
177 proto_pppoa_teardown
() {
178 ppp_generic_teardown
"$@"
181 proto_pptp_init_config
() {
182 ppp_generic_init_config
183 proto_config_add_string
"server"
192 local ip serv_addr server
193 json_get_var server server
&& {
194 for ip
in $
(resolveip
-t 5 "$server"); do
195 ( proto_add_host_dependency
"$config" "$ip" )
199 [ -n "$serv_addr" ] ||
{
200 echo "Could not resolve server address"
202 proto_setup_failed
"$config"
207 for module
in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp
; do
208 grep -q "^$module " /proc
/modules
&& continue
209 /sbin
/insmod
$module 2>&- >&-
212 [ "$load" = "1" ] && sleep 1
214 ppp_generic_setup
"$config" \
216 pptp_server
$server \
217 file /etc
/ppp
/options.pptp
220 proto_pptp_teardown
() {
221 ppp_generic_teardown
"$@"
224 [ -n "$INCLUDE_ONLY" ] ||
{
226 [ -f /usr
/lib
/pppd
/*/rp-pppoe.so
] && add_protocol pppoe
227 [ -f /usr
/lib
/pppd
/*/pppoatm.so
] && add_protocol pppoa
228 [ -f /usr
/lib
/pppd
/*/pptp.so
] && add_protocol pptp