[SR-Users] Terminate dialog from another dialog

2018-03-25 Thread Joel Serrano
Hi guys,

I'm trying to set kamailio to not allow simultaneous calls from the same
user, but if a second call comes in, the behavior desired is to process
that second call and terminate the previous (already active) one.

Say you have call A that creates dialog A.

Then you have call B come in, creates dialog B.

Can I save some info from dialog (call) A in a htable for example, then
check that htable for the needed info from dialog (call) B and terminate
dialog (call) A if it exists?

I think using dlg_get() and dlg_bye() would do the trick but not 100% sure
how they work..


The example in the docs seems exactly the case:

dlg_get --> "Search and set current dialog based on Call-ID, From-Tag and
To-Tag parameters"

if(dlg_get("abcdef", "123", "456"))
{
dlg_bye("all");
}

After the dlg_get() and dlg_bye() what happens to call B? Does the route
continue running or does it end? Will it automatically switch back to the
current dialog or do you have to manually switch back running dlg_get()
again? (Sorry if I'm not explaining myself correctly, let me know if it
sounds confusing)

Does anyone have experience with these two functions?


Thanks,
Joel.
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Re: Audio stops after resuming call from hold

2018-03-25 Thread gerry kernan
Update didn't make any difference, when back to investigate reinvites 
Added if statement that sets rtpengie direction if is invite with to tag , all 
ok now 






Gerry Kernan 
InfinityIT 

 
Suite 17 The Mall 
Beacon Court, 
Sandyford, 
Dublin 18. 

 
p: +35312930090 
f:  +35312930137 
w: www.infinityit.ie



 From:   gerry kernan  
 To:   'Kamailio (SER) - Users Mailing List'  
 Sent:   23/03/2018 3:55 PM 
 Subject:   Re: [SR-Users]  Re: Audio stops after resuming call from 
hold 




Hi Segriu
 
I’ve updated to 4.3. I’ll let you know how I go on with the new version
 
 
Best Regards
 
Gerry Kernan
 
From: sr-users [mailto:sr-users-boun...@lists.kamailio.org] On Behalf Of Sergiu 
Pojoga
Sent: 23 March 2018 12:50
To: Kamailio (SER) - Users Mailing List 
Subject: Re: [SR-Users]  Re: Audio stops after resuming call from hold
 

Config code looks solid to me. Look at the 'c=' in SDP in the forward and reply 
re-INVITEs. If it gets properly overwritten (same way as it is for the dialog 
forming INVITE) when rtpengine is engaged, then I believe we are facing some 
kind of bug in the 4.2 version of Kamailio, something about this thread: 
https://lists.kamailio.org/pipermail/sr-users/2012-September/074567.html

 

I can't upgrade Kamailio at the moment to test my theory as it's a production 
environment, but may be you can?

 

On Fri, Mar 23, 2018 at 6:17 AM, gerry kernan  
wrote:


Hi 
 
I think my issue is related to rtpengine when the call is take off hold. Im 
using a private address and a public address . below is route section of our 
Kamailio.cfg and do I have somethimg setup incorrectly for handleing re-invites?
 
 
/usr/sbin/rtpengine --pidfile /var/run/rtpengine.pid --table=-1 
--interface=priv/192.X.X.X --interface=pub/212.X.X.X --listen-ng=127.0.0.1:7722 
--tos=184 --timeout=60 --log-level=7 --log-facility=local5 --homer-protocol=udp 
--homer-id=2011
 
 
request_route {
 
    route(SANITY);
 
    force_rport();
 
    # CANCEL processing
    if (is_method("CANCEL")) {
    if (t_check_trans()) {
    route(RELAY);
    }
    exit;
    }
 
    # handle retransmissions
    if (!is_method("ACK")) {
    if(t_precheck_trans()) {
    t_check_trans();
    exit;
    }
    t_check_trans();
    }
 
    # handle requests within SIP dialogs
    route(WITHINDLG);
 
    ### only initial requests (no To tag)
 
    # record routing for dialog forming requests (in case they are routed)
    if (is_method("INVITE|SUBSCRIBE")) {
    record_route();
    }
 
    if (af==INET) {
    route(SIPIPV4);
    } else {
    route(SIPIPV6);
    }
}
 
