aboutsummaryrefslogtreecommitdiffstats
path: root/channels/sip/reqresp_parser.c
AgeCommit message (Collapse)AuthorFilesLines
2011-06-23Merged revisions 324685 via svnmerge from dvossel1-4/+12
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r324685 | dvossel | 2011-06-23 13:31:00 -0500 (Thu, 23 Jun 2011) | 8 lines Fixes sip crash when calling remove_uri_parameters with NULL AST-2011-009 (closes issue ASTERISK-18017) Reported by: jaredmauch ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@324689 f38db490-d61c-443f-a65b-d21fe96a405b
2011-05-27Merged revisions 321273 via svnmerge from jrose1-17/+21
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r321273 | jrose | 2011-05-27 09:59:34 -0500 (Fri, 27 May 2011) | 3 lines markm committed a patch I was working on yesterday, this fixes it to mesh up with suggestions by mnicholson. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@321289 f38db490-d61c-443f-a65b-d21fe96a405b
2011-05-26Merged revisions 321155 via svnmerge from markm1-0/+17
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r321155 | markm | 2011-05-26 17:48:45 -0400 (Thu, 26 May 2011) | 10 lines Fixed build problem with dev mode enabled, which was caused by commit 321100. Reformulated patch to be more generic. Moved the sip uri parse variable initalization to parse_uri_full in reqresp_parser.c. This will ensure that any use of parse uri will have null output variables if the parse fails. (closes issue #19346) Reported by: kobaz Tested by: kobaz,JonathanRose Review: [full review board URL with trailing slash] ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@321156 f38db490-d61c-443f-a65b-d21fe96a405b
2011-05-13Merged revisions 318720 via svnmerge from mnicholson1-2/+11
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r318720 | mnicholson | 2011-05-12 18:35:51 -0500 (Thu, 12 May 2011) | 4 lines Handle ipv6 addresses in the sent-by Via: field. This change fixes a regression in via header parsing and ipv6 handling. (closes issue #18951) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@318785 f38db490-d61c-443f-a65b-d21fe96a405b
2011-04-27Merged revisions 315894 via svnmerge from mnicholson1-4/+1
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r315894 | mnicholson | 2011-04-27 14:14:27 -0500 (Wed, 27 Apr 2011) | 28 lines Merged revisions 315893 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r315893 | mnicholson | 2011-04-27 14:03:05 -0500 (Wed, 27 Apr 2011) | 21 lines Merged revisions 315891 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r315891 | mnicholson | 2011-04-27 13:57:56 -0500 (Wed, 27 Apr 2011) | 14 lines Fix our compliance with RFC 3261 section 18.2.2. This change optimizes the free_via() function and removes some redundant null checking. It also fixes compliance with RFC 3261 section 18.2.2 by always using the port specified in the Via header for routing responses (even when maddr is not set). Also the htons() function is now used when setting the port. Additional documentation comments have been added in various places to make the logic in the code clearer. (closes issue #18951) Reported by: jmls Patches: issue18951_set_proper_port_from_via.patch uploaded by wdoekes (license 717) (modified) ........ ................ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@315895 f38db490-d61c-443f-a65b-d21fe96a405b
2011-03-23Merged revisions 311612 via svnmerge from bbryant1-1/+5
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r311612 | bbryant | 2011-03-23 17:45:46 -0400 (Wed, 23 Mar 2011) | 9 lines Fix a possible crash in sip/reqresp_parser.c that is caused by a possible null value. (closes issue #18821) Reported by: cmaj Patches: patch-reqresp_parser_sip_uri_domain_cmp_c_locale-crash-1.8.3-rc2.diff.tx uploaded by cmaj (license 830) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@311613 f38db490-d61c-443f-a65b-d21fe96a405b
2011-03-23Merged revisions 311558 via svnmerge from twilson1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r311558 | twilson | 2011-03-22 19:24:53 -0700 (Tue, 22 Mar 2011) | 5 lines Don't use static declared buf in parse_name_andor_addr This function isn't used anywhere yet, but we definitely don't want to keep the same value for buf between calls to the function. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@311559 f38db490-d61c-443f-a65b-d21fe96a405b
2011-01-26Merged revisions 304245 via svnmerge from mnicholson1-82/+194
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r304245 | mnicholson | 2011-01-26 14:43:27 -0600 (Wed, 26 Jan 2011) | 20 lines Merged revisions 304244 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r304244 | mnicholson | 2011-01-26 14:42:16 -0600 (Wed, 26 Jan 2011) | 13 lines Merged revisions 304241 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r304241 | mnicholson | 2011-01-26 14:38:22 -0600 (Wed, 26 Jan 2011) | 6 lines This patch modifies chan_sip to route responses to the address the request came from. It also modifies chan_sip to respect the maddr parameter in the Via header. ABE-2664 Review: https://reviewboard.asterisk.org/r/1059/ ........ ................ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@304246 f38db490-d61c-443f-a65b-d21fe96a405b
2011-01-24According to section 19.1.2 of RFC 3261:mnicholson1-3/+3
For each component, the set of valid BNF expansions defines exactly which characters may appear unescaped. All other characters MUST be escaped. This patch modifies ast_uri_encode() to encode strings in line with this recommendation. This patch also adds an ast_escape_quoted() function which escapes '"' and '\' characters in quoted strings in accordance with section 25.1 of RFC 3261. The ast_uri_encode() function has also been modified to take an ast_flags struct describing the set of rules it should use when escaping characters to allow for it to escape SIP URIs in addition to HTTP URIs and other types of URIs or variations of those two URI types in the future. The ast_uri_decode() function has also been modified to accept an ast_flags struct describing the set of rules to use when decoding to enable decoding '+' as ' ' in legacy http URLs. The unit tests for these functions have also been updated. ABE-2705 Review: https://reviewboard.asterisk.org/r/1081/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@303509 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-28Merged revisions 280269 via svnmerge from jpeeler1-1/+1
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r280269 | jpeeler | 2010-07-28 15:49:26 -0500 (Wed, 28 Jul 2010) | 2 lines Give test category missing leading slash ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@280270 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-26Merged revisions 279568 via svnmerge from dvossel1-0/+147
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r279568 | dvossel | 2010-07-26 14:59:03 -0500 (Mon, 26 Jul 2010) | 21 lines transaction matching using top most Via header 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. Review: https://reviewboard.asterisk.org/r/776/ ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@279569 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-26Merged revisions 279504 via svnmerge from mmichelson1-0/+10
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r279504 | mmichelson | 2010-07-26 11:04:09 -0500 (Mon, 26 Jul 2010) | 14 lines Allow for systems without locale support to be usable. A recent change to SIP URI comparison code added a locale-specific string comparison to the mix, and certain systems do not support such functions. This fix allows for those systems to still use Asterisk 1.8 (closes issue #17697) Reported by: pprindeville Patches: asterisk-trunk-bugid17697.patch uploaded by pprindeville (license 347) Tested by: mmichelson ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@279533 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-23SIP URI comparison fixes.mmichelson1-1/+483
This initially was created to work around the issue of using a string comparison instead of a binary comparison for IP addresses. It evolved a bit when test cases were created and it was discovered that comparison of URI parameters was not working exactly as it should. sip_uri_cmp() and its helpers have been moved to reqresp_parser.c and a new test has been added. (closes issue #17662) Reported by: oej Review: https://reviewboard.asterisk.org/r/792 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@278980 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-16Fix up some weird indentation problems in reqresp_parser.cmmichelson1-10/+10
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@277175 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-09Kill some startup warnings and errors and make some messages more helpful in ↵tilghman1-8/+8
tracking down the source. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@275105 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-09Fix sip_uri_parse test comparison.mmichelson1-2/+2
Part of the change with the IPv6 changes is to treat a host:port as a single 'domain' entity. This test was not updated to have the correct expectation after calling parse_uri(). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@274984 f38db490-d61c-443f-a65b-d21fe96a405b
2010-07-08Add IPv6 to Asterisk.mmichelson1-137/+107
This adds a generic API for accommodating IPv6 and IPv4 addresses within Asterisk. While many files have been updated to make use of the API, chan_sip and the RTP code are the files which actually support IPv6 addresses at the time of this commit. The way has been paved for easier upgrading for other files in the near future, though. Big thanks go to Simon Perrault, Marc Blanchet, and Jean-Philippe Dionne for their hard work on this. (closes issue #17565) Reported by: russell Patches: asteriskv6-test-report.pdf uploaded by russell (license 2) Review: https://reviewboard.asterisk.org/r/743 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@274783 f38db490-d61c-443f-a65b-d21fe96a405b
2010-06-28rfc compliant sip option parsing + new unit testdvossel1-0/+231
RFC 3261 section 8.2.2.3 states that if any unsupported options are found in the Require header field, a "420 (Bad Extension)" response should be sent with an Unsupported header field containing only the unsupported options. This is not currently being done correctly. Right now, if Asterisk detects any unsupported sip options in a Require header the entire list of options are returned in the Unsupported header even if some of those options are in fact supported. This patch fixes that by building an unsupported options character buffer when parsing the options that can be sent with the 420 response. A unit test verifying this functionality has been created. Some code refactoring was required. Review: https://reviewboard.asterisk.org/r/680/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@272880 f38db490-d61c-443f-a65b-d21fe96a405b
2010-06-21fixes crash when From header URI is missing "sip:"dvossel1-0/+22
(closes issue #17437) Reported by: klaus3000 Patches: sip_crash uploaded by dvossel (license 671) Tested by: klaus3000 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@271553 f38db490-d61c-443f-a65b-d21fe96a405b
2010-06-17fixes some coding guideline issuedvossel1-6/+6
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@271300 f38db490-d61c-443f-a65b-d21fe96a405b
2010-06-16addition of more parse_uri test casesdvossel1-0/+54
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@271056 f38db490-d61c-443f-a65b-d21fe96a405b
2010-04-09Add routines for parsing SIP URIs consistently.mmichelson1-56/+916
From the original issue report opened by Nick Lewis: Many sip headers in many sip methods contain the ABNF structure name-andor-addr = name-addr / addr-spec Examples include the to-header, from-header, contact-header, replyto-header At the moment chan_sip.c makes various different attempts to parse this name-andor-addr structure for each header type and for each sip method with sometimes limited degrees of success. I recommend that this name-andor-addr structure be parsed by a dedicated function and that it be used irrespective of the specific method or header that contains the name-andor-addr structure Nick has also included unit tests for verifying these routines as well, so...heck yeah. (closes issue #16708) Reported by: Nick_Lewis Patches: reqresp_parser-nameandoraddr2.patch uploaded by Nick Lewis (license 657 Review: https://reviewboard.asterisk.org/r/549 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@256530 f38db490-d61c-443f-a65b-d21fe96a405b
2010-02-15chan_sip parse code refactoring plus two new unit testsdvossel1-0/+259
Code Refactoring Changes - read_to_parts() moved to reqresp_parser.c and has been renamed as get_name_and_number() - get_in_brackets() moved to reqresp_parser.c - find_closing_quotes() added to sip_utils.h Logic Changes - get_name_and_number() now uses parse_uri() and get_calleridname() for parsing. Before this change only names within quotes were found, when names not within quotes are possible. New Unit Tests -sip_get_name_and_number_test -sip_get_in_brackets_test (closes issue #16707) Reported by: Nick_Lewis Patches: issue16706.diff uploaded by dvossel (license 671) Review: https://reviewboard.asterisk.org/r/499/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@246627 f38db490-d61c-443f-a65b-d21fe96a405b
2010-02-11fixes some test description formatting inconsistencies so log file looks nicedvossel1-2/+2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@246338 f38db490-d61c-443f-a65b-d21fe96a405b
2010-02-10additional parse_uri test and documentationdvossel1-1/+14
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@246249 f38db490-d61c-443f-a65b-d21fe96a405b
2010-02-09Various updates to the unit test API.russell1-45/+36
1) It occurred to me that the difference in usage between the error ast_str and the ast_test_update_status() usage has turned out to be a bit ambiguous in practice. In a lot of cases, the same message was being sent to both. In other cases, it was only sent to one or the other. My opinion now is that in every case, I think it makes sense to do both; we should output it to the CLI as well as save it off for logging purposes. This change results in most of the changes in this diff, since it required changes to all existing unit tests. It also allowed for some simplifications of unit test API implementation code. 2) Update ast_test_status_update() to include the file, function, and line number for the code providing the update. 3) There are some formatting tweaks here and there. Hopefully they aren't too distracting for code review purposes. Reviewboard's diff viewer seems to do a pretty good job of pointing out when something is a whitespace change. 4) I moved the md5_test and sha1_test into the test_utils module. It seemed like a better approach since these tests are so tiny. 5) I changed the number of nodes used in heap_test_2 from 1 million to 100 thousand. The only reason for this was to reduce the time it took for this test to run. 6) Remove an unused function prototype that was at the bottom of utils.h. 7) Simplify test_insert() using the LIST_INSERT_SORTALPHA() macro. The one minor difference in behavior is that it no longer checks for a test registered with the same name. 8) Expand the code in test_alloc() to provide specific error messages for each failure case, to clearly inform developers if they forget to set the name, summary, description, etc. 9) Tweak the output of the "test show registered" CLI command. I swapped the name and category to have the category first. It seemed more natural since that is the sort key. 10) Don't output the status ast_str in the "test show results" CLI command. This is going to tend to be pretty verbose, so just leave that for the detailed test logs (test generate results). Review: https://reviewboard.asterisk.org/r/493/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@245864 f38db490-d61c-443f-a65b-d21fe96a405b
2010-02-03-----Changes -----dvossel1-0/+398
New files - channels/sip/sip.h – A new header for shared #define, enum, and struct definitions. - channels/sip/include/sip_utils.h – sip util functions shared among the all the sip APIs - channels/sip/include/config_parser.h – sip config-parser API - channels/sip/config_parser.c – Contains sip.conf parsing helper functions with unit tests. - channels/sip/include/reqresp_parser.h – sip request response parser API - channels/sip/reqresp_parser.c – Contains sip request and response parsing helper functions with unit tests. New Unit Tests - sip_parse_uri_test - sip_parse_host_test - sip_parse_register_line_test Code Refactoring - All reusable #define, enum, and struct definitions were moved out of chan_sip.c into sip.h. During this process formatting changes were made to comments in both sip.h and chan_sip.c in order to better adhere to the coding guidelines. - The beginnings of three new sip APIs, sip-utils.h, config-parser.h, reqresp-parser.h using existing chan_sip.c functions. - parse_uri() and get_calleridname() were moved from chan_sip.c to request-parser.c along with unit tests for both functions. - sip_parse_host() and sip_parse_register_line() were moved from chan_sip.c to config-parser.c along with unit tests for both functions. Changes to parse_uri() -removal of the options parameter. It was never used and did not behave correctly. -additional check for [?header] field. When this field was present, the transport type was not being set correctly. ----- Overview ----- This patch is introduced with the hope that unit tests for all our sip parsing functions will be written soon. chan_sip is a huge file, and with the addition of each unit test chan_sip is going to grow larger and harder to maintain. I'm proposing we begin refactoring chan_sip, starting with the parsing functions. With each parsing function we move into a separate helper file, a unit test should accompany it. I've attempted to lay down the ground work for this change by creating two new parser helper files (config-parser.c and reqresp-parser.c) and moving all shared structs, enums, and defines from chan_sip.c into a shared sip.h file. We can't verify everything in Asterisk using unit tests, but string parsing is one area where unit tests make the most sense. By beginning to restructure the code in this way, chan_sip not only becomes less bloated, but Asterisk as a whole will become more stable. Review: https://reviewboard.asterisk.org/r/477/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@244597 f38db490-d61c-443f-a65b-d21fe96a405b