mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2026-03-06 17:31:44 +01:00
* fix some issues in the lan_device param: X_INTENO_SE_OperatingChannelBandwidth Signed-off-by: MOHAMED Kallel <mohamed.kallel@pivasoftware.com>
1240 lines
48 KiB
Bash
1240 lines
48 KiB
Bash
#!/bin/sh
|
|
# Copyright (C) 2012 Luka Perkov <freecwmp@lukaperkov.net>
|
|
# Copyright (C) 2013-2014 Inteno Broadband Technology AB
|
|
# Author Ahmed Zribi <ahmed.zribi@pivasoftware.com>
|
|
# Author Mohamed Kallel <mohamed.kallel@pivasoftware.com>
|
|
|
|
prefix_list="$prefix_list InternetGatewayDevice.Services."
|
|
|
|
voice_service_save_instance_config() {
|
|
local i="$1" #line number
|
|
local j="$2" #line profile
|
|
local k="$3" #profile number
|
|
local line_name="$4"
|
|
local instances=""
|
|
t=1
|
|
while [ $t -lt $j ];do
|
|
if [ "$instances" != "" ];then
|
|
instances=$instances:"0"
|
|
else
|
|
instances="0"
|
|
fi
|
|
let t++
|
|
done
|
|
if [ "$instances" != "" ];then
|
|
instances=$instances:"$i"
|
|
else
|
|
instances="$i"
|
|
fi
|
|
while [ $t -lt $k ];do
|
|
instances=$instances:"0"
|
|
let t++
|
|
done
|
|
$UCI_SET voice_client.$line_name.instances="$instances"
|
|
$UCI_COMMIT
|
|
}
|
|
|
|
load_voice() {
|
|
local max_profile_number=`$UCI_SHOW voice_client|grep "voice_client.sip"|grep -v sip_service_provider|awk -F '.' '{print $2}'|sort -u|sed 's/sip//g'|sort -n|tail -1`
|
|
let max_profile_number++
|
|
for sip in `/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q show voice_client|grep "voice_client.sip"|grep -v sip_service_provider|awk -F '.' '{print $2}'|sort -u`;do
|
|
sip_number=`echo $sip|sed 's/sip//g'`
|
|
let profile_number=$sip_number+1
|
|
# Line
|
|
local line_number="0"
|
|
for line_name in `$UCI_SHOW voice_client|grep sip_account|grep sip$sip_number|awk -F '.' '{print$2}'`;do
|
|
let line_number++
|
|
if [ "`$UCI_GET voice_client.$line_name.instances`" = "" ];then
|
|
voice_service_save_instance_config "$line_number" "$profile_number" "$max_profile_number" "$line_name"
|
|
else
|
|
local instances=`$UCI_GET voice_client.$line_name.instances`
|
|
length=`echo $instances|tr -d -c [0-9] |wc -c`
|
|
new_length=`get_voice_profile_max_instance`
|
|
for r in `seq $length $new_length`;do
|
|
instances=$instances:0
|
|
done
|
|
$UCI_SET voice_client.$line_name.instances="$instances"
|
|
$UCI_COMMIT
|
|
instances=""
|
|
fi
|
|
done
|
|
done
|
|
}
|
|
|
|
# under InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.
|
|
|
|
get_voice_profile_enable() {
|
|
local num="$1"
|
|
val=`$UCI_GET voice_client.sip$num.enabled`
|
|
if [ "$val" = "0" ]; then
|
|
val="Disabled"
|
|
else
|
|
val="Enabled"
|
|
fi
|
|
echo $val
|
|
}
|
|
|
|
set_voice_profile_enable() {
|
|
local num="$1"
|
|
local val="$2"
|
|
if [ "$val" = "Enabled" ]; then
|
|
val="1"
|
|
else
|
|
val="0"
|
|
fi
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.enabled="$val"
|
|
}
|
|
|
|
set_voice_profile_reset() {
|
|
local num="$1"
|
|
local val="$2"
|
|
if [ "$val" = "1" ];then
|
|
/etc/init.d/asterisk reload
|
|
fi
|
|
}
|
|
|
|
set_voice_profile_signaling_protocol() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
get_voice_profile_max_sessions() {
|
|
local num="$1"
|
|
local val=""
|
|
local number_line=`/usr/sbin/asterisk -rx "brcm show status"|grep "Subchannel:"|sort -u|wc -l`
|
|
local sub_channel=`/usr/sbin/asterisk -rx "brcm show status"|grep -c "Default context : sip$num"`
|
|
let val=$number_line*$sub_channel
|
|
echo $val
|
|
}
|
|
|
|
get_voice_profile_number_of_lines() {
|
|
local num="$1"
|
|
local val=""
|
|
val=`/usr/sbin/asterisk -rx "brcm show status"|grep -c "Default context : sip$num"`
|
|
echo $val
|
|
}
|
|
|
|
capabilities_regions="\
|
|
AUS AU"$'\n'"\
|
|
BEL BE"$'\n'"\
|
|
BRA BR"$'\n'"\
|
|
CHL CL"$'\n'"\
|
|
CHN CN"$'\n'"\
|
|
CZE CZ"$'\n'"\
|
|
DNK DK"$'\n'"\
|
|
FIN FI"$'\n'"\
|
|
FRA FR"$'\n'"\
|
|
DEU DE"$'\n'"\
|
|
HUN HU"$'\n'"\
|
|
IND IN"$'\n'"\
|
|
ITA IT"$'\n'"\
|
|
JPN JP"$'\n'"\
|
|
NLD NL"$'\n'"\
|
|
NZL NZ"$'\n'"\
|
|
USA US"$'\n'"\
|
|
ESP ES"$'\n'"\
|
|
SWE SE"$'\n'"\
|
|
CHE CH"$'\n'"\
|
|
NOR NO"$'\n'"\
|
|
TWN TW"$'\n'"\
|
|
GBR GB"$'\n'"\
|
|
ARE AE"$'\n'"\
|
|
ETS ETS"$'\n'"\
|
|
T57 T57"
|
|
|
|
get_sip_profile_region() {
|
|
local val=`$UCI_GET voice_client.BRCM.country`
|
|
echo "$capabilities_regions" | awk '$1=="'"$val"'" { print $2 }'
|
|
}
|
|
|
|
set_sip_profile_region() {
|
|
local val="$1"
|
|
val=`echo $val|tr '[a-z]' '[A-Z]'`
|
|
val=`echo "$capabilities_regions" | awk '$2=="'"$val"'" { print $1 }'`
|
|
[ "$val" = "" ] && return
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.BRCM.country="$val"
|
|
}
|
|
|
|
enum_svsvp_dtmfmethod="/InBand:inband/RFC2833:rfc2833/SIPInfo:info/"
|
|
set_voice_config_with_enum() {
|
|
set_config_with_enum $1 $2 $3
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
}
|
|
|
|
get_voice_service_serviceproviderinfo_name() {
|
|
local num="$1"
|
|
local val=`$UCI_GET voice_client.sip$num.provider_name`
|
|
if [ "$val" = "" ]; then val=`$UCI_GET voice_client.sip$num.domain | cut -f1 -d'.'`; fi
|
|
echo $val
|
|
}
|
|
|
|
#under InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.SIP.
|
|
|
|
set_sip_proxy_server() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.SIP.sip_proxy="$val"
|
|
}
|
|
|
|
set_sip_proxy_server_port() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
get_sip_proxy_server_transport() {
|
|
local num="$1"
|
|
local val=""
|
|
val=`/usr/sbin/asterisk -rx "sip show settings"|grep "Outbound transport"|awk -F' ' '{print $3}'`
|
|
echo $val
|
|
}
|
|
|
|
set_sip_proxy_server_transport() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_registrar_server() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.host="$val"
|
|
}
|
|
|
|
set_sip_registrar_server_port() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.port="$val"
|
|
}
|
|
|
|
get_sip_registrar_server_transport() {
|
|
local num="$1"
|
|
local val=""
|
|
val=`/usr/sbin/asterisk -rx "sip show settings"|grep "Outbound transport"|awk -F' ' '{print $3}'`
|
|
echo $val
|
|
}
|
|
|
|
set_sip_registrar_server_transport() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_user_agent_domain() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.domain="$val"
|
|
}
|
|
|
|
set_sip_user_agent_port() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.SIP.bindport="$val"
|
|
}
|
|
|
|
get_sip_user_agent_transport() {
|
|
local num="$1"
|
|
local val=""
|
|
val=`/usr/sbin/asterisk -rx "sip show settings"|grep "Allowed transports"|awk -F' ' '{print $3}'`
|
|
echo $val
|
|
}
|
|
|
|
set_sip_user_agent_transport() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_outbound_proxy() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.outboundproxy="$val"
|
|
}
|
|
|
|
set_sip_outbound_proxy_port() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.outboundproxyport="$val"
|
|
}
|
|
|
|
set_sip_organization() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_registration_period() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.SIP.defaultexpiry="$val"
|
|
}
|
|
|
|
set_sip_invite_expires() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_re_invite_expires() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.SIP.registertimeout="$val"
|
|
}
|
|
|
|
set_sip_register_expires() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.SIP.registertimeout="$val"
|
|
}
|
|
|
|
set_sip_registers_min_expires() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_register_retry_interval() {
|
|
local num="$1"
|
|
local val="$2"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.SIP.registertimeout="$val"
|
|
}
|
|
|
|
set_sip_inbound_auth() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_inbound_auth_username() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_inbound_auth_password() {
|
|
local num="$1"
|
|
local val="$2"
|
|
}
|
|
|
|
set_sip_x_002207_call_lines() {
|
|
local num="$1"
|
|
shift
|
|
local val="$*"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.call_lines="$val"
|
|
}
|
|
|
|
#under InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.Line.{i}.
|
|
|
|
get_line_enable() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local line_num=""
|
|
local val=""
|
|
val=`$UCI_GET voice_client.sip$num.enabled 2> /dev/null`
|
|
let num=$num+1
|
|
line_num=`$UCI_GET voice_client.$line_name.instances|cut -d : -f$num`
|
|
if [ "$val" = "0" ]; then
|
|
val="Disabled"
|
|
else
|
|
val="Enabled"
|
|
fi
|
|
echo $val
|
|
}
|
|
|
|
set_line_enable() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val="$3"
|
|
if [ "$val" = "Enabled" ]; then
|
|
val="1"
|
|
else
|
|
val="0"
|
|
fi
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.enabled="$val"
|
|
}
|
|
|
|
set_line_directory_number() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val="$3"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.$line_name.extension="$val"
|
|
}
|
|
|
|
get_line_status() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val=""
|
|
val1="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get asterisk.sip$num.sip_registry_registered"
|
|
val2="/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q -P /var/state get asterisk.sip$num.sip_registry_request_sent"
|
|
if [ "$val1" = "yes" ];then
|
|
val="Up"
|
|
else
|
|
if [ "$val2" = "yes" ];then
|
|
val="Registering"
|
|
else
|
|
val="Disabled"
|
|
fi
|
|
fi
|
|
echo $val
|
|
}
|
|
|
|
get_line_call_state() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val=""
|
|
state=`/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -P /var/state -q get chan_brcm.$line_name.subchannel_0`
|
|
if [ "$state" = "ONHOOK" ];then
|
|
val="Idle"
|
|
elif [ "$state" = "OFFHOOK" ];then
|
|
val="Disconnecting"
|
|
elif [ "$state" = "DIALING" ];then
|
|
val="Calling"
|
|
elif [ "$state" = "INCALL" ];then
|
|
val="InCall"
|
|
elif [ "$state" = "RINGING" ];then
|
|
val="Ringing"
|
|
fi
|
|
echo $val
|
|
}
|
|
|
|
set_line_calling_features_caller_id_name() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val="$3"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.displayname="$val"
|
|
}
|
|
|
|
get_line_calling_features_callwaiting() {
|
|
local line_name="$1"
|
|
local val=`$UCI_GET voice_client.$line_name.callwaiting`
|
|
echo ${val:-0}
|
|
}
|
|
|
|
set_line_calling_features_callwaiting() {
|
|
local line_name="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
val="1"
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
val=""
|
|
else
|
|
return
|
|
fi
|
|
$UCI_SET voice_client.$line_name.callwaiting=$val
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
}
|
|
|
|
get_line_x_002207_line_profile() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val=""
|
|
let val=$num+1
|
|
echo $val
|
|
}
|
|
|
|
set_line_x_002207_line_profile() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val="$3"
|
|
let sip_id=$val-1
|
|
if [ "`$UCI_GET voice_client.sip$sip_id`" = "" ];then
|
|
return 0
|
|
fi
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
delete_line $line_name
|
|
i=`echo $line_name|sed 's/brcm//g'`
|
|
add_line "$i" "$sip_id"
|
|
instance=`$UCI_GET voice_client.$line_name.instances|cut -f $val -d :`
|
|
if [ "$instance" = "0" ];then
|
|
max_line_instance=`$UCI_SHOW voice_client|grep instances|awk -F '=' '{print$2}'|cut -f $val -d:|sort -un|tail -1`
|
|
let instance=$max_line_instance+1
|
|
local j=0
|
|
for k in `$UCI_GET voice_client.$line_name.instances|sed 's/:/ /g'`;do
|
|
let j++
|
|
if [ "$j" != "$val" ];then
|
|
if [ "$instances" = "" ];then
|
|
instances=$k
|
|
else
|
|
instances=$instances:$k
|
|
fi
|
|
else
|
|
if [ "$instances" = "" ];then
|
|
instances=$instance
|
|
else
|
|
instances=$instances:$instance
|
|
fi
|
|
fi
|
|
done
|
|
$UCI_SET voice_client.$line_name.instances="$instances"
|
|
fi
|
|
call_lines=`$UCI_GET voice_client.sip$sip_id.call_lines`
|
|
if [ "$call_lines" != "" ];then
|
|
$UCI_SET voice_client.sip$sip_id.call_lines="$call_lines $i"
|
|
else
|
|
$UCI_SET voice_client.sip$sip_id.call_lines="$i"
|
|
fi
|
|
}
|
|
|
|
#under InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.Line.{i}.SIP.
|
|
|
|
set_line_sip_auth_username() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val="$3"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.authuser="$val"
|
|
}
|
|
|
|
set_line_sip_auth_password() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val="$3"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.secret="$val"
|
|
}
|
|
|
|
get_line_sip_uri() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local domain=""
|
|
local user=""
|
|
domain=`$UCI_GET voice_client.sip$num.domain`
|
|
user=`$UCI_GET voice_client.sip$num.user`
|
|
echo "$user@$domain"
|
|
}
|
|
|
|
set_line_sip_uri() {
|
|
local num="$1"
|
|
local line_name="$2"
|
|
local val="$3"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"q
|
|
local user=${val%@*}
|
|
local domain=${val#*@}
|
|
if [ "$user" != "" ] ; then
|
|
$UCI_SET voice_client.sip$num.user="$user"
|
|
fi
|
|
if [ "$domain" != "" -a "$domain" != "$user" ] ; then
|
|
$UCI_SET voice_client.sip$num.domain="$domain"
|
|
fi
|
|
}
|
|
|
|
set_sip_fax_t38_enable() {
|
|
local num="$1"
|
|
local val="$2"
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
val="1"
|
|
elif [ "$val" = "false" -o "$val" = "0" -o "$val" = "" ]; then
|
|
val="0"
|
|
else
|
|
return
|
|
fi
|
|
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
$UCI_SET voice_client.sip$num.is_fax="$val"
|
|
}
|
|
|
|
allowed_sip_codecs="ulaw alaw g729 g723 g726"
|
|
|
|
capabilities_sip_codecs="\
|
|
g723 G.723.1 6451 30-300 30"$'\n'"\
|
|
gsm GSM-FR 13312 20-300 20"$'\n'"\
|
|
ulaw G.711MuLaw 65536 10-150 20"$'\n'"\
|
|
alaw G.711ALaw 65536 10-150 20"$'\n'"\
|
|
g726aal2 g726aal2 32768 10-300 20"$'\n'"\
|
|
adpcm adpcm 32768 10-300 20"$'\n'"\
|
|
slin slin 0 10-70 20"$'\n'"\
|
|
lpc10 lpc10 2457 20-20 20"$'\n'"\
|
|
g729 G.729a 8192 10-230 20"$'\n'"\
|
|
speex speex 49152 10-60 20"$'\n'"\
|
|
ilbc iLBC 8192 30-30 30"$'\n'"\
|
|
g726 G.726 32768 10-300 20"$'\n'"\
|
|
g722 G.722 65536 0-0 0"$'\n'"\
|
|
siren7 G.722.1 32768 0-0 0"$'\n'"\
|
|
siren14 siren14 0 0-0 0"$'\n'"\
|
|
slin16 slin16 0 0-0 0"$'\n'"\
|
|
g719 g719 0 0-0 0"$'\n'"\
|
|
speex16 speex16 0 0-0 0"$'\n'"\
|
|
testlaw testlaw 0 0-0 0"
|
|
|
|
capabilities_sip_codecs_get() {
|
|
local codec="$1"
|
|
local varn="$2"
|
|
echo "$capabilities_sip_codecs" | awk '$1=="'"$codec"'" {print $'"$varn"'}'
|
|
}
|
|
|
|
get_voice_service_vp_rtp_portmin() {
|
|
val=`$UCI_GET voice_client.SIP.rtpstart`
|
|
echo ${val:-5000}
|
|
}
|
|
|
|
get_voice_service_vp_rtp_portmax() {
|
|
val=`$UCI_GET voice_client.SIP.rtpend`
|
|
echo ${val:-31000}
|
|
}
|
|
|
|
enum_rtp_tos="/\
|
|
CS0:0/\
|
|
CS1:32/\
|
|
AF11:40/\
|
|
AF12:48/\
|
|
AF13:56/\
|
|
CS2:64/\
|
|
AF21:72/\
|
|
AF22:80/\
|
|
AF23:88/\
|
|
CS3:96/\
|
|
AF31:104/\
|
|
AF32:112/\
|
|
AF33:120/\
|
|
CS4:128/\
|
|
AF41:136/\
|
|
AF42:144/\
|
|
AF43:152/\
|
|
CS5:160/\
|
|
EF:184/\
|
|
CS6:192/\
|
|
CS7:224/"
|
|
|
|
get_voice_service_vp_rtp_dscp() {
|
|
local val=`$UCI_GET voice_client.SIP.tos_audio`
|
|
val=`echo $val|tr '[a-z]' '[A-Z]'`
|
|
val=${val:-CS0}
|
|
val=${enum_rtp_tos#*/$val:}
|
|
[ "$val" = "" -o "$val" = "$enum_rtp_tos" ] && return
|
|
echo ${val%%/*}
|
|
}
|
|
|
|
get_capabilities_sip_regions() {
|
|
local val=`echo "$capabilities_regions" | awk '{ print $2 }'`
|
|
echo ${val//$'\n'/, }
|
|
}
|
|
|
|
set_voice_service_vp_rtp_dscp() {
|
|
local val="$1"
|
|
val=${enum_rtp_tos%:$val/*}
|
|
[ "$val" = "" -o "$val" = "$enum_rtp_tos" ] && return
|
|
val=${val##*/}
|
|
$UCI_SET voice_client.SIP.tos_audio=$val
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
}
|
|
|
|
get_voice_service_vp_rtp_rtcp_enable() {
|
|
local val=`ps | awk '$NF=="/usr/sbin/asterisk"'`
|
|
[ "$val" = "" ] && echo 0 || echo 1
|
|
}
|
|
|
|
get_voice_service_vp_rtp_rtcp_txrepeatinterval() {
|
|
local val=`$UCI_GET voice_client.SIP.rtcpinterval`
|
|
echo ${val:-5000}
|
|
}
|
|
|
|
set_voice_service_vp_rtp_rtcp_txrepeatinterval() {
|
|
local val="$1"
|
|
$UCI_SET voice_client.SIP.rtcpinterval=$val
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
}
|
|
|
|
get_voice_service_vp_rtp_srtp_enable() {
|
|
local sip_id="$1"
|
|
local val=`$UCI_GET voice_client.sip$sip_id.encryption`
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
[ "$val" = "yes" ] && echo 1 || echo 0
|
|
}
|
|
|
|
set_voice_service_vp_rtp_srtp_enable() {
|
|
local sip_id="$1"
|
|
local val="$2"
|
|
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
`$UCI_SET voice_client.sip$sip_id.encryption=yes`
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
`$UCI_SET voice_client.sip$sip_id.encryption=`
|
|
else
|
|
return
|
|
fi
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
}
|
|
|
|
codec_priority_sort() {
|
|
local sip_id="$1"
|
|
local codec="$2"
|
|
local ucodecs=`$UCI_SHOW voice_client.sip$sip_id |sed -n "s/voice_client\.sip$sip_id\.codec//p" | sort'`
|
|
[ "$codec" != "" ] && ucodecs="$ucodecs"$'\n'"6=$codec"
|
|
local pcodec pcodecs=`$UCI_SHOW voice_client.sip$sip_id |sed -n "s/voice_client\.sip$sip_id\.priority_//p" | awk -F '=' '{print $2"="$1}' | sort -n'`
|
|
|
|
local cn=0
|
|
for pcodec in $pcodecs; do
|
|
local pc=${pcodec#*=}
|
|
local uc=`echo "$ucodecs" | awk -F '=' '$2=="'"$pc"'"'`
|
|
if [ "$uc" != "" ]; then
|
|
[ "$pc" != "-" ] && $UCI_SET voice_client.sip$sip_id.codec$((cn++))=$pc
|
|
ucodecs=${ucodecs//$uc/}
|
|
fi
|
|
done
|
|
|
|
for uc in $ucodecs; do
|
|
[ $cn -gt 5 ] && break
|
|
[ "${uc#*=}" != "-" ] && $UCI_SET voice_client.sip$sip_id.codec$((cn++))=${uc#*=}
|
|
ucodecs=${ucodecs//$uc/}
|
|
done
|
|
|
|
while [ $cn -le 5 ]; do
|
|
$UCI_SET voice_client.sip$sip_id.codec$((cn++))=""
|
|
done
|
|
|
|
if [ "${ucodecs/6=$codec/}" != "$ucodecs" ]; then
|
|
$UCI_SET voice_client.sip$sip_id.codec5=$codec
|
|
fi
|
|
}
|
|
|
|
codec_priority_update() {
|
|
local sip_id="$1"
|
|
local cdc
|
|
for cdc in $allowed_sip_codecs; do
|
|
local priority=`$UCI_GET voice_client.sip$sip_id.priority_$cdc`
|
|
[ "$priority" != "" ] && continue
|
|
priority=`$UCI_SHOW voice_client.sip$sip_id | awk -F'[.=]' '/voice_client\.sip'"$sip_id"'\.codec[0-5]='"$cdc"'/ {print $3}'`
|
|
if [ "$priority" != "" ]; then
|
|
priority=${priority/codec/}
|
|
let priority++
|
|
else
|
|
priority=1
|
|
fi
|
|
$UCI_SET voice_client.sip$sip_id.priority_$cdc=$priority
|
|
done
|
|
codec_priority_sort $sip_id
|
|
$UCI_COMMIT
|
|
}
|
|
|
|
get_line_codec_list_packetization() {
|
|
local sip_id="$1"
|
|
local codec="$2"
|
|
local val=`$UCI_GET voice_client.sip$sip_id.ptime_$codec`
|
|
[ "$val" = "" ] && val=`capabilities_sip_codecs_get $codec 5`
|
|
echo $val
|
|
}
|
|
|
|
get_line_codec_list_enable() {
|
|
local sip_id="$1"
|
|
local codec="$2"
|
|
local val=`$UCI_SHOW voice_client.sip$sip_id | grep "voice_client\.sip$sip_id\.codec[0-5]=$codec"`
|
|
[ "$val" = "" ] && echo 0 || echo 1
|
|
}
|
|
|
|
set_line_codec_list_enable() {
|
|
local sip_id="$1"
|
|
local codec="$2"
|
|
local val="$3"
|
|
local ucodec ucodecs=`$UCI_SHOW voice_client.sip$sip_id | awk -F'[.=]' '/voice_client\.sip'"$sip_id"'\.codec[0-5]='"$codec"'/ {print $3}'`
|
|
|
|
val=`echo $val|tr '[A-Z]' '[a-z]'`
|
|
if [ "$val" = "true" -o "$val" = "1" ]; then
|
|
[ "$ucodecs" != "" ] && return
|
|
codec_priority_sort "$sip_id" "$codec"
|
|
elif [ "$val" = "false" -o "$val" = "0" ]; then
|
|
[ "$ucodecs" = "" ] && return
|
|
for ucodec in $ucodecs; do
|
|
$UCI_SET voice_client.sip$sip_id.$ucodec=""
|
|
done
|
|
else
|
|
return
|
|
fi
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
}
|
|
|
|
set_line_codec_list_priority() {
|
|
local sip_id="$1"
|
|
local codec="$2"
|
|
local val="$3"
|
|
|
|
$UCI_SET voice_client.sip$sip_id.priority_$codec=$val
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
|
|
local en=`$UCI_SHOW voice_client.sip$sip_id | grep "voice_client\.sip$sip_id\.codec[0-5]=$codec"`
|
|
[ "$en" = "" ] && return
|
|
codec_priority_sort "$sip_id"
|
|
}
|
|
|
|
# Global SET/GET functions
|
|
uci_voice_set() {
|
|
$UCI_SET $1=$2
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
}
|
|
|
|
get_voice_service_max_profile() {
|
|
local val=`$UCI_SHOW voice_client|grep -c sip_service_provider`
|
|
let val=$val-1
|
|
eval "export -- \"$1=$val\""
|
|
}
|
|
|
|
get_voice_service_max_line() {
|
|
local val=`/usr/sbin/asterisk -rx "brcm show status"|grep -c "Line id"`
|
|
let val=$val-1
|
|
eval "export -- \"$1=$val\""
|
|
}
|
|
|
|
get_services_voice_service_generic() {
|
|
local profile_num="$1"
|
|
local sip_id="$2"
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num." "1"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Enable" "1" "get_voice_profile_enable $sip_id" "set_voice_profile_enable $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Reset" "1" "echo 0" "set_voice_profile_reset $sip_id \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Name" "0" "$UCI_GET voice_client.sip$sip_id.name"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SignalingProtocol" "1" "echo SIP" "set_voice_profile_signaling_protocol $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.MaxSessions" "0" "get_voice_profile_max_sessions $sip_id" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.NumberOfLines" "0" "get_voice_profile_number_of_lines $sip_id" "" "" "xsd:unsignedInt"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.ProxyServer" "1" "$UCI_GET voice_client.SIP.sip_proxy" "set_sip_proxy_server $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.ProxyServerPort" "1" "" "set_sip_proxy_server_port $sip_id \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.ProxyServerTransport" "1" "get_sip_proxy_server_transport $sip_id" "set_sip_proxy_server_transport $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.RegistrarServer" "1" "$UCI_GET voice_client.sip$sip_id.host" "set_sip_registrar_server $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.RegistrarServerPort" "1" "$UCI_GET voice_client.sip$sip_id.port" "set_sip_registrar_server_port $sip_id \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.RegistrarServerTransport" "1" "get_sip_registrar_server_transport $sip_id" "set_sip_registrar_server_transport $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.UserAgentDomain" "1" "$UCI_GET voice_client.sip$sip_id.domain" "set_sip_user_agent_domain $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.UserAgentPort" "1" "$UCI_GET voice_client.SIP.bindport" "set_sip_user_agent_port $sip_id \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.UserAgentTransport" "1" "get_sip_user_agent_transport $sip_id" "set_sip_user_agent_transport $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.OutboundProxy" "1" "$UCI_GET voice_client.sip$sip_id.outboundproxy" "set_sip_outbound_proxy $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.OutboundProxyPort" "1" "$UCI_GET voice_client.sip$sip_id.outboundport" "set_sip_outbound_proxy_port $sip_id \$val" "" "xsd:unsignedInt"
|
|
# get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.Organization" "1" "" "set_sip_organization $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.RegistrationPeriod" "1" "$UCI_GET voice_client.SIP.defaultexpiry" "set_sip_registration_period $sip_id \$val" "" "xsd:unsignedInt"
|
|
# get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.InviteExpires" "1" "" "set_sip_invite_expires $sip_id \$val" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.ReInviteExpires" "1" "$UCI_GET voice_client.SIP.registertimeout" "set_sip_re_invite_expires $sip_id \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.RegisterExpires" "1" "$UCI_GET voice_client.SIP.registertimeout" "set_sip_register_expires $sip_id \$val" "" "xsd:unsignedInt"
|
|
# get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.RegistersMinExpires" "1" "" "set_sip_registers_min_expires $sip_id \$val" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.RegisterRetryInterval" "1" "$UCI_GET voice_client.SIP.registertimeout" "set_sip_register_retry_interval $sip_id \$val" "" "xsd:unsignedInt"
|
|
# get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.InboundAuth" "1" "" "set_sip_inbound_auth $sip_id \$val"
|
|
# get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.InboundAuthUsername" "1" "" "set_sip_inbound_auth_username $sip_id \$val"
|
|
# get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.InboundAuthPassword" "1" "" "set_sip_inbound_auth_password $sip_id \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.SIP.X_002207_CallLines" "1" "$UCI_GET voice_client.sip$sip_id.call_lines" "set_sip_x_002207_call_lines $sip_id \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.DTMFMethod" "1" "get_config_with_enum voice_client.SIP.dtmfmode $enum_svsvp_dtmfmethod" "set_voice_config_with_enum voice_client.SIP.dtmfmode \$enum_svsvp_dtmfmethod \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Region" "1" "get_sip_profile_region" "set_sip_profile_region \$val"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.ServiceProviderInfo." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.ServiceProviderInfo.Name" "1" "get_voice_service_serviceproviderinfo_name $sip_id" "\$UCI_SET voice_client.sip$sip_id.provider_name=\$val"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.FaxT38." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.FaxT38.Enable" "1" "$UCI_GET voice_client.sip$sip_id.is_fax" "set_sip_fax_t38_enable $sip_id \$val" "" "xsd:boolean"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.LocalPortMin" "1" "get_voice_service_vp_rtp_portmin" "uci_voice_set voice_client.SIP.rtpstart \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.LocalPortMax" "1" "get_voice_service_vp_rtp_portmax" "uci_voice_set voice_client.SIP.rtpend \$val" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.DSCPMark" "1" "get_voice_service_vp_rtp_dscp" "set_voice_service_vp_rtp_dscp \$val" "" "xsd:unsignedInt"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.RTCP." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.RTCP.Enable" "0" "" "" "get_voice_service_vp_rtp_rtcp_enable" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.RTCP.TxRepeatInterval" "1" "get_voice_service_vp_rtp_rtcp_txrepeatinterval" "set_voice_service_vp_rtp_rtcp_txrepeatinterval \$val" "" "xsd:unsignedInt"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.SRTP." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.RTP.SRTP.Enable" "1" "get_voice_service_vp_rtp_srtp_enable $sip_id" "set_voice_service_vp_rtp_srtp_enable $sip_id \$val" "" "xsd:boolean"
|
|
}
|
|
|
|
get_services_voice_service_line_generic() {
|
|
local profile_num="$1"
|
|
local sip_id="$2"
|
|
local line_num="$3"
|
|
local ucodec
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num." "1"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Enable" "1" "get_line_enable $sip_id $line_name" "set_line_enable $sip_id $line_name \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.DirectoryNumber" "1" "$UCI_GET voice_client.$line_name.extension" "set_line_directory_number $sip_id $line_name \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Status" "0" "" "" "get_line_status $sip_id $line_name"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.CallState" "0" "" "" "get_line_call_state $sip_id $line_name"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.CallingFeatures." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.CallingFeatures.CallerIDName" "1" "$UCI_GET voice_client.sip$sip_id.displayname" "set_line_calling_features_caller_id_name $sip_id $line_name \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.CallingFeatures.CallWaitingEnable" "1" "get_line_calling_features_callwaiting $line_name" "set_line_calling_features_callwaiting $line_name \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.X_002207_LineProfile" "1" "get_line_x_002207_line_profile $sip_id $line_name" "set_line_x_002207_line_profile $sip_id $line_name \$val"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.SIP." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.SIP.AuthUserName" "1" "$UCI_GET voice_client.sip$sip_id.authuser" "set_line_sip_auth_username $sip_id $line_name \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.SIP.AuthPassword" "1" "" "set_line_sip_auth_password $sip_id $line_name \$val" "" "" "" "" "" "1"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.SIP.URI" "1" "get_line_sip_uri $sip_id $line_name" "set_line_sip_uri $sip_id $line_name \$val"
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List." "0"
|
|
local codec cn=0
|
|
codec_priority_update "$sip_id"
|
|
for codec in $allowed_sip_codecs; do
|
|
get_services_voice_service_line_codec_list_generic "$profile_num" "$sip_id" "$line_num" "$((++cn))" "$codec"
|
|
done
|
|
}
|
|
|
|
get_services_voice_service_line_codec_list_generic() {
|
|
local profile_num="$1"
|
|
local sip_id="$2"
|
|
local line_num="$3"
|
|
local codec_num="$4"
|
|
local codec="$5"
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num.EntryID" "0" "echo $codec_num" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num.Codec" "0" "capabilities_sip_codecs_get $codec 2"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num.BitRate" "0" "capabilities_sip_codecs_get $codec 3" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num.PacketizationPeriod" "1" "get_line_codec_list_packetization $sip_id $codec" "uci_voice_set voice_client.sip$sip_id.ptime_$codec \$val"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num.SilenceSuppression" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num.Enable" "1" "get_line_codec_list_enable $sip_id $codec" "set_line_codec_list_enable $sip_id $codec \$val" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line.$line_num.Codec.List.$codec_num.Priority" "1" "$UCI_GET voice_client.sip$sip_id.priority_$codec" "set_line_codec_list_priority $sip_id $codec \$val" "" "xsd:unsignedInt"
|
|
}
|
|
|
|
get_services_voice_service_capabilities_codecs_generic() {
|
|
local id="$1"
|
|
local codec="$2"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Codecs.$id." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Codecs.$id.EntryID" "0" "echo $id" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Codecs.$id.Codec" "0" "capabilities_sip_codecs_get $codec 2"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Codecs.$id.BitRate" "0" "capabilities_sip_codecs_get $codec 3" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Codecs.$id.PacketizationPeriod" "0" "capabilities_sip_codecs_get $codec 4"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Codecs.$id.SilenceSuppression" "0" "echo 0" "" "" "xsd:boolean"
|
|
}
|
|
|
|
get_cache_InternetGatewayDevice_Services() {
|
|
local max_line
|
|
# load instance numbers
|
|
load_voice
|
|
get_voice_service_max_line max_line
|
|
get_object_cache_generic "InternetGatewayDevice.Services." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService." "0"
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1." "0"
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.MaxProfileCount" "0" "echo 8" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.MaxLineCount" "0" "echo 6" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.MaxSessionsPerLine" "0" "echo 1" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.MaxSessionCount" "0" "echo 6" "" "" "xsd:unsignedInt"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SignalingProtocols" "0" "echo SIP"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Regions" "0" "get_capabilities_sip_regions"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.RTCP" "0" "echo 1" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SRTP" "0" "echo 1" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.RTPRedundancy" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.PSTNSoftSwitchOver" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.FaxT38" "0" "echo 1" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.FaxPassThrough" "0" "echo 1" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.ModemPassThrough" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.ToneGeneration" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.ToneDescriptionsEditable" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.PatternBasedToneGeneration" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.FileBasedToneGeneration" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.ToneFileFormats" "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.RingGeneration" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.RingDescriptionsEditable" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.PatternBasedRingGeneration" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.RingPatternEditable" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.FileBasedRingGeneration" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.RingFileFormats" "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.DigitMap" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.NumberingPlan" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.ButtonMap" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.VoicePortTests" "0" "echo 0" "" "" "xsd:boolean"
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP." "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.Role" "0" "echo BackToBackUserAgents"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.Extensions" "0" "echo INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.Transports" "0" "echo UDP, TCP, TLS"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.URISchemes" "0"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.EventSubscription" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.ResponseMap" "0" "echo 0" "" "" "xsd:boolean"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.TLSAuthenticationProtocols" "0" "echo MD5"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.TLSEncryptionProtocols" "0" "echo RC4, RC2, DES, 3DES"
|
|
get_param_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.SIP.TLSKeyExchangeProtocols" "0" "echo RSA, DSS"
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.Capabilities.Codecs." "0"
|
|
local codec num=0
|
|
for codec in $allowed_sip_codecs; do
|
|
get_services_voice_service_capabilities_codecs_generic "$((++num))" $codec
|
|
done
|
|
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile." "1"
|
|
for sip_id in `$UCI_SHOW voice_client|grep "voice_client.sip"|grep -v sip_service_provider|awk -F '.' '{print $2}'|sed 's/sip//g'|sort -un`;do
|
|
let profile_num=$sip_id+1
|
|
get_services_voice_service_generic "$profile_num" "$sip_id"
|
|
# Line
|
|
get_object_cache_generic "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.$profile_num.Line." "1"
|
|
for line_name in `$UCI_SHOW voice_client|grep sip_account|grep sip$sip_id$|awk -F'.' '{print$2}'`;do
|
|
line_id=`echo $line_name|sed 's/brcm//g'`
|
|
if [ $line_id -gt $max_line ];then
|
|
continue
|
|
fi
|
|
line_num=`$UCI_GET voice_client.$line_name.instances|cut -d : -f$profile_num`
|
|
get_services_voice_service_line_generic "$profile_num" "$sip_id" "$line_num"
|
|
done
|
|
done
|
|
}
|
|
|
|
get_voice_profile_max_instance() {
|
|
local max=`$UCI_SHOW voice_client|grep sip_service_provider|awk -F '.' '{print $2}'|awk -F '=' '{print $1}'|sed 's/sip//g'|sort -n|tail -1`
|
|
for i in `seq 0 $max`;do
|
|
if [ "`$UCI_GET voice_client.sip$i`" = "" ];then
|
|
let j=$i-1
|
|
echo $j
|
|
return 0
|
|
fi
|
|
done
|
|
if [ "$max" = "" ];then
|
|
echo -1
|
|
else
|
|
echo $max
|
|
fi
|
|
}
|
|
|
|
get_line_max_instance() {
|
|
local line_number=`/usr/sbin/asterisk -rx "brcm show status"|grep -c "Line id"`
|
|
for i in `seq 0 $line_number`;do
|
|
if [ "`$UCI_GET voice_client.brcm$i.sip_account`" = "-" ];then
|
|
echo $i
|
|
break
|
|
fi
|
|
done
|
|
}
|
|
|
|
add_voice_profile() {
|
|
local i="$1"
|
|
let j=$i+1
|
|
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q batch << EOF 2>&1 >/dev/null
|
|
set voice_client.sip$i=sip_service_provider
|
|
set voice_client.sip$i.name='Account $j'
|
|
set voice_client.sip$i.enabled='0'
|
|
set voice_client.sip$i.codec0='ulaw'
|
|
set voice_client.sip$i.codec1='alaw'
|
|
set voice_client.sip$i.codec2='g729'
|
|
set voice_client.sip$i.codec3='g726'
|
|
set voice_client.sip$i.cfim_on='*21*'
|
|
set voice_client.sip$i.cfim_off='#21#'
|
|
set voice_client.sip$i.cfbs_on='*61*'
|
|
set voice_client.sip$i.cfbs_off='#61#'
|
|
set voice_client.sip$i.call_return='*69'
|
|
set voice_client.sip$i.redial='*66'
|
|
set voice_client.sip$i.cbbs_key='5'
|
|
set voice_client.sip$i.cbbs_maxretry='5'
|
|
set voice_client.sip$i.cbbs_retrytime='300'
|
|
set voice_client.sip$i.cbbs_waittime='30'
|
|
EOF
|
|
}
|
|
|
|
delete_voice_profile() {
|
|
local i="$1"
|
|
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q delete voice_client.sip$i
|
|
}
|
|
|
|
add_line() {
|
|
local i="$1"
|
|
local j="$2"
|
|
/sbin/uci ${UCI_CONFIG_DIR:+-c $UCI_CONFIG_DIR} -q batch << EOF 2>&1 >/dev/null
|
|
set voice_client.brcm$i.sip_account="sip$j"
|
|
EOF
|
|
}
|
|
|
|
delete_line() {
|
|
local line_name="$1"
|
|
local call_lines_exist=""
|
|
sip_id=`$UCI_GET voice_client.$line_name.sip_account|sed 's/sip//g'`
|
|
line_id=`echo $line_name|sed 's/brcm//g'`
|
|
$UCI_SET voice_client.$line_name.sip_account='-'
|
|
call_lines_exist=`$UCI_GET voice_client.sip$sip_id.call_lines|wc -w`
|
|
if [ $call_lines_exist -gt 1 ];then
|
|
call_lines="`$UCI_GET voice_client.sip$sip_id.call_lines|sed "s/ *$line_id */ /g"`"
|
|
else
|
|
call_lines=""
|
|
fi
|
|
$UCI_SET voice_client.sip$sip_id.call_lines="$call_lines"
|
|
}
|
|
|
|
get_line_instances_list() {
|
|
local i=$1
|
|
local j=$1
|
|
local instances
|
|
let j--
|
|
for line in `$UCI_SHOW voice_client|grep sip_account|awk -F '.' '{print $2}'`;do
|
|
if [ "`$UCI_GET voice_client.$line.sip_account`" = "sip$j" ];then
|
|
local instance=`$UCI_GET voice_client.$line.instances|cut -f $i -d:`
|
|
if [ "$instance" != "0" ];then
|
|
instances="$instances $instance"
|
|
fi
|
|
fi
|
|
done
|
|
echo $instances
|
|
}
|
|
|
|
delete_associated_line_instances() {
|
|
local i=$1
|
|
for line in `$UCI_SHOW voice_client|grep sip_account|awk -F '.' '{print $2}'`;do
|
|
if [ "`$UCI_GET voice_client.$line.sip_account`" = "sip$i" ];then
|
|
$UCI_SET voice_client.$line.sip_account="-"
|
|
fi
|
|
done
|
|
}
|
|
|
|
add_object_InternetGatewayDevice_Services() {
|
|
local filename="$2"
|
|
case $1 in
|
|
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-9]*.Line.)
|
|
freecwmp_parse_formated_parameter "$1" "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}.Line." "rc" "num"
|
|
if [ "$rc" != "0" ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
|
|
let sip_id=$num-1
|
|
local exist=`$UCI_GET voice_client.sip$sip_id`
|
|
if [ "$exist" = "" ];then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
fi
|
|
local i=`get_line_max_instance`
|
|
if [ "$i" = "" ];then
|
|
return $FAULT_CPE_RESOURCES_EXCEEDED
|
|
fi
|
|
add_line "$i" "$sip_id"
|
|
local instance=`$UCI_GET voice_client.brcm$i.instances|cut -f $num -d :`
|
|
if [ "$instance" = "0" ];then
|
|
max_line_instance=`$UCI_SHOW voice_client|grep instances|awk -F '=' '{print$2}'|cut -f $num -d:|sort -un|tail -1`
|
|
let instance=$max_line_instance+1
|
|
local j=0
|
|
for k in `$UCI_GET voice_client.brcm$i.instances|sed 's/:/ /g'`;do
|
|
let j++
|
|
if [ "$j" != "$num" ];then
|
|
if [ "$instances" = "" ];then
|
|
instances=$k
|
|
else
|
|
instances=$instances:$k
|
|
fi
|
|
else
|
|
if [ "$instances" = "" ];then
|
|
instances=$instance
|
|
else
|
|
instances=$instances:$instance
|
|
fi
|
|
fi
|
|
done
|
|
$UCI_SET voice_client.brcm$i.instances="$instances"
|
|
fi
|
|
call_lines=`$UCI_GET voice_client.sip$sip_id.call_lines`
|
|
if [ "$call_lines" != "" ];then
|
|
$UCI_SET voice_client.sip$sip_id.call_lines="$call_lines $i"
|
|
else
|
|
$UCI_SET voice_client.sip$sip_id.call_lines="$i"
|
|
fi
|
|
freecwmp_set_parameter_notification "$1$instance." "0"
|
|
$UCI_COMMIT
|
|
let profile_num=$sip_id+1
|
|
get_services_voice_service_line_generic "$profile_num" "$sip_id" "$instance" >> $cache_path/$filename
|
|
freecwmp_output "" "" "" "" "" "" "1" "$instance"
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
return $FAULT_CPE_NO_FAULT
|
|
;;
|
|
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.)
|
|
local instance=`get_voice_profile_max_instance`
|
|
let instance++
|
|
add_voice_profile "$instance"
|
|
$UCI_COMMIT
|
|
let instance++
|
|
freecwmp_output "" "" "" "" "" "" "1" "$instance"
|
|
freecwmp_set_parameter_notification "$1$instance." "0"
|
|
get_services_voice_service_generic "$instance" "$sip_id" >> $cache_path/$filename
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
return $FAULT_CPE_NO_FAULT
|
|
;;
|
|
InternetGatewayDevice.Services.VoiceService.)
|
|
return $FAULT_CPE_RESOURCES_EXCEEDED
|
|
;;
|
|
esac
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
}
|
|
|
|
delete_object_InternetGatewayDevice_Services() {
|
|
local param="$1"
|
|
local filename="$2"
|
|
local profile_object=${param%%Line.*}
|
|
freecwmp_parse_formated_parameter "$profile_object" "InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.{i}." "rc" "num"
|
|
if [ "$rc" != "0" ]; then return $FAULT_CPE_INVALID_PARAMETER_NAME; fi
|
|
let sip_id=$num-1
|
|
exist=`$UCI_GET voice_client.sip$sip_id`
|
|
if [ "$exist" = "" ];then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
fi
|
|
line_instances_list=`get_line_instances_list $num`
|
|
case $1 in
|
|
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-9]*.Line.[1-9]*.)
|
|
local num1=$num
|
|
freecwmp_parse_formated_parameter "${param#$profile_object}" "Line.{i}." "rc" "num"
|
|
local num2=$num
|
|
if [ $rc -eq 0 ];then
|
|
local l_inst_found=0
|
|
for line_instance in $line_instances_list;do
|
|
if [ "$line_instance" = "$num2" ];then
|
|
l_inst_found=1
|
|
break
|
|
fi
|
|
done
|
|
if [ "$l_inst_found" = "0" ];then
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
fi
|
|
for line in `$UCI_SHOW voice_client|grep brcm|grep instances`;do
|
|
if [ "`echo $line|awk -F '=' '{print $2}'|cut -d: -f $num1`" = "$num2" ];then
|
|
line_name=`echo $line|awk -F '.' '{print $2}'`
|
|
break
|
|
fi
|
|
done
|
|
delete_line $line_name
|
|
$UCI_COMMIT
|
|
freecwmp_output "" "" "" "" "" "" "1"
|
|
sed -i "/$1/d" $cache_path/$filename
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
return $FAULT_CPE_NO_FAULT
|
|
fi
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
;;
|
|
InternetGatewayDevice.Services.VoiceService.1.VoiceProfile.[1-9]*.)
|
|
delete_voice_profile $sip_id
|
|
delete_associated_line_instances $sip_id
|
|
$UCI_COMMIT
|
|
freecwmp_output "" "" "" "" "" "" "1"
|
|
sed -i "/$1/d" $cache_path/$filename
|
|
delay_service restart "voice_client" "5"
|
|
delay_service restart "asterisk" "6"
|
|
return $FAULT_CPE_NO_FAULT
|
|
;;
|
|
esac
|
|
return $FAULT_CPE_INVALID_PARAMETER_NAME
|
|
}
|
|
|
|
get_dynamic_InternetGatewayDevice_Services() {
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|
|
get_dynamic_linker_InternetGatewayDevice_Services() {
|
|
return $FAULT_CPE_NO_FAULT
|
|
}
|
|
|