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_kill_command "$interface"
79 # PPP on serial device
81 proto_ppp_init_config() {
82 proto_config_add_string "device"
83 ppp_generic_init_config
91 json_get_var device device
92 ppp_generic_setup "$config" "$device"
95 proto_ppp_teardown() {
96 ppp_generic_teardown "$@"
99 proto_pppoe_init_config() {
100 ppp_generic_init_config
101 proto_config_add_string "ac"
102 proto_config_add_string "service"
105 proto_pppoe_setup() {
109 for module in slhc ppp_generic pppox pppoe; do
110 /sbin/insmod $module 2>&- >&-
117 json_get_var service service
119 ppp_generic_setup "$config" \
121 ${ac:+rp_pppoe_ac "$ac"} \
122 ${service:+rp_pppoe_service "$service"} \
126 proto_pppoe_teardown() {
127 ppp_generic_teardown "$@"
130 proto_pppoa_init_config() {
131 ppp_generic_init_config
132 proto_config_add_int "atmdev"
133 proto_config_add_int "vci"
134 proto_config_add_int "vpi"
135 proto_config_add_string "encaps"
138 proto_pppoa_setup() {
142 for module in slhc ppp_generic pppox pppoatm; do
143 /sbin/insmod $module 2>&- >&-
146 json_get_vars atmdev vci vpi encaps
149 1|vc) encaps="vc-encaps" ;;
150 *) encaps="llc-encaps" ;;
153 ppp_generic_setup "$config" \
155 ${atmdev:+$atmdev.}${vpi:-8}.${vci:-35} \
159 proto_pppoa_teardown() {
160 ppp_generic_teardown "$@"
163 [ -n "$INCLUDE_ONLY" ] || {
165 [ -f /usr/lib/pppd/*/rp-pppoe.so ] && add_protocol pppoe
166 [ -f /usr/lib/pppd/*/pppoatm.so ] && add_protocol pppoa