Commit graph

1510 commits

Author SHA1 Message Date
Luigi Rizzo
0d59b76dd2 correct fix for the bug i previously introduced - the strings
are meant to be always initialized, independently from their content.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46104 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-24 06:52:15 +00:00
Russell Bryant
6e65bea242 Fix a seg fault on a registration. Line 7706, in parse_register_contact,
explicitly passes NULL as the "pass" argument to this function.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46055 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-24 00:52:06 +00:00
Luigi Rizzo
a989f7cd47 Unlike ast_strdup(), ast_strdupa() does not take a NULL pointer as argument,
so fix the places where this might happen.

This is also a fix that ought to go into 1.4

[The difference between the two functions is a bit confusing,
and in asterisk i believe all string handling functions
should be able to handl a NULL string as argument,
but changing the API in trunk and not in 1.4 would make
backporting harder.]



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46045 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 21:46:15 +00:00
Luigi Rizzo
6345c91eb3 remove a useless check for ocseq = 0.
As discussed on the mailing lists, 0 is a legal value
for Cseq, so there is no point to treat it specially.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46035 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 20:01:14 +00:00
Luigi Rizzo
a31aa6f320 get_header() always returns a non-NULL value, so checking
for NULL is certainly wrong and usually disables the
checks that we want to make instead.

This commit fixes a number of the above bugs where the result
of get_header() is immediately checked for NULL.

This is certainly a candidate for merging into 1.4




git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46026 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 19:52:43 +00:00
Luigi Rizzo
f1c2342c96 put another duplicated block of code in a function.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46025 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 19:28:23 +00:00
Luigi Rizzo
eb44903b08 reformat a statement and comment a potentially wrong
assignement (altering state on an unvalidated message).



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46015 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 18:38:42 +00:00
Luigi Rizzo
85fe7cac03 Remove unnecessary casts from const char * to char *,
if necessary by slightly rearranging the code.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46004 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 17:49:09 +00:00
Luigi Rizzo
8a7ba881e2 another use for parse_uri().
On passing, remove a wrong comment (that probably I wrote
myself!) and introduce a temporary variable to avoid a     
misleading cast.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@46003 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 17:41:03 +00:00
Luigi Rizzo
0cb5e93383 + make sure parse_uri never returns NULL pointers - this
simplifies its usage.

+ add another client for parse_uri, in handling Contact: strings
  (on passing, document the content of the "fullcontact" field);

+ in register_verify(), mark with XXX what i believe is another
  misinterpretation on the URI format when '@' is missing.
  No code changed here, so no fixes applied.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45977 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 15:45:36 +00:00
Luigi Rizzo
7dd92fd181 After reading better the SIP RFC on sip URI (19.1.1)
fix parse_uri() to interpret a missing userinfo
section as a domain-only URI, and comment a wrong
interpretation of the above in check_user_full().

The function has been patched to preserve the existing
behaviour (in what admittedly is a corner case, but
could be received under attacks).
Hopefully the From: based matching will go away soon!



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45976 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 15:08:40 +00:00
Luigi Rizzo
ee60094592 in function get_also_info(), move argument stripping
before splitting around the @, otherwise the refer_to_domain
might contain arguments as well, causing failures.
 
I think this is a true bug that ought to be fixed in 1.4 as well.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45966 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 14:35:37 +00:00
Luigi Rizzo
00b88f30b4 start putting the URI parsing code in one place,
introducing the function parse_uri() that splits
a URI in its components.

Right now use it only in one place, because the custom
parsing that is done here and there sometimes has
bugs that i want to figure out first.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45965 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 14:30:33 +00:00
Luigi Rizzo
32f82c2ca1 put common code in function terminate_uri() so we need to
fix it only in one place.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45955 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 13:19:13 +00:00
Luigi Rizzo
c761bea8e2 More cleanup of check_user_full with no functional change
apart from a small (but disabled by default) new option.
In detail:

+ introduce a new value for enum check_auth_result, AUTH_DONT_KNOW,
  used (read below) when a function does not have a conclusive response.
  Possibly this is the same as AUTH_NOT_FOUND, but need to check further.

+ move the large blocks (checking in the users list and in the peers
  list, respectively) from check_user_full() to separate functions.
  They return AUTH_DONT_KNOW in case they don't find a match, so
  the caller know that it has to try the next method.
     There is still some duplication of code here, but i
  have not tried yet to remove it.

+ [new option] a new option in sip.conf, match_auth_username,
  has been introduced, and disabled by default.
  If set, and the incoming request carries authentication info,
  the username to match in the users list is taken from there
  rather than from the From: field.
        This change is easy to identify, being made of
  - one line to declare the variable match_auth_username
  - a block of 15 lines in check_user_full()
  - one line in sip list settings
  - two lines for parsing the config file.

