From 492fe67b4ae418feda69074f3335be14fbcc79ab Mon Sep 17 00:00:00 2001 From: Robbie Smith Date: Wed, 10 Apr 2013 11:33:37 +1000 Subject: Changed connections to use underscores. --- docs/examples/mobile-ppp | 34 ---------- docs/examples/mobile_ppp | 34 ++++++++++ src/lib/connections/mobile-ppp | 147 ----------------------------------------- src/lib/connections/mobile_ppp | 147 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 181 insertions(+), 181 deletions(-) delete mode 100644 docs/examples/mobile-ppp create mode 100644 docs/examples/mobile_ppp delete mode 100644 src/lib/connections/mobile-ppp create mode 100644 src/lib/connections/mobile_ppp diff --git a/docs/examples/mobile-ppp b/docs/examples/mobile-ppp deleted file mode 100644 index b624175..0000000 --- a/docs/examples/mobile-ppp +++ /dev/null @@ -1,34 +0,0 @@ -Description='Example PPP mobile connection' -Interface=ttyUSB0 -Connection=mobile-ppp -IdleTimeout=30 - -# Debug pppd / chat output (separately from netctl) -#PPPDebug=true - -# Use default route provided by the peer (default: true) -#DefaultRoute=true -# Use DNS provided by the peer (default: true) -#UsePeerDNS=true - -# Always keep a connection established -ConnectionMode='persist' -# Establish connection on demand -#ConnectionMode='demand' -#IdleTimeout=300 - -# The user and password are not always required -#User='example@yourprovider.com' -#Password='very secret' - -# The access point name you are connecting to -AccessPointName=apn - -# If your device has a PIN code, set it here. Defaults to None -#Pin=None - -# Mode can be one of 3Gpref, 3Gonly, GPRSpref, GPRSonly, None -# These only work for Huawei USB modems; all other devices should use None -Mode=3Gpref - -# vim:ft=dosini diff --git a/docs/examples/mobile_ppp b/docs/examples/mobile_ppp new file mode 100644 index 0000000..4e5079f --- /dev/null +++ b/docs/examples/mobile_ppp @@ -0,0 +1,34 @@ +Description='Example PPP mobile connection' +Interface=ttyUSB0 +Connection=mobile_ppp +IdleTimeout=30 + +# Debug pppd / chat output (separately from netctl) +#PPPDebug=true + +# Use default route provided by the peer (default: true) +#DefaultRoute=true +# Use DNS provided by the peer (default: true) +#UsePeerDNS=true + +# Always keep a connection established +ConnectionMode='persist' +# Establish connection on demand +#ConnectionMode='demand' +#IdleTimeout=300 + +# The user and password are not always required +#User='example@yourprovider.com' +#Password='very secret' + +# The access point name you are connecting to +AccessPointName=apn + +# If your device has a PIN code, set it here. Defaults to None +#Pin=None + +# Mode can be one of 3Gpref, 3Gonly, GPRSpref, GPRSonly, None +# These only work for Huawei USB modems; all other devices should use None +Mode=3Gpref + +# vim:ft=dosini diff --git a/src/lib/connections/mobile-ppp b/src/lib/connections/mobile-ppp deleted file mode 100644 index 6a11fdd..0000000 --- a/src/lib/connections/mobile-ppp +++ /dev/null @@ -1,147 +0,0 @@ -# Contributed by Robbie Smith -# Based on Thomas Bächler’s pppoe script -# Also see for more information. - -: ${PPPD:=pppd} -# Set the interface route -: ${InterfaceRoot=dev/} - -_quotestring() { - echo "\"${1/\"/\\\"}\"" -} - -mobile-ppp_up() { - local cfg - local chat - - mkdir -p "$STATE_DIR/mobile-ppp.${Interface}.${Profile}/" - chmod 700 "$STATE_DIR/mobile-ppp.${Interface}.${Profile}/" - cfg="$STATE_DIR/mobile-ppp.${Interface}.${Profile}/options" - chat="$STATE_DIR/mobile-ppp.${Interface}.${Profile}/modem.chat" - : > "${cfg}" - chmod 600 "${cfg}" - - echo "linkname $(_quotestring "${Profile}")" >> "${cfg}" - - cat >> "${cfg}" << EOF -${Interface} -921600 -lock -crtscts -modem -passive -novj -holdoff 10 -maxfail 5 -EOF - - # Debug pppd output separately from netcfg - if is_yes "${PPPDebug:-yes}"; then - echo "debug" >> "${cfg}" - fi - - # Sets up route - if is_yes "${DefaultRoute:-yes}"; then - echo "defaultroute" >> "${cfg}" - else - echo "nodefaultroute" >> "${cfg}" - fi - if is_yes "${UsePeerDNS:-yes}"; then - echo "usepeerdns" >> "${cfg}" - fi - - # Writes username and password - echo "noauth" >> "${cfg}" - echo "hide-password" >> ${cfg} - [[ -n ${User} ]] && echo "user $(_quotestring "${User}")" >> "${cfg}" - [[ -n ${Password} ]] && echo "password $(_quotestring "${Password}")" >> "${cfg}" - - #echo "'OK' @/etc/ppp/chatscripts/pin" >> "${chat}" - if [ -n "${Pin}" ]; then - PinStr="'OK' 'AT+CPIN=${Pin}'" - else - PinStr="'OK' 'AT'" - fi - report_debug echo $PinStr - - # Mode can be one of 3Gpref, 3Gonly, GPRSpref, GPRSonly, None - # Only works for Huawei modems - #echo "'OK' @/etc/ppp/chatscripts/mode" >> "${chat}" - case "${Mode}" in - 3Gonly) - ModeStr="'OK' 'AT\^SYSCFG=14,2,3fffffff,0,1'" - ;; - 3Gpref) - ModeStr="'OK' 'AT\^SYSCFG=2,2,3fffffff,0,1'" - ;; - GPRSonly) - ModeStr="'OK' 'AT\^SYSCFG=13,1,3fffffff,0,0'" - ;; - GPRSpref) - ModeStr="'OK' 'AT\^SYSCFG=2,1,3fffffff,0,0'" - ;; - *) - ModeStr="'OK' 'AT'" - ;; - esac - - # Now that we’ve got the ppp configuration set up, write the chat script - cat >> "${chat}" << EOF -ECHO ON -ABORT 'BUSY' -ABORT 'NO CARRIER' -ABORT 'VOICE' -ABORT 'NO DIALTONE' -ABORT 'NO DIAL TONE' -ABORT 'NO ANSWER' -ABORT 'DELAYED' -ABORT '\nRINGING\r\n\r\nRINGING\r' -REPORT CONNECT -TIMEOUT 6 -'' 'ATQ0' -'OK-AT-OK' 'ATZ' -TIMEOUT 3 -${PinStr} -'OK\d-AT-OK' 'ATI' -'OK' 'ATZ' -'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' -${ModeStr} -'OK-AT-OK' 'AT+CGDCONT=1,"IP","${AccessPointName}"' -'OK' 'ATDT*99#' -TIMEOUT 30 -CONNECT '' -EOF - - # Add the chat script line to the configuration - echo "connect \"/usr/sbin/chat -v -t15 -f ${chat}\"" >> "${cfg}" - - ip link set dev "${Interface}" up - #$PPPD call "$Peer" updetach child-timeout "$PPPTimeout" linkname "$Peer" - $PPPD file "${cfg}" - - if [[ $? -ne 0 ]]; then - rmdir "$STATE_DIR/mobile-ppp.${Interface}.${Profile}/" - report_error "Couldn't make pppd connection." - return 1 - fi -} - -mobile-ppp_down() { - local cfg - local chat - cfg="$STATE_DIR/mobile-ppp.${Interface}.${Profile}/options" - chat="$STATE_DIR/mobile-ppp.${Interface}.${Profile}/modem.chat" - PIDFILE="/var/run/ppp-${Profile}.pid" - - if [[ -e $PIDFILE ]]; then - read PID < "$PIDFILE" - [[ "$PID" ]] && kill "$PID" - fi - - rm "${cfg}" - rm "${chat}" - rmdir "$STATE_DIR/mobile-ppp.${Interface}.${Profile}/" -} - - -# vim: ft=sh ts=4 et sw=4: diff --git a/src/lib/connections/mobile_ppp b/src/lib/connections/mobile_ppp new file mode 100644 index 0000000..fe01fe0 --- /dev/null +++ b/src/lib/connections/mobile_ppp @@ -0,0 +1,147 @@ +# Contributed by Robbie Smith +# Based on Thomas Bächler’s pppoe script +# Also see for more information. + +: ${PPPD:=pppd} +# Set the interface route +: ${InterfaceRoot=dev/} + +_quotestring() { + echo "\"${1/\"/\\\"}\"" +} + +mobile_ppp_up() { + local cfg + local chat + + mkdir -p "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" + chmod 700 "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" + cfg="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/options" + chat="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/modem.chat" + : > "${cfg}" + chmod 600 "${cfg}" + + echo "linkname $(_quotestring "${Profile}")" >> "${cfg}" + + cat >> "${cfg}" << EOF +${Interface} +921600 +lock +crtscts +modem +passive +novj +holdoff 10 +maxfail 5 +EOF + + # Debug pppd output separately from netcfg + if is_yes "${PPPDebug:-yes}"; then + echo "debug" >> "${cfg}" + fi + + # Sets up route + if is_yes "${DefaultRoute:-yes}"; then + echo "defaultroute" >> "${cfg}" + else + echo "nodefaultroute" >> "${cfg}" + fi + if is_yes "${UsePeerDNS:-yes}"; then + echo "usepeerdns" >> "${cfg}" + fi + + # Writes username and password + echo "noauth" >> "${cfg}" + echo "hide-password" >> ${cfg} + [[ -n ${User} ]] && echo "user $(_quotestring "${User}")" >> "${cfg}" + [[ -n ${Password} ]] && echo "password $(_quotestring "${Password}")" >> "${cfg}" + + #echo "'OK' @/etc/ppp/chatscripts/pin" >> "${chat}" + if [ -n "${Pin}" ]; then + PinStr="'OK' 'AT+CPIN=${Pin}'" + else + PinStr="'OK' 'AT'" + fi + report_debug echo $PinStr + + # Mode can be one of 3Gpref, 3Gonly, GPRSpref, GPRSonly, None + # Only works for Huawei modems + #echo "'OK' @/etc/ppp/chatscripts/mode" >> "${chat}" + case "${Mode}" in + 3Gonly) + ModeStr="'OK' 'AT\^SYSCFG=14,2,3fffffff,0,1'" + ;; + 3Gpref) + ModeStr="'OK' 'AT\^SYSCFG=2,2,3fffffff,0,1'" + ;; + GPRSonly) + ModeStr="'OK' 'AT\^SYSCFG=13,1,3fffffff,0,0'" + ;; + GPRSpref) + ModeStr="'OK' 'AT\^SYSCFG=2,1,3fffffff,0,0'" + ;; + *) + ModeStr="'OK' 'AT'" + ;; + esac + + # Now that we’ve got the ppp configuration set up, write the chat script + cat >> "${chat}" << EOF +ECHO ON +ABORT 'BUSY' +ABORT 'NO CARRIER' +ABORT 'VOICE' +ABORT 'NO DIALTONE' +ABORT 'NO DIAL TONE' +ABORT 'NO ANSWER' +ABORT 'DELAYED' +ABORT '\nRINGING\r\n\r\nRINGING\r' +REPORT CONNECT +TIMEOUT 6 +'' 'ATQ0' +'OK-AT-OK' 'ATZ' +TIMEOUT 3 +${PinStr} +'OK\d-AT-OK' 'ATI' +'OK' 'ATZ' +'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' +${ModeStr} +'OK-AT-OK' 'AT+CGDCONT=1,"IP","${AccessPointName}"' +'OK' 'ATDT*99#' +TIMEOUT 30 +CONNECT '' +EOF + + # Add the chat script line to the configuration + echo "connect \"/usr/sbin/chat -v -t15 -f ${chat}\"" >> "${cfg}" + + ip link set dev "${Interface}" up + #$PPPD call "$Peer" updetach child-timeout "$PPPTimeout" linkname "$Peer" + $PPPD file "${cfg}" + + if [[ $? -ne 0 ]]; then + rmdir "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" + report_error "Couldn't make pppd connection." + return 1 + fi +} + +mobile_ppp_down() { + local cfg + local chat + cfg="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/options" + chat="$STATE_DIR/mobile_ppp.${Interface}.${Profile}/modem.chat" + PIDFILE="/var/run/ppp-${Profile}.pid" + + if [[ -e $PIDFILE ]]; then + read PID < "$PIDFILE" + [[ "$PID" ]] && kill "$PID" + fi + + rm "${cfg}" + rm "${chat}" + rmdir "$STATE_DIR/mobile_ppp.${Interface}.${Profile}/" +} + + +# vim: ft=sh ts=4 et sw=4: -- cgit v1.2.3-24-g4f1b