mirror of
https://github.com/breeze303/nss-packages.git
synced 2025-12-15 16:22:25 +00:00
Add config for 4G cell ID locking
This commit is contained in:
parent
9d1be874b7
commit
27c9b64b6a
@ -155,5 +155,30 @@ return network.registerProtocol('quectel', {
|
||||
o.placeholder = '0';
|
||||
o.datatype = 'uinteger';
|
||||
o.depends('defaultroute', '1');
|
||||
|
||||
o = s.taboption('advanced', form.DynamicList, 'cell_lock_4g', _('4G Cell ID Lock'));
|
||||
o.datatype = 'string';
|
||||
o.placeholder = _('<PCI>,<EARFCN>');
|
||||
|
||||
o.validate = function(section_id, value) {
|
||||
if (value === null || value === '')
|
||||
return true;
|
||||
|
||||
var parts = value.split(',');
|
||||
if (parts.length !== 2)
|
||||
return _('Must be two values separated by a comma(,)');
|
||||
|
||||
var isUnsignedInteger = function(str) {
|
||||
return /^\d+$/.test(str);
|
||||
};
|
||||
|
||||
if (!isUnsignedInteger(parts[0]))
|
||||
return _('Invalid PCI!');
|
||||
|
||||
if (!isUnsignedInteger(parts[1]))
|
||||
return _('Invalid EARFCN!');
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@ -26,12 +26,13 @@ proto_quectel_init_config() {
|
||||
proto_config_add_boolean "sourcefilter"
|
||||
proto_config_add_boolean "delegate"
|
||||
proto_config_add_int "mtu"
|
||||
proto_config_add_array 'cell_lock_4g:list(string)'
|
||||
proto_config_add_defaults
|
||||
}
|
||||
|
||||
proto_quectel_setup() {
|
||||
local interface="$1"
|
||||
local device apn apnv6 auth username password pincode delay pdptype pdnindex pdnindexv6 multiplexing
|
||||
local device apn apnv6 auth username password pincode delay pdptype pdnindex pdnindexv6 multiplexing cell_lock_4g
|
||||
local dhcp dhcpv6 sourcefilter delegate mtu $PROTO_DEFAULT_OPTIONS
|
||||
local ip4table ip6table
|
||||
local pid zone
|
||||
@ -45,6 +46,30 @@ proto_quectel_setup() {
|
||||
[ -n "$delay" ] || delay="5"
|
||||
sleep "$delay"
|
||||
|
||||
if json_is_a cell_lock_4g array; then
|
||||
echo "4G Cell ID Locking"
|
||||
json_select cell_lock_4g
|
||||
idx=1
|
||||
cell_ids=""
|
||||
|
||||
while json_is_a ${idx} string
|
||||
do
|
||||
json_get_var cell_lock $idx
|
||||
pci=$(echo $cell_lock | cut -d',' -f1)
|
||||
earfcn=$(echo $cell_lock | cut -d',' -f2)
|
||||
cell_ids="$cell_ids,$earfcn,$pci"
|
||||
idx=$(( idx + 1 ))
|
||||
done
|
||||
idx=$(( idx - 1 ))
|
||||
|
||||
if [ "$idx" -gt 0 ]; then
|
||||
cell_ids="${idx}${cell_ids}"
|
||||
echo -e "AT+QNWLOCK=\"COMMON/4G\",${cell_ids}" | atinout - /dev/ttyUSB2 -
|
||||
fi
|
||||
else
|
||||
echo -e "AT+QNWLOCK=\"COMMON/4G\",0" | atinout - /dev/ttyUSB2 -
|
||||
fi
|
||||
|
||||
[ -n "$metric" ] || metric="0"
|
||||
[ -z "$ctl_device" ] || device="$ctl_device"
|
||||
|
||||
@ -119,6 +144,8 @@ proto_quectel_setup() {
|
||||
zone="$(fw3 -q network "$interface" 2>/dev/null)"
|
||||
|
||||
if [ "$pdptype" = "ipv6" ] || [ "$pdptype" = "ipv4v6" ]; then
|
||||
ip -6 addr flush dev $ifname6
|
||||
|
||||
json_init
|
||||
json_add_string name "${interface}_6"
|
||||
json_add_string device "$ifname6"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user