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:file'
18 proto_config_add_string
'disconnect:file'
19 proto_config_add_string ipv6
20 proto_config_add_boolean authfail
21 proto_config_add_int mtu
22 proto_config_add_string pppname
26 local config
="$1"; shift
28 json_get_vars ipv6 demand keepalive username password pppd_options pppname
29 if [ "$ipv6" = 0 ]; then
31 elif [ -z "$ipv6" -o "$ipv6" = auto
]; then
33 proto_export
"IPV6IFACE=${config}6"
36 if [ "${demand:-0}" -gt 0 ]; then
37 demand
="precompiled-active-filter /etc/ppp/filter demand idle $demand"
41 [ "${keepalive:-0}" -lt 1 ] && keepalive
=""
42 [ -n "$mtu" ] || json_get_var mtu mtu
43 [ -n "$pppname" ] || pppname
="${proto:-ppp}-$config"
45 local interval
="${keepalive##*[, ]}"
46 [ "$interval" != "$keepalive" ] || interval
=5
47 [ -n "$connect" ] || json_get_var connect connect
48 [ -n "$disconnect" ] || json_get_var disconnect disconnect
50 proto_run_command
"$config" /usr
/sbin
/pppd \
51 nodetach ipparam
"$config" \
53 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
58 ${username:+user "$username" password "$password"} \
59 ${connect:+connect "$connect"} \
60 ${disconnect:+disconnect "$disconnect"} \
61 ip-up-script
/lib
/netifd
/ppp-up \
62 ipv6-up-script
/lib
/netifd
/ppp-up \
63 ip-down-script
/lib
/netifd
/ppp-down \
64 ipv6-down-script
/lib
/netifd
/ppp-down \
65 ${mtu:+mtu $mtu mru $mtu} \
69 ppp_generic_teardown
() {
74 proto_notify_error
"$interface" AUTH_FAILED
75 json_get_var authfail authfail
76 if [ "${authfail:-0}" -gt 0 ]; then
77 proto_block_restart
"$interface"
81 proto_notify_error
"$interface" INVALID_OPTIONS
82 proto_block_restart
"$interface"
85 proto_kill_command
"$interface"
88 # PPP on serial device
90 proto_ppp_init_config
() {
91 proto_config_add_string
"device"
92 ppp_generic_init_config
100 json_get_var device device
101 ppp_generic_setup
"$config" "$device"
104 proto_ppp_teardown
() {
105 ppp_generic_teardown
"$@"
108 proto_pppoe_init_config
() {
109 ppp_generic_init_config
110 proto_config_add_string
"ac"
111 proto_config_add_string
"service"
114 proto_pppoe_setup
() {
118 for module
in slhc ppp_generic pppox pppoe
; do
119 /sbin
/insmod
$module 2>&- >&-
126 json_get_var service service
128 ppp_generic_setup
"$config" \
130 ${ac:+rp_pppoe_ac "$ac"} \
131 ${service:+rp_pppoe_service "$service"} \
135 proto_pppoe_teardown
() {
136 ppp_generic_teardown
"$@"
139 proto_pppoa_init_config
() {
140 ppp_generic_init_config
141 proto_config_add_int
"atmdev"
142 proto_config_add_int
"vci"
143 proto_config_add_int
"vpi"
144 proto_config_add_string
"encaps"
149 proto_pppoa_setup
() {
153 for module
in slhc ppp_generic pppox pppoatm
; do
154 /sbin
/insmod
$module 2>&- >&-
157 json_get_vars atmdev vci vpi encaps
160 1|vc
) encaps
="vc-encaps" ;;
161 *) encaps
="llc-encaps" ;;
164 ppp_generic_setup
"$config" \
166 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
170 proto_pppoa_teardown
() {
171 ppp_generic_teardown
"$@"
174 proto_pptp_init_config
() {
175 ppp_generic_init_config
176 proto_config_add_string
"server"
185 local ip serv_addr server
186 json_get_var server server
&& {
187 for ip
in $
(resolveip
-t 5 "$server"); do
188 ( proto_add_host_dependency
"$config" "$ip" )
192 [ -n "$serv_addr" ] ||
{
193 echo "Could not resolve server address"
195 proto_setup_failed
"$config"
200 for module
in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp
; do
201 grep -q "^$module " /proc
/modules
&& continue
202 /sbin
/insmod
$module 2>&- >&-
205 [ "$load" = "1" ] && sleep 1
207 ppp_generic_setup
"$config" \
209 pptp_server
$server \
210 file /etc
/ppp
/options.pptp
213 proto_pptp_teardown
() {
214 ppp_generic_teardown
"$@"
217 [ -n "$INCLUDE_ONLY" ] ||
{
219 [ -f /usr
/lib
/pppd
/*/rp-pppoe.so
] && add_protocol pppoe
220 [ -f /usr
/lib
/pppd
/*/pppoatm.so
] && add_protocol pppoa
221 [ -f /usr
/lib
/pppd
/*/pptp.so
] && add_protocol pptp