1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/ppp/rocknet_ppp.sh
3 # Copyright (C) 2004 - 2022 The T2 SDE Project
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
14 local opt
=$2 ; shift 2
17 hide-password|show-password
) optx
="hide-password|show-password" ;;
18 refuse-chap|require-chap
) optx
="refuse-chap|require-chap" ;;
19 refuse-mschap|require-mschap
) optx
="refuse-mschap|require-mschap" ;;
20 refuse-mschap-v2|require-mschap-v2
) optx
="refuse-mschap-v2|require-mschap-v2" ;;
21 refuse-eap|require-eap
) optx
="refuse-eap|require-eap" ;;
22 refuse-pap|require-pap
) optx
="refuse-pap|require-pap" ;;
23 require-mppe|nomppe
) optx
="require-mppe|nomppe" ;;
24 require-mppe-40|nomppe-40
) optx
="require-mppe-40|nomppe-40" ;;
25 require-mppe-128|nomppe-128
) optx
="require-mppe-128|nomppe-128" ;;
26 noauth|auth
) optx
="noauth|auth" ;;
27 nobsdcomp|bsdcomp
) optx
="nobsdcomp|bsdcomp" ;;
28 nocrtscts|crtscts
) optx
="nocrtscts|crtscts" ;;
29 nocdtrcts|cdtrcts
) optx
="nocdtrcts|cdtrcts" ;;
30 nodefaultroute|defaultroute
) optx
="nodefaultroute|defaultroute" ;;
31 nodeflate|deflate
) optx
="nodeflate|deflate" ;;
32 noendpoint|endpoint
) optx
="noendpoint|endpoint" ;;
33 noipv6|ipv6
) optx
="noipv6|ipv6" ;;
34 noipx|ipx
) optx
="noipx|ipx" ;;
35 noktune|ktune
) optx
="noktune|ktune" ;;
36 nomp|mp
) optx
="nomp|mp" ;;
37 nomppe-stateful|mppe-stateful
) optx
="nomppe-stateful|mppe-stateful" ;;
38 nompshortseq|mpshortseq
) optx
="nompshortseq|mpshortseq" ;;
39 nomultilink|multilink
) optx
="nomultilink|multilink" ;;
40 nopersist|persist
) optx
="nopersist|persist" ;;
41 nopredictor1|predictor1
) optx
="nopredictor1|predictor1" ;;
42 noproxyarp|proxyarp
) optx
="noproxyarp|proxyarp" ;;
43 novj|vj
) optx
="novj|vj" ;;
47 if egrep "^($optx) .*" $optfile 1>/dev
/null
2>/dev
/null
; then
48 optx
="`echo $optx | sed 's,|,\\\\|,g'`"
49 sed -i "s,^\($optx\) .*,$opt $*," $optfile
51 echo "$opt $*" >> $optfile
56 if isfirst
"chat_$if"; then
57 addcode up
4 1 "echo -n > \$ppp_${if}_chat"
58 addcode up
4 6 "ppp_option \$ppp_${if}_config \
59 connect \'chat -v -s -f \$ppp_${if}_chat\'"
63 # PUBLIC COMMANDS ###########################################################
64 # pppoe ppp-interface [config file|auto] [ppp-command-line-arg [...]]
67 eval "ppp_${if}_config=$rocknet_tmp_base/ppp_${if}_options"
68 eval "ppp_${if}_chat=$rocknet_tmp_base/ppp_${if}_chat"
75 local ppp_args
="`echo $* | sed 's,",\\\\",g'`"
77 addcode up
4 1 "echo -n > \$ppp_${if}_config"
78 addcode up
4 2 "chmod 0600 \$ppp_${if}_config"
80 ppp_command
="/usr/sbin/pppd file \$ppp_${if}_config $ppp_if"
81 ppp_command
="$ppp_command unit $ppp_unit"
82 ppp_command
="$ppp_command $ppp_args"
84 if [ "$CANUSESERVICE" == "1" ]; then
85 addcode up
5 1 "service_create $if 'ip link set $ppp_if down up
86 exec `eval echo $ppp_command` nodetach' \
87 '[ -f /var/run/$if.pid ] && rm -f /var/run/$if.pid'"
88 addcode down
5 1 "service_destroy $if"
90 addcode up
6 2 "$ppp_command"
92 addcode down
5 5 "[ -f /var/run/$if.pid ] && kill -TERM \`head -n 1 /var/run/$if.pid\`"
93 addcode down
5 4 "[ -f /var/run/$if.pid ] && rm -f /var/run/$if.pid"
98 addcode up
4 5 "ppp_option \$ppp_${if}_config plugin rp-pppoe.so"
99 addcode up
4 5 "ppp_option \$ppp_${if}_config mru 1492"
100 addcode up
4 5 "ppp_option \$ppp_${if}_config mtu 1492"
102 if [ "$CANUSESERVICE" != "1" ]; then
103 addcode up
5 1 "ip link set $ppp_if up"
107 public_ppp_defaults
() {
109 for each
in noipdefault noauth hide-password \
110 ipcp-accept-local ipcp-accept-remote \
111 defaultroute usepeerdns
; do
112 addcode up
4 4 "ppp_option \$ppp_${if}_config $each"
116 public_ppp_speed_defaults
() {
118 for each
in default-asyncmap noaccomp nobsdcomp nodeflate nopcomp \
119 novj novjccomp ktune
; do
120 addcode up
4 4 "ppp_option \$ppp_${if}_config $each"
123 addcode up
4 5 "ppp_option \$ppp_${if}_config lcp-echo-interval 20"
124 addcode up
4 5 "ppp_option \$ppp_${if}_config lcp-echo-failure 3"
127 public_ppp_option
() {
128 local param
="`echo $* | sed 's,",\\\\",g'`"
129 addcode up
4 6 "ppp_option \$ppp_${if}_config $param"
132 public_ppp_on_demand
() {
133 addcode up
4 6 "ppp_option \$ppp_${if}_config demand"
134 addcode up
4 6 "ppp_option \$ppp_${if}_config idle $1"
135 addcode up
4 6 "ppp_option \$ppp_${if}_config persist"
138 public_chat_defaults
() {
141 addcode up
4 1 "echo 'ABORT BUSY
145 ABORT \"NO DIALTONE\"
148 \"\" \"AT\"' >> \$ppp_${if}_chat"
153 # don't ask and count ...
154 opts
="`echo "$@
" | sed -e 's/"/\\\\\\\\\\\\\"/g
' \
156 addcode up 4 3 "echo 'OK
\"$opts\"' >> \$ppp_${if}_chat"
161 # don't ask and count ...
162 opts
="`echo "$@
" | sed 's/"/\\\\\\\\\\\\\"/g
'`"
163 addcode up 4 5 "echo -e 'TIMEOUT
60
164 OK
\"$opts\"\nCONNECT
' >> \$ppp_${if}_chat"