Freeswitch: Назначение CallerID из параметров User Directory
FreeSWITCH outbound_caller_id_number effective_caller_id_number sip_profile gateway
Directory
../freeswitch/conf/directory/…/2666.xml
<include> <user id="2666"> <params> <param name="password" value="$${default_password}"/> <param name="vm-password" value="2666"/> </params> <variables> <variable name="toll_allow" value="domestic,international,local"/> <variable name="accountcode" value="2666"/> <variable name="user_context" value="default"/> <variable name="effective_caller_id_name" value="Phone Dwarf 2666"/> <variable name="effective_caller_id_number" value="2666"/> <variable name="outbound_caller_id_name" value="8129981138"/> <variable name="outbound_caller_id_number" value="8129981138"/> <variable name="callgroup" value="it"/> </variables> </user> </include>
Dialplan
../freeswitch/conf/dialplan/…/dp.xml
Используйте outbound_caller_id_number для вызовов через SIP gateway.
<include> <extension name="external_call"> <condition field="destination_number" expression="^9(\d+)$"> <action application="set" data="outbound_caller_id_name=${user_data(${caller_id_number}@${domain_name} var outbound_caller_id_number)}"/> <action application="set" data="outbound_caller_id_number=${user_data(${caller_id_number}@${domain_name} var outbound_caller_id_name)}"/> <action application="bridge" data="sofia/gateway/[sip_gateway]/$1"/> </condition> </extension> </include>
а effective_caller_id_number для внутренних вызовов.
<include> <extension name="internal_call"> <condition field="destination_number" expression="^(2\d{3})$"> <action application="set" data="effective_caller_id_name=${user_data(${caller_id_number}@${domain_number} var effective_caller_id_number)}"/> <action application="set" data="effective_caller_id_number=${user_data(${caller_id_number}@${domain_name} var effective_caller_id_number)}"/> <action application="bridge" data="user/$1@{domain_name}"/> </condition> </extension> </include>
user_data
Для получения значений переменных и параметров из директории используется команда user_data.
Использование: user_data <user>@<domain> [attr|var|param] <name>
Где <user>@<domain> идентификатор пользователя, данные которого мы хотим получить.
В нашем примере использована переменная ${caller_id_number}@${domain_name}
т.е. мы идентифицируем вызывающего по его CallerID и получаем переменные (var) по имени effective_caller_id_num и effective_caller_id_name, которые могут отличаться от ${caller_id_number}.
Gateway
../freeswitch/conf/sip_profiles/internal/sip_gateway.xml
Но все вышеописанное игнорируется если в настройка gateway указано: <param name="caller-id-in-from" value="true"/>
<include> <gateway name="sip_gateway"> <param name="username" value=""/> <param name="password" value="register:false"/> <param name="proxy" value="192.168.252.252"/> <param name="expire-seconds" value="800"/> <param name="register" value="false"/> <param name="register-transport" value="udp"/> <param name="retry-seconds" value="60"/> <param name="context" value="public"/> <param name="caller-id-in-from" value="true"/> </gateway> </include>
SIP header
а берется из From: … <sip:2666 …
From: "2666"<sip:2666@192.168.0.231>;tag=...
SIP/2.0 100 Trying From: "2666"<sip:2666@192.168.0.231>;tag=pNyyD5yytBQ5j To: <sip:2230@192.168.0.252> Call-ID: fff56bcc-edd3-1233-b8bc-bcaec51dca30 CSeq: 82118469 INVITE Via: SIP/2.0/UDP 192.168.0.231:5070;rport=5070;branch=z9hG4bKmy1QNemeF117c Supported: replaces User-Agent: Avaya IP Office r_9.1 Contact: <sip:2230@192.168.0.252:5060> Content-Length: 0