Commit Graph

108 Commits

Author SHA1 Message Date
Kevin P. Fleming
94fa4d11b5 Improve support for media paths that can generate multiple frames at once.
There are various media paths in Asterisk (codec translators and UDPTL, primarily)
that can generate more than one frame to be generated when the application calling
them expects only a single frame. This patch addresses a number of those cases,
at least the primary ones to solve the known problems. In addition it removes the
broken TRACE_FRAMES support, fixes a number of bugs in various frame-related API
functions, and cleans up various code paths affected by these changes.

https://reviewboard.asterisk.org/r/175/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@200991 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-16 17:05:38 +00:00
Mark Michelson
3268149a1f Add flags to chanspy audiohook so that audio stays in sync.
There are two flags being added to the chanspy audiohook here. One
is the pre-existing AST_AUDIOHOOK_TRIGGER_SYNC flag. With this set,
we ensure that the read and write slinfactories on the audiohook do
not skew beyond a certain tolerance.

In addition, there is a new audiohook flag added here,
AST_AUDIOHOOK_SMALL_QUEUE. With this flag set, we do not allow for
a slinfactory to build up a substantial amount of audio before 
flushing it. For this particular issue, this means that the person 
spying on the call will hear the conversations in real time with very 
little delay in the audio.

(closes issue #13745)
Reported by: geoffs
Patches:
      13745.patch uploaded by mmichelson (license 60)
Tested by: snblitz



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@197537 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-28 14:49:13 +00:00
Mark Michelson
972d9bf53c Kevin has informed me that thi sort of thing is not necessary.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@191629 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-02 10:45:24 +00:00
Mark Michelson
85a8916552 Move static buffers to outside for loops in app_chanspy.
Similar to seanbright's commit 191422, this moves some static buffers
to be defined outside of for loops since it is undefined if memory
will be re-used or if the stack will grow with each iteration of the
loop.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@191628 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-05-02 10:21:00 +00:00
Kevin P. Fleming
59f867a5cb revert commit that included extranous changes
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@182807 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-18 01:51:21 +00:00
Kevin P. Fleming
f1f417a9d8 Improve the build system to *properly* remove unnecessary symbols from the runtime global namespace. Along the way, change the prefixes on some internal-only API calls to use a common prefix.
With these changes, for a module to export symbols into the global namespace, it must have *both* the AST_MODFLAG_GLOBAL_SYMBOLS flag and a linker script that allows the linker to leave the symbols exposed in the module's .so file (see res_odbc.exports for an example).



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@182802 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-03-18 01:28:42 +00:00
Mark Michelson
82937be553 Revert my previous change because it was stupid
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@173396 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-04 17:44:48 +00:00
Mark Michelson
fed7d2308b Add a missing unlock. Extremely unlikely to ever matter, but it's needed.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@173392 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-04 17:40:29 +00:00
Russell Bryant
5de6848d0c Ensure that the chanspy datastore is fully initialized.
This patch resolved some random crash issues observed by a user on a BSD system

(closes issue #14111)
Reported by: ys
Patches:
      app_chanspy.c.diff uploaded by ys (license 281)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@165889 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-12-19 15:03:02 +00:00
Kevin P. Fleming
add5ff5b05 fix a bunch of potential problems found by gcc 4.3.x, primarily bare strings being passed to printf()-like functions and ignored results from read()/write() and friends
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@153337 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-01 18:22:39 +00:00
Russell Bryant
6177d367e2 Fix a crash in the ChanSpy application. The issue here is that if you call
ChanSpy and specify a spy group, and sit in the application long enough looping
through the channel list, you will eventually run out of stack space and the
application with exit with a seg fault.  The backtrace was always inside of
a harmless snprintf() call, so it was tricky to track down.  However, it turned
out that the call to snprintf() was just the biggest stack consumer in this
code path, so it would always be the first one to hit the boundary.

(closes issue #13338)
Reported by: ruddy


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@139213 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-08-20 22:14:35 +00:00
Mark Michelson
ccfa1564da Add a lock and unlock prior to the destruction of the chanspy_ds
lock to ensure that no other threads still have it locked. While
this should not happen under normal circumstances, it appears that
if the spyer and spyee hang up at nearly the same time, the following
may occur.

1. ast_channel_free is called on the spyee's channel.
2. The chanspy datastore is removed from the spyee's channel in 
   ast_channel_free.
3. In the spyer's thread, the spyer attempts to remove and destroy the datastore
   from the spyee channel, but the datastore has already been removed in step 2, 
   so the spyer continues in the code.
4. The spyee's thread continues and calls the datastore's destroy callback, 
   chanspy_ds_destroy. This involves locking the chanspy_ds.
5. Now the spyer attempts to destroy the chanspy_ds lock. The problem is that in step 4, 
   the spyee has locked this lock, meaning that the spyer is attempting to destroy a lock 
   which is currently locked by another thread.

The backtrace provided in issue #12969 supports the idea that this is possible
(and has even occurred). This commit does not close the issue, but should help
in preventing one type of crash associated with the use of app_chanspy.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@138886 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-08-19 18:50:53 +00:00
Kevin P. Fleming
cd12517eeb make some more changes to the dahdi/zap channel name support stuff to ensure allthe globals are 'const', and clean up mmichelson's changes to app_chanspy to simplify the code
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@133226 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-23 20:42:30 +00:00
Mark Michelson
252c5728fc As suggested by seanbright, the PSEUDO_CHAN_LEN in
app_chanspy should be set at load time, not at compile
time, since dahdi_chan_name is determined at load time.

Also changed the next_unique_id_to_use to have the 
static qualifier.

Also added the dahdi_chan_name_len variable so that
strlen(dahdi_chan_name) isn't necessary. Thanks to
seanbright for the suggestion.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@133169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-23 19:39:47 +00:00
Mark Michelson
9482af686b Zap/pseudo is ten characters, but DAHDI/pseudo is
twelve. The strncmp call in next_channel should
account for this.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@133104 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-23 19:06:16 +00:00
Mark Michelson
ba642db1f4 Update the "last" channel in next_channel in app_chanspy so
that the same pseudo channel isn't constantly returned.

related to issue #13124



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@133101 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-07-23 18:57:17 +00:00
Jeff Peeler
f9818af8dd Adds DAHDI support alongside Zaptel. DAHDI usage favored, but all Zap stuff should continue working. Release announcement to follow.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@122314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-12 19:08:20 +00:00
Mark Michelson
a7f2c5dbf9 Russell noted to me that in the case that separate threads use their
own addressing system, the fix I made for issue 12376 does not guarantee
uniqueness to the datastores' uids. Though I know of no system that works
this way, I am going to change this right now to prevent trying to track
down some future bug that may occur and cause untold hours of debugging
time to track down.

The change involves using a global counter which increases with each new
chanspy_ds which is created. This guarantees uniqueness.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@118509 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-27 19:07:26 +00:00
Mark Michelson
9460de70ef Add a unique id to the datastore allocated in app_chanspy since
it is possible that multiple spies may be listening to the same
channel.

(closes issue #12376)
Reported by: DougUDI
Patches:
      12376_chanspy_uid.diff uploaded by putnopvut (license 60)
Tested by: destiny6628

(closes issue #12243)
Reported by: atis



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@118365 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-27 16:38:38 +00:00
Mark Michelson
fcd288a33e Move the unlock of the spyee channel to outside the start_spying() function so that
the channel is not unlocked twice when using whisper mode.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-25 19:32:02 +00:00
Russell Bryant
74694c686d Fix an issue that caused getting the correct next channel to not always work.
Also, remove setting the amount of time to wait for a digit from 5 seconds back
down to 1/10 of a second.  I believe this was so the beep didn't get played over
and over really fast, but a while back I put in another fix for that issue.

(closes issue #12498)
Reported by: jsmith
Patches:
      app_chanspy_channel_walk.trunk.patch uploaded by jsmith (license 15)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114597 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-23 20:49:18 +00:00
Mark Michelson
2dbf0778b3 Declaration of the peer channel in this scope was making it so the peer variable defined
in the outer scope was never set properly, therefore making iterating through the channel
list always restart from the beginning. This bug would have affected anyone who called
chanspy without specifying a first argument.

(closes issue #12461)
Reported by: stever28



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114226 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-17 21:03:29 +00:00
Sean Bright
e7072918e0 Make sure we have enough room for the recording's filename.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@114191 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-04-17 10:51:20 +00:00
Mark Michelson
ebb67cf852 Add a missing unlock in the case that memory allocation fails in app_chanspy.
Thanks to Russell for confirming that this was an issue.



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@110083 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-19 20:33:03 +00:00
Russell Bryant
755933863f Fix one place where the chanspy datastore isn't removed from a channel.
(issue #12243, reported by atis, patch by me)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@109763 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-18 22:34:42 +00:00
Mark Michelson
284f74997d Make sure that we release the lock on the spyee channel if the spyee or spy has hung up
(closes issue #12232)
Reported by: atis



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@109012 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-17 14:18:26 +00:00
Russell Bryant
efa3b46cdf Fix another issue that was causing crashes in chanspy. This introduces a new
datastore callback, called chan_fixup().  The concept is exactly like the
fixup callback that is used in the channel technology interface.  This callback
gets called when the owning channel changes due to a masquerade.  Before this
was introduced, if a masquerade happened on a channel being spyed on, the
channel pointer in the datastore became invalid.

(closes issue #12187)
(reported by, and lots of testing from atis)
(props to file for the help with ideas)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@108583 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-13 21:38:16 +00:00
Russell Bryant
a169524ff6 (closes issue #12187, reported by atis, fixed by me after some brainstorming
on the issue with mmichelson)

- Update copyright info on app_chanspy.

- Fix a race condition that caused app_chanspy to crash.  The issue was that
  the chanspy datastore magic that was used to ensure that spyee channels did
  not disappear out from under the code did not completely solve the problem.
  It was actually possible for chanspy to acquire a channel reference out of
  its datastore to a channel that was in the middle of being destroyed.  That
  was because datastore destruction in ast_channel_free() was done near the
  end.  So, this left the code in app_chanspy accessing a channel that was
  partially, or completely invalid because it was in the process of being free'd
  by another thread.  The following sort of shows the code path where the race 
  occurred:

  =============================================================================
  Thread 1 (PBX thread for spyee chan)  ||   Thread 2 (chanspy)
  --------------------------------------||-------------------------------------
  ast_channel_free()                    ||
    - remove channel from channel list  ||
    - lock/unlock the channel to ensure ||
      that no references retrieved from ||
      the channel list exist.           ||
  --------------------------------------||-------------------------------------
                                        || channel_spy()
    - destroy some channel data         ||  - Lock chanspy datastore
                                        ||  - Retrieve reference to channel
                                        ||  - lock channel
                                        ||  - Unlock chanspy datastore
  --------------------------------------||-------------------------------------
     - destroy channel datastores       ||
        - call chanspy datastore d'tor  ||  
          which NULL's out the ds'      ||  - Operate on the channel ...
          reference to the channel      ||     
                                        ||
    - free the channel                  || 
                                        ||
                                        ||  - unlock the channel
  --------------------------------------||-------------------------------------
  =============================================================================



git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@108135 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-12 19:57:42 +00:00
Tilghman Lesher
56e908b787 Safely use the strncat() function.
(closes issue #11958)
 Reported by: norman
 Patches: 
       20080209__bug11958.diff.txt uploaded by Corydon76 (license 14)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@106552 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-03-07 06:36:33 +00:00
Joshua Colp
fdb44349e9 Don't loop around infinitely trying to spy on our own channel, and don't forget to free/detach the datastore upon hangup of the spy.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@104787 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-27 20:56:23 +00:00
Russell Bryant
750067bd1a Fix a problem in ChanSpy where it could get stuck in an infinite loop without
being able to detect that the calling channel hung up.
(closes issue #12076, reported by junky, patched by me)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@104625 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-27 17:33:04 +00:00
Russell Bryant
c882e6da6f Avoid some recursion in the cleanup code for the chanspy datastore
(closes issue #12076, reported by junky, patched by me)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@104334 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-27 01:15:02 +00:00
Russell Bryant
f64df49235 This patch fixes some pretty significant problems with how app_chanspy handles
pointers to channels that are being spied upon.  It was very likely that a
crash would occur if the channel being spied upon hung up.  This was because
the current ast_channel handling _requires_ that the object is locked or else
it could disappear at any time (except in the owning channel thread).  So, this
patch uses some channel datastore magic on the spied upon channel to be able to
detect if and when the channel goes away.
(closes issue #11877)
(patch written by me, but thanks to kpfleming for the idea, and to file for review)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@104106 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-02-25 23:42:42 +00:00
Russell Bryant
ece4c9c40c ChanSpy issues a beep when it starts at the beginning of a list of channels to
potentially spy on.  However, if there were no matching channels, it would beep
at you over and over, which is pretty annoying.  Now, it will only beep once in
the case that there are no channels to spy on, but it will still beep again once
it reaches the beginning of the channel list again.

(closes issue #11738, patched by me)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@99923 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-23 17:46:55 +00:00
Joshua Colp
fa640604de Replace current spy architecture with backport of audiohooks. This should take care of current known spy issues.
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@98972 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-01-16 20:33:47 +00:00
Mark Michelson
90da4da6ad Merged revisions 75066 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r75066 | mmichelson | 2007-07-13 15:10:39 -0500 (Fri, 13 Jul 2007) | 5 lines

Fixed an issue where chanspy flags were uninitialized if no options were passed.
What triggered this investigation was an IRC chat where some people's quiet flags were
set while others' weren't even though none of them had specified the q option.


........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@75078 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-13 20:15:30 +00:00
Joshua Colp
0e80607e17 Merged revisions 73349 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r73349 | file | 2007-07-05 11:19:14 -0300 (Thu, 05 Jul 2007) | 2 lines

Tweak spy locking. (issue #9951 reported by welles)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@73355 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2007-07-05 14:21:44 +00:00
Joshua Colp
6c9e737d70 Only split up extension and context if a value exists. (issue #8332 reported by loloski)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@47437 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-11-10 16:53:16 +00:00
Joshua Colp
ba3ac1c86b Merged revisions 45060 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r45060 | file | 2006-10-13 13:01:22 -0400 (Fri, 13 Oct 2006) | 2 lines

Turn on volume adjustment if it needs to be on (issue #8136 reported by mnicholson)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@45066 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-10-13 17:05:02 +00:00
Joshua Colp
d95288fdf8 Slight overhaul of the whisper support. 1. We need to duplicate the frame from ast_translate 2. We need to ensure we always have signed linear coming in for signed linear combining. 3. We need to ensure we are always feeding signed linear out. 4. Properly store and restore write format when beeping on the channel we are whispering on. 5. Properly discontinue the stream on the channel for the beep. (issue #8019 reported by timkelly1980)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@43695 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-26 20:09:41 +00:00
Joshua Colp
4a7947501e Minor tweak - we need to lock the channel when we are removing the spy from it.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@42021 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-05 17:01:02 +00:00
Joshua Colp
49cfc19f0a Use tabs instead of spaces (I <3 tabs -- this is for you Qwell)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@41960 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-03 23:45:03 +00:00
Joshua Colp
55d594e9da Make the difference clear about what the responsibilities of the core and a spy are when it comes to spying on a channel. The core is responsible for adding a spy to a channel, feeding frames into the spy, removing the spy from the channel, and notifying the spy that is has been detached. The spy is responsible for reading frames in, and cleaning itself up. Each side will not try to do the other's job.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@41959 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-03 23:30:37 +00:00
BJ Weschke
c4dac0c1e5 We don't spy on Zap/psuedo channels. Not at all. Never. (#7871 - sxpert reporting)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@41850 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-03 15:21:12 +00:00
Kevin P. Fleming
0a27d8bfe5 merge new_loader_completion branch, including (at least):
- restructured build tree and makefiles to eliminate recursion problems
  - support for embedded modules
  - support for static builds
  - simpler cross-compilation support
  - simpler module/loader interface (no exported symbols)



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-21 02:11:39 +00:00
Russell Bryant
b9ee151d22 suppress a compiler warning about the usage of a potentially uninitialized
variable


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@39014 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-05 11:25:36 +00:00
Kevin P. Fleming
21e3c3a561 play a beep tone into the spied-on channel if we are about to whisper to them
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38466 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-07-28 23:47:05 +00:00
Kevin P. Fleming
4bc6613648 add ExtenSpy variant of ChanSpy
implement whisper mode for ExtenSpy/ChanSpy



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38465 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-07-28 23:36:06 +00:00
Kevin P. Fleming
a8b85fda84 more simplification, and correct a bug i introduced in the last commit
fix prototype for a channel walking function to use a const input pointer
use existing channel walk by name prefix instead of reproducing that code in this app


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38389 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-07-27 23:16:08 +00:00
Kevin P. Fleming
94fa23aaa1 remove local channel finding wrappers
move guts of dialplan application into separate function, so it can be shared bythe new application i'm about to add :-)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38374 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-07-27 23:00:27 +00:00