Hello,

On 11 Oct 2017 10:16 a.m., "Daniel Tryba" <d.tryba@pocos.nl> wrote:
On Tue, Oct 10, 2017 at 11:36:56PM +0100, Marrold wrote:
> I've included add_path_received() in my REGISTRAR routing block, however I
> see 'Path: [not set]' in the USRLOC table.
>
> Is it possible to force the insertion of the local proxy into the path
> field?

Like Daniel already mentioned, add the header and msg_apply_changes()
For example:
https://lists.kamailio.org//pipermail/sr-users/2015-April/087872.html

> One additional question, in the case of NAT keepalives, is it possible to
> only send these from the proxy the received the register request?

I decided to not use kamailio itself for sending these OPTIONS but to
use a simple script that queries the database and simply opens a
connection to the local kamailio. Mainly because I needed to monitor
some UAC and alert when it wasn't reachable (even though it is present
in location). In your case select the approriate UACs on Path.

  while($location=mysql_fetch_assoc($res))
  {
    usleep(1000);
    $branch=uniqid();
    $send[$location['id']]=0;
    $dst=preg_replace('/.*@([^;]+);.*/',"$1",$location['path']);
    $dst=explode(':',$dst);
    if(count($dst)<2)
    {
      $dst[1]=5060;
    }
    $str=<<<EOS
OPTIONS {$location['contact']} SIP/2.0\r
Via: SIP/2.0/UDP 127.0.1.1:$listenport;branch=$branch;rport;alias\r
Route: {$location['path']}\r
From: sip:pinger@localhost;tag={$location['ruid']}\r
To: {$location['contact']}\r
Call-ID: {$location['id']}-$listenport-$uid@localhost\r
CSeq: 1 OPTIONS\r
Content-Length: 0\r
\r

EOS;
    socket_sendto($sock,$str,strlen($str),MSG_EOR,$dst[0],$dst[1]);


Just to add, another option is to use the nat_traversal module: https://kamailio.org/docs/modules/stable/modules/nat_traversal.html. We use it for this very reason.

Cheers,

Charles


Sipcentric Ltd. Company registered in England & Wales no. 7365592. Registered office: Faraday Wharf, Innovation Birmingham Campus, Holt Street, Birmingham Science Park, Birmingham B7 4BB.