Commit Graph

4369 Commits

Author SHA1 Message Date
Russell Bryant
5f1f3ed473 Merge changes from team/russell/iax2_find_callno and iax2_find_callno_1.4
These changes address a critical performance issue introduced in the latest
release.  The fix for the latest security issue included a change that made
Asterisk randomly choose call numbers to make them more difficult to guess by
attackers.  However, due to some inefficient (this is by far, an understatement)
code, when Asterisk chose high call numbers, chan_iax2 became unusable after
just a small number of calls.  On a small embedded platform, it would not be
able to handle a single call.  On my Intel Core 2 Duo @ 2.33 GHz, I couldn't
run more than about 16 IAX2 channels.  Ouch.

These changes address some performance issues of the find_callno() function
that have bothered me for a very long time.  On every incoming media frame,
it iterated through every possible call number trying to find a matching
active call.  This involved a mutex lock and unlock for each call number
checked.  So, if the random call number chosen was 20000, then every media
frame would cause 20000 locks and unlocks.  Previously, this problem was
not as obvious since Asterisk always chose the lowest call number it could.

A second container for IAX2 pvt structs has been added.  It is an astobj2
hash table.  When we know the remote side's call number, the pvt goes into
the hash table with a hash value of the remote side's call number.  Then,
lookups for incoming media frames are a very fast hash lookup instead of an
absolutely insane array traversal.

In a quick test, I was able to get more than 3600% more IAX2 channels
on my machine with these changes.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114891 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-30 16:30:01 +00:00
Olle Johansson
26fc3d5ac6 Don't crash on bad SIP replys.
Fix created in Huntsville together with Mark M (putnopvut)

