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 if [ "$ipv6" = 0 ]; then
34 if [ "${demand:-0}" -gt 0 ]; then
35 demand="precompiled-active-filter /etc/ppp/filter demand idle $demand"
39 [ "${keepalive:-0}" -lt 1 ] && keepalive=""
40 [ -n "$mtu" ] || json_get_var mtu mtu
41 [ -n "$pppname" ] || pppname="${proto:-ppp}-$config"
43 local interval="${keepalive##*[, ]}"
44 [ "$interval" != "$keepalive" ] || interval=5
45 [ -n "$connect" ] || json_get_var connect connect
46 [ -n "$disconnect" ] || json_get_var disconnect disconnect
48 proto_run_command "$config" /usr/sbin/pppd \
49 nodetach ipparam "$config" \
51 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
56 ${username:+user "$username" password "$password"} \
57 ${connect:+connect "$connect"} \
58 ${disconnect:+disconnect "$disconnect"} \
59 ip-up-script /lib/netifd/ppp-up \
60 ipv6-up-script /lib/netifd/ppp-up \
61 ip-down-script /lib/netifd/ppp-down \
62 ipv6-down-script /lib/netifd/ppp-down \
63 ${mtu:+mtu $mtu mru $mtu} \
67 ppp_generic_teardown() {
72 proto_notify_error "$interface" AUTH_FAILED
73 json_get_var authfail authfail
74 if [ "${authfail:-0}" -gt 0 ]; then
75 proto_block_restart "$interface"
79 proto_notify_error "$interface" INVALID_OPTIONS
80 proto_block_restart "$interface"
83 proto_kill_command "$interface"
86 # PPP on serial device
88 proto_ppp_init_config() {
89 proto_config_add_string "device"
90 ppp_generic_init_config
98 json_get_var device device
99 ppp_generic_setup "$config" "$device"
102 proto_ppp_teardown() {
103 ppp_generic_teardown "$@"
106 proto_pppoe_init_config() {
107 ppp_generic_init_config
108 proto_config_add_string "ac"
109 proto_config_add_string "service"
112 proto_pppoe_setup() {
116 for module in slhc ppp_generic pppox pppoe; do
117 /sbin/insmod $module 2>&- >&-
124 json_get_var service service
126 ppp_generic_setup "$config" \
128 ${ac:+rp_pppoe_ac "$ac"} \
129 ${service:+rp_pppoe_service "$service"} \
133 proto_pppoe_teardown() {
134 ppp_generic_teardown "$@"
137 proto_pppoa_init_config() {
138 ppp_generic_init_config
139 proto_config_add_int "atmdev"
140 proto_config_add_int "vci"
141 proto_config_add_int "vpi"
142 proto_config_add_string "encaps"
147 proto_pppoa_setup() {
151 for module in slhc ppp_generic pppox pppoatm; do
152 /sbin/insmod $module 2>&- >&-
155 json_get_vars atmdev vci vpi encaps
158 1|vc) encaps="vc-encaps" ;;
159 *) encaps="llc-encaps" ;;
162 ppp_generic_setup "$config" \
164 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
168 proto_pppoa_teardown() {
169 ppp_generic_teardown "$@"
172 proto_pptp_init_config() {
173 ppp_generic_init_config
174 proto_config_add_string "server"
183 local ip serv_addr server
184 json_get_var server server && {
185 for ip in $(resolveip -t 5 "$server"); do
186 ( proto_add_host_dependency "$config" "$ip" )
190 [ -n "$serv_addr" ] || {
191 echo "Could not resolve server address"
193 proto_setup_failed "$config"
198 for module in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp; do
199 grep -q "^$module " /proc/modules && continue
200 /sbin/insmod $module 2>&- >&-
203 [ "$load" = "1" ] && sleep 1
205 ppp_generic_setup "$config" \
207 pptp_server $server \
208 file /etc/ppp/options.pptp
211 proto_pptp_teardown() {
212 ppp_generic_teardown "$@"
215 [ -n "$INCLUDE_ONLY" ] || {
217 [ -f /usr/lib/pppd/*/rp-pppoe.so ] && add_protocol pppoe
218 [ -f /usr/lib/pppd/*/pppoatm.so ] && add_protocol pppoa
219 [ -f /usr/lib/pppd/*/pptp.so ] && add_protocol pptp