Commit 2d9f9ac6 authored by Ad Schellevis's avatar Ad Schellevis

(legacy) move functions from pfsense-utils.inc to interfaces.inc

parent 2443b718
...@@ -5302,3 +5302,119 @@ function get_interface_info($ifdescr) ...@@ -5302,3 +5302,119 @@ function get_interface_info($ifdescr)
return $ifinfo; return $ifinfo;
} }
function convert_seconds_to_hms($sec){
$min=$hrs=0;
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;
}
function huawei_rssi_to_string($rssi) {
$dbm = array();
$i = 0;
$dbstart = -113;
while($i < 32) {
$dbm[$i] = $dbstart + ($i * 2);
$i++;
}
$percent = round(($rssi / 31) * 100);
$string = "rssi:{$rssi} level:{$dbm[$rssi]}dBm percent:{$percent}%";
return $string;
}
function huawei_mode_to_string($mode, $submode) {
$modes[0] = "None";
$modes[1] = "AMPS";
$modes[2] = "CDMA";
$modes[3] = "GSM/GPRS";
$modes[4] = "HDR";
$modes[5] = "WCDMA";
$modes[6] = "GPS";
$submodes[0] = "No Service";
$submodes[1] = "GSM";
$submodes[2] = "GPRS";
$submodes[3] = "EDGE";
$submodes[4] = "WCDMA";
$submodes[5] = "HSDPA";
$submodes[6] = "HSUPA";
$submodes[7] = "HSDPA+HSUPA";
$submodes[8] = "TD-SCDMA";
$submodes[9] = "HSPA+";
$string = "{$modes[$mode]}, {$submodes[$submode]} Mode";
return $string;
}
function huawei_service_to_string($state) {
$modes[0] = "No";
$modes[1] = "Restricted";
$modes[2] = "Valid";
$modes[3] = "Restricted Regional";
$modes[4] = "Powersaving";
$string = "{$modes[$state]} Service";
return $string;
}
function huawei_simstate_to_string($state) {
$modes[0] = "Invalid SIM/locked";
$modes[1] = "Valid SIM";
$modes[2] = "Invalid SIM CS";
$modes[3] = "Invalid SIM PS";
$modes[4] = "Invalid SIM CS/PS";
$modes[255] = "Missing SIM";
$string = "{$modes[$state]} State";
return $string;
}
function zte_rssi_to_string($rssi) {
return huawei_rssi_to_string($rssi);
}
function zte_mode_to_string($mode, $submode) {
$modes[0] = "No Service";
$modes[1] = "Limited Service";
$modes[2] = "GPRS";
$modes[3] = "GSM";
$modes[4] = "UMTS";
$modes[5] = "EDGE";
$modes[6] = "HSDPA";
$submodes[0] = "CS_ONLY";
$submodes[1] = "PS_ONLY";
$submodes[2] = "CS_PS";
$submodes[3] = "CAMPED";
$string = "{$modes[$mode]}, {$submodes[$submode]} Mode";
return $string;
}
function zte_service_to_string($state) {
$modes[0] = "Initializing";
$modes[1] = "Network Lock error";
$modes[2] = "Network Locked";
$modes[3] = "Unlocked or correct MCC/MNC";
$string = "{$modes[$state]} Service";
return $string;
}
function zte_simstate_to_string($state) {
$modes[0] = "No action";
$modes[1] = "Network lock";
$modes[2] = "(U)SIM card lock";
$modes[3] = "Network Lock and (U)SIM card Lock";
$string = "{$modes[$state]} State";
return $string;
}
...@@ -435,26 +435,6 @@ function is_pppoe_server_enabled() { ...@@ -435,26 +435,6 @@ function is_pppoe_server_enabled() {
return $pppoeenable; return $pppoeenable;
} }
function convert_seconds_to_hms($sec){
$min=$hrs=0;
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;
}
/* Compute the total uptime from the ppp uptime log file in the conf directory */ /* Compute the total uptime from the ppp uptime log file in the conf directory */
function get_ppp_uptime($port){ function get_ppp_uptime($port){
...@@ -1036,98 +1016,3 @@ function calculate_ipv6_delegation_length($if) { ...@@ -1036,98 +1016,3 @@ function calculate_ipv6_delegation_length($if) {
return($pdlen); return($pdlen);
} }
function huawei_rssi_to_string($rssi) {
$dbm = array();
$i = 0;
$dbstart = -113;
while($i < 32) {
$dbm[$i] = $dbstart + ($i * 2);
$i++;
}
$percent = round(($rssi / 31) * 100);
$string = "rssi:{$rssi} level:{$dbm[$rssi]}dBm percent:{$percent}%";
return $string;
}
function huawei_mode_to_string($mode, $submode) {
$modes[0] = "None";
$modes[1] = "AMPS";
$modes[2] = "CDMA";
$modes[3] = "GSM/GPRS";
$modes[4] = "HDR";
$modes[5] = "WCDMA";
$modes[6] = "GPS";
$submodes[0] = "No Service";
$submodes[1] = "GSM";
$submodes[2] = "GPRS";
$submodes[3] = "EDGE";
$submodes[4] = "WCDMA";
$submodes[5] = "HSDPA";
$submodes[6] = "HSUPA";
$submodes[7] = "HSDPA+HSUPA";
$submodes[8] = "TD-SCDMA";
$submodes[9] = "HSPA+";
$string = "{$modes[$mode]}, {$submodes[$submode]} Mode";
return $string;
}
function huawei_service_to_string($state) {
$modes[0] = "No";
$modes[1] = "Restricted";
$modes[2] = "Valid";
$modes[3] = "Restricted Regional";
$modes[4] = "Powersaving";
$string = "{$modes[$state]} Service";
return $string;
}
function huawei_simstate_to_string($state) {
$modes[0] = "Invalid SIM/locked";
$modes[1] = "Valid SIM";
$modes[2] = "Invalid SIM CS";
$modes[3] = "Invalid SIM PS";
$modes[4] = "Invalid SIM CS/PS";
$modes[255] = "Missing SIM";
$string = "{$modes[$state]} State";
return $string;
}
function zte_rssi_to_string($rssi) {
return huawei_rssi_to_string($rssi);
}
function zte_mode_to_string($mode, $submode) {
$modes[0] = "No Service";
$modes[1] = "Limited Service";
$modes[2] = "GPRS";
$modes[3] = "GSM";
$modes[4] = "UMTS";
$modes[5] = "EDGE";
$modes[6] = "HSDPA";
$submodes[0] = "CS_ONLY";
$submodes[1] = "PS_ONLY";
$submodes[2] = "CS_PS";
$submodes[3] = "CAMPED";
$string = "{$modes[$mode]}, {$submodes[$submode]} Mode";
return $string;
}
function zte_service_to_string($state) {
$modes[0] = "Initializing";
$modes[1] = "Network Lock error";
$modes[2] = "Network Locked";
$modes[3] = "Unlocked or correct MCC/MNC";
$string = "{$modes[$state]} Service";
return $string;
}
function zte_simstate_to_string($state) {
$modes[0] = "No action";
$modes[1] = "Network lock";
$modes[2] = "(U)SIM card lock";
$modes[3] = "Network Lock and (U)SIM card Lock";
$string = "{$modes[$state]} State";
return $string;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment