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_boolean 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 [ "$ipv6" = 1 ] || ipv6
=""
30 if [ "${demand:-0}" -gt 0 ]; then
31 demand
="precompiled-active-filter /etc/ppp/filter demand idle $demand"
36 [ -n "$mtu" ] || json_get_var mtu mtu
37 [ -n "$pppname" ] || pppname
="${proto:-ppp}-$config"
39 local interval
="${keepalive##*[, ]}"
40 [ "$interval" != "$keepalive" ] || interval
=5
41 [ -n "$connect" ] || json_get_var connect connect
42 [ -n "$disconnect" ] || json_get_var disconnect disconnect
44 proto_run_command
"$config" /usr
/sbin
/pppd \
45 nodetach ipparam
"$config" \
47 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
52 ${username:+user "$username" password "$password"} \
53 ${connect:+connect "$connect"} \
54 ${disconnect:+disconnect "$disconnect"} \
55 ip-up-script
/lib
/netifd
/ppp-up \
56 ipv6-up-script
/lib
/netifd
/ppp-up \
57 ip-down-script
/lib
/netifd
/ppp-down \
58 ipv6-down-script
/lib
/netifd
/ppp-down \
59 ${mtu:+mtu $mtu mru $mtu} \
63 ppp_generic_teardown
() {
68 proto_notify_error
"$interface" AUTH_FAILED
69 json_get_var authfail authfail
70 if [ "${authfail:-0}" -gt 0 ]; then
71 proto_block_restart
"$interface"
75 proto_notify_error
"$interface" INVALID_OPTIONS
76 proto_block_restart
"$interface"
79 proto_kill_command
"$interface"
82 # PPP on serial device
84 proto_ppp_init_config
() {
85 proto_config_add_string
"device"
86 ppp_generic_init_config
94 json_get_var device device
95 ppp_generic_setup
"$config" "$device"
98 proto_ppp_teardown
() {
99 ppp_generic_teardown
"$@"
102 proto_pppoe_init_config
() {
103 ppp_generic_init_config
104 proto_config_add_string
"ac"
105 proto_config_add_string
"service"
108 proto_pppoe_setup
() {
112 for module
in slhc ppp_generic pppox pppoe
; do
113 /sbin
/insmod
$module 2>&- >&-
120 json_get_var service service
122 ppp_generic_setup
"$config" \
124 ${ac:+rp_pppoe_ac "$ac"} \
125 ${service:+rp_pppoe_service "$service"} \
129 proto_pppoe_teardown
() {
130 ppp_generic_teardown
"$@"
133 proto_pppoa_init_config
() {
134 ppp_generic_init_config
135 proto_config_add_int
"atmdev"
136 proto_config_add_int
"vci"
137 proto_config_add_int
"vpi"
138 proto_config_add_string
"encaps"
143 proto_pppoa_setup
() {
147 for module
in slhc ppp_generic pppox pppoatm
; do
148 /sbin
/insmod
$module 2>&- >&-
151 json_get_vars atmdev vci vpi encaps
154 1|vc
) encaps
="vc-encaps" ;;
155 *) encaps
="llc-encaps" ;;
158 ppp_generic_setup
"$config" \
160 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
164 proto_pppoa_teardown
() {
165 ppp_generic_teardown
"$@"
168 proto_pptp_init_config
() {
169 ppp_generic_init_config
170 proto_config_add_string
"server"
179 local ip serv_addr server
180 json_get_var server server
&& {
181 for ip
in $
(resolveip
-t 5 "$server"); do
182 ( proto_add_host_dependency
"$config" "$ip" )
186 [ -n "$serv_addr" ] ||
{
187 echo "Could not resolve server address"
189 proto_setup_failed
"$config"
194 for module
in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp
; do
195 grep -q "^$module " /proc
/modules
&& continue
196 /sbin
/insmod
$module 2>&- >&-
199 [ "$load" = "1" ] && sleep 1
201 ppp_generic_setup
"$config" \
203 pptp_server
$server \
204 file /etc
/ppp
/options.pptp
207 proto_pptp_teardown
() {
208 ppp_generic_teardown
"$@"
211 [ -n "$INCLUDE_ONLY" ] ||
{
213 [ -f /usr
/lib
/pppd
/*/rp-pppoe.so
] && add_protocol pppoe
214 [ -f /usr
/lib
/pppd
/*/pppoatm.so
] && add_protocol pppoa
215 [ -f /usr
/lib
/pppd
/*/pptp.so
] && add_protocol pptp