# Stateful fowarding
route[RELAY] {
    if (!t_relay()) {
    sl_reply_error();
    }
    exit;
}
 
# Handle requests within SIP dialogs
route[WITHINDLG] {
    if (!has_totag()) return;
 
    # sequential request withing a dialog should
    # take the path determined by record-routing
    if (loose_route()) {
    route(DLGURI);
    if ( is_method("ACK") ) {
    # ACK is forwarded statelessly
    if (has_body("application/sdp")) {
    rtpengine_answer();
    }
    } else if ( is_method("NOTIFY") ) {
    # Add Record-Route for in-dialog NOTIFY as per RFC 6665.
    record_route();
    }
    route(DISPATCH);
    exit;
    }
 
    if ( is_method("ACK") ) {
    if ( t_check_trans() ) {
    # no loose-route, but stateful ACK;
    # must be an ACK after a 487
    # or e.g. 404 from upstream server
    route(RELAY);
    exit;
    } else {
    # ACK without matching transaction ... ignore and 
discard
        exit;
    }
    }
    sl_send_reply("404","Not here");
    exit;
}
 
route[SIPIPV4] {
    if (src_ip != BACKEND_NET4)
    {
    # device (client) to server (backend)
    route(V4DEVTOSRV);
    } else {
    # server (backend) to devuce (client)
    route(V4SRVTODEV);
    }
}
 
route[SIPIPV6] {
    sl_send_reply("404", "Not routing for IPv6");
    exit;
}
 
