[09/29] pppsetup.cgi: Add support for QMI profiles

Message ID 20221201172318.3166615-9-michael.tremer@ipfire.org
State Accepted
Commit 80989cc935682e637b55d262e8e0e0a0077937c3
Headers
Series [01/29] libgudev: New package |

Commit Message

Michael Tremer Dec. 1, 2022, 5:22 p.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 html/cgi-bin/pppsetup.cgi | 37 +++++++++++++++++++++++++++++++++++--
 langs/en/cgi-bin/en.pl    |  3 +++
 2 files changed, 38 insertions(+), 2 deletions(-)
  

Patch

diff --git a/html/cgi-bin/pppsetup.cgi b/html/cgi-bin/pppsetup.cgi
index d7e5799ec..696fa2c96 100644
--- a/html/cgi-bin/pppsetup.cgi
+++ b/html/cgi-bin/pppsetup.cgi
@@ -87,6 +87,16 @@  elsif ($pppsettings{'ACTION'} eq $Lang::tr{'save'})
                 $errormessage = $Lang::tr{'invalid input'};
                 goto ERROR;
         }
+	if ($pppsettings{'TYPE'} eq "qmi") {
+		# APN cannot be empty
+		if ($pppsettings{'APN'} eq "") {
+			$errormessage = $Lang::tr{'access point name is required'};
+			goto ERROR;
+		} elsif (!&General::validdomainname($pppsettings{'APN'})) {
+			$errormessage = $Lang::tr{'access point name is invalid'};
+			goto ERROR;
+		}
+	}
 
         if ($pppsettings{'PROFILENAME'} eq '') {
                 $errormessage = $Lang::tr{'profile name not given'};
@@ -523,6 +533,7 @@  print <<END
 	<option value='pppoe' $selected{'TYPE'}{'pppoe'}>PPPoE</option>
 	<option value='pptp' $selected{'TYPE'}{'pptp'}>PPTP</option>
 	<option value='vdsl' $selected{'TYPE'}{'vdsl'}>VDSL</option>
+	<option value='qmi' $selected{'TYPE'}{'qmi'}>QMI</option>
 END
 ;
 
@@ -719,7 +730,8 @@  END
 ;
 }
 
-print <<END
+if ($pppsettings{'TYPE'} ne "qmi") {
+	print <<END
 <tr>
         <td colspan='3' width='75%'>$Lang::tr{'idle timeout'}&nbsp;<img src='/blob.gif' alt='*' /></td>
         <td width='25%'><input type='text' name='TIMEOUT' value='$pppsettings{'TIMEOUT'}' /></td>
@@ -738,7 +750,7 @@  print <<END
  </tr>
 END
 ;
-print <<END
+	print <<END
  <tr>
         <td colspan='4' width='100%'><input type='radio' name='RECONNECTION' value='persistent' $checked{'RECONNECTION'}{'persistent'}>$Lang::tr{'persistent'}</td>
  </tr>
@@ -767,6 +779,7 @@  END
 </tr>
 END
 ;
+}
 
 if ($pppsettings{'TYPE'} eq 'pptp')
 {
@@ -908,6 +921,26 @@  print <<END
 <tr>
         <td bgcolor='$color{'color20'}' colspan='4' width='100%'><b>$Lang::tr{'authentication'}</b></td>
 </tr>
+END
+;
+
+# Ask for the APN for QMI
+if ($pppsettings{'TYPE'} eq 'qmi') {
+	print <<END;
+		<tr>
+			<td width="25%">
+				$Lang::tr{'access point name'}
+				&nbsp;
+				<img src='/blob.gif' alt='*'/>
+			</td>
+			<td colspan="3" width="75%">
+				<input type="text" name="APN" value="$pppsettings{'APN'}" />
+			</td>
+		</tr>
+END
+}
+
+print <<END
 <tr>
         <td width='25%'>$Lang::tr{'username'}&nbsp;<img src='/blob.gif' alt='*' /></td>
         <td width='25%'><input type='text' name='USERNAME' value='$pppsettings{'USERNAME'}' /></td>
diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl
index d504c58b6..c8fb82586 100644
--- a/langs/en/cgi-bin/en.pl
+++ b/langs/en/cgi-bin/en.pl
@@ -129,6 +129,9 @@ 
 'a connection with this name already exists' => 'A connection with this name already exists.',
 'abort' => 'abort',
 'access allowed' => 'Access allowed from:',
+'access point name' => 'Access Point Name',
+'access point name is invalid' => 'Access Point Name is invalid',
+'access point name is required' => 'Access Point Name is required',
 'access refused with this oinkcode' => 'Access refused with this Oink Code',
 'accounting' => 'Accounting',
 'accounting user nonpdc' => 'Accounting - none PDC Mode',