Summary:ASTERISK-15023: [patch] Fix/improve transaction/dialog-matching in pedantic mode
Reporter:Alex Hermann (alexh)Labels:
Date Opened:2009-10-23 04:41:40Date Closed:2015-02-25 19:30:27.000-0600
Versions:Frequency of
is related toASTERISK-14723 [patch] [regression] Simultaneous calls from same Call-ID silently ignored by asterisk
Environment:Attachments:( 0) fix-dialog-matching
( 1) improved-dialog-matching
Description:Attached patch fixes the following issues in chan_sip:

1) Use astobj2 as a true hash table instead of doing a 'fancy' linear searchg over the entire list trying to find the correct entry.

2) Fix tag matching. Currently in pedantic mode it is impossible to handle a call that is being forwarded by a proxy, eg receiving a 183 (client, no answer) and a 200 (voicemail) from 2 different UA's.

3) Fix spiralling calls. Each new branch creates a new pvt.

4) Part of 2) is to not clear the SIP_PAGE2_DIALOG_ESTABLISHED flag on a BYE, to be able to absorb retransmissions.

I'm sorry this is all in one patch, but I'm a little time contraint to split them now.
Comments:By: Alex Hermann (alexh) 2009-10-23 04:46:38

The 1.4.26 version of the patch.

By: Alex Hermann (alexh) 2009-10-23 04:47:56

No option to rename attachments?

fix-dialog-matching -> 1.6.1
improved-dialog-matching ->

By: David Woolley (davidw) 2009-10-23 06:27:11

You may need to split the new feature part from the bug fix part, as I believe that new features can only be accepted against the trunk, whereas there is a live bug report, ASTERISK-14723, against your item (2), relating to

By: Matt Jordan (mjordan) 2015-02-25 19:30:17.385-0600

I think this issue is essentially completed, even if the existing code doesn't look much like the patches here any more.
# We track dialogs in an {{ao2}} container
# We should detect forked dialogs in {{match_req_to_dialog}}:
/* Forked Request Detection
* If this is a 200ok response and the totags do not match, this
* might be a forked response to an outgoing Request. Detection of
* a forked response must meet the criteria below.
* 1. must be a 2xx Response
* 2. call-d equal to call-id of Request. this is done earlier
* 3. from-tag equal to from-tag of Request. this is done earlier
* 4. branch parameter equal to branch of inital Request
* 5. to-tag _NOT_ equal to previous 2xx response that already established the dialog.
if ((arg->respid == 200) &&
!ast_strlen_zero(invite_branch) &&
!ast_strlen_zero(arg->viabranch) &&
!strcmp(invite_branch, arg->viabranch)) {
# We should detect spirals in the same function:
/* Loop/Merge Detected
* ---Current Matches to Initial Request---
* request uri
* Call-id
* their-tag
* no totag present
* method
* cseq
* --- Does not Match Initial Request ---
* Top Via
* Without the same Via, this can not match our initial transaction for this dialog,
* but given that this Request matches everything else associated with that initial
* Request this is most certainly a Forked request in which we have already received
* part of the fork.
# We do clear {{SIP_PAGE2_DIALOG_ESTABLISHED}} on a {{200 OK}} to a {{BYE}} request:
} else if (sipmethod == SIP_BYE) { /* Ok, we're ready to go */
pvt_set_needdestroy(p, "received 200 response");
ast_clear_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);

Closing this issue out as "Fixed" (at some point in time). If there is some aspect of this that is not fixed, please comment here and I'll be happy to reopen it.