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_vars ipv6 peerdns defaultroute demand keepalive username password pppd_options
29 [ "$ipv6" = 1 ] || ipv6
=""
30 [ "$peerdns" = 0 ] && peerdns
="" || peerdns
="1"
31 if [ "$defaultroute" = 1 ]; then
32 defaultroute
="defaultroute replacedefaultroute";
34 defaultroute
="nodefaultroute"
36 if [ "${demand:-0}" -gt 0 ]; then
37 demand
="precompiled-active-filter /etc/ppp/filter demand idle $demand"
42 [ -n "$mtu" ] || json_get_var mtu mtu
44 local interval
="${keepalive##*[, ]}"
45 [ "$interval" != "$keepalive" ] || interval
=5
46 [ -n "$connect" ] || json_get_var connect connect
47 [ -n "$disconnect" ] || json_get_var disconnect disconnect
49 proto_run_command
"$config" /usr
/sbin
/pppd \
50 nodetach ipparam
"$config" \
51 ifname
"${proto:-ppp}-$config" \
52 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
53 ${ipv6:++ipv6} $defaultroute \
54 ${peerdns:+usepeerdns} \
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 proto_block_restart
"$interface"
76 proto_notify_error
"$interface" INVALID_OPTIONS
77 proto_block_restart
"$interface"
80 proto_kill_command
"$interface"
83 # PPP on serial device
85 proto_ppp_init_config
() {
86 proto_config_add_string
"device"
87 ppp_generic_init_config
95 json_get_var device device
96 ppp_generic_setup
"$config" "$device"
99 proto_ppp_teardown
() {
100 ppp_generic_teardown
"$@"
103 proto_pppoe_init_config
() {
104 ppp_generic_init_config
105 proto_config_add_string
"ac"
106 proto_config_add_string
"service"
109 proto_pppoe_setup
() {
113 for module
in slhc ppp_generic pppox pppoe
; do
114 /sbin
/insmod
$module 2>&- >&-
121 json_get_var service service
123 ppp_generic_setup
"$config" \
125 ${ac:+rp_pppoe_ac "$ac"} \
126 ${service:+rp_pppoe_service "$service"} \
130 proto_pppoe_teardown
() {
131 ppp_generic_teardown
"$@"
134 proto_pppoa_init_config
() {
135 ppp_generic_init_config
136 proto_config_add_int
"atmdev"
137 proto_config_add_int
"vci"
138 proto_config_add_int
"vpi"
139 proto_config_add_string
"encaps"
144 proto_pppoa_setup
() {
148 for module
in slhc ppp_generic pppox pppoatm
; do
149 /sbin
/insmod
$module 2>&- >&-
152 json_get_vars atmdev vci vpi encaps
155 1|vc
) encaps
="vc-encaps" ;;
156 *) encaps
="llc-encaps" ;;
159 ppp_generic_setup
"$config" \
161 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
165 proto_pppoa_teardown
() {
166 ppp_generic_teardown
"$@"
169 [ -n "$INCLUDE_ONLY" ] ||
{
171 [ -f /usr
/lib
/pppd
/*/rp-pppoe.so
] && add_protocol pppoe
172 [ -f /usr
/lib
/pppd
/*/pppoatm.so
] && add_protocol pppoa