diff options
-rw-r--r-- | etc/inc/interfaces.inc | 346 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 36 | ||||
-rw-r--r-- | usr/local/sbin/mpd.script | 1629 | ||||
-rwxr-xr-x | usr/local/www/interfaces_assign.php | 12 | ||||
-rw-r--r-- | usr/local/www/interfaces_ppp.php | 9 | ||||
-rw-r--r-- | usr/local/www/interfaces_ppp_edit.php | 117 | ||||
-rwxr-xr-x | usr/local/www/status_interfaces.php | 10 |
7 files changed, 1970 insertions, 189 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 13ba21a..b0fadeb 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -686,9 +686,6 @@ function interfaces_configure() { interfaces_qinq_configure(); - /* Set up PPP interfaces */ - interfaces_ppp_configure(); - $iflist = get_configured_interface_with_descr(); $delayed_list = array(); $bridge_list = array(); @@ -824,8 +821,6 @@ function interface_bring_down($interface = "wan", $destroy = false) { unlink_if_exists("{$g['tmp_path']}/{$realif}up"); unlink_if_exists("{$g['vardb_path']}/{$interface}ip"); unlink_if_exists("{$g['tmp_path']}/{$realif}_router"); - - interface_ppp_bring_down($realif); switch ($ifcfg['ipaddr']) { case "pppoe": @@ -857,6 +852,10 @@ function interface_bring_down($interface = "wan", $destroy = false) { mwexec("/usr/sbin/arp -d -i {$realif} -a"); } break; + case "ppp": + killbypid("{$g['varrun_path']}/{$realif}.pid"); + sleep(2); + break; default: if(does_interface_exist("$realif")) { mwexec("/sbin/ifconfig " . escapeshellarg($realif) . " delete", true); @@ -874,127 +873,227 @@ function interface_bring_down($interface = "wan", $destroy = false) { return; } -function interfaces_ppp_configure($write_config=true) { +function interface_ppp_configure($ppp_int,$edit=false) { global $config, $g; - if(!$g['booting']) - conf_mount_rw(); - if($g['booting']) - echo "Configuring PPP interfaces..."; - if($config['ppps']['ppp']) { - foreach($config['ppps']['ppp'] as $ppp) { - $dev = substr($ppp['port'], 5); - interface_ppp_configure($dev,$write_config); + + $serial_device = 0; + if ($ppp_int <> -1) + if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { + foreach ($config['ppps']['ppp'] as $ppp) { + if ($ppp_int == "ppp".$ppp['pppid']) + $serial_device = $ppp['port']; + } } + + // mpd5 requires a /var/spool/lock directory + if(!is_dir("/var/spool/lock")) { + exec("/bin/mkdir -p /var/spool/lock"); + exec("/bin/chmod a+rw /var/spool/lock/."); } - if(!$g['booting']) - conf_mount_ro(); - if($g['booting']) - echo "done.\n"; -} + if (!file_exists("{$g['varetc_path']}/mpd.script")) + if($g['booting']) + mwexec("/bin/ln -s /usr/local/sbin/mpd.script {$g['varetc_path']}/."); + + if ($edit || $g['booting']){ + if($g['booting']) + echo " configuring PPP on {$ppp_int} interface...\n"; + /* generate mpd.conf */ + $fd = fopen("{$g['varetc_path']}/mpd-ppp.conf", "w"); + if (!$fd) { + printf("Error: cannot open mpd-ppp.conf in interface_ppp_configure().\n"); + return 1; + } + /* generate mpd.secret */ + $fds = fopen("{$g['varetc_path']}/mpd.secret", "w"); + if (!$fds) { + printf("Error: cannot open mpd.secret in interface_ppp_configure().\n"); + return 1; + } -function interface_ppp_configure($ifcfg,$edit=false) { - global $config, $g; - - /* Remove the /dev/ from the device name. */ - $orig_dev = $ifcfg; + // Create mpd.secret file + + $secret = <<<EOD +################################################################# +# +# MPD secrets file +# Entries are for authentication in either or both directions, as well +# as telnet console login. Auto generated from /etc/inc/interfaces.inc +# {$g['varetc_path']}/mpd.secret +# +################################################################## +Mylogin "" - // ppp (userland) requires a /var/spool/lock directory - if(!is_dir("/var/spool/lock")) { - exec("mkdir -p /var/spool/lock"); - exec("chmod a+rw /var/spool/lock/."); - } - if ($edit){ - // Construct the ppp.conf file - $peerfile .= "default:\n"; - $peerfile .= " set log Phase Chat LCP IPCP CCP tun command\n"; - $peerfile .= " ident user-ppp VERSION (built COMPILATIONDATE)\n"; - $peerfile .= " set dial \"ABORT BUSY ABORT NO\\\sCARRIER TIMEOUT 5 \\\n"; - $peerfile .= " \\\"\\\" AT OK-AT-OK ATE1Q0 OK \\\dATDT\\\T TIMEOUT 40 CONNECT\"\n"; - $peerfile .= " enable dns\n"; - $peerfile .= " nat enable yes\n"; - $peerfile .= " set reconnect {$ifcfg['connect-max-attempts']} 5\n"; - $peerfile .= " allow users root\n\n"; - - // Loop variables - $i = 0; - $startingip = 1; +EOD; + // Construct the mpd.conf file + $mpdconf = <<<EOD +################################################################# +# +# MPD Configuration file +# Auto generated by pfSense from /etc/inc/interfaces.inc +# {$g['varetc_path']}/mpd_ppp.conf +# +################################################################## - // Start ppp.linkup file - $rclinkup = "default:\n"; - // Start ppp.linkdown file - $rclinkdown = "default:\n"; +startup: + # configure mpd users + set user admin pfsense admin + set user user pfsense + # configure the console + set console self 127.0.0.1 5005 + set console open + # configure the web server + #set web self 0.0.0.0 5006 + #set web open + +default: + +EOD; + + $ip = 1; if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { foreach ($config['ppps']['ppp'] as $ppp) { - $dev = substr($ppp['port'], 5); - $realif = $ppp['port']; - $peerfile .= "{$dev}:\n"; - $peerfile .= " set device {$realif}\n"; - if($ppp['dialcmd']) { - $peerfile .= " set dial " . base64_decode($ppp['dialcmd']) . "\n"; - } else - $peerfile .= " set dial \"\"\n"; - $peerfile .= " set speed {$ppp['linespeed']}\n"; - if (isset($ppp['defaultgw'])) - $peerfile .= " add default HISADDR\n"; - $peerfile .= " set timeout 0\n"; - $peerfile .= " enable dns\n"; - $endingip = $startingip+1; + //$dev = substr($ppp['port'], 5); //Device sans path + $id = $ppp['pppid']; + $ppp_port = "ppp{$id}"; + + $endingip = $ip+1; if($ppp['localip'] && $ppp['gateway']) - $peerfile .= " set ifaddr {$ppp['localip']}/0 {$ppp['gateway']}/0 255.255.255.0 0.0.0.0\n"; + $ranges = "set ipcp ranges {$ppp['localip']}/0 {$ppp['gateway']}/0"; if(!$ppp['localip'] && $ppp['gateway']) - $peerfile .= " set ifaddr 10.0.0.{$startingip}/0 {$ppp['gateway']}/0 255.255.255.0 0.0.0.0\n"; + $ranges = "set ipcp ranges 10.0.0.{$ip}/0 {$ppp['gateway']}/0"; if($ppp['localip'] and !$ppp['gateway']) - $peerfile .= " set ifaddr {$ppp['localip']}/0 10.0.0.{$endingip}/0 255.255.255.0 0.0.0.0\n"; + $ranges = "set ipcp ranges {$ppp['localip']}/0 10.0.0.{$endingip}/0"; if(!$ppp['localip'] and !$ppp['gateway']) - $peerfile .= " set ifaddr 10.0.0.{$startingip}/0 10.0.0.{$endingip}/0 255.255.255.0 0.0.0.0\n"; - //$peerfile .= " iface name ppp_{$orig_dev}\n"; - $peerfile .= " set phone \"{$ppp['phone']}\"\n"; - $peerfile .= " set authname \"{$ppp['username']}\"\n"; - $peerfile .= " set authkey \"{$ppp['password']}\"\n"; - // Add a local socket for the daemon so we can query it later - $peerfile .= " set server /var/run/{$dev}.sock \"\" 0177\n"; - $peerfile .= "\n"; - $i++; - $startingip++; - $rclinkup .= "{$dev}:\n"; - $rclinkup .= " ! sh -c \"/etc/rc.conf_mount_rw\"\n"; - $rclinkup .= " ! sh -c \"/bin/echo `date -j +%Y.%m.%d-%H:%M:%S` 00:00:00 >> /conf/ppp-up.{$dev}.log\"\n"; - $rclinkup .= " ! sh -c \"/sbin/ppp-script HISADDR INTERFACE DNS0 DNS1\"\n"; - $rclinkup .= " ! sh -c \"/etc/rc.linkup INTERFACE start\"\n"; - $rclinkup .= " ! sh -c \"/etc/rc.conf_mount_ro\"\n"; - $rclinkup.= " ! sh -c \"/etc/rc.filter_configure_sync\"\n"; - // Link down file - $rclinkdown .= "{$dev}:\n"; - $rclinkdown .= " ! sh -c \"/etc/rc.conf_mount_rw\"\n"; - $rclinkdown .= " ! sh -c \"/bin/echo `date -j +%Y.%m.%d-%H:%M:%S` UPTIME >> /conf/ppp-up.{$dev}.log\"\n"; - $rclinkdown .= " ! sh -c \"/etc/rc.conf_mount_ro\"\n"; - $rclinkdown .= " ! sh -c \"/bin/rm -f /var/run/{$dev}.if\"\n"; - } - } + $ranges = "set ipcp ranges 10.0.0.{$ip}/0 10.0.0.{$endingip}/0"; + if ($ppp['username'] <> ""){ + $user = "{$ppp['username']}"; + } else { + $user = "Mylogin"; + } + + $mpdconf .= <<<EOD +{$ppp_port}: + create bundle static B{$id} + {$ranges} + set ipcp yes req-pri-dns + set ipcp yes req-sec-dns + set iface name {$ppp_port} + +EOD; + if (isset($ppp['defaultgw'])){ + $mpdconf .= <<<EOD + set iface route default - // Write out configuration for ppp.conf - file_put_contents("/etc/ppp/ppp.conf", $peerfile); +EOD; + } + $mpdconf .= <<<EOD + set iface up-script /usr/local/sbin/ppp-linkup + set iface down-script /usr/local/sbin/ppp-linkdown +# Create link. + create link static lnk-{$ppp_port} modem + set modem device {$ppp['port']} + set modem var \$DialPrefix "DT" + set modem var \$Telephone "{$ppp['phone']}" - // Write out linkup file - file_put_contents("/etc/ppp/ppp.linkup", $rclinkup); - file_put_contents("/etc/ppp/ppp.linkdown", $rclinkdown); - // Make executable - exec("chmod a+rx /etc/ppp/ppp.linkup"); - exec("chmod a+rx /etc/ppp/ppp.linkdown"); +EOD; + $ip++; + if (isset($ppp['connect-timeout'])){ + $mpdconf .= <<<EOD + set modem var \$ConnectTimeout "{$ppp['connect-timeout']}" + +EOD; + } + if (isset($ppp['initstr'])){ + $initstr = base64_decode($ppp['initstr']); + $mpdconf .= <<<EOD + set modem var \$InitString "{$initstr}" + +EOD; + } + if (isset($ppp['simpin'])){ + $mpdconf .= <<<EOD + set modem var \$SimPin "{$ppp['simpin']}" + set modem var \$PinWait "{$ppp['pin-wait']}" + +EOD; + } + if (isset($ppp['apn'])){ + $mpdconf .= <<<EOD + set modem var \$APN "{$ppp['apn']}" + set modem var \$APNum "{$ppp['apnum']}" + +EOD; + } + $mpdconf .= <<<EOD + set modem script DialPeer + set modem idle-script Ringback + set modem watch -cd +# We expect to be authenticated by peer using any protocol. + set link disable chap pap + set link accept chap pap eap + set link enable no-orig-auth +# Configure the account name. Password will be taken from mpd.secret. + set auth authname {$user} +# To make Ringback work we should specify how to handle incoming calls originated by it. + #set link enable incoming + set link action bundle B{$id} + open + +EOD; + + $fdlnkq = fopen("{$g['varetc_path']}/{$ppp_port}.query", "w"); + if (!$fdlnkq) { + printf("Error: cannot open {$ppp_port}.query in interface_ppp_configure().\n"); + return 1; + } + $linkquery = <<<EOD +admin +pfsense +link lnk-{$ppp_port} +show iface +exit + +EOD; + + // Write out linkquery file for each configured PPP interface. + fwrite($fdlnkq, $linkquery); + fclose($fdlnkq); + + + if ($ppp['username'] <> ""){ + $secret .= <<<EOD +{$ppp['username']} "{$ppp['password']}" + +EOD; + + } + } + } + + // Write out configuration for mpd_ppp.conf and mpd.secret + fwrite($fd, $mpdconf); + fclose($fd); + fwrite($fds, $secret); + fclose($fds); + sleep(2); } // Launch specified ppp instance - if( (!$edit || $g['booting']) && file_exists("/dev/{$orig_dev}")){ - $running = `/bin/pgrep -f "ppp .* $orig_dev"`; - if(!$running) - mwexec_bg("/usr/sbin/ppp -background {$orig_dev}"); - } -} + if( (!$edit || $g['booting']) && file_exists("{$serial_device}")){ + $timeout = 15; + /* if mpd is active, lets take it down -> accomplished by starting mpd with the -k flag*/ + /* fire up mpd */ + if (file_exists("{$g['tmp_path']}/{$ppp_int}_router")) + mwexec("/bin/rm -r {$g['tmp_path']}/{$ppp_int}_router"); + mwexec("/usr/local/sbin/mpd5 -b -k -d {$g['varetc_path']} -f mpd-ppp.conf -p {$g['varrun_path']}/{$ppp_int}.pid -s ppp {$ppp_int}"); + /* Wait for mpd5 to bring up connection, but don't wait longer than $timeout */ + for ($i=0; $i < $timeout; $i++){ + sleep(1); + if (file_exists("{$g['tmp_path']}/{$ppp_int}_router")) + break; + } + -function interface_ppp_bring_down($if) { - if(file_exists("/var/run/{$if}.pid")) { - $pid = trim(file_get_contents("/var/run/{$if}.pid")); - mwexec("kill -QUIT {$pid}"); } } @@ -1896,15 +1995,15 @@ function interface_configure($interface = "wan", $reloadall = false) { case 'dhcp': interface_dhcp_configure($interface); break; - case 'pppoe': interface_pppoe_configure($interface); break; - case 'pptp': interface_pptp_configure($interface); break; - + case 'ppp': + interface_ppp_configure($realif); + break; default: if ($wancfg['ipaddr'] <> "" && $wancfg['subnet'] <> "") { if (isset($wancfg['ispointtopoint']) && $wancfg['pointtopoint']) { @@ -1929,9 +2028,6 @@ function interface_configure($interface = "wan", $reloadall = false) { if (!$g['booting']) interface_reload_carps($realif); - if($wancfg['serialport']) - interface_ppp_configure($wancfg['serialport']); - if (!$g['booting']) { if (link_interface_to_gre($interface)) { foreach ($config['gres']['gre'] as $gre) @@ -2570,17 +2666,6 @@ function get_real_interface($interface = "wan") { if ($interface == $if || $interface == $ifdesc) { - // PPP Support - if($config['interfaces'][$if]['serialport']) { - $dev = $config['interfaces'][$if]['serialport']; - if(file_exists("/var/run/{$dev}.if")) { - $wanif = trim(file_get_contents("/var/run/{$dev}.if")); - } else - $wanif = "Not connected"; - - break; - } - $cfg = $config['interfaces'][$if]; // Wireless cloned NIC support (FreeBSD 8+) @@ -2624,6 +2709,9 @@ function get_real_interface($interface = "wan") { else $wanif = "pptp" . substr($if, 3); break; + case "ppp": + $wanif = $cfg['if']; + break; default: $wanif = $cfg['if']; break; @@ -2923,16 +3011,14 @@ function get_interfaces_with_gateway() { /* loop interfaces, check config for outbound */ foreach($config['interfaces'] as $ifdescr => $ifname) { - if($ifname['serialport']) { - $ints[] = $ifdescr; - continue; - } + switch ($ifname['ipaddr']) { case "dhcp": case "carpdev-dhcp": case "pppoe": case "pptp": - $ints[] = $ifdescr; + case "ppp"; + $ints[] = $ifdescr; break; default: if ($ifname['pointtopoint']) diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index dbc128f..6333762 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1177,12 +1177,29 @@ function get_ppp_uptime($serialport){ } } - +function convert_seconds_to_hms($sec){ + if ($sec != 0){ + $min = floor($sec/60); + $sec %= 60; + } + if ($min != 0){ + $hrs = floor($min/60); + $min %= 60; + } + if ($sec < 10) + $sec = "0".$sec; + if ($min < 10) + $min = "0".$min; + if ($hrs < 10) + $hrs = "0".$hrs; + $result = $hrs.":".$min.":".$sec; + return $result; +} //returns interface information function get_interface_info($ifdescr) { - global $config, $linkinfo, $netstatrninfo; + global $config, $linkinfo, $netstatrninfo, $g; $ifinfo = array(); /* if list */ @@ -1299,15 +1316,17 @@ function get_interface_info($ifdescr) { $ifinfo['pptplink'] = "down"; break; /* PPP interface? -> get uptime for this session and cumulative uptime from the persistant log file in conf */ - case "": - if ($config['interfaces'][$if]['serialport']){ + case "ppp": + $ppp_int = $config['interfaces'][$if]['if']; $dev = $config['interfaces'][$if]['serialport']; + if ($dev == "") + break; if (file_exists("/dev/{$dev}")){ $ifinfo['ppplink'] = $dev; - - if (file_exists("/var/run/{$dev}.sock") && file_exists("/var/run/{$dev}.if")){ - $ifinfo['ppp_uptime'] = `/usr/sbin/pppctl /var/run/$dev.sock show physical | grep 'Connect time' | cut -c 15-`; - } //else if (`/sbin/ifconfig + if (file_exists("{$g['varrun_path']}/{$ppp_int}.pid") && file_exists("{$g['varetc_path']}/{$ppp_int}.query")){ + $sec = trim(`/usr/bin/nc localhost 5005 < {$g['varetc_path']}/{$ppp_int}.query | grep 'Session time' | cut -f7 -d ' '`); + $ifinfo['ppp_uptime'] = convert_seconds_to_hms($sec); + } $ifinfo['missing_device'] = 0; } else{ @@ -1316,7 +1335,6 @@ function get_interface_info($ifdescr) { } // Calculate cumulative uptime for PPP link. Useful for connections that have per minute/hour contracts so you don't go over! $ifinfo['ppp_uptime_accumulated'] = get_ppp_uptime($dev); - } break; default: diff --git a/usr/local/sbin/mpd.script b/usr/local/sbin/mpd.script new file mode 100644 index 0000000..ca02a1f --- /dev/null +++ b/usr/local/sbin/mpd.script @@ -0,0 +1,1629 @@ +################################################################# +# +# $Id: mpd.script.sample,v 1.9 2009/10/04 19:36:04 amotin Exp $ +# +# Copyright (c) 1995-1999 Whistle Communications, Inc. All rights reserved. +# See ``COPYRIGHT.whistle'' +# +################################################################# + +## +## MPD Modem script variables: +## +## $DialPrefix Modem dialing prefix (eg. "DT") +## $Telephone Telephone number to dial (not duplicated using &) +## $ConnectTimeout Wait-for-connect timeout, in seconds (default 45 secs) +## $SpeakerOff Set to "yes" to quiet modem speakers +## $Serial230K If "yes", we can support 230K serial port speed +## $CountryCode Country code for Winmodem +## $InitString External initialization string +## $LoginScript If "yes", look for script login +## +## pfSense specific variables: +## $APN Access Point (host)Name for 3G connections +## $APNum Access Point Number, typically "1", might not matter +## $SimPin SIM card PIN number +## $PinWait Wait for SIM to connect to network after PIN entered +## +## ISDN Terminal Adapter specific variables (all start with "TA_"): +## +## $TA_Bonding Bonding on TA: "yes" or "no" +## $TA_NoDoubleTelno When $TA_Bonding, don't double the dialed number +## $TA_56K Restrict to 56K on TA: "yes" or "no" +## $TA_VoiceCall Originate calls using voice mode +## $TA_AuthChap Tell TA to use CHAP: "yes" or "no" +## $TA_Dirno1 TA directory #1 +## $TA_Dirno2 TA directory #2 +## $TA_SPID1 SPID #1 +## $TA_SPID2 SPID #2 +## $TA_SwitchType One of these values +## "NI-1" +## "DMS-100" +## "5ESS P2P" +## "5ESS MP" +## $TA_NewSwitch Means the switch type is new, initiate auto-detect +## (3Com Impact IQ only) +## +## We set $OptimizeNextTime to "yes" after a successful connection so we +## can avoid verifing configuration when things are working good. +## +## Internal variables: +## +## $ModemSetupFunc Routine to set up modem for dialing out +## $ModemAnsSetupFunc Routine to set up modem for answer mode (if different) +## $ModemDetectRing Routine to detect an incoming call for ringback +## $ModemIsAnalog If "yes" modem is analog (ie, not terminal adapter) +## + +################################################################# +# +# MODEM DIALING +# +################################################################# + +DialPeer: + set $CallingID "" + set $CalledID $Telephone + if $Telephone == "00000" goto DialNullModem + set $optimize $OptimizeNextTime + set $OptimizeNextTime "no" + + if $optimize == "yes" goto DialPeer2 + call ModemFind + if $ErrorMsg == "" goto DialPeer1 + log $ErrorMsg + failure +DialPeer1: + set $ModTelephone $Telephone + call ModemIdent + if $ModemDescription != "" goto DialPeer2 + log "The modem is not responding." + failure + +DialPeer2: + log "Detected $ModemDescription." + call $ModemSetupFunc + if $SimPin != "" goto DialPeerSetPin + if $APN != "" goto DialPeerSetAPN + log "Dialing server at $Telephone..." + call ModemDial + if $dialResult == "OK" goto DialPeerOK + set $optimize "no" + failure + +DialPeerOK: + if $ConnectionSpeed == "" log "Connected at an unknown speed." + if $ConnectionSpeed == "" goto DialPeer3 + log "Connected at $ConnectionSpeed." +DialPeer3: + if $LoginScript == "yes" call AutoLogin + set $OptimizeNextTime "yes" + success + +DialPeerSetPin: + set $modemCmd "+CPIN=$SimPin" + call ModemCmd2 + wait $ConnectTimeout + return + +DialPeerSetAPN: + set $modemCmd "+CGDCONT=$APNum,\"IP\",\"$APN\"" + call ModemCmd2 + return + +# Null-modem connection +DialNullModem: + log "Connected via null modem connection." + success + +## +## Dial modem +## +## Variables: +## +## $DialPrefix Modem dialing prefix (eg. "DT") +## $ModTelephone Telephone number to dial +## $ConnectTimeout Wait-for-connect timeout, in seconds (default 45 secs) +## $noDialToneSubr (optional) Subroutine to call if NO DIALTONE +## $dialErrorSubr (optional) Subroutine to call if ERR +## +## Returns: +## +## $dialResult "OK" or "FAIL" +## $ConnectionSpeed Connection speed reported by modem (possibly empty) +## + +ModemDial: + set $dialResult "FAIL" + set $ConnectionSpeed "" + if $ConnectTimeout == "" set $ConnectTimeout 45 + print "AT${DialPrefix}${ModTelephone}\r\n" + match "NO CARRIER" DialAbortNoCar + match "NO DIAL" DialAbortNoDial + match "BUSY" DialAbortBusy + regex "CONNECT *([0-9]*).*$" DialConnect + match "ERR" DialError + wait $ConnectTimeout + log "No response from the modem after dialing." + return +DialAbortNoCar: + log "The remote modem did not answer." + return +DialAbortNoDial: + if $noDialToneSubr != "" goto $noDialToneSubr + log "No dialtone. Is the modem plugged in?" + return +DialError: + if ${ModTelephone} != "" goto DialErrorInit + log "Invalid empty telephone number." + return +DialErrorInit: + if $dialErrorSubr != "" goto $dialErrorSubr + log "Invalid dial init string." + return +DialAbortBusy: + log "The line was busy." + return +DialConnect: + set $ConnectionSpeed $matchedString1 + set $dialResult "OK" + return + +################################################################# +# +# MODEM ANSWERING +# +################################################################# + +## +## This is an idle script that waits for an incoming call and answers it +## +## Variables: +## +## $RingTimeout How long to wait for a RING before giving up +## $ConnectTimeout Wait-for-connect timeout, in seconds (default 45 secs) +## + +AnswerCall: + set $CallingID "" + set $CalledID "" + set $optimize $OptimizeNextTime + set $OptimizeNextTime "no" + +# Skip modem detection if we connected successfully last time + + if $optimize == "yes" goto AnswerCall2 + call ModemFind + if $ErrorMsg == "" goto AnswerCall0 + log $ErrorMsg + failure +AnswerCall0: + call ModemIdent + if $ModemDescription != "" goto AnswerCall1 + log "The modem is not responding." + failure +AnswerCall1: + log "Detected $ModemDescription." + +AnswerCall2: + if $ModemAnsSetupFunc == "" set $ModemAnsSetupFunc $ModemSetupFunc + call $ModemAnsSetupFunc + log "Waiting for ring..." + call ModemAnswer + if $answerReturn == "OK" goto AnswerCallOK + set $IdleResult "" + set $optimize "no" + failure + +AnswerCallOK: + log "Connected at $ConnectionSpeed." + set $OptimizeNextTime "yes" + set $IdleResult "answer" + success + +################################################################# +# +# MODEM RINGBACK +# +################################################################# + +## +## This is an idle script that implements the ringback feature. +## When we're idle, and we detect an incoming call, then call back +## to bring up the link. For analog modems, we have to wait until +## the ringing stops before dialing back (otherwise we'd answer the +## call, which we don't want to do). +## +## Variables: +## +## $RingbackTimeout How long before giving up (reset and try again). +## Default: 60 minutes +## $RingStoppedTime Max time between consecutive "RING"s (if analog) +## Default: 8 seconds +## + +Ringback: + set $CallingID "" + set $CalledID "" + if $RingbackTimeout == "" set $RingbackTimeout "3600" + if $RingStoppedTime == "" set $RingStoppedTime "8" + set $ModemDetectRing RingbackWait + call ModemFind + if $ErrorMsg == "" goto Ringback1 + log $ErrorMsg + failure +Ringback1: + call ModemIdent + if $ModemDescription != "" goto Ringback2 + log "The modem is not responding." + failure + +Ringback2: + log "Detected $ModemDescription." + goto $ModemDetectRing + +# Detect an incoming call by waiting for a "RING" indication +# On an analog modem, we have to wait for the ringing to stop + +RingbackWait: + match "RING\r\n" RingbackGotRings + log "Remote Dial-Back mode enabled; waiting for incoming call." + wait $RingbackTimeout + failure + +# We saw it ring; wait for the ringing to stop (analog modems only). + +RingbackGotRings: + log "Incoming call detected..." + if $ModemIsAnalog != "yes" goto RingbackDone +RingbackWaitStop: + match "RING\r\n" RingbackWaitStop + wait $RingStoppedTime +RingbackDone: + set $IdleResult "ringback" + success + +# Strip leading and trailing spaces and log calling party number + +RingbackDetectCID: + if $cid match " *(.*) *" nop + set $cid $matchedString1 + if $cid == "" goto RingbackDetectNoCID + log "Incoming call detected from $cid..." + success + +# We couldn't determine calling party number + +RingbackDetectNoCID: + log "Incoming call detected..." + success + +################################################################# +# +# MODEM IDENTIFICATION +# +################################################################# + +## +## Identify +## +## This is meant to be called from the top level, to just identify +## what's on the serial port and print out some info about it. +## + +Identify: + call ModemFind + if $ErrorMsg == "" goto Identify1 + failure +Identify1: + call ModemIdent + if $ModemDescription == "" failure + log "ANALOG=$ModemIsAnalog" + log "DESCRIPTION=$ModemDescription" + success + +## +## ModemIdent +## +## This identifies the type of modem and sets these variables accordingly: +## +## $ModemDescription +## $ModemSetupFunc +## $ModemAnsSetupFunc +## $ModemDetectRing +## $ModemIsAnalog +## +## If no response seen, this sets $ModemDescription to the empty string. +## + +ModemIdent: + set $ModemDescription "" + set $ModemSetupFunc "" + set $ModemAnsSetupFunc "" + set $ModemDetectRing "" + set $ModemIsAnalog "yes" + if $InitString != "" goto ModemIdentCustom + print "ATI\r\n" + match "ADTRAN EXPRESS XR" ModemIdentAdtranXRT + match "Model: Ovation MC950D Card" ModemIdentMC950D + match "C885" ModemIdentC885 + match "ERR" ModemIdentGeneric + match "OK\r\n" ModemIdentGeneric + wait 3 + print "ATI8\r\n" + match "BitSURFR PRO\r" ModemIdentBitsurfr + match "BitSURFR PRO EZ" ModemIdentBitsurfrEZ + match "3C882" ModemIdentImpactIQ + match "ERR" + match "OK\r\n" + wait 3 + print "ATI3\r\n" + match "Courier" ModemIdentUsr + match "Sportster" ModemIdentUsr + match "3ComImpact IQ" ModemIdentImpactIQ + match "U.S. Robotics 56K" ModemIdentUsr + match "ZOOM V.90" ModemIdentZoom56 + match "LT V.90" ModemIdentLucent + match "ERR" + match "OK\r\n" + wait 3 + print "ATI4\r\n" + match "AtermIT NEC Corporation" ModemIdentAterm + match "INSMATEV-7 NTT Corporation" ModemIdentAterm + match "MNP Class 10 V.34 Modem" ModemIdentDeskPorte + match "Smart One 56" ModemIdentSmartOne + match "ERR" + match "OK\r\n" + wait 3 + print "ATI1\r\n" + match "NTK omni.net" ModemIdentNTK + match "ERR" ModemIdentGeneric + match "OK\r\n" ModemIdentGeneric + wait 3 + log "The modem is not responding." + failure + +ModemIdentGeneric: + set $ModemDescription "Hayes compatible modem" + set $ModemSetupFunc GenericSetup + return + +ModemIdentCustom: + set $ModemDescription "Custom modem" + set $ModemSetupFunc CustomSetup + return + +ModemIdentUsr: + set $SportsterHack "no" + if $matchedString == "Sportster" set $SportsterHack "yes" + set $ModemDescription "USR $matchedString modem" + call GetOK + set $ModemSetupFunc UsrSetup + return +ModemIdentC885: + set $ModemDescription "Sierra Wireless Compass $matchedString USB 3G modem" + set $ModemSetupFunc GenericSetup + return +ModemIdentMC950D: + set $ModemDescription "Novatel Wireless $matchedString USB 3G modem" + set $ModemSetupFunc GenericSetup + return +ModemIdentBitsurfrEZ: + set $bitsEZ "yes" +ModemIdentBitsurfr: + set $ModemDescription "Motorola $matchedString" + call GetOK + set $ModemSetupFunc BitsurfrSetup + set $ModemIsAnalog "no" + set $ModemDetectRing BitsurfrDetectRing + return + +ModemIdentImpactIQ: + set $matchedString "3ComImpact IQ" + set $ModemDescription "$matchedString" + call GetOK + set $ModemSetupFunc ImpactIQSetup + set $ModemIsAnalog "no" + set $ModemDetectRing ImpactIQDetectRing + return + +ModemIdentAdtranXRT: + set $ModemDescription "AdTran Express XR/XRT" + call GetOK + set $ModemSetupFunc AdtranXRTSetup + set $ModemIsAnalog "no" + return + +ModemIdentAterm: + set $ModemDescription "NEC Aterm TA" + call GetOK + set $ModemSetupFunc AtermSetup + set $ModemIsAnalog "no" + return + +ModemIdentNTK: + set $ModemDescription "$matchedString" + call GetOK + set $ModemSetupFunc NTKSetup + set $ModemIsAnalog "no" + return + +ModemIdentDeskPorte: + set $ModemDescription "$matchedString" + call GetOK + set $ModemSetupFunc DeskPorteSetup + return + +ModemIdentZoom56: +ModemIdentSmartOne: + set $ModemDescription "$matchedString" + call GetOK + set $ModemSetupFunc Modem56Setup + return + +# Support the Lucent Winmodem, Xircom 56k +ModemIdentLucent: + set $ModemDescription "$matchedString" + call GetOK + set $ModemSetupFunc ModemLucentSetup + return + +################################################################# +# +# GENERIC MODEM SETUP +# +################################################################# + +GenericSetup: + set $noDialToneSubr GenericNoDialtone + set $temp "M1" + if $SpeakerOff == "yes" set $temp "M0" + set $modemCmd "&F&C1&D2E0S0=0${temp}" + call ModemCmd2 + return + +CustomSetup: + set $noDialToneSubr GenericNoDialtone + set $modemCmd "${InitString}" + call ModemCmd2 + return + +GenericNoDialtone: + log "No dialtone. Is the modem plugged in?" + return + +################################################################# +# +# USR MODEM SETUP +# +################################################################# + +UsrSetup: +# Lower baudrate to 57600 for crappy internal Sportster modem + if $SportsterHack != "yes" goto UsrSetup2 + if $modemDevice != "/dev/cuad2" goto UsrSetup2 + set $Baudrate 57600 + set $modemCmd "" + call ModemCmd2 +UsrSetup2: + set $noDialToneSubr GenericNoDialtone + set $temp "M1" + if $SpeakerOff == "yes" set $temp "M0" + set $modemCmd "&F1&C1&D2E0S0=0S13.0=1L0S6=5${temp}" + call ModemCmd2 + return + +################################################################# +# +# GENERAL 56K MODEM SETUP +# +################################################################# + +Modem56Setup: + set $noDialToneSubr GenericNoDialtone + set $temp "M1" + if $SpeakerOff == "yes" set $temp "M0" + set $modemCmd "&FL2W2E0${temp}" + call ModemCmd2 + return + +################################################################# +# +# LUCENT WINMODEM AND XIRCOM 56K SETUP +# +################################################################# + +ModemLucentSetup: + set $noDialToneSubr GenericNoDialtone + set $temp "M1" + if $SpeakerOff == "yes" set $temp "M0" + set $tempCountryCode "" + if $CountryCode != "" set $tempCountryCode "+GCI=${CountryCode}" + if $CountryCode != "" log "Use country ${CountryCode}" + set $modemCmd "&FL2W2E0${temp}${tempCountryCode}" + call ModemCmd2 + return + +################################################################# +# +# BITSURFR PRO AND BITSURFR PRO EZ SETUP +# +################################################################# + +BitsurfrSetup: + set $noDialToneSubr BitsurfrNoDialtone + set $factory "1" + if $bitsEZ == "yes" set $factory "0" + set $modemCmd "Z&F${factory}&C1&D2E0W1X2%A2=95S0=0" + call ModemCmd2 + +# Set to 230K baud if we support it + + if $bitsEZ != "yes" goto BitsurfrSetup1 + set $modemCmd "@P2=230400" + set $newBaudrate "230400" + call SetBaudrate + +# Check software revision and ISDN settings + +BitsurfrSetup1: + if $optimize == "yes" goto BitsurfrSetup2 + if $bitsEZ != "yes" call BitsurfrCheckRev + call BitsurfrCheckConfig + +# Set the PAP/CHAP, multi-link, and 56K/64K settings, and return + +BitsurfrSetup2: + set $authCmd "@M2=P" + if $TA_AuthChap == "yes" set $authCmd "@M2=C" + set $bondCmd "@B0=1" + if $TA_Bonding == "yes" set $bondCmd "@B0=2" + set $bearCmd "%A4=0" + if $TA_56K == "yes" set $bearCmd "%A4=1" + if $TA_VoiceCall == "yes" set $bearCmd "%A4=1" + set $voiceCmd "%A98=D%A96=0" + if $TA_VoiceCall == "yes" set $voiceCmd "%A98=S%A96=1" + +# BS PRO EZ changes + + if $bitsEZ == "yes" set $authCmd "${authCmd}@M20=\"\"" + set $modemCmd "$authCmd$bondCmd$bearCmd$voiceCmd" + call ModemCmd2 + if $TA_NoDoubleTelno == "yes" return + if $TA_Bonding == "yes" set $ModTelephone "${Telephone}&${Telephone}" + return + +## +## What to do when NO DIALTONE +## + +BitsurfrNoDialtone: + log "ISDN initialization failed (or BitSURFR restarting). Please verify proper line connection and ISDN settings." + return + +## +## BitsurfrCheckConfig +## +## Verify and adjust ISDN configuration as necessary +## + +BitsurfrCheckConfig: + log "Checking the BitSURFR's ISDN configuration..." + set $valueChanged "no" + +# Check switch type + + set $checkCmd "!C0" + set $checkValue "000" + set $checkValueNew "0" + if $TA_SwitchType == "DMS-100" set $checkValue "001" + if $TA_SwitchType == "DMS-100" set $checkValueNew "1" + if $TA_SwitchType == "NI-1" set $checkValue "002" + if $TA_SwitchType == "NI-1" set $checkValueNew "2" + set $checkMsg "Reprogramming switch type ($TA_SwitchType)..." + call ModemCheckValue + + set $checkCmd "!C1" + set $checkValue "004" + set $checkValueNew "4" + if $TA_SwitchType == "DMS-100" set $checkValue "003" + if $TA_SwitchType == "DMS-100" set $checkValueNew "3" + if $TA_SwitchType == "5ESS P2P" set $checkValue "000" + if $TA_SwitchType == "5ESS P2P" set $checkValueNew "0" + if $TA_SwitchType == "5ESS MP" set $checkValue "001" + if $TA_SwitchType == "5ESS MP" set $checkValueNew "1" + set $checkMsg "Reprogramming switch software version..." + call ModemCheckValue + +# Check directory numbers + + set $checkCmd "*1!N1" + set $checkValue $TA_Dirno1 + set $checkValueNew $TA_Dirno1 + set $checkMsg "Reprogramming voice line #1 directory number..." + call ModemCheckValue + + set $checkCmd "*2!N1" + set $checkValue $TA_Dirno2 + set $checkValueNew $TA_Dirno2 + set $checkMsg "Reprogramming voice line #2 directory number..." + call ModemCheckValue + set $checkCmd "!N1" + set $checkMsg "Reprogramming data line directory number..." + call ModemCheckValue + +# Check SPIDs + + set $checkCmd "*1!C6" + set $checkValue $TA_SPID1 + set $checkValueNew $TA_SPID1 + set $checkMsg "Reprogramming voice line #1 SPID..." + call ModemCheckValue + + set $checkCmd "*2!C6" + set $checkValue $TA_SPID2 + set $checkValueNew $TA_SPID2 + set $checkMsg "Reprogramming voice line #2 SPID..." + call ModemCheckValue + set $checkCmd "!C6" + set $checkMsg "Reprogramming data line SPID..." + call ModemCheckValue + +# Restart if necessary + + if $valueChanged == "no" return + log "Restarting BitSURFR Pro with new configuration..." + set $modemCmd ">W" + call ModemCmd2 + set $modemCmd ">Z" + call ModemCmd2 + failure + +## +## Verify the BitSURFR's software revision. Only do this +## once, the first time we try to dial. +## + +BitsurfrCheckRev: + log "Checking the BitSURFR's software revision..." + print "ATI3\r\n" + match "-1A" BitsurfrCheckRevOld + match "-1B" BitsurfrCheckRevOld + match "-1C" BitsurfrCheckRevOld + match "-1D" BitsurfrCheckRevOld + match "-1E" BitsurfrCheckRevOld + match "-1F" BitsurfrCheckRevOld + match "-1G" BitsurfrCheckRevOld + match "-1H" BitsurfrCheckRevOld + match "-1I" BitsurfrCheckRevOld + match "OK\r\n" BitsurfrCheckRevOK + match "ERR" + wait 5 + log "The BitSURFR did not properly answer ATI3." + failure +BitsurfrCheckRevOK: + return +BitsurfrCheckRevOld: + log "The BitSURFR Pro has an old software revision $matchedString. Please upgrade according to the manufacturer's instructions." + call GetOK + failure + +# This is how we detect an incoming call with a BitSURFR + +BitsurfrDetectRing: +# First, we need to be properly configured + call BitsurfrSetup +# Enable Caller-ID logging + set $modemCmd "@N0=1*1@N0=1*2@N0=1" + call ModemCmd + if $modemCmdResult != "OK" goto RingbackWait +# A "RING" at any time is good enough + match ringset "RING\r\n" RingbackDone +# Clear Caller-ID buffers + set $modemCmd "@L0*1@L0*2@L0" + call ModemCmd2 +# Read each buffer + call BitsurfrDetectReadCID + log "Remote Dial-Back mode enabled; waiting for incoming call." +# Now wait indefinitely for one of those buffers to change +BitsurfrDetectLoop: + wait 5 + set $oldDataCID $dataCID + set $oldVoice1CID $voice1CID + set $oldVoice2CID $voice2CID + call BitsurfrDetectReadCID + if $oldDataCID != $dataCID goto BitsurfrDetectDone + if $oldVoice1CID != $voice1CID goto BitsurfrDetectDone + if $oldVoice2CID != $voice2CID goto BitsurfrDetectDone + goto BitsurfrDetectLoop + +# Examine the CID from each port +BitsurfrDetectDone: + set $cid $dataCID + call BitsurfrDetectTryCID + set $cid $voice1CID + call BitsurfrDetectTryCID + set $cid $voice2CID + call BitsurfrDetectTryCID + goto RingbackDetectNoCID + +# Try to extract the calling party number +BitsurfrDetectTryCID: +# Strip the log number + if $cid match "[0-9] (.*)" set $cid $matchedString1 +# Check for various strings + if $cid match "BLOCKED" return + if $cid match "NO NUMBER" return + if $cid match "NO CID SERVICE" return + if $cid match "OUT OF AREA" return + goto RingbackDetectCID + +# Read Caller-ID buffers +BitsurfrDetectReadCID: + set $modemCmd "@L1" + call ModemQueryStrip + set $dataCID $modemQuery + set $modemCmd "*1@L1" + call ModemQueryStrip + set $voice1CID $modemQuery + set $modemCmd "*2@L1" + call ModemQueryStrip + set $voice2CID $modemQuery + return + +################################################################# +# +# 3COM IMPACT IQ SETUP +# +################################################################# + +ImpactIQSetup: + set $noDialToneSubr ImpactIQNoDialtone + set $modemCmd "Z&F%C2E0" + call ModemCmd2 + +# Set to 230K baud if we support it + + set $modemCmd "$$B230400" + set $newBaudrate "230400" + call SetBaudrate + +# Check ISDN config and link status (XXX should we check revision too?) + +ImpactIQSetup1: + if $optimize == "yes" goto IQInitSetup2 + call ImpactIQCheckConfig + call ImpactIQCheckLink + +# Now set the PAP/CHAP setting and voice/data originate mode setting + +IQInitSetup2: + set $authCmd "S84=1" + if $TA_AuthChap == "yes" set $authCmd "S84=0" + set $voiceCmd "S61=0" + if $TA_VoiceCall == "yes" set $voiceCmd "S61=1" + set $modemCmd "$authCmd$voiceCmd" + call ModemCmd2 + if $TA_NoDoubleTelno == "yes" return + if $TA_Bonding == "yes" set $ModTelephone "${Telephone}&${Telephone}" + return + +## +## What to do when NO DIALTONE +## + +ImpactIQNoDialtone: + log "ISDN config problem (or modem restart). Check your ISDN switch type, directory numbers, and SPID settings." + return + +## +## ImpactIQCheckLink +## +## Check the link status registers +## + +ImpactIQCheckLink: + log "Checking the ISDN modem's link status..." + print "ATS59?\r\n" + match "000" IQSyncFail + match "001" IQSyncOK + match "ERR" + match "OK\r\n" + wait 3 + call GetOK + log "The ISDN modem did not properly answer ATS59?" + failure +IQSyncOK: + call GetOK + goto ImpactIQCheckInit +IQSyncFail: + log "The ISDN modem is not receiving any ISDN signal. Please verify that it's connected to an ISDN line." + call GetOK + failure + +ImpactIQCheckInit: + set $impactInitReg "57" + call IQInitCheck + if $TA_Bonding == "yes" return + set $impactInitReg "58" + call IQInitCheck + return + +# A little subroutine + +IQInitCheck: + print "ATS${impactInitReg}?\r\n" + match "000" IQInitOK + match "001" IQInitOK + match "002" IQInitFail + match "ERR" + match "OK\r\n" + wait 3 + call GetOK + log "The ISDN modem did not properly answer ATS${impactInitReg}?" + failure +IQInitOK: + call GetOK + return +IQInitFail: + log "ISDN initialization failed. Please check your ISDN switch type, directory numbers, and SPID settings." + call GetOK + failure + +## +## ImpactIQCheckConfig +## +## Verify and adjust ISDN configuration as necessary +## + +ImpactIQCheckConfig: + log "Checking the ISDN modem's ISDN configuration..." + set $valueChanged "no" + +# Check switch type XXX +# +# NOTE: The Impact IQ changes the value of this field as it auto-detects. +# Not only that, but it cycles through each switch type as it is "trying +# out" that type, so that reading this field is pretty much useless... +# Our strategy is just to hope that auto-detect works! + + if $TA_NewSwitch != "yes" goto ImpactIQCheckDirnos + log "Initiating switch type auto-detect..." + set $modemCmd "S50=0" + call ModemCmd2 + set $TA_NewSwitch "" + set $valueChanged "yes" + set $iq_new_switch "yes" + +# Check directory numbers + +ImpactIQCheckDirnos: + set $checkCmd "S51" + set $checkValue $TA_Dirno1 + set $checkValueNew $TA_Dirno1 + set $checkMsg "Reprogramming line #1 directory number..." + call ModemCheckValue + + set $checkCmd "S53" + set $checkValue $TA_Dirno2 + set $checkValueNew $TA_Dirno2 + set $checkMsg "Reprogramming line #2 directory number..." + call ModemCheckValue + +# Check SPIDs + + set $checkCmd "S52" + set $checkValue $TA_SPID1 + set $checkValueNew $TA_SPID1 + set $checkMsg "Reprogramming line #1 SPID..." + call ModemCheckValue + + set $checkCmd "S54" + set $checkValue $TA_SPID2 + set $checkValueNew $TA_SPID2 + set $checkMsg "Reprogramming line #2 SPID..." + call ModemCheckValue + +# Check 56K/64K setting + + set $checkValue "064" + set $checkValueNew "64" + if $TA_56K == "yes" set $checkValue "056" + if $TA_56K == "yes" set $checkValueNew "56" + set $checkCmd "S60" + set $checkMsg "Reprogramming B channel data rate to ${checkValueNew}K..." + call ModemCheckValue + set $checkValueNew "" + +# Check Multi-link setting + + set $checkValue "000" + set $checkValueNew "0" + if $TA_Bonding == "yes" set $checkValue "001" + if $TA_Bonding == "yes" set $checkValueNew "1" + set $checkCmd "S80" + set $checkMsg "Reprogramming mutli-link PPP setting..." + call ModemCheckValue + +# Restart if necessary, and wait extra long if the switch type changed + + if $valueChanged == "no" return + log "Restarting ISDN modem with the new configuration..." + set $modemCmd "Z" + call ModemCmd2 + failure + +## +## Detect an incoming call with the 3Com +## + +ImpactIQDetectRing: + call ImpactIQSetup + if $modemCmdResult != "OK" goto RingbackWait + match ringset "RING\r\n" RingbackDone +# Clear Caller-ID buffers + set $modemCmd "\\N0" +# We don't care if this command fails... + call ModemCmd +# Read most recent incoming call + call ImpactIQDetectReadCID + log "Remote Dial-Back mode enabled; waiting for incoming call." +# Now wait for a change +ImpactIQDetectLoop: + wait 5 + set $oldIncomingCall $incomingCall + call ImpactIQDetectReadCID + if $oldIncomingCall != $incomingCall goto ImpactIQDetectDone + goto ImpactIQDetectLoop + +# Examine the CID from each port +ImpactIQDetectDone: + if $incomingCall !match "((.{14}).{10}) ((.{14}).{10}) ((.{14}).{10})" goto RingbackDetectNoCID + set $dataCID $matchedString2 + set $voice1CID $matchedString4 + set $voice2CID $matchedString6 + set $cid $dataCID + call ImpactIQDetectTryCID + set $cid $voice1CID + call ImpactIQDetectTryCID + set $cid $voice2CID + call ImpactIQDetectTryCID + goto RingbackDetectNoCID + +# Look for a valid CID string +ImpactIQDetectTryCID: + if $cid match " *" return + if $cid match " *N/A" return + goto RingbackDetectCID + +# Read first line of incoming call log (it's the 14th line of output) +ImpactIQDetectReadCID: + set $modemCmd "\\N" + call ModemCmdSend + call ReadLine +# Older version of the 3Com don't support this command + if $matchedString == "OK" return + if $matchedString match "ERR(O)?(R)?" return + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + call ReadLine + set $incomingCall $matchedString + call GetOK + return + +################################################################# +# +# NEC ATERM SETUP +# +################################################################# + +AtermSetup: + if $AtermHardReset == "yes" goto AtermSetup2 + +# Do hardware reset, which takes a while and doesn't give back "OK" + + log "Initializing modem..." + print "ATZ98\r\n" + wait 6 + set $AtermHardReset "yes" + failure + +AtermSetup2: + +# Set to 230K baud if we support it + + set $modemCmd "" + set $newBaudrate "230400" + call SetBaudrate + +# Is this an IT55 or IT65? + + set $atermIT65 "" + set $modemCmd "$$N14=0" + call ModemCmd + if $modemCmdResult == "OK" set $atermIT65 "yes" + +# Set normal stuff, PPP mode + + set $modemCmd "&C1&D0&K3X4$$N1=1$$N9=0" + call ModemCmd2 + +# Set the multi-link setting + + set $bondCmd "$$N11=0" + if $TA_Bonding == "yes" set $bondCmd "$$N11=1" + set $modemCmd "$bondCmd" + call ModemCmd2 + +# Additional settings for the IT65 go here... + + if $atermIT65 != "yes" return + return + +################################################################# +# +# MICROCOM DESKPORTE SETUP +# +################################################################# + +DeskPorteSetup: + set $noDialToneSubr GenericNoDialtone + set $temp "M1" + if $SpeakerOff == "yes" set $temp "M0" + set $modemCmd "Z&F&C1&D2X3E0S0=0${temp}" + call ModemCmd2 + return + +################################################################# +# +# KOREAN TERMINAL ADAPTER SETUP +# +################################################################# + +NTKSetup: + set $noDialToneSubr GenericNoDialtone + set $modemCmd "ZB40&J3" + call ModemCmd2 + return + +################################################################# +# +# ADTRAN EXPRESS XRT SETUP +# +################################################################# + +AdtranXRTSetup: + set $noDialToneSubr ImpactIQNoDialtone + set $dialErrorSubr AdtranXRTDialError + set $bonding "&F1" + if $TA_Bonding == "yes" set $bonding "&F2" + set $chap "S118=0" + if $TA_AuthChap == "yes" set $chap "S118=32" + set $origCmd "S53=3" + if $TA_56K == "yes" set $origCmd "S53=2" + if $TA_VoiceCall == "yes" set $origCmd "S53=0" + set $modemCmd "ZE0${bonding}&C1&D2${chap}${origCmd}" + call ModemCmd2 + +# Check ISDN config and link status (XXX should we check revision too?) + + if $optimize == "yes" return + call AdtranXRTCheckConfig + call AdtranXRTCheckLink + return + +## +## What to do when ERROR when dialing +## +## This is what the Adtran returns if the line is not ready yet. +## So we look into the status buffer to see if we recognize the +## error condition. +## + +AdtranXRTDialError: + call AdtranXRTDiagnose + failure + +## +## Check the last status bufffer entry for what the problem is +## XXX Figure out more stuff to look for and when it can happen +## + +AdtranXRTDiagnose: + log "Checking the Adtran status buffer..." + print "AT!S\r\n" + match "\r\n\r\n" AdtranXRTDiagBlank + match "END OF STATUS BUFFER" AdtranXRTDiagBlank + match "L1 not up." AdtranXRTDiagL1 + match "FACILITY_NOT_SUBSCRIBED" AdtranXRTDiagFNS + match "Unknown AT cmd" IQSyncOK + match "ERR" + match "OK\r\n" + wait 3 + call GetOK + log "The ISDN modem did not properly answer ATS59?" + failure + goto ImpactIQCheckInit + +AdtranXRTDiagFNS: + log "ISDN initialization failed. Please check your ISDN switch type, directory numbers, and SPID settings." + failure + +AdtranXRTDiagL1: + log "The ISDN modem is not receiving any ISDN signal. Please verify that it's connected to an ISDN line." + failure + +AdtranXRTDiagBlank: + log "ISDN initialization failed or restarting link. Please verify proper line connection and ISDN settings." + failure + +## +## AdtranXRTCheckLink +## +## Check the link status registers +## + +AdtranXRTCheckLink: + log "Checking the ISDN modem's link status..." + print "AT!S1\r\n" + match "Link In Sync" AdtranXRTSyncReg + match "Getting" AdtranXRTSyncReg + match "Register" AdtranXRTSyncReg + match "Ready" AdtranXRTSyncOK + match "Down" AdtranXRTSyncFail + match "ERR" + match "OK\r\n" + wait 3 + call GetOK + log "The ISDN modem did not properly answer AT!S1." + failure +AdtranXRTSyncOK: + return +AdtranXRTSyncFail: + print "ATDT1\r\n" + wait 1 + goto AdtranXRTDiagnose +AdtranXRTSyncReg: + log "The ISDN modem is initializing itself." + failure + +## +## AdtranXRTCheckConfig +## +## Verify and adjust ISDN configuration as necessary +## + +AdtranXRTCheckConfig: + log "Checking the ISDN modem's ISDN configuration..." + set $valueChanged "no" + + set $checkCmd "S52" + set $checkValue "000" + set $checkValueNew "0" + if $TA_SwitchType == "DMS-100" set $checkValue "001" + if $TA_SwitchType == "DMS-100" set $checkValueNew "1" + if $TA_SwitchType == "NI-1" set $checkValue "002" + if $TA_SwitchType == "NI-1" set $checkValueNew "2" + set $checkMsg "Reprogramming switch type ($TA_SwitchType)..." + call ModemCheckValue + +# Check directory numbers + +AdtranXRTCheckDirnos: + set $checkCmd "SS62" + set $checkValue $TA_Dirno1 + set $checkValueNew $TA_Dirno1 + set $checkMsg "Reprogramming line #1 directory number..." + call ModemCheckValue + + set $checkCmd "SS63" + set $checkValue $TA_Dirno2 + set $checkValueNew $TA_Dirno2 + set $checkMsg "Reprogramming line #2 directory number..." + call ModemCheckValue + +# Check SPIDs + + set $checkCmd "SS60" + set $checkValue $TA_SPID1 + set $checkValueNew $TA_SPID1 + set $checkMsg "Reprogramming line #1 SPID..." + call ModemCheckValue + + set $checkCmd "SS61" + set $checkValue $TA_SPID2 + set $checkValueNew $TA_SPID2 + set $checkMsg "Reprogramming line #2 SPID..." + call ModemCheckValue + +# Restart if necessary + + if $valueChanged == "no" return + log "Restarting ISDN modem with the new configuration..." + set $modemCmd "&W" + call ModemCmd2 + set $modemCmd "Z" + call ModemCmd2 + failure + +################################################################# +# +# BASIC MODEM STUFF +# +################################################################# + +## +## ModemAnswer +## +## Wait for a RING and answer it. Variables: +## +## $RingTimeout How long for a RING before giving up (default 10 min) +## $ConnectTimeout How long for connect after answering (default 45 secs) +## +## Returns: +## +## $answerReturn "OK" or "FAIL" +## $ConnectionSpeed Connection speed reported by modem (possibly empty) +## + +ModemAnswer: + if $RingTimeout == "" set $RingTimeout 600 + if $ConnectTimeout == "" set $ConnectTimeout 45 + match "RING\r" ModemAnswerGotRing + wait $RingTimeout + log "No RING detected after $RingTimeout seconds." + set $answerReturn "FAIL" + return +ModemAnswerGotRing: + log "Incoming call detected..." + print "ATA\r\n" + regex "CONNECT *([0-9]*).*$" ModemAnswerConnect + wait $ConnectTimeout + log "Failed to connect incoming call." + set $answerReturn "FAIL" + return +ModemAnswerConnect: + set $ConnectionSpeed $matchedString1 + set $answerReturn "OK" + return + +## +## ModemFind +## +## Just try to get where we are talking to the modem. +## Returns with $ErrorMsg equal to the empty string if +## we found the modem, or else some error message if not. +## + +ModemFind: + +# Do a quick check first... + + set $ErrorMsg "" + call ModemFind4 + if $modemCmdResult == "OK" return + if $Serial230K != "yes" goto ModemFind1 + set $newBaudrate 230400 + if $Baudrate == "230400" set $newBaudrate 115200 + set $Baudrate $newBaudrate + call ModemFind4 + if $modemCmdResult == "OK" return + +# Now try possible baud rates more extensively + +ModemFind1: + set $Baudrate 115200 + call ModemFind2 + if $modemCmdResult == "OK" return + if $Serial230K != "yes" return + set $Baudrate 230400 + wait 1 + call ModemFind2 + if $modemCmdResult == "OK" return + set $ErrorMsg "The modem is not responding." + return + +# This tries the +++ sequence in case the modem is in "on-line" mode + +ModemFind2: + call ModemFind3 + if $modemCmdResult == "OK" return + call SendTriplePlus + call ModemFind3 + return + +# This tries a few commands to see if the modem responds with "OK" + +ModemFind3: + set $modemCmd "" + set $modemCmdTimeout 1 + call ModemCmd0 + if $modemCmdResult == "OK" return + set $modemCmd "Z" + set $modemCmdTimeout 2 + call ModemCmd0 + if $modemCmdResult == "OK" return +ModemFind4: + set $modemCmd "" + set $modemCmdTimeout 1 + call ModemCmd0 + return + +## +## SetBaudrate +## +## Change baud rates (as allowed) and verify modem is still there. +## If not, then fail the script. +## +## $newBaudrate New baud rate; if we don't support it, just return. +## $modemCmd Command to send modem to jump to the new baud rate. +## + +SetBaudrate: + if $Baudrate == $newBaudrate return + if $newBaudrate != 230400 goto SetBaudrate2 + if $Serial230K != "yes" return +SetBaudrate2: + log "Setting serial port speed to $newBaudrate..." + print "AT$modemCmd\r\n" + wait 1 + set $Baudrate $newBaudrate + wait 1 + set $modemCmd "" + goto ModemCmd2 + +## +## ModemCheckValue +## +## Check the value in an S-register (or equivalent). If it is +## not what we want, then change it and set $valueChanged to "yes", +## and log $checkMsg (if not empty). The value $checkValueNew is +## what we program the S-register to equal if it doesn't match. +## +## The $checkValue must match exactly on the first line of output. +## If we get any wierd error, then fail the script. +## + +ModemCheckValue: + set $modemCmd "${checkCmd}?" + call ModemQuery + if $modemQuery == $checkValue return + set $valueChanged "yes" + set $checkValueMyNew $checkValueNew + if $checkValueNew == "" set $checkValueMyNew $checkValue + set $modemCmd "${checkCmd}=${checkValueMyNew}" + if $checkMsg != "" log $checkMsg + goto ModemCmd2 + +## +## ModemCmd +## +## Do the modem command in $modemCmd. Set $modemCmdResult to +## +## OK The modem returned "OK" +## ERROR The modem returned "ERR" or "ERROR" +## TIMEOUT The modem did not respond within three seconds +## +## If ERR or TIMEOUT, also set $ErrorMsg to an appropriate message +## + +ModemCmd: + set $modemCmdTimeout 3 +ModemCmd0: + print "AT$modemCmd\r\n" + match "OK\r\n" ModemCmdOk + match "ERR" ModemCmdErr + wait $modemCmdTimeout + set $modemCmdResult "TIMEOUT" +ModemCmdTimeout: + set $ErrorMsg "The modem is not responding." + return +ModemCmdOk: + set $modemCmdResult "OK" + return +ModemCmdErr: + set $modemCmdResult "ERROR" + set $ErrorMsg "The modem did not accept the command AT$modemCmd." + return + +## +## ModemCmd2 +## +## Do the modem command in $modemCmd. If we don't get OK back, +## fail the script and log an error message. +## + +ModemCmd2: + call ModemCmd + if $modemCmdResult == "OK" return + log $ErrorMsg + failure + +## +## ModemCmdSend +## +## Send a modem command and read the echo'ed CR-LF +## + +ModemCmdSend: + print "AT$modemCmd\r\n" + match "\r\n" ModemCmdSend2 + wait 3 + goto ModemCmdTimeout +ModemCmdSend2: + return + +## +## ModemQuery +## +## Do the $modemCmd and expect exactly one line of response, then OK. +## Return the response in $modemQuery. If anything goes wrong, die. +## + +ModemQuery: + call ModemCmdSend + call ReadLine + set $modemQuery $matchedString + if $modemQuery == "ERR" goto ModemQueryError + if $modemQuery == "ERROR" goto ModemQueryError + goto GetOK +ModemQueryError: + call ModemCmdErr + failure + +# Same thing, but strip leading and trailing blanks + +ModemQueryStrip: + call ModemQuery + if $modemQuery match " *(.*) *" nop + set $modemQuery $matchedString1 + return + +## +## ReadLine +## +## Read the next line of output. It should come within $modemCmdTimeout +## seconds, or else we fail. Return it in $matchedString. +## + +ReadLine: + regex "^.*$" ReadLineDone + wait $modemCmdTimeout + set $ErrorMsg "The modem is not responding." + log $ErrorMsg + failure +ReadLineDone: + return + +## +## Get an OK within 3 seconds or die +## + +GetOK: + match "OK\r\n" GotOK + wait 3 + log "The modem is not responding." + failure +GotOK + return + +## +## Send "+++" to get modem attention if on-line +## + +SendTriplePlus: + print "\r\n" + wait 2 + print "+++" + wait 2 + return + +################################################################# +# +# LOGIN AUTO-SCRIPTING +# +################################################################# + +## +## AutoLogin +## +## Here we attempt to figure out what the remote server wants +## from us. We do this by checking for bytes that correspond +## to PPP packets (in which case we are done) as well as common +## login type stuff like "name:", "ogin:", etc. +## +## This always returns. The hope is that when it returns, the +## remote side has reached PPP mode. +## +## This has been crafted from empirical evidence. Lots of terminal +## servers have various intelligent/stupid features which we +## take advantage of/have to work around. +## +## Variables (set automatically by mpd): +## +## $Login Authorization login +## $Password Authorization password +## + +AutoLogin: + log "Initiating auto-login..." + +# Spend at most this long doing auto-login before giving up + + timer autoLogin 5 AutoLoginTimeout + +# At any time if we see an LCP frame (not our own echo) then we're done + + match autoLogin "\x7e\xff\x03\xc0\x21" AutoLoginFrame + match autoLogin "\x7e\xff\x7d\x23\xc0\x21\x7d\x21" AutoLoginFrame + match autoLogin "\x7e\xc0\x21" AutoLoginFrame + +# Now send a "fake" PPP frame (this is an empty config-reject with id# 172). +# This should trigger any auto-detecting servers to jump into PPP mode, +# which is good because it's faster (by avoiding human readable messages) +# and more reliable (PPP framing). + + print "\x7e\xff\x7d\x23\xc0\x21\x7d\x24\xac\x7d\x20\x7d\x24\x2e\x2b\x7e" + +# Wait one second for server to auto-detect PPP or send a login prompt. +# After one second of neither, try sending a carriage return (some servers +# require this). After that, we have to see something recognizable from +# the peer, otherwise we'll just timeout. + + match "ogin" AutoLoginPrompt + match "name" AutoLoginPrompt + wait 1 + print "\r" + match "ogin" AutoLoginPrompt + match "name" AutoLoginPrompt + wait + +# At this point we've seen a login prompt; do the manual login + +AutoLoginPrompt: + log "Sending login..." + print "${Login}\r" + match "word" + wait + log "Sending password..." + print "${Password}\r" + match "\r" + wait + if $didLogin != "yes" match "ogin:" LoginAgain + match ">" + match "%" + match ":" + wait + log "Enabling PPP..." + print "ppp\r" + cancel all + return + +LoginAgain: + set $didLogin "yes" + goto AutoLoginPrompt + +# We saw a PPP frame + +AutoLoginFrame: + log "Detected PPP frame." + cancel all + return + +# We timed out before seeing a PPP frame. Cross your fingers and pray. + +AutoLoginTimeout: + log "Auto-login timeout." + cancel all + return + diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php index f5c13aa..71b4a70 100755 --- a/usr/local/www/interfaces_assign.php +++ b/usr/local/www/interfaces_assign.php @@ -127,12 +127,11 @@ if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry /* add PPP interfaces */ if (is_array($config['ppps']['ppp']) && count($config['ppps']['ppp'])) { - $i = 0; foreach ($config['ppps']['ppp'] as $ppp) { - $portname = 'ppp_' . basename($ppp['port']); + $portname = "ppp{$ppp['pppid']}"; + log_error("portname = " . $portname); $portlist[$portname] = $ppp; $portlist[$portname]['isppp'] = true; - $i++; } } @@ -202,9 +201,10 @@ if ($_POST['apply']) { $reloadif = true; } $config['interfaces'][$ifname]['if'] = $ifport; - if (preg_match('/^ppp_(.+)$/', $ifport, $matches)) { + if (preg_match('/^ppp[0-9]+/',$ifport)){ + $config['interfaces'][$ifname]['serialport'] = basename($portlist[$ifport]['port']); $config['interfaces'][$ifname]['pointtopoint'] = true; - $config['interfaces'][$ifname]['serialport'] = $matches[1]; + $config['interfaces'][$ifname]['ipaddr'] = "ppp"; } else { unset($config['interfaces'][$ifname]['pointtopoint']); unset($config['interfaces'][$ifname]['serialport']); @@ -415,7 +415,7 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed")) $descr .= " (" . $portinfo['descr'] . ")"; echo htmlspecialchars($descr); } elseif ($portinfo['isppp']) { - $descr = "PPP {$portinfo['port']}"; + $descr = "{$portname} {$portinfo['port']}"; if ($portinfo['descr']) $descr .= " (" . $portinfo['descr'] . ")"; echo htmlspecialchars($descr); diff --git a/usr/local/www/interfaces_ppp.php b/usr/local/www/interfaces_ppp.php index 3eb93ba..3b5d339 100644 --- a/usr/local/www/interfaces_ppp.php +++ b/usr/local/www/interfaces_ppp.php @@ -67,7 +67,7 @@ if ($_GET['act'] == "del") { } else { unset($a_ppps[$_GET['id']]); write_config(); - interfaces_ppp_configure(); + interface_ppp_configure(-1); header("Location: interfaces_ppp.php"); exit; } @@ -103,12 +103,15 @@ include("head.inc"); <div id="mainarea"> <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> + <td width="10%" class="listhdrr">PPP Port</td> <td width="20%" class="listhdrr">Serial Port</td> - <td width="50%" class="listhdr">Description</td> + <td width="40%" class="listhdr">Description</td> <td width="10%" class="list"></td> </tr> <?php $i = 0; foreach ($a_ppps as $id => $ppp): ?> <tr ondblclick="document.location='interfaces_ppp_edit.php?id=<?=$i;?>'"> + <td class="listr">ppp<?=htmlspecialchars($ppp['pppid']);?> + </td> <td class="listr"> <?=htmlspecialchars($ppp['port']);?> </td> @@ -120,7 +123,7 @@ include("head.inc"); </tr> <?php $i++; endforeach; ?> <tr> - <td class="list" colspan="2"> </td> + <td class="list" colspan="3"> </td> <td class="list"> <a href="interfaces_ppp_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> </tr> </table> diff --git a/usr/local/www/interfaces_ppp_edit.php b/usr/local/www/interfaces_ppp_edit.php index ca5fc6c..56146dd 100644 --- a/usr/local/www/interfaces_ppp_edit.php +++ b/usr/local/www/interfaces_ppp_edit.php @@ -56,18 +56,19 @@ if (isset($_POST['id'])) if (isset($id) && $a_ppps[$id]) { $pconfig['port'] = $a_ppps[$id]['port']; - $pconfig['ap'] = $a_ppps[$id]['ap']; - $pconfig['initstr'] = $a_ppps[$id]['initstr']; + $pconfig['initstr'] = base64_decode($a_ppps[$id]['initstr']); + $pconfig['simpin'] = $a_ppps[$id]['simpin']; + $pconfig['pin-wait'] = $a_ppps[$id]['pin-wait']; + $pconfig['apn'] = $a_ppps[$id]['apn']; + $pconfig['apnum'] = $a_ppps[$id]['apnum']; + $pconfig['phone'] = $a_ppps[$id]['phone']; $pconfig['username'] = $a_ppps[$id]['username']; $pconfig['password'] = $a_ppps[$id]['password']; - $pconfig['gateway'] = $a_ppps[$id]['gateway']; $pconfig['localip'] = $a_ppps[$id]['localip']; + $pconfig['gateway'] = $a_ppps[$id]['gateway']; if (isset($a_ppps[$id]['defaultgw'])) $pconfig['defaultgw'] = true; - $pconfig['phone'] = $a_ppps[$id]['phone']; - $pconfig['dialcmd'] = base64_decode($a_ppps[$id]['dialcmd']); - $pconfig['connect-max-attempts'] = $a_ppps[$id]['connect-max-attempts']; - $pconfig['linespeed'] = $a_ppps[$id]['linespeed']; + $pconfig['connect-timeout'] = $a_ppps[$id]['connect-timeout']; $pconfig['descr'] = $a_ppps[$id]['descr']; } @@ -94,11 +95,37 @@ if ($_POST) { if (!$input_errors) { $ppp = array(); + if (isset($id)) + $ppp['pppid'] = $id; + else + $ppp['pppid'] = count($a_ppps); + $ppp['port'] = $_POST['port']; - $ppp['initstr'] = $_POST['initstr']; - $ppp['ap'] = $_POST['ap']; + if ($_POST['initstr'] <> "") + $ppp['initstr'] = base64_encode($_POST['initstr']); + else + unset($ppp['initstr']); + + if ($_POST['simpin'] <> "") { + $ppp['simpin'] = $_POST['simpin']; + $ppp['pin-wait'] = $_POST['pin-wait']; + } else { + unset($ppp['simpin']); + unset($ppp['pin-wait']); + } + + $ppp['apn'] = $_POST['apn']; + if ($ppp['apn'] <> ""){ + if ($_POST['apnum'] <> "") + $ppp['apnum'] = $_POST['apnum']; + else + $ppp['apnum'] = "1"; + } else { + unset($ppp['apn']); + unset($ppp['apnum']); + } + $ppp['phone'] = $_POST['phone']; - $ppp['dialcmd'] = base64_encode($_POST['dialcmd']); $ppp['username'] = $_POST['username']; $ppp['password'] = $_POST['password']; $ppp['localip'] = $_POST['localip']; @@ -107,8 +134,10 @@ if ($_POST) { $ppp['defaultgw'] = true; else unset($ppp['defaultgw']); - $ppp['linespeed'] = $_POST['linespeed']; - $ppp['connect-max-attempts'] = $_POST['connect-max-attempts']; + if ($_POST['connect-timeout'] <> "") + $ppp['connect-timeout'] = $_POST['connect-timeout']; + else + unset($ppp['connect-timeout']); $ppp['descr'] = $_POST['descr']; @@ -119,7 +148,7 @@ if ($_POST) { write_config(); - interfaces_ppp_configure(); + interface_ppp_configure(-1,true); header("Location: interfaces_ppp.php"); exit; @@ -139,25 +168,28 @@ include("head.inc"); </script> <script type="text/javascript"> function prefill_att() { - $('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATQ0V1E1S0=0&C1&D2+FCLASS=0 OK \AT+CGDCONT=1,\\\\\\"IP\\\\\\",\\\\\\"ISP.CINGULAR\\\\\\" OK \\\\dATDT\\\\T \TIMEOUT 40 CONNECT"'; + $('initstr').value = "Q0V1E1S0=0&C1&D2+FCLASS=0"; + $('apn').value = "ISP.CINGULAR"; + $('apnum').value = "1"; $('phone').value = "*99#"; $('username').value = "att"; $('password').value = "att"; - $('linespeed').value = "921600"; } function prefill_sprint() { - $('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"'; + $('initstr').value = "E1Q0"; + $('apn').value = ""; + $('apnum').value = ""; $('phone').value = "#777"; $('username').value = "sprint"; $('password').value = "sprint"; - $('linespeed').value = "921600"; } function prefill_vzw() { - $('dialcmd').value = '"ABORT BUSY ABORT NO\\\\sCARRIER TIMEOUT 5 \\"\\" AT OK-AT-OK ATE1Q0s7=60 OK \\\\dATDT\\\\T TIMEOUT 40 CONNECT"'; + $('initstr').value = "E1Q0s7=60"; + $('apn').value = ""; + $('apnum').value = ""; $('phone').value = "#777"; $('username').value = "123@vzw3g.com"; $('password').value = "vzw"; - $('linespeed').value = "921600"; } </script> <table width="100%" border="0" cellpadding="6" cellspacing="0"> @@ -192,32 +224,47 @@ include("head.inc"); <tr> <td width="22%" valign="top" class="vncell">Link Type</td> <td width="78%" class="vtable"> - <input type="checkbox" value="on" id="defaultgw" name="defaultgw" <?php if (isset($pconfig['defaultgw'])) echo "checked"; ?>>This link will be used as default gateway. + <input type="checkbox" value="on" id="defaultgw" name="defaultgw" <?php if (isset($pconfig['defaultgw'])) echo "checked"; ?>>This link will be used as the default gateway. </td> </tr> <tr> <td width="22%" valign="top" class="vncell">Init String</td> <td width="78%" class="vtable"> <textarea id="initstr" name="initstr"><?=htmlspecialchars($pconfig['initstr']);?></textarea> - <br><span class="vexpl">Enter the modem initialization string here</span> + <br><span class="vexpl">Note: Enter the modem initialization string here. Do NOT include the "AT" string at the beginning of the command.</span> </td> </tr> <tr> - <td width="22%" valign="top" class="vncell">AP Hostname</td> + <td width="22%" valign="top" class="vncell">Sim PIN</td> <td width="78%" class="vtable"> - <input name="ap" type="text" class="formfld unknown" id="ap" size="40" value="<?=htmlspecialchars($pconfig['ap']);?>"> + <input name="simpin" type="text" class="formfld unknown" id="simpin" size="12" value="<?=htmlspecialchars($pconfig['simpin']);?>"> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">Sim PIN wait</td> + <td width="78%" class="vtable"> + <input name="pin-wait" type="text" class="formfld unknown" id="pin-wait" size="2" value="<?=htmlspecialchars($pconfig['pin-wait']);?>"> + <br><span class="vexpl">Note: Time to wait for SIM to discover network after PIN is sent to SIM (seconds).</span> </td> </tr> <tr> - <td width="22%" valign="top" class="vncell">Dial command</td> + <td width="22%" valign="top" class="vncell">Access Point Name (APN)</td> <td width="78%" class="vtable"> - <textarea rows="4" cols="65" name="dialcmd" id="dialcmd"><?=htmlspecialchars($pconfig['dialcmd']);?></textarea> - </td> + <input name="apn" type="text" class="formfld unknown" id="apn" size="40" value="<?=htmlspecialchars($pconfig['apn']);?>"> + </td> + </tr> + <tr> + <td width="22%" valign="top" class="vncell">APN number (optional)</td> + <td width="78%" class="vtable"> + <input name="apnum" type="text" class="formfld unknown" id="apnum" size="2" value="<?=htmlspecialchars($pconfig['apnum']);?>"> + <br><span class="vexpl">Note: Defaults to 1 if you set APN above. Ignored if you set no APN above.</span> + </td> </tr> <tr> <td width="22%" valign="top" class="vncell">Phone Number</td> <td width="78%" class="vtable"> <input name="phone" type="text" class="formfld unknown" id="phone" size="40" value="<?=htmlspecialchars($pconfig['phone']);?>"> + <br><span class="vexpl">Note: Typically (*99# or *99***# or *99***1#) for GSM networks and *777 for CDMA networks</span> </td> </tr> <tr> @@ -236,33 +283,29 @@ include("head.inc"); <td width="22%" valign="top" class="vncell">Local IP</td> <td width="78%" class="vtable"> <input name="localip" type="text" class="formfld unknown" id="localip" size="40" value="<?=htmlspecialchars($pconfig['localip']);?>"> - <span><p>Note: Enter your IP address here if it is not automatically assigned.</span> + <br><span class="vexpl">Note: Enter your IP address here if it is not automatically assigned.</span> </td> </tr> <tr> - <td width="22%" valign="top" class="vncell">Remote IP</td> + <td width="22%" valign="top" class="vncell">Remote IP (Gateway)</td> <td width="78%" class="vtable"> <input name="gateway" type="text" class="formfld unknown" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>"> - <span><p>Note: Enter the remote IP here if not automatically assigned. This is where the packets will be routed, equivalent to the gateway.</span> + <br><span class="vexpl">Note: Enter the remote IP here if not automatically assigned. This is where the packets will be routed.</span> </td> </tr> <tr> - <td width="22%" valign="top" class="vncell">Line Speed</td> - <td width="78%" class="vtable"> - <input name="linespeed" type="text" class="formfld unknown" id="linespeed" size="40" value="<?=htmlspecialchars($pconfig['linespeed']);?>"> - </td> - </tr> <tr> - <td width="22%" valign="top" class="vncell">Maximum connection retry</td> + <td width="22%" valign="top" class="vncell">Connection Timeout</td> <td width="78%" class="vtable"> - <input name="connect-max-attempts" type="text" class="formfld unknown" id="connect-max-attempts" size="2" value="<?=htmlspecialchars($pconfig['connect-max-attempts']);?>"> + <input name="connect-timeout" type="text" class="formfld unknown" id="connect-timeout" size="2" value="<?=htmlspecialchars($pconfig['connect-timeout']);?>"> + <br><span class="vexpl">Note: Enter timeout in seconds for connection to be established (sec.) Default is 45 sec.</span> </td> </tr> <tr> <td width="22%" valign="top" class="vncell">Description</td> <td width="78%" class="vtable"> <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>"> - <br> <span class="vexpl">You may enter a description here for your reference (not parsed).</span> + <br><span class="vexpl">You may enter a description here for your reference (not parsed).</span> </td> </tr> <tr> diff --git a/usr/local/www/status_interfaces.php b/usr/local/www/status_interfaces.php index 80ef507..5ebde3d 100755 --- a/usr/local/www/status_interfaces.php +++ b/usr/local/www/status_interfaces.php @@ -143,17 +143,19 @@ include("head.inc"); <a href="status_interfaces.php?action=Disconnect&if=<?php echo $ifdescr; ?>"> <input type="button" name="<?php echo $ifdescr; ?>" value="Disconnect" class="formbtns"> <?php else: ?> - <a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>"> - <input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns"> + <?php if (!$ifinfo['missing_device']): ?> + <a href="status_interfaces.php?action=Connect&if=<?php echo $ifdescr; ?>"> + <input type="button" name="<?php echo $ifdescr; ?>" value="Connect" class="formbtns"> + <?php endif; ?> <?php endif; ?> </a> </td> </tr> <?php endif; if ($ifinfo['ppp_uptime'] || $ifinfo['ppp_uptime_accumulated']): ?> <tr> - <td width="22%" class="vncellt">PPP uptime</td> + <td width="22%" class="vncellt">PPP uptime (historical)</td> <td width="78%" class="listr"> - <?=htmlspecialchars($ifinfo['ppp_uptime']);?>Previous Sessions: <?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?> + <span id="uptime"><?=htmlspecialchars($ifinfo['ppp_uptime']);?></span><span id="uptime_hist"> (<?=htmlspecialchars($ifinfo['ppp_uptime_accumulated']);?>)</span> </td> </tr> <?php endif; if ($ifinfo['macaddr']): ?> |