(closes issue #12363)
Reported by: jvandal
Tested by: putnopvut, oej


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114890 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-30 16:23:17 +00:00
Kevin P. Fleming
8b8a6f2486 use the ARRAY_LEN macro for indexing through the iaxs/iaxsl arrays so that the size of the arrays can be adjusted in one place, and change the size of the arrays from 32768 calls to 2048 calls when LOW_MEMORY is defined
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114880 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-30 14:46:57 +00:00
Tilghman Lesher
a4732cfb3c When modules are embedded, they take on a different name, without the ".so"
extension.  Specifically check for this name, when we're checking if a module
is loaded.
(Closes issue #12534)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114708 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-28 04:47:39 +00:00
Russell Bryant
609ed327eb Use consistent logic for checking to see if a call number has been chosen yet.
Also, remove some redundant logic I recently added in a fix.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114673 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-25 21:54:40 +00:00
Mark Michelson
709502b119 Re-invite RTP during a masquerade so that, for instance, an AMI
redirect of two channels which are natively bridged will preserve audio
on both channels. This prevents a problem with Asterisk not re-inviting
due to one of the channels having being a zombie.

(closes issue #12513)
Reported by: mneuhauser
Patches:
      asterisk-1.4-114602_restore-RTP-on-fixup.patch uploaded by mneuhauser (license 425)



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114632 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-24 21:35:08 +00:00
Mark Michelson
8eee7feb2b Resolve a deadlock in chan_local by releasing the channel lock
temporarily.

(closes issue #11712)
Reported by: callguy
Patches:
      11712.patch uploaded by putnopvut (license 60)
Tested by: acunningham



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114624 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-24 20:04:24 +00:00
Tilghman Lesher
0cd455c19b Ensure that when we set the accountcode, it actually shows up in the CDR.
(Fix for AMI Originate)
(Closes issue #12007)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114621 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-24 19:53:36 +00:00
Russell Bryant
57c68bcb3a Fix a silly mistake in a change I made yesterday that caused chan_iax2 to blow
up very quickly.
(issue #12515)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114608 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-24 15:55:21 +00:00
Olle Johansson
2acde60c29 Only have one max-forwards header in outbound REFERs.
Discovered in the Asterisk SIP Masterclass in Orlando. Thanks Joe!


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114603 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-24 14:55:18 +00:00
Russell Bryant
694a6b4abb Fix find_callno_locked() to actually return the callno locked in some more cases.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114587 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-23 17:16:32 +00:00
Olle Johansson
5980514bb0 Add 502 support for both directions, not only one... (see r114571)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114584 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-23 16:51:41 +00:00
Tilghman Lesher
0c777767c9 Treat a 502 just like a 503, when it comes to processing a response code
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114571 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-22 23:51:44 +00:00
Russell Bryant
5648feb3e9 When we receive a full frame that is supposed to contain our call number,
ensure that it has the correct one.
(closes issue #10078)
(AST-2008-006)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114558 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-22 22:15:36 +00:00
Russell Bryant
0f59f5491d If the dial string passed to the call channel callback does not indicate an
extension, then consider the extension on the channel before falling back
to the default.

(closes issue #12479)
Reported by: darren1713
Patches:
      exten_dial_fix_chan_iax2.c.patch uploaded by darren1713 (license 116)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114537 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-22 18:03:33 +00:00
Russell Bryant
39d1303e14 Merge changes from team/russell/issue_9520
These changes make sure that the reference count for sip_peer objects properly
reflects the fact that the peer is sitting in the scheduler for a scheduled
callback for qualifying peers or for expiring registrations.  Without this, it
was possible for these callbacks to happen at the same time that the peer was
being destroyed.  This was especially likely to happen with realtime peers, and
for people making use of the realtime prune CLI command.

(closes issue #9520)
Reported by: kryptolus
Committed patch by me


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114522 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-22 15:20:37 +00:00
Joshua Colp
3053679ade Only drop audio if we receive it without a progress indication. We allow other frames through such as DTMF because they may be needed to complete the call.
(closes issue #12440)
Reported by: aragon


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114322 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-21 14:39:32 +00:00
Mark Michelson
f32e7af11a Clearing up error messages so they make a bit more sense. Also removing a redundant error
message.

Issue AST-15



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114257 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-18 17:44:29 +00:00
Russell Bryant
de529ba5f7 Ensure that we don't ast_strdupa(NULL)
(closes issue #12476)
Reported by: davidw
Patch by me


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114248 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-18 15:24:09 +00:00
Sean Bright
da91e55eaf Only complete the SIP channel name once for 'sip show channel <channel>'
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114245 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-18 13:33:32 +00:00
Kevin P. Fleming
cbc844ae8a use the ZT_SET_DIALPARAMS ioctl properly by initializing the structure to all zeroes in case it contains fields that we don't write values into (which it does as of Zaptel 1.4.10)
(closes issue #12456)
Reported by: fnordian



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114184 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-16 20:46:38 +00:00
Tilghman Lesher
19a16f4634 Backport revisions for latest vpb drivers to 1.4
(Closes issue #12457)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114180 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-16 19:59:37 +00:00
Jason Parker
89e7986ccb Fix "fallthrough" behavior here, so config options in a previously configured user don't override settings in general.
(closes issue #12458)
Reported by: tzafrir
Patches:
      chanzap_users_sections.diff uploaded by tzafrir (license 46)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114173 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-16 17:30:09 +00:00
Olle Johansson
29c90c2fa0 Handle subscribe queues in all situations... Thanks to festr_ on irc for telling me about this bug.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114148 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-15 20:26:05 +00:00
Jason Parker
5fbfbc6b7c The call_token on the pvt can occasionally be NULL, causing a crash.
If it is NULL, we can skip this channel, since it can't the one we're looking for.

(closes issue #9299)
Reported by: vazir


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114120 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-14 18:31:57 +00:00
Joshua Colp
1e771acf2e It is possible for the remote side to say they want T38 but not give any capabilities.
(closes issue #12414)
Reported by: MVF


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114103 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-14 14:52:46 +00:00
Terry Wilson
2d791a431f Several places in the code called find_callno() (which releases the lock on the pvt structure) and then immediately locked the call and did things with it. Unfortunately, the call can disappear between the find_callno and the lock, causing Bad Stuff(tm) to happen.
Added find_callno_locked() function to return the callno withtout unlocking for instances that it is needed.

(issue #12400)
Reported by: ztel


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114083 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-11 22:32:51 +00:00
Mark Michelson
98b06bace4 Be sure that we're not about to set bridgepvt NULL prior to dereferencing it.
(closes issue #11775)
Reported by: fujin



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114045 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-10 19:55:33 +00:00
Joshua Colp
5cfba06089 Don't add custom URI options if they don't exist OR they are empty.
(closes issue #12407)
Reported by: homesick
Patches:
      uri_options-1.4.diff uploaded by homesick (license 91)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114021 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-10 13:27:11 +00:00
Mark Michelson
38e66ce8a2 We need to set the persistant_route [sic] parameter for the sip_pvt
during the initial INVITE, no matter if we're building the route set from
an INVITE request or response.

(closes issue #12391)
Reported by: benjaminbohlmann
Tested by: benjaminbohlmann


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113927 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-09 20:54:31 +00:00
Joshua Colp
800565fff8 If we receive an AUTHREQ from the remote server and we are unable to reply (for example they have a secret configured, but we do not) then queue a hangup frame on the Asterisk channel. This will cause the channel to hangup and a HANGUP to be sent via IAX2 to the remote side which is the proper thing to do in this scenario.
(closes issue #12385)
Reported by: viraptor


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113784 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-09 16:50:45 +00:00
Mark Michelson
784d1b7b3e If Asterisk receives a 488 on an INVITE (not a reinvite), then
we should not send a BYE.

(closes issue #12392)
Reported by: fnordian
Patches:
      chan_sip.patch uploaded by fnordian (license 110) with small modification from me



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113681 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-09 14:40:05 +00:00
Terry Wilson
346841ef05 Initialize fr->cacheable to make valgrind happy
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113596 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-09 01:34:25 +00:00
Jason Parker
55f577bc29 Add a little more that is required for previously added devices.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113504 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-08 18:48:55 +00:00
Jason Parker
40ff61ff52 Add support for several new(ish) devices - most notably, 7942/7945, 7962/7965, 7975.
Thanks to Greg Oliver for providing me the required information.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113454 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-08 18:07:49 +00:00
Tilghman Lesher
3949ff32df Move check for still-bridged channels out a little further, to avoid possible
deadlocks.  (Closes issue #12252)
Reported by: callguy
 Patches: 
       20080319__bug12252.diff.txt uploaded by Corydon76 (license 14)
 Tested by: callguy


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113348 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-08 15:39:16 +00:00
Jeff Peeler
3296b7882e (closes issue #12362) [redo of 113012]
This fixes a for loop (in realtime_peer) to check all the ast_variables the loop was intending to test rather than just the first one. The change exposed the problem of calling memcpy on a NULL pointer, in this case the passed in sockaddr_in struct which is now checked. 



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113240 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-07 21:34:45 +00:00
Jason Parker
4c046cd2b7 Allow playback with noanswer (and add earlyrtp option).
(closes issue #9077)
Reported by: pj
Patches:
      earlyrtp.diff uploaded by wedhorn (license 30)
Tested by: pj, qwell, DEA, wedhorn


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113118 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-07 18:00:09 +00:00
Jeff Peeler
ca8d1cf992 (closes issue #12362)
(closes issue #12372)
Reported by: vinsik
Tested by: tecnoxarxa

This one line change makes an if inside a for loop (in realtime_peer) check all the ast_variables the loop was intending to test rather than just the first one.


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@113012 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-07 15:16:44 +00:00
Philippe Sultan
fbf0f7107e Free newly allocated channel before returning
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@112820 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-04 19:26:15 +00:00
Philippe Sultan
5e5094f89e Prevent call connections when codecs don't match.
(closes issue #10604)
Reported by: keepitcool
Patches:
      branch-1.4-10604-2.diff uploaded by phsultan (license 73)
Tested by: phsultan

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@112766 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-04 17:16:59 +00:00
Mark Michelson
6df4e58654 Fix the testing of the "res" variable so that it is more logically correct and
makes the correct warning and debug messages print.

(closes issue #12361)
Reported by: one47
Patches:
      chan_zap_deferred_digit.patch uploaded by one47 (license 23)



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@112599 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-03 14:32:20 +00:00
Joshua Colp
dcad2163df Do not pass audio until the remote side has indicated they are providing early media, or if the channel has been answered.
(closes issue #11823)
Reported by: SDamm


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@112204 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-01 17:43:46 +00:00
Jason Parker
8f6e8e6711 Remove unimplemented softkeys. Prompted by issue #12325.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@111720 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-28 17:55:05 +00:00
Joshua Colp
d2eef8c07e If we are requested to authenticate a reinvite make sure that it contains T38 SDP if need be.
(closes issue #11995)
Reported by: fall


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@111020 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-26 19:04:35 +00:00
Joshua Colp
af904bf602 Make sure that full video frames are sent whenever the 15 bit timestamp rolls over.
(closes issue #11923)
Reported by: mihai
Patches:
      asterisk-fullvideo.patch uploaded by mihai (license 94)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@111014 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-26 18:41:29 +00:00
Jeff Peeler
e510971e20 This one line change makes an if inside a for loop (in realtime_peer) check all the ast_variables the loop was intending to test rather than just the first one.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@110727 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-25 20:03:13 +00:00
Mark Michelson
baa405e8c3 When reverting a commit, I accidentally left in this bit which was an experiment
to see what would happen. It passed the compile test, and I didn't notice I had
left this change in too.

So this is a revert of a revert...sort of.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@110635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-25 15:40:33 +00:00
Mark Michelson
6eed7ae503 This is a revert for revision 108288. The reason is that that revision
was not for an actual bug fix per se, and so it really should not have been in 1.4 in
the first place. Plus, people who compile with DO_CRASH are more likely
to encounter a crash due to this change. While I think the usage of DO_CRASH
in ast_sched_del is a bit absurd, this sort of change is beyond the scope of 1.4
and should be done instead in a developer branch based on trunk 
so that all scheduler functions are fixed at once.

I also am reverting the change to trunk and 1.6 since they also suffer from
the DO_CRASH potential.

(closes issue #12272)
Reported by: qq12345



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@110618 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-24 19:17:41 +00:00
Russell Bryant
e34ecbfc92 Turn a NOTICE into a DEBUG message.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@110614 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-24 17:34:56 +00:00