[SR-Users] SIP Ping a device using Kamailio

Carsten Bock carsten at ng-voice.com
Fri Jun 19 11:59:47 CEST 2015


Hi,

if you do not want to store the usr-location-info on that Kamailio,
you can accomplish that by using the nat_traversal module in Kamailio:
http://www.kamailio.org/docs/modules/devel/modules/nat_traversal.html

An alternative approach is doing this directly from Script:

modparam("htable", "htable", "natping=>size=8;autoexpire=3600;")

# time interval set to 10 seconds
modparam("rtimer", "timer", "name=NATPING;interval=10;mode=1;")
modparam("rtimer", "exec", "timer=NATPING;route=NATPING")

onreply_route[REGISTER_reply]
{
    if (t_check_status("200")) {
      if ($T_req($pr) == "udp") {
         $var(ouri) = "sip:"+$T_req($si)+":"+$T_req($sp);
         $sht(natping=>$var(ouri)) = $(T_req($ct){nameaddr.uri});
      }
    }
    exit;
}

# NATPING Route:                                                    #
#####################################################################
route[NATPING] {
  sht_iterator_start("nat_iterator", "natping");
  while(sht_iterator_next("nat_iterator")) {
    xlog("OPTIONS to $shtitval(nat_iterator) via $shtitkey(nat_iterator)...\n");
    $uac_req(method) = "OPTIONS";
    $uac_req(ruri) = $shtitval(nat_iterator);
    $uac_req(furi) = "sip:server";
    $uac_req(turi) = $shtitval(nat_iterator);
    $uac_req(ouri) = $shtitkey(nat_iterator);
    $uac_req(evroute) = 1;
    uac_req_send();
  }
  sht_iterator_end("nat_iterator");
}

event_route[uac:reply] {
  xlog("request sent to $uac_req(ruri) completed with code:
$uac_req(evcode), Type $uac_req(evtype)\n");
  if (($uac_req(evtype) != 1)) {
    $sht(natping=>$uac_req(ouri)) = $null;
  }
}

Thanks,
Carsten

2015-06-18 17:03 GMT+02:00 Nelson Migliaro <eng.migliaro at gmail.com>:
> Hello,
>
> Is there a way to ping a device using Kamailio.
>
> In my scenario I need to access a Kamailio located in my DMZ over a firewall
> that is only open in LAN > DMZ direction. It is close in the other way
> round.
>
> In my current configuration I keep the link open using Asterisk qualify
> option in SIP. I would like to replace Astersik located in LAN with Kamailio
> thus I need to keep the link open.
>
> I know there is an option using dispatch but I would like to avoid using
> this module in order to keep it simple.
>
> Is there a "simple embedded function" in order to accomplish this.
>
> thank you
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>



-- 
Carsten Bock
CEO (Geschäftsführer)

ng-voice GmbH
Schomburgstr. 80
D-22767 Hamburg / Germany

http://www.ng-voice.com
mailto:carsten at ng-voice.com

Office +49 40 5247593-0
Fax +49 40 5247593-99

Sitz der Gesellschaft: Hamburg
Registergericht: Amtsgericht Hamburg, HRB 120189
Geschäftsführer: Carsten Bock
Ust-ID: DE279344284

Hier finden Sie unsere handelsrechtlichen Pflichtangaben:
http://www.ng-voice.com/imprint/



More information about the sr-users mailing list