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_int
"mtu"
26 local config
="$1"; shift
28 json_get_var ipv6 ipv6
29 [ "$ipv6" = 1 ] || ipv6
=""
31 json_get_var peerdns peerdns
32 [ "$peerdns" = 0 ] && peerdns
="" || peerdns
="1"
34 json_get_var defaultroute defaultroute
35 if [ "$defaultroute" = 1 ]; then
36 defaultroute
="defaultroute replacedefaultroute";
38 defaultroute
="nodefaultroute"
41 json_get_var demand demand
42 if [ "${demand:-0}" -gt 0 ]; then
43 demand
="precompiled-active-filter /etc/ppp/filter demand idle $demand"
48 [ -n "$mtu" ] || json_get_var mtu mtu
50 json_get_var keepalive keepalive
51 local interval
="${keepalive##*[, ]}"
52 [ "$interval" != "$keepalive" ] || interval
=5
54 json_get_var username username
55 json_get_var password password
57 [ -n "$connect" ] || json_get_var connect connect
58 [ -n "$disconnect" ] || json_get_var disconnect disconnect
59 json_get_var pppd_options pppd_options
61 proto_run_command
"$config" /usr
/sbin
/pppd \
62 nodetach ipparam
"$config" \
63 ifname
"${proto:-ppp}-$config" \
64 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
65 ${ipv6:++ipv6} $defaultroute \
66 ${peerdns:+usepeerdns} \
68 ${username:+user "$username" password "$password"} \
69 ${connect:+connect "$connect"} \
70 ${disconnect:+disconnect "$disconnect"} \
71 ip-up-script
/lib
/netifd
/ppp-up \
72 ipv6-up-script
/lib
/netifd
/ppp-up \
73 ip-down-script
/lib
/netifd
/ppp-down \
74 ipv6-down-script
/lib
/netifd
/ppp-down \
75 ${mtu:+mtu $mtu mru $mtu} \
79 ppp_generic_teardown
() {
84 proto_notify_error
"$interface" AUTH_FAILED
85 proto_block_restart
"$interface"
88 proto_kill_command
"$interface"
91 # PPP on serial device
93 proto_ppp_init_config
() {
94 proto_config_add_string
"device"
95 ppp_generic_init_config
103 json_get_var device device
104 ppp_generic_setup
"$config" "$device"
107 proto_ppp_teardown
() {
108 ppp_generic_teardown
"$@"
111 proto_pppoe_init_config
() {
112 ppp_generic_init_config
113 proto_config_add_string
"ac"
114 proto_config_add_string
"service"
117 proto_pppoe_setup
() {
121 for module
in slhc ppp_generic pppox pppoe
; do
122 /sbin
/insmod
$module 2>&- >&-
129 json_get_var service service
131 ppp_generic_setup
"$config" \
133 ${ac:+rp_pppoe_ac "$ac"} \
134 ${service:+rp_pppoe_service "$service"} \
138 proto_pppoe_teardown
() {
139 ppp_generic_teardown
"$@"
142 proto_pppoa_init_config
() {
143 ppp_generic_init_config
144 proto_config_add_int
"atmdev"
145 proto_config_add_int
"vci"
146 proto_config_add_int
"vpi"
147 proto_config_add_string
"encaps"
150 proto_pppoa_setup
() {
154 for module
in slhc ppp_generic pppox pppoatm
; do
155 /sbin
/insmod
$module 2>&- >&-
158 json_get_var atmdev atmdev
162 json_get_var encaps encaps
164 1|vc
) encaps
="vc-encaps" ;;
165 *) encaps
="llc-encaps" ;;
168 ppp_generic_setup
"$config" \
170 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
174 proto_pppoa_teardown
() {
175 ppp_generic_teardown
"$@"
178 [ -n "$INCLUDE_ONLY" ] ||
{
180 [ -f /usr
/lib
/pppd
/*/rp-pppoe.so
] && add_protocol pppoe
181 [ -f /usr
/lib
/pppd
/*/pppoatm.so
] && add_protocol pppoa