route[V4DEVTOSRV] {
    xlog("L_NOTICE", "client->backend FROM CLIENT IP: $si $rm $ru  $td 
ID=$ci\n");
 
    # SIP request packet client->backend
 
    # - remove preloaded route headers
    remove_hf("Route");
 
    if (!lookup_domain("$td", "dattr_")) {
    

[SR-Users] is t_flush_flags() really needed?

2018-03-25 Thread Juha Heinanen
While testing xflags, i noticed that a regular flag that I set AFTER
calling t_newtrans() stays set in onreply_route even when I do not
call t_flush_flags().

In a route block:

if (!t_newtran()) {
ERROR(Failed to create new transaction for $rm <$ru>);
exit;
};
if (!isflagset(19))
INFO( flag 19 is NOT set after t_newtran());
setflag(19);

and in onreply_route:

if (isflagset(19))
INFO(* flag 19 is set);
else
INFO(* flag 19 is NOT set);

Syslog gets:

Mar 25 11:24:41 trout /usr/bin/sip-proxy[21362]: INFO:  flag 19 is NOT 
set after t_newtran()
Mar 25 11:24:41 trout /usr/bin/sip-proxy[21433]: INFO: * flag 19 is set

So what is the point of t_flush_flags()?

-- Juha

___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Can't get route[AUTH] working as expected.

2018-03-25 Thread Aqs Younas
Thanks Samy.

On Sat, 24 Mar 2018, 8:50 pm SamyGo,  wrote:

> Yeah, so thats a sample script and definitely needs add-on functions to
> enable what you're expecting it to do.
> I believe in the past(*or maybe in opensips, Im not certain) it used to
> have the function db_check_from() / check_from()  to validate user in DB if
> so then engage in AUTH. Check URI_DB module.
> You can also use this function is_subscriber("$fU","subscriber",3)
>  
> to
> ensure authentication is engaged for everyone.
>
>
>
> On Fri, Mar 23, 2018 at 3:54 PM, Aqs Younas  wrote:
>
>> Thanks Samy for replying.
>>
>> I wanted if Caller IP was not allowed it should be asked for digest
>> authentication. But above default AUTH route only do that if from_uri is
>> local. If someone set a different URI in from header he will be able to
>> bypass the security check. Correct me if I am wrong somewhere.
>>
>> I know I can modify the route to get the expected request.
>>
>> But just wanted to ask if setting #!define WITH_AUTH and #!define
>> WITH_IPAUTH was not enough in default configuration just to make sure
>> caller is legitimate.
>>
>> Br. Aqs.
>>
>> On 23 March 2018 at 23:54, SamyGo  wrote:
>>
>>> Hi Aqs,
>>> What seems to be the problem ! do you want this caller to be IP
>>> Authenticated or Digest Authenticated or denied !?
>>>
>>>
>>> On Fri, Mar 23, 2018 at 6:16 AM, Aqs Younas  wrote:
>>>
 Greetings list.

 I can see that I was able to bypass the default route[AUTH] if I send
 an invite containing from_uri which is not local but requested line
 containing a local user.

 llisten=udp:172.16.40.10:5060

 route[AUTH] {
 #!ifdef WITH_AUTH
 #!ifdef WITH_IPAUTH
 if((!is_method("REGISTER")) && allow_source_address()) {
 # source IP allowed
 return;
 }
 #!endif
 if (is_method("REGISTER") || from_uri==myself) {
 # authenticate requests
 if (!auth_check("$fd", "subscriber", "1")) {
 auth_challenge("$fd", "0");
 exit;
 }
 # user authenticated - remove auth header
 if(!is_method("REGISTER|PUBLISH"))
 consume_credentials();
 }
 # if caller is not local subscriber, then check if it calls
 # a local destination, otherwise deny, not an open relay here
 if (from_uri!=myself && uri!=myself) {
 sl_send_reply("403","Not relaying");
 exit;
 }
 #!else
 # authentication not enabled - do not relay at all to foreign networks
 if(uri!=myself) {
 sl_send_reply("403","Not relaying");
 exit;
 }
 #!endif
 return;
 }

 Below INVITE get passed above auth route.


 INVITE sip:60129879190@172.16.40.10 SIP/2.0
 Via: SIP/2.0/UDP 139.5.177.91:5060;branch=z9hG4bK31edc7f4;rport
 Max-Forwards: 70
 From: ;tag=as2274e806
 To: 
 Contact: 
 Call-ID: 7b6d32bc6c679bb23eb248b955c0ac8b@139.5.177.91:5060
 CSeq: 102 INVITE
 User-Agent: FPBX-13.0.194.2(13.17.0)
 Date: Fri, 23 Mar 2018 09:33:01 GMT
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY,
 INFO, PUBLISH, MESSAGE
 Supported: replaces, timer
 Content-Type: application/sdp
 Content-Length: 321

 v=0
 o=root 237494576 237494576 IN IP4 139.5.177.99
 s=Asterisk PBX 13.17.0
 c=IN IP4 139.5.177.99
 t=0 0
 m=audio 15332 RTP/AVP 0 18 8 101
 a=rtpmap:0 PCMU/8000
 a=rtpmap:18 G729/8000
 a=fmtp:18 annexb=no
 a=rtpmap:8 PCMA/8000
 a=rtpmap:101 telephone-event/8000
 a=fmtp:101 0-16
 a=ptime:20
 a=maxptime:150
 a=sendrecv

 From INVITE and route[AUTH] I can see why it is being passed.

 But should not it by default authenticate every request if IP address
 is not allowed in permission module.

 Br, Aqs.

 ___
 Kamailio (SER) - Users Mailing List
 sr-users@lists.kamailio.org
 https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


>>>
>>> ___
>>> Kamailio (SER) - Users Mailing List
>>> sr-users@lists.kamailio.org
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>>>
>>
>> ___
>> Kamailio (SER) - Users Mailing List
>> sr-users@lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
> ___
> Kamailio (SER) - Users Mailing List
> sr-users@lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
___
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users