1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../ppp/rocknet_ppp.sh
5 # Copyright (C) 2004 - 2009 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License. A copy of the
12 # GNU General Public License can be found in the file COPYING.
13 # --- T2-COPYRIGHT-NOTE-END ---
17 local opt
=$2 ; shift 2
20 hide-password|show-password
) optx
="hide-password|show-password" ;;
21 refuse-chap|require-chap
) optx
="refuse-chap|require-chap" ;;
22 refuse-mschap|require-mschap
) optx
="refuse-mschap|require-mschap" ;;
23 refuse-mschap-v2|require-mschap-v2
) optx
="refuse-mschap-v2|require-mschap-v2" ;;
24 refuse-eap|require-eap
) optx
="refuse-eap|require-eap" ;;
25 refuse-pap|require-pap
) optx
="refuse-pap|require-pap" ;;
26 require-mppe|nomppe
) optx
="require-mppe|nomppe" ;;
27 require-mppe-40|nomppe-40
) optx
="require-mppe-40|nomppe-40" ;;
28 require-mppe-128|nomppe-128
) optx
="require-mppe-128|nomppe-128" ;;
29 noauth|auth
) optx
="noauth|auth" ;;
30 nobsdcomp|bsdcomp
) optx
="nobsdcomp|bsdcomp" ;;
31 nocrtscts|crtscts
) optx
="nocrtscts|crtscts" ;;
32 nocdtrcts|cdtrcts
) optx
="nocdtrcts|cdtrcts" ;;
33 nodefaultroute|defaultroute
) optx
="nodefaultroute|defaultroute" ;;
34 nodeflate|deflate
) optx
="nodeflate|deflate" ;;
35 noendpoint|endpoint
) optx
="noendpoint|endpoint" ;;
36 noipv6|ipv6
) optx
="noipv6|ipv6" ;;
37 noipx|ipx
) optx
="noipx|ipx" ;;
38 noktune|ktune
) optx
="noktune|ktune" ;;
39 nomp|mp
) optx
="nomp|mp" ;;
40 nomppe-stateful|mppe-stateful
) optx
="nomppe-stateful|mppe-stateful" ;;
41 nompshortseq|mpshortseq
) optx
="nompshortseq|mpshortseq" ;;
42 nomultilink|multilink
) optx
="nomultilink|multilink" ;;
43 nopersist|persist
) optx
="nopersist|persist" ;;
44 nopredictor1|predictor1
) optx
="nopredictor1|predictor1" ;;
45 noproxyarp|proxyarp
) optx
="noproxyarp|proxyarp" ;;
46 novj|vj
) optx
="novj|vj" ;;
50 if egrep "^($optx) .*" $optfile 1>/dev
/null
2>/dev
/null
; then
51 optx
="`echo $optx | sed 's,|,\\\\|,g'`"
52 sed -i "s,^\($optx\) .*,$opt $*," $optfile
54 echo "$opt $*" >> $optfile
59 if isfirst
"chat_$if" ; then
60 addcode up
4 1 "echo -n > \$ppp_${if}_chat"
61 addcode up
4 6 "ppp_option \$ppp_${if}_config \
62 connect \'chat -v -s -f \$ppp_${if}_chat\'"
66 # PUBLIC COMMANDS ###########################################################
67 # pppoe ppp-interface [config file|auto] [ppp-command-line-arg [...]]
70 eval "ppp_${if}_config=$rocknet_tmp_base/ppp_${if}_options"
71 eval "ppp_${if}_chat=$rocknet_tmp_base/ppp_${if}_chat"
78 local ppp_args
="`echo $* | sed 's,",\\\\",g'`"
80 addcode up
4 1 "echo -n > \$ppp_${if}_config"
81 addcode up
4 2 "chmod 0600 \$ppp_${if}_config"
83 ppp_command
="/usr/sbin/pppd file \$ppp_${if}_config $ppp_if"
84 ppp_command
="$ppp_command unit $ppp_unit"
85 ppp_command
="$ppp_command $ppp_args"
87 if [ "$CANUSESERVICE" == "1" ]; then
88 addcode up
5 1 "service_create $if 'ip link set $ppp_if down up
89 exec `eval echo $ppp_command` nodetach' \
90 '[ -f /var/run/$if.pid ] && rm -f /var/run/$if.pid'"
91 addcode down
5 1 "service_destroy $if"
93 addcode up
6 2 "$ppp_command"
95 addcode down
5 5 "[ -f /var/run/$if.pid ] && kill -TERM \`head -n 1 /var/run/$if.pid\`"
96 addcode down
5 4 "[ -f /var/run/$if.pid ] && rm -f /var/run/$if.pid"
101 addcode up
4 5 "ppp_option \$ppp_${if}_config plugin rp-pppoe.so"
102 addcode up
4 5 "ppp_option \$ppp_${if}_config mru 1492"
103 addcode up
4 5 "ppp_option \$ppp_${if}_config mtu 1492"
105 if [ "$CANUSESERVICE" != "1" ]; then
106 addcode up
5 1 "ip link set $ppp_if up"
110 public_ppp_defaults
() {
112 for each
in noipdefault noauth hide-password \
113 ipcp-accept-local ipcp-accept-remote \
114 defaultroute usepeerdns
; do
115 addcode up
4 4 "ppp_option \$ppp_${if}_config $each"
119 public_ppp_speed_defaults
() {
121 for each
in default-asyncmap noaccomp nobsdcomp nodeflate nopcomp \
122 novj novjccomp ktune
; do
123 addcode up
4 4 "ppp_option \$ppp_${if}_config $each"
126 addcode up
4 5 "ppp_option \$ppp_${if}_config lcp-echo-interval 20"
127 addcode up
4 5 "ppp_option \$ppp_${if}_config lcp-echo-failure 3"
130 public_ppp_option
() {
131 local param
="`echo $* | sed 's,",\\\\",g'`"
132 addcode up
4 6 "ppp_option \$ppp_${if}_config $param"
135 public_ppp_on_demand
() {
136 addcode up
4 6 "ppp_option \$ppp_${if}_config demand"
137 addcode up
4 6 "ppp_option \$ppp_${if}_config idle $1"
138 addcode up
4 6 "ppp_option \$ppp_${if}_config persist"
141 public_chat_defaults
() {
144 addcode up
4 1 "echo 'ABORT BUSY
148 ABORT \"NO DIALTONE\"
151 \"\" \"AT\"' >> \$ppp_${if}_chat"
156 # don't ask and count ...
157 opts
="`echo "$@
" | sed -e 's/"/\\\\\\\\\\\\\"/g
' \
159 addcode up 4 3 "echo 'OK
\"$opts\"' >> \$ppp_${if}_chat"
164 # don't ask and count ...
165 opts
="`echo "$@
" | sed 's/"/\\\\\\\\\\\\\"/g
'`"
166 addcode up 4 5 "echo -e 'TIMEOUT
60
167 OK
\"$opts\"\nCONNECT
' >> \$ppp_${if}_chat"