I followed Daniel's instructions and made some progress but not 100% there yet.Errol
-------[Global section]----------
user_agent_header=""
-------[Main Routing Logic]-------
# handle registrations
if (is_method("REGISTER"))
{
$avp(new_user_agent) = $ua;
}
route(REGISTRAR);
.
.
# Forward REGISTER to Freeswitch
route[REGFWD] {
if(!is_method("REGISTER"))
{
return;
}
route(DISPATCH);
$uac_req(method)="REGISTER";
$uac_req(ruri)=$du;
$uac_req(furi)=$fn + "<sip:" + $au + "@" + $ar + ">";
$uac_req(turi)=$tn + "<sip:" + $au + "@" + $ar + ">";
$uac_req(hdrs)="Contact: <sip:" + $au + "@"
+ $ar
+ ";fs_path=sip:"
+ $sel(cfg_get.kamailio.bindip)
+ ":" + $sel(cfg_get.kamailio.bindport)
+ ">"
+ "\r\n";
if($sel(contact.expires) != $null)
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n";
else
$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
$uac_req(hdrs)= $uac_req(hdrs) + "User-Agent: " + $avp(new_user_agent) + "\r\n";
uac_req_send();
exit;
}
#!endif
------------
Now the correct User-Agent appears in the REGISTER message but in Freeswitch it shows as unknown.
U 184.xx.xx.208:5060 -> 184.xx.xx.198:6060
REGISTER sip:184.x.x.198:6060 SIP/2.0.
Via: SIP/2.0/UDP 184.xx.xx.208;branch=z9hG4bKa764.668d6dc7.0.
To: <sip:1001@pbx.mydomain.com>.
From: <sip:1001@pbx.mydomain.com>;tag=6f72f76f3402bf7cf11f6917529ca761-2ceb.
CSeq: 10 REGISTER.
Call-ID: 4570a277563cdffc-61869@184.xx.xx.208.
Max-Forwards: 70.
Content-Length: 0.
.
Contact: <sip:1001@pbx.mydomain.com;fs_path=sip:184.xx.xx.208:5060>.
Expires: 120.
User-Agent: Yealink SIP-T46G 28.72.0.26.
.
----------------
Got some extra dots in there but not sure why they are there and how they got there.
Any ideas? Anything I missed?
BROn Wed, Oct 8, 2014 at 12:34 PM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:Perhaps you can get it with adding User-Agent header to $uac_req(hdrs):
$uac_req(hdrs)= $uac_req(hdrs) + "User-Agent: " + $ua + "\r\n";
And sent the global parameter:
user_agent_header=""
But then no local generated request has user agent, which probably is ok for you.
There are still ways to use event_route[tm:local-request] to set a custom user agent header, but would require something like:
- add $us in $uac_req(hdrs) as X-UA header
- in event_route[tm:local-request], remove User-Agent and X-UA headers and add again User-Agent taking the value from X-UA
Cheers,
Daniel