check_user_full() is now a lot cleaner - basically a sequence of
checks that are applied to the request. This will help future
work with new matching schemes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45945 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-23 11:08:47 +00:00
Luigi Rizzo
dc83868813 more streamlining of check_user_full
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45915 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-22 21:08:07 +00:00
Luigi Rizzo
e7c0a0524a simplify the flow of function check_user_full()
A large block needs reindentation now, but we don't do that because
it can be moved to a separate function.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45905 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-22 20:59:38 +00:00
Luigi Rizzo
36d7b8f488 put duplicated code in functions.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45904 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-22 20:51:05 +00:00
Luigi Rizzo
70ee76d64b introduce sip_pvt_lock() and sip_pvt_unlock() wrappers to
lock these data structures.

This improve readability, and also hides the underlying
locking mechanism so it is a lot easier to add diagnostic
code, or move the object locks somewhere else, etc.

On passing, rename the lock field in sip_pvt to pvt_lock,
also for ease of readability.




git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45786 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-20 20:59:06 +00:00
Russell Bryant
02ec7acf6a put the constants for whether methods can create a dialog or not in an enum
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45764 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-20 15:54:14 +00:00
Olle Johansson
d6602b1b5e Let's repair the SIP attack shield :-)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45743 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-20 08:14:14 +00:00
Joshua Colp
ceb2c7bc48 Merged revisions 45678 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r45678 | file | 2006-10-19 12:03:09 -0400 (Thu, 19 Oct 2006) | 2 lines

If the jitterbuffer is forced on then we can't partially bridge (reported by wangster on #asterisk-dev)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45679 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 16:06:14 +00:00
Luigi Rizzo
293330e7a9 move a large block out of do_monitor() and into a function,
to improve readability.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45668 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 10:05:02 +00:00
Luigi Rizzo
d553659017 + move the definition of netlock as it was not related to the
comment just above;

+ decouple the struct definition and variable declaration (iflist);



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45658 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 09:54:51 +00:00
Olle Johansson
f2d11e403c Cleaning up... Removing duplicate (again)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45647 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 07:17:13 +00:00
Kevin P. Fleming
4b8e41c529 restore freeing of threadstorage objects without custom cleanup functions
allow custom threadstorage init functions to return failure
use a custom init function for chan_sip's temp_pvt, to improve performance a bit


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45634 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 02:16:34 +00:00
Russell Bryant
777d03bd17 Merge fix to not leak the stringfields of a thread speicif sip_pvt. This also
includes the fix not to leak the actual sip_pvt.


Merged revisions 45622 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r45622 | russell | 2006-10-18 20:59:51 -0400 (Wed, 18 Oct 2006) | 2 lines

Don't leak the actual thread-specific sip_pvt struct

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45624 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 01:04:18 +00:00
Russell Bryant
bd53e7ee4c Extend the thread storage API such that a custom initialization function can
be called for each thread specific object after they are allocated.  Note that
there was already the ability to define a custom cleanup function.  Also, if
the custom cleanup function is used, it *MUST* call free on the thread
specific object at the end.  There is no way to have this magically done that
I can think of because the cleanup function registered with the pthread
implementation will only call the function back with a pointer to the
thread specific object, not the parent ast_threadstorage object.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45623 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-19 01:00:57 +00:00
Olle Johansson
7db2dfaf4e Remove duplicate declarations...
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45528 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-18 12:15:23 +00:00
Kevin P. Fleming
696f9ed677 Merged revisions 45408 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r45408 | kpfleming | 2006-10-17 17:24:10 -0500 (Tue, 17 Oct 2006) | 3 lines

optimize the 'quick response' code a bit more... no more malloc() or memset() for each response
expand stringfields API a bit to allow reusing the stringfield pool on a structure when needed, and remove some unnecessary code when the structure was being freed

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45409 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 22:24:45 +00:00
Joshua Colp
15c473908b Merged revisions 45378 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r45378 | file | 2006-10-17 16:30:34 -0400 (Tue, 17 Oct 2006) | 2 lines

