[Kamailio-Users] Kamailio -> Asterisk Redirect/Reinvite and Remote-Party-ID

Klaus Darilion klaus.mailinglists at pernau.at
Tue Dec 1 15:56:51 CET 2009


Hi Florian!

1. As Asterisk detects the "spiral" and handles it internally, there is 
nothing you can do in Kamailio.

2. Just a warning: In general, Remote-Party-ID is used for CLI 
indication, not for billing purposes. In your setup it might be possibly 
to use RPID for billing to, but it would be better to use the proper 
headers, like the obsolete (as you are using RPID I suspect you like 
obsolete headers ;-) Diversion header, or the History-Info header. 
(another warning: make sure that your system ignores/removes these 
headers when sent by your customers - otherwise they can fool your 
billing system and signal arbitrary CLIs)

3. You can for example easily bypass the problem by making the DB lookup 
also in Asterisk. Use e.g. func_odbc to query your call-forwarding table 
from within Asterisk, set the CDR(whatever) variables to fulfill you 
billing requirements, and then send the call to the PSTN again.

regards
Klaus

Florian Meister wrote:
> Hi,
> 
> basically I'm using this structure at the moment:
> 
> SIP Users <----> Kamailio <-----> Asterisk <-----> PSTN
> 
> I have to add a diversion-functionality at kamailio-level, so to simply rewrite $ru with something else defined in the database. That's working without problems. For billing issues, I also have to add a Remote-Party-ID header, set to the SIP user, which initiated the redirect in the database.
> 
> Now to the problem:
> 
> When a call is coming from PSTN, it's passing the asterisk server, then at kamailio level $ru is rewritten and sent back to asterisk (I'm talking about a redirect to a number in PSTN here)
> 
> What I've seen from the logs is, that asterisk is seeing that it gets an invite back with the same call-id, and therefore it cancels the original invite and handles the whole call internally via the Local Channel. The Problem is, that in the invite sent from kamailio back to asterisk, I've set a Remote-Party-ID header to tell asterisk to set the Callerid correctly for billing purposes. Now it seems that asterisk is _ignoring_ this header from the second invite.
> 
> So is this an expected behavior ? If yes, how to do it correctly ?
> 
> Below you can see the verbose output of asterisk. Since the call is handled at "Local" Channels the function to read sip headers does not work. The only message I get is "thanks to SIP/tpsiptestproxyu01-00d0a0b8". 
> 
>     -- Called tpsiptestproxyu01/+435572949012
>     -- Now forwarding DAHDI/2-1 to 'Local/066480588134 at from-internal' (thanks to SIP/tpsiptestproxyu01-00d0a0b8)
>     -- Executing [066480588134 at from-internal:1] NoOp("Local/066480588134 at from-internal-d69e;2", "435572501134") in new stack
> [Dec  1 15:14:50] WARNING[20506]: chan_sip.c:15797 func_header_read: This function can only be used on SIP channels.
>     -- Executing [066480588134 at from-internal:2] NoOp("Local/066480588134 at from-internal-d69e;2", "") in new stack
>     -- Executing [066480588134 at from-internal:3] Dial("Local/066480588134 at from-internal-d69e;2", "DAHDI/G0/066480588134") in new stack
>     -- Requested transfer capability: 0x00 - SPEECH
>     -- Called G0/066480588134
>     -- DAHDI/124-1 is proceeding passing it to Local/066480588134 at from-internal-d69e;2
>     -- Local/066480588134 at from-internal-d69e;1 is proceeding passing it to DAHDI/2-1
> 
> In the SIP debug you can see that asterisk is cancelling the dialog with kamailio and doing it itself:
> 
> 13:49:30.589054 IP [--ASTERISK--].5060 > [--KAMAILIO--].5060: SIP, length: 938
> E....... at ..L..,L..,N........INVITE sip:+435572949012@[--KAMAILIO--] SIP/2.0
> Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport
> Max-Forwards: 70
> From: "435572501134" <sip:435572501134@[--ASTERISK--]>;tag=as27658014
> To: <sip:+435572949012@[--KAMAILIO--]>
> Contact: <sip:435572501134@[--ASTERISK--]>
> Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]
> CSeq: 102 INVITE
> User-Agent: Asterisk PBX 1.6.1.5
> Remote-Party-ID: "435572501134" <sip:435572501134@[--ASTERISK--]>;privacy=off;screen=yes
> Date: Tue, 01 Dec 2009 12:49:30 GMT
> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
> Supported: replaces, timer
> Content-Type: application/sdp
> Content-Length: 263
> 
> v=0
> o=root 930830518 930830518 IN IP4 [--ASTERISK--]
> s=Asterisk PBX 1.6.1.5
> c=IN IP4 [--ASTERISK--]
> t=0 0
> m=audio 16924 RTP/AVP 8 101
> a=rtpmap:8 PCMA/8000
> a=rtpmap:101 telephone-event/8000
> a=fmtp:101 0-16
> a=silenceSupp:off - - - -
> a=ptime:20
> a=sendrecv
> 
> 13:49:30.591037 IP [--KAMAILIO--].5060 > [--ASTERISK--].5060: SIP, length: 342
> E..r.. at .@.[0..,N..,L.....^.aSIP/2.0 100 Trying
> Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060
> From: "435572501134" <sip:435572501134@[--ASTERISK--]>;tag=as27658014
> To: <sip:+435572949012@[--KAMAILIO--]>
> Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]
> CSeq: 102 INVITE
> Server: OpenSER (1.3.2-notls (x86_64/linux))
> Content-Length: 0
> 
> 
> 13:49:30.594345 IP [--KAMAILIO--].5060 > [--ASTERISK--].5060: SIP, length: 1093
> E..a.. at .@.XA..,N..,L.....M+LINVITE sip:066480588134@[--ASTERISK--]:5060;transport=udp SIP/2.0
> Record-Route: <sip:[--KAMAILIO--];lr;ftag=as27658014>
> Via: SIP/2.0/UDP [--KAMAILIO--];branch=z9hG4bK06.05390227.0
> Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060
> Max-Forwards: 69
> From: "435572501134" <sip:435572501134@[--ASTERISK--]>;tag=as27658014
> To: <sip:+435572949012@[--KAMAILIO--]>
> Contact: <sip:435572501134@[--ASTERISK--]>
> Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]
> CSeq: 102 INVITE
> User-Agent: Asterisk PBX 1.6.1.5
> Date: Tue, 01 Dec 2009 12:49:30 GMT
> Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
> Supported: replaces, timer
> Content-Type: application/sdp
> Content-Length: 263
> Remote-Party-ID: "435572949012" <sip:435572949012 at tpseru01.tele.net>;party=caller;privacy=none;screen=yes
> 
> v=0
> o=root 930830518 930830518 IN IP4 [--ASTERISK--]
> s=Asterisk PBX 1.6.1.5
> c=IN IP4 [--ASTERISK--]
> t=0 0
> m=audio 16924 RTP/AVP 8 101
> a=rtpmap:8 PCMA/8000
> a=rtpmap:101 telephone-event/8000
> a=fmtp:101 0-16
> a=silenceSupp:off - - - -
> a=ptime:20
> a=sendrecv
> 
> 13:49:30.594605 IP [--ASTERISK--].5060 > [--KAMAILIO--].5060: SIP, length: 460
> E....... at ..)..,L..,N....... CANCEL sip:+435572949012@[--KAMAILIO--] SIP/2.0
> Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport
> Max-Forwards: 70
> From: "435572501134" <sip:435572501134@[--ASTERISK--]>;tag=as27658014
> To: <sip:+435572949012@[--KAMAILIO--]>
> Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]
> CSeq: 102 CANCEL
> User-Agent: Asterisk PBX 1.6.1.5
> Remote-Party-ID: "435572501134" <sip:435572501134@[--ASTERISK--]>;privacy=off;screen=yes
> Content-Length: 0
> 
> 
> 13:49:30.596307 IP [--KAMAILIO--].5060 > [--ASTERISK--].5060: SIP, length: 387
> E..... at .@.[...,N..,L.......KSIP/2.0 200 canceling
> Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060
> From: "435572501134" <sip:435572501134@[--ASTERISK--]>;tag=as27658014
> To: <sip:+435572949012@[--KAMAILIO--]>;tag=45db18648893e7acabf725621374d382-4ddb
> Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]
> CSeq: 102 CANCEL
> Server: OpenSER (1.3.2-notls (x86_64/linux))
> Content-Length: 0
> 
> 
> 13:49:30.596801 IP [--KAMAILIO--].5060 > [--ASTERISK--].5060: SIP, length: 396
> E..... at .@.Z...,N..,L.......kSIP/2.0 487 Request Terminated
> Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060
> From: "435572501134" <sip:435572501134@[--ASTERISK--]>;tag=as27658014
> To: <sip:+435572949012@[--KAMAILIO--]>;tag=45db18648893e7acabf725621374d382-4ddb
> Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]
> CSeq: 102 INVITE
> Server: OpenSER (1.3.2-notls (x86_64/linux))
> Content-Length: 0
> 
> 
> 13:49:30.596842 IP [--ASTERISK--].5060 > [--KAMAILIO--].5060: SIP, length: 539
> E..7.... at .....,L..,N.....#.oACK sip:+435572949012@[--KAMAILIO--] SIP/2.0
> Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport
> Max-Forwards: 70
> From: "435572501134" <sip:435572501134@[--ASTERISK--]>;tag=as27658014
> To: <sip:+435572949012@[--KAMAILIO--]>;tag=45db18648893e7acabf725621374d382-4ddb
> Contact: <sip:435572501134@[--ASTERISK--]>
> Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]
> CSeq: 102 ACK
> User-Agent: Asterisk PBX 1.6.1.5
> Remote-Party-ID: "435572501134" <sip:435572501134@[--ASTERISK--]>;privacy=off;screen=yes
> Content-Length: 0
> 
> 
> Thanks, 
> 
> Florian
> 
> _______________________________________________
> Kamailio (OpenSER) - Users mailing list
> Users at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users





More information about the sr-users mailing list