; Pre-configured SIP trunks
-[voip]
+[voip] ; "Generic" easy-asterisk do not remove this comment
type=friend
context=default
user=user
allow=ulaw,g729
qualify=yes
+;[oeg] ; "OEG" easy-asterisk do not remove this comment
+;host=voip.oeg.com.au
+;secret=pass
+;user=your user number
+;fromdomain=voip.oeg.com.au
+;fromuser=your user number
+;insecure=port,invite
+;type=friend
+;disallow=all
+;allow=g729,ulaw
+;dtmfmod=rfc2833
+;qualify=yes
+;canreinvite=no
+;nat=yes
+;context=default
+
is present, or the IP phone has not been set
up.</div>
+<div id="voiplines_voiplines" class="tip">
+ A VOIP line allows you to make and receive
+ phones calls over the Internet. Normally a
+ VOIP line is provided by an Internet Telephony
+ Service Provider (ITSP). They will give you
+ an account, which includes the user and
+ password details that you can fill in below.
+ Refresh this page on your browser to see if
+ your VOIP line is working. </div>
+
$next_state = "finished";
#print "$next_state\n";
}
+ if (/^;.*\[/) { # commented out next stanza
+ $next_state = "finished";
+ }
- if (/user=(.*)/) {
+ if (/^user=(.*)/) {
$user = $1;
}
- if (/secret=(.*)/) {
+ if (/^secret=(.*)/) {
$pass = $1;
}
- if (/host=(.*)/) {
+ if (/^host=(.*)/) {
$host = $1;
}
}
}
close SIP;
+# Determine list of possible VOIP lines to use
+
+open SIP, "/etc/asterisk/sip.conf";
+
+@voiplines=();
+
+while (<SIP>) {
+ if (/^;\[.* \"(.*)\" easy-asterisk/) {
+ push (@voiplines, $1);
+ #print "$1\n";
+ }
+ if (/^\[.* \"(.*)\" easy-asterisk/) {
+ push (@voiplines, $1);
+ $voipline_current = $1;
+ #print "$1\n";
+ }
+}
+close SIP;
+
+# Determine if Asterisk can see our Voip Line (SIP trunk)
+
+my %voip = (); # SIP trunks status keyed on sip.conf names
+ # if no entry we can't see SIP trunk
+
+open SIP, "sipshowpeers.txt";
+while (<SIP>) {
+ if (/^(voip[0-9]*)[\s\/].*(OK)/) {
+ $voip{$1} = $2;
+ #print "'$1' '$2' $voip{$1}\n";
+ $e = $1;
+ if (/\s([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\s/) {
+ $ipad{$e} = $1;
+ #print "'$1'\n";
+ }
+ }
+}
+
+close SIP;
+
# generate form fields -------------------------------------------
+print "<tr><td>Provider</td><td>\n";
+print "<select name=\"voiplines\">\n";
+foreach (@voiplines) {
+ if ($_ eq $voipline_current) {
+ print "<option selected=\"yes\">$_</option>\n";
+ }
+ else {
+ print "<option>$_</option>\n";
+ }
+}
+print "</select></td></tr>\n";
+
print "<tr><td>User:</td><td><input type=\"text\" name=\"user\" value=\"$user\"></td></tr>\n";
print "<tr><td>Password:</td><td><input type=\"password\" name=\"pass\" value=\"$pass\"></td></tr>";
print "<tr><td>Host:</td><td><input type=\"text\" name=\"host\" value=\"$host\"></td></tr>";
+if ($voip{"voip"} eq "OK") {
+ $icon = "<img src=\"tick.png\" alt=\"VOIP Line OK\" />";
+}
+else {
+ $icon = "<img src=\"cross.png\" alt=\"VOIP Line OK\" />";
+}
+print "<tr><td>Voip Line Status:</td><td>$icon</td></tr>";
exit
fi
+# See if we have can reach the VOIP Line host
+
+asterisk "-rx sip show peers" 2>/dev/null > sipshowpeers.txt
+
# Construct the web page -------------------------------
cat <<EOF
<table align="right" width=600>
<tr><td> </td></tr>
<form action="set_voiplines.sh" method="get">
- <tr><td align="left" valign="top"><h2>VOIP Line</h2></td></tr>
+ <tr><td onMouseOver="popUp(event,'voiplines_voiplines')" onmouseout="popUp(event,'voiplines_voiplines')" align="left" valign="top"><h2>VOIP Line</h2></td></tr>
<tr><td> </td></tr>
EOF