Don't create a "real" pvt structure for requests that shouldn't be able to create one. Instead use a temporary pvt and fill it with enough information so we can send a reply.

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45379 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 20:34:22 +00:00
Olle Johansson
0b0d72579e Issue #5484 (branch sipdiversion) - Support for Diversion header in redirects of calls
with 302 redirection. (tinning)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45365 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 19:57:35 +00:00
Olle Johansson
3376c8e976 Issue #7254 - Add support of "423 Interval too brief" to outbound SIP registrations.
Thanks, tardieu!


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45335 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 17:54:59 +00:00
Olle Johansson
748de51a84 - Remove unneeded code that won't be reached now that we kill responses
to unkonwn dialogs earlier in the process. 
- move debug message.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45331 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 17:47:09 +00:00
Olle Johansson
9f837a0baa Get rid of the ignore variable that was only partially replaced
by the flag.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45295 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-17 06:47:02 +00:00
Joshua Colp
c62784c10d In the course of a data this has been turned into an option to ignore replies, then ignore responses and finally I'm just getting rid of the option altogether and making it the default no matter what. C'est la vie!
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45286 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 20:26:56 +00:00
Joshua Colp
da330feb60 Merged revisions 45280 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r45280 | file | 2006-10-16 16:06:18 -0400 (Mon, 16 Oct 2006) | 10 lines

Merged revisions 45265 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r45265 | file | 2006-10-16 15:59:54 -0400 (Mon, 16 Oct 2006) | 2 lines

Use responses rather then replies even though they mean the same thing.

........

................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 20:08:23 +00:00
Joshua Colp
b58cc9e1bd Merged revisions 45262 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r45262 | file | 2006-10-16 15:37:34 -0400 (Mon, 16 Oct 2006) | 10 lines

Merged revisions 45260 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r45260 | file | 2006-10-16 15:28:18 -0400 (Mon, 16 Oct 2006) | 2 lines

Add 'ignoreoodreplies' option which will not create a pvt structure on a SIP response but instead basically drop it.

........

................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45263 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 19:43:33 +00:00
Olle Johansson
5b52f69201 When adding new functions, please add a forward declaration.
I *know* it is not required, but it makes navigation easier and will help
when splitting up this large source code file. 

Thank you!


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45209 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 13:20:21 +00:00
Olle Johansson
43505df9f4 Importing rev 45196 from 1.4 - don't kill dialog for a bad response
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45204 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 13:03:02 +00:00
Olle Johansson
09b8583937 A B2BUA should *not* issue proxy auth.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45194 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-16 12:28:18 +00:00
Joshua Colp
e1bb0dab37 Merged revisions 45040 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r45040 | file | 2006-10-13 12:01:17 -0400 (Fri, 13 Oct 2006) | 2 lines

Complete merging in RPID screen changes (issue #8101 reported by hristo, patch by oej in revision 44757)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45047 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-13 16:02:27 +00:00
Luigi Rizzo
e1378c470f Try to avoid the use of 'z' modifier in cases where it is not
necessary - rather, cast the argument to int.

In this case, the string is in a UDP packet and as such
limited to 64k so its length can be safely represented in an int
without truncation (besides, this is just a debugging message!)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-13 11:18:01 +00:00
Luigi Rizzo
1fe21371a3 arguments to auth_headers() needed to be swapped here.
To avoid the same mistake in the future (due to slightly
confusing variable names), add a comment.

On passing, remove a redundant initialization.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@45009 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-13 11:11:19 +00:00
Kevin P. Fleming
49b0cc8c94 eliminate compiler warning
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44973 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-12 19:16:16 +00:00
Kevin P. Fleming
0ecfae3dbd Merged revisions 44971 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r44971 | kpfleming | 2006-10-12 14:14:24 -0500 (Thu, 12 Oct 2006) | 2 lines

we can only send one 'a=ptime' attribute per media session, not one for each format

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44972 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-12 19:15:25 +00:00
Kevin P. Fleming
035aeb82e4 Merged revisions 44956 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r44956 | kpfleming | 2006-10-12 13:38:51 -0500 (Thu, 12 Oct 2006) | 10 lines

Merged revisions 44955 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r44955 | kpfleming | 2006-10-12 13:31:26 -0500 (Thu, 12 Oct 2006) | 2 lines

ensure that IAX2 and SIP sockets allow UDP fragmentation when running on Linux (thanks to Brian Candler on the asterisk-dev list for the tip)

........

................


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44957 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-12 18:43:52 +00:00
Luigi Rizzo
97ac6793c7 + move [almost] all instances of WWW-Authenticate/Proxy-Authenticate
and friends in a function, auth_headers(), which is used to
  simplify the interface of do_{proxy|register}_auth().
 
+ use PROXY_AUTH = 407, WWW_AUTH = 401 as values for enum sip_auth_type;

No functional change, only code cleanup.



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44933 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-12 15:12:54 +00:00
Luigi Rizzo
59e61ae4a0 reduce indentation of two large blocks
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44901 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-11 23:36:25 +00:00
Luigi Rizzo
6d6e60be79 operator != also works between booleans...
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44900 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-11 23:26:44 +00:00