[asterisk-dev] [Code Review] SIP: transaction matching using top most Via header
David Vossel
dvossel at digium.com
Tue Jul 13 12:07:59 CDT 2010
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/776/
-----------------------------------------------------------
(Updated 2010-07-13 12:07:59.148053)
Review request for Asterisk Developers.
Changes
-------
This update fixes the place I missed verifying the cseq numbers correctly when matching a Request to a dialog.
Summary
-------
This patch modifies the way chan_sip.c does transaction to dialog matching. Asterisk now stores information in the top most Via header of the initial incoming request and compares that against other Requests that have the same call-id. This results in Asterisk being able to detect a forked call in which it has received multiple legs of the fork. I completely stripped out the previous matching code and made the comparisons a little more explicit and easier to understand. My comments in the code should offer all the details involving this patch.
This patch also fixes a bug with the usage of the OBJ-MULTIPLE flag to find multiple dialogs with the same call-id. Since the callback function was returning (CMP_MATCH | CMP_STOP) only the first item found was being returned. I fixed this by making a new callback function for finding multiple dialogs that only returns (CMP_MATCH) on a match allowing for multiple items to be returned.
Diffs (updated)
-----
/trunk/channels/chan_sip.c 275997
/trunk/channels/sip/include/reqresp_parser.h 275997
/trunk/channels/sip/include/sip.h 275997
/trunk/channels/sip/reqresp_parser.c 275997
Diff: https://reviewboard.asterisk.org/r/776/diff
Testing
-------
I tested this with various sip forking scenarios. I created some of my own scenarios using sipp, and then set up an openSIPS proxy to fork all requests to my asterisk box and watch how they were handled. Asterisk now only accepts the first request to a forked call and responds with a 482 (Loop Detected) to the second (or thrid or forth). The 482 message is not entirely intuitive to me, but from what I understood that is what RFC 3261 section 8.2.2.2 indicates we should respond with in this scenario.
8.2.2.2 Merged Requests
If the request has no tag in the To header field, the UAS core MUST
check the request against ongoing transactions. If the From tag,
Call-ID, and CSeq exactly match those associated with an ongoing
transaction, but the request does not match that transaction (based
on the matching rules in Section 17.2.3), the UAS core SHOULD
generate a 482 (Loop Detected) response and pass it to the server
transaction.
The same request has arrived at the UAS more than once, following
different paths, most likely due to forking. The UAS processes
the first such request received and responds with a 482 (Loop
Detected) to the rest of them.
Thanks,
David
More information about the asterisk-dev
mailing list