]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/modem-status.cgi
Merge remote-tracking branch 'ms/dns-forwarding' into next
[ipfire-2.x.git] / html / cgi-bin / modem-status.cgi
CommitLineData
c5e3d520
MT
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
d4af74b7 5# Copyright (C) 2007-2014 IPFire Team <info@ipfire.org> #
c5e3d520
MT
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22use strict;
23
24# enable only the following on debugging purpose
25use warnings;
26use CGI::Carp 'fatalsToBrowser';
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
31require "${General::swroot}/modem-lib.pl";
32
33my $modem;
34my %ethsettings = {};
35my %pppsettings = {};
36
37&General::readhash("${General::swroot}/ethernet/settings", \%ethsettings);
38
39if ($ethsettings{"RED_TYPE"} eq "PPPOE") {
40 &General::readhash("${General::swroot}/ppp/settings", \%pppsettings);
41
42 # Establish the connection to the modem.
43 my $port = $pppsettings{'MONPORT'};
44 if ($port) {
45 $port = "/dev/$port";
46 $modem = Modem->new($port, $pppsettings{"DTERATE"});
47 }
48}
49
50&Header::showhttpheaders();
51&Header::openpage($Lang::tr{'modem information'}, 1, '');
52&Header::openbigbox('100%', 'left');
53
54if ($modem) {
55 &Header::openbox("100%", "center", $Lang::tr{'modem hardware details'});
56
57 print <<END;
58 <table width="100%">
59 <tbody>
60END
61
62 my $vendor = $modem->get_vendor();
63 if ($vendor) {
64 print <<END;
65 <tr>
66 <td width="33%">$Lang::tr{'vendor'}</td>
67 <td>$vendor</td>
68 </tr>
69END
70 }
71
72 my $model = $modem->get_model();
73 if ($model) {
74 print <<END;
75 <tr>
76 <td width="33%">$Lang::tr{'model'}</td>
77 <td>$model</td>
78 </tr>
79END
80 }
81
82 my $software_version = $modem->get_software_version();
83 if ($software_version) {
84 print <<END;
85 <tr>
86 <td width="33%">$Lang::tr{'software version'}</td>
87 <td>$software_version</td>
88 </tr>
89END
90 }
91
92 my $imei = $modem->get_imei();
93 if ($imei) {
94 print <<END;
95 <tr>
96 <td width="33%">$Lang::tr{'imei'}</td>
97 <td>$imei</td>
98 </tr>
99END
100 }
101
102 my @caps = $modem->get_capabilities();
103 if (@caps) {
104 my $caps_string = join(", ", @caps);
105
106 print <<END;
107 <tr>
108 <td width="33%">$Lang::tr{'capabilities'}</td>
109 <td>$caps_string</td>
110 </tr>
111END
112 }
113
114 print <<END;
115 </tbody>
116 </table>
117END
118 &Header::closebox();
119
120
121 &Header::openbox("100%", "center", $Lang::tr{'modem sim information'});
122 print <<END;
123 <table width="100%">
124 <tbody>
125END
126
127 my $imsi = $modem->get_sim_imsi();
128 if ($imsi) {
129 print <<END;
130 <tr>
131 <td width="33%">$Lang::tr{'imsi'}</td>
132 <td>$imsi</td>
133 </tr>
134END
135 }
136
137 print <<END;
138 </tbody>
139 </table>
140END
141 &Header::closebox();
142
143 &Header::openbox("100%", "center", $Lang::tr{'modem network information'});
144 print <<END;
145 <table width="100%">
146 <tbody>
147END
148
149 my $network_registration = $modem->get_network_registration();
150 if ($network_registration) {
151 print <<END;
152 <tr>
153 <td width="33%">$Lang::tr{'modem network registration'}</td>
154 <td>$network_registration</td>
155 </tr>
156END
157 }
158
159 my $network_operator = $modem->get_network_operator();
160 if ($network_operator) {
161 print <<END;
162 <tr>
163 <td width="33%">$Lang::tr{'modem network operator'}</td>
164 <td>$network_operator</td>
165 </tr>
166END
167 }
168
169 my $network_mode = $modem->get_network_mode();
170 if ($network_mode) {
171 print <<END;
172 <tr>
173 <td width="33%">$Lang::tr{'modem network mode'}</td>
174 <td>$network_mode</td>
175 </tr>
176END
177 }
178
179 my $signal_quality = $modem->get_signal_quality();
180 if ($signal_quality) {
181 print <<END;
182 <tr>
183 <td width="33%">$Lang::tr{'modem network signal quality'}</td>
184 <td>$signal_quality dBm</td>
185 </tr>
186END
187 }
188
189 my $bit_error_rate = $modem->get_bit_error_rate();
190 if ($bit_error_rate) {
191 print <<END;
192 <tr>
193 <td width="33%">$Lang::tr{'modem network bit error rate'}</td>
194 <td>$bit_error_rate</td>
195 </tr>
196END
197 }
198 print <<END;
199 </tbody>
200 </table>
201END
202
203 &Header::closebox();
204} else {
205 &Header::openbox("100%", "center", $Lang::tr{'modem no connection'});
206 print "<p>$Lang::tr{'modem no connection message'}</p>";
207 &Header::closebox();
208}
209
210&Header::closebigbox();
211&Header::closepage();