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"
18 proto_config_add_string
"disconnect"
19 proto_config_add_boolean
"defaultroute"
20 proto_config_add_boolean
"peerdns"
21 proto_config_add_boolean
"ipv6"
22 proto_config_add_boolean
"authfail"
23 proto_config_add_int
"mtu"
27 local config
="$1"; shift
29 json_get_vars ipv6 peerdns defaultroute demand keepalive username password pppd_options
30 [ "$ipv6" = 1 ] || ipv6
=""
31 [ "$peerdns" = 0 ] && peerdns
="" || peerdns
="1"
32 if [ "$defaultroute" = 1 ]; then
33 defaultroute
="defaultroute replacedefaultroute";
35 defaultroute
="nodefaultroute"
37 if [ "${demand:-0}" -gt 0 ]; then
38 demand
="precompiled-active-filter /etc/ppp/filter demand idle $demand"
43 [ -n "$mtu" ] || json_get_var mtu mtu
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" \
52 ifname
"${proto:-ppp}-$config" \
53 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
54 ${ipv6:++ipv6} $defaultroute \
55 ${peerdns:+usepeerdns} \
57 ${username:+user "$username" password "$password"} \
58 ${connect:+connect "$connect"} \
59 ${disconnect:+disconnect "$disconnect"} \
60 ip-up-script
/lib
/netifd
/ppp-up \
61 ipv6-up-script
/lib
/netifd
/ppp-up \
62 ip-down-script
/lib
/netifd
/ppp-down \
63 ipv6-down-script
/lib
/netifd
/ppp-down \
64 ${mtu:+mtu $mtu mru $mtu} \
68 ppp_generic_teardown
() {
73 proto_notify_error
"$interface" AUTH_FAILED
74 json_get_var authfail authfail
75 if [ "${authfail:-0}" -gt 0 ]; then
76 proto_block_restart
"$interface"
80 proto_notify_error
"$interface" INVALID_OPTIONS
81 proto_block_restart
"$interface"
84 proto_kill_command
"$interface"
87 # PPP on serial device
89 proto_ppp_init_config
() {
90 proto_config_add_string
"device"
91 ppp_generic_init_config
99 json_get_var device device
100 ppp_generic_setup
"$config" "$device"
103 proto_ppp_teardown
() {
104 ppp_generic_teardown
"$@"
107 proto_pppoe_init_config
() {
108 ppp_generic_init_config
109 proto_config_add_string
"ac"
110 proto_config_add_string
"service"
113 proto_pppoe_setup
() {
117 for module
in slhc ppp_generic pppox pppoe
; do
118 /sbin
/insmod
$module 2>&- >&-
125 json_get_var service service
127 ppp_generic_setup
"$config" \
129 ${ac:+rp_pppoe_ac "$ac"} \
130 ${service:+rp_pppoe_service "$service"} \
134 proto_pppoe_teardown
() {
135 ppp_generic_teardown
"$@"
138 proto_pppoa_init_config
() {
139 ppp_generic_init_config
140 proto_config_add_int
"atmdev"
141 proto_config_add_int
"vci"
142 proto_config_add_int
"vpi"
143 proto_config_add_string
"encaps"
148 proto_pppoa_setup
() {
152 for module
in slhc ppp_generic pppox pppoatm
; do
153 /sbin
/insmod
$module 2>&- >&-
156 json_get_vars atmdev vci vpi encaps
159 1|vc
) encaps
="vc-encaps" ;;
160 *) encaps
="llc-encaps" ;;
163 ppp_generic_setup
"$config" \
165 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
169 proto_pppoa_teardown
() {
170 ppp_generic_teardown
"$@"
173 proto_pptp_init_config
() {
174 ppp_generic_init_config
175 proto_config_add_string
"server"
184 local ip serv_addr server
185 json_get_var server server
&& {
186 for ip
in $
(resolveip
-t 5 "$server"); do
187 ( proto_add_host_dependency
"$config" "$ip" )
191 [ -n "$serv_addr" ] ||
{
192 echo "Could not resolve server address"
194 proto_setup_failed
"$config"
199 for module
in slhc ppp_generic ppp_async ppp_mppe ip_gre gre pptp
; do
200 grep -q "$module" /proc
/modules
&& continue
201 /sbin
/insmod
$module 2>&- >&-
204 [ "$load" = "1" ] && sleep 1
206 ppp_generic_setup
"$config" \
208 pptp_server
$server \
209 file /etc
/ppp
/options.pptp
212 proto_pptp_teardown
() {
213 ppp_generic_teardown
"$@"
216 [ -n "$INCLUDE_ONLY" ] ||
{
218 [ -f /usr
/lib
/pppd
/*/rp-pppoe.so
] && add_protocol pppoe
219 [ -f /usr
/lib
/pppd
/*/pppoatm.so
] && add_protocol pppoa
220 [ -f /usr
/lib
/pppd
/*/pptp.so
] && add_protocol pptp