Mon Mar 12 2012 21:23:16

Asterisk developer's documentation


app_chanspy.c File Reference

ChanSpy: Listen in on any channel. More...

#include "asterisk.h"
#include <ctype.h>
#include <errno.h>
#include "asterisk/paths.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/audiohook.h"
#include "asterisk/features.h"
#include "asterisk/app.h"
#include "asterisk/utils.h"
#include "asterisk/say.h"
#include "asterisk/pbx.h"
#include "asterisk/translate.h"
#include "asterisk/manager.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/options.h"
#include "asterisk/autochan.h"
Include dependency graph for app_chanspy.c:

Go to the source code of this file.

Data Structures

struct  chanspy_translation_helper
struct  spy_dtmf_options

Defines

#define AST_NAME_STRLEN   256
#define NUM_SPYGROUPS   128

Enumerations

enum  {
  OPTION_QUIET = (1 << 0), OPTION_BRIDGED = (1 << 1), OPTION_VOLUME = (1 << 2), OPTION_GROUP = (1 << 3),
  OPTION_RECORD = (1 << 4), OPTION_WHISPER = (1 << 5), OPTION_PRIVATE = (1 << 6), OPTION_READONLY = (1 << 7),
  OPTION_EXIT = (1 << 8), OPTION_ENFORCED = (1 << 9), OPTION_NOTECH = (1 << 10), OPTION_BARGE = (1 << 11),
  OPTION_NAME = (1 << 12), OPTION_DTMF_SWITCH_MODES = (1 << 13), OPTION_DTMF_EXIT = (1 << 14), OPTION_DTMF_CYCLE = (1 << 15),
  OPTION_DAHDI_SCAN = (1 << 16), OPTION_STOP = (1 << 17), OPTION_EXITONHANGUP = (1 << 18)
}
enum  {
  OPT_ARG_VOLUME = 0, OPT_ARG_GROUP, OPT_ARG_RECORD, OPT_ARG_ENFORCED,
  OPT_ARG_NAME, OPT_ARG_EXIT, OPT_ARG_CYCLE, OPT_ARG_ARRAY_SIZE
}

Functions

static void __reg_module (void)
static void __unreg_module (void)
static void change_spy_mode (const char digit, struct ast_flags *flags)
static int channel_spy (struct ast_channel *chan, struct ast_autochan *spyee_autochan, int *volfactor, int fd, struct spy_dtmf_options *user_options, struct ast_flags *flags, char *exitcontext)
static int chanspy_exec (struct ast_channel *chan, const char *data)
static int common_exec (struct ast_channel *chan, struct ast_flags *flags, int volfactor, const int fd, struct spy_dtmf_options *user_options, const char *mygroup, const char *myenforced, const char *spec, const char *exten, const char *context, const char *mailbox, const char *name_context)
static int dahdiscan_exec (struct ast_channel *chan, const char *data)
static int extenspy_exec (struct ast_channel *chan, const char *data)
static int load_module (void)
static struct ast_autochannext_channel (struct ast_channel_iterator *iter, struct ast_autochan *autochan, struct ast_channel *chan)
static void * spy_alloc (struct ast_channel *chan, void *data)
static int spy_generate (struct ast_channel *chan, void *data, int len, int samples)
static void spy_release (struct ast_channel *chan, void *data)
static int start_spying (struct ast_autochan *autochan, const char *spychan_name, struct ast_audiohook *audiohook)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Listen to the audio of an active channel" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static const char app_chan [] = "ChanSpy"
static const char app_dahdiscan [] = "DAHDIScan"
static const char app_ext [] = "ExtenSpy"
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_app_option spy_opts [128] = { [ 'b' ] = { .flag = OPTION_BRIDGED }, [ 'B' ] = { .flag = OPTION_BARGE }, [ 'c' ] = { .flag = OPTION_DTMF_CYCLE , .arg_index = OPT_ARG_CYCLE + 1 }, [ 'd' ] = { .flag = OPTION_DTMF_SWITCH_MODES }, [ 'e' ] = { .flag = OPTION_ENFORCED , .arg_index = OPT_ARG_ENFORCED + 1 }, [ 'E' ] = { .flag = OPTION_EXITONHANGUP }, [ 'g' ] = { .flag = OPTION_GROUP , .arg_index = OPT_ARG_GROUP + 1 }, [ 'n' ] = { .flag = OPTION_NAME , .arg_index = OPT_ARG_NAME + 1 }, [ 'o' ] = { .flag = OPTION_READONLY }, [ 'q' ] = { .flag = OPTION_QUIET }, [ 'r' ] = { .flag = OPTION_RECORD , .arg_index = OPT_ARG_RECORD + 1 }, [ 's' ] = { .flag = OPTION_NOTECH }, [ 'S' ] = { .flag = OPTION_STOP }, [ 'v' ] = { .flag = OPTION_VOLUME , .arg_index = OPT_ARG_VOLUME + 1 }, [ 'w' ] = { .flag = OPTION_WHISPER }, [ 'W' ] = { .flag = OPTION_PRIVATE }, [ 'x' ] = { .flag = OPTION_DTMF_EXIT , .arg_index = OPT_ARG_EXIT + 1 }, [ 'X' ] = { .flag = OPTION_EXIT },}
static struct ast_generator spygen

Detailed Description

ChanSpy: Listen in on any channel.

Author:
Anthony Minessale II <anthmct@yahoo.com>
Joshua Colp <jcolp@digium.com>
Russell Bryant <russell@digium.com>

Definition in file app_chanspy.c.


Define Documentation

#define AST_NAME_STRLEN   256

Definition at line 59 of file app_chanspy.c.

Referenced by common_exec().

#define NUM_SPYGROUPS   128

Definition at line 60 of file app_chanspy.c.

Referenced by common_exec().


Enumeration Type Documentation

anonymous enum
Enumerator:
OPTION_QUIET 
OPTION_BRIDGED 
OPTION_VOLUME 
OPTION_GROUP 
OPTION_RECORD 
OPTION_WHISPER 
OPTION_PRIVATE 
OPTION_READONLY 
OPTION_EXIT 
OPTION_ENFORCED 
OPTION_NOTECH 
OPTION_BARGE 
OPTION_NAME 
OPTION_DTMF_SWITCH_MODES 
OPTION_DTMF_EXIT 
OPTION_DTMF_CYCLE 
OPTION_DAHDI_SCAN 
OPTION_STOP 
OPTION_EXITONHANGUP 

Definition at line 350 of file app_chanspy.c.

     {
   OPTION_QUIET             = (1 << 0),    /* Quiet, no announcement */
   OPTION_BRIDGED           = (1 << 1),    /* Only look at bridged calls */
   OPTION_VOLUME            = (1 << 2),    /* Specify initial volume */
   OPTION_GROUP             = (1 << 3),    /* Only look at channels in group */
   OPTION_RECORD            = (1 << 4),
   OPTION_WHISPER           = (1 << 5),
   OPTION_PRIVATE           = (1 << 6),    /* Private Whisper mode */
   OPTION_READONLY          = (1 << 7),    /* Don't mix the two channels */
   OPTION_EXIT              = (1 << 8),    /* Exit to a valid single digit extension */
   OPTION_ENFORCED          = (1 << 9),    /* Enforced mode */
   OPTION_NOTECH            = (1 << 10),   /* Skip technology name playback */
   OPTION_BARGE             = (1 << 11),   /* Barge mode (whisper to both channels) */
   OPTION_NAME              = (1 << 12),   /* Say the name of the person on whom we will spy */
   OPTION_DTMF_SWITCH_MODES = (1 << 13),   /* Allow numeric DTMF to switch between chanspy modes */
   OPTION_DTMF_EXIT         = (1 << 14),  /* Set DTMF to exit, added for DAHDIScan integration */
   OPTION_DTMF_CYCLE        = (1 << 15),  /* Custom DTMF for cycling next avaliable channel, (default is '*') */
   OPTION_DAHDI_SCAN        = (1 << 16),  /* Scan groups in DAHDIScan mode */
   OPTION_STOP              = (1 << 17),
   OPTION_EXITONHANGUP      = (1 << 18),   /* Hang up when the spied-on channel hangs up. */
};
anonymous enum
Enumerator:
OPT_ARG_VOLUME 
OPT_ARG_GROUP 
OPT_ARG_RECORD 
OPT_ARG_ENFORCED 
OPT_ARG_NAME 
OPT_ARG_EXIT 
OPT_ARG_CYCLE 
OPT_ARG_ARRAY_SIZE 

Definition at line 372 of file app_chanspy.c.


Function Documentation

static void __reg_module ( void  ) [static]

Definition at line 1323 of file app_chanspy.c.

static void __unreg_module ( void  ) [static]

Definition at line 1323 of file app_chanspy.c.

static void change_spy_mode ( const char  digit,
struct ast_flags flags 
) [static]

Definition at line 495 of file app_chanspy.c.

References ast_clear_flag, ast_set_flag, OPTION_BARGE, and OPTION_WHISPER.

Referenced by channel_spy().

{
   if (digit == '4') {
      ast_clear_flag(flags, OPTION_WHISPER);
      ast_clear_flag(flags, OPTION_BARGE);
   } else if (digit == '5') {
      ast_clear_flag(flags, OPTION_BARGE);
      ast_set_flag(flags, OPTION_WHISPER);
   } else if (digit == '6') {
      ast_clear_flag(flags, OPTION_WHISPER);
      ast_set_flag(flags, OPTION_BARGE);
   }
}
static int channel_spy ( struct ast_channel chan,
struct ast_autochan spyee_autochan,
int *  volfactor,
int  fd,
struct spy_dtmf_options user_options,
struct ast_flags flags,
char *  exitcontext 
) [static]

Definition at line 509 of file app_chanspy.c.

References ast_activate_generator(), ast_audiohook_destroy(), ast_audiohook_detach(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_init(), ast_audiohook_lock, AST_AUDIOHOOK_STATUS_RUNNING, AST_AUDIOHOOK_TYPE_SPY, AST_AUDIOHOOK_TYPE_WHISPER, ast_audiohook_unlock, ast_audiohook_write_frame(), ast_autochan_destroy(), ast_autochan_setup(), ast_bridged_channel(), ast_channel_lock, ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_unlock, ast_check_hangup(), ast_clear_flag, ast_copy_flags, ast_deactivate_generator(), ast_debug, AST_FLAG_END_DTMF_ONLY, AST_FLAGS_ALL, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frfree, ast_goto_if_exists(), ast_log(), ast_manager_event, ast_manager_event_multichan, ast_read(), ast_set_flag, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verb, ast_waitfor(), chanspy_translation_helper::bridge_whisper_audiohook, ast_autochan::chan, change_spy_mode(), spy_dtmf_options::cycle, EVENT_FLAG_CALL, spy_dtmf_options::exit, f, chanspy_translation_helper::fd, chanspy_translation_helper::flags, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, name, ast_channel::name, OPTION_BARGE, OPTION_DTMF_SWITCH_MODES, OPTION_EXIT, OPTION_PRIVATE, OPTION_WHISPER, ast_audiohook::options, pbx_builtin_setvar_helper(), ast_audiohook_options::read_volume, chanspy_translation_helper::spy_audiohook, start_spying(), ast_audiohook::status, ast_frame::subclass, chanspy_translation_helper::volfactor, spy_dtmf_options::volume, chanspy_translation_helper::whisper_audiohook, and ast_audiohook_options::write_volume.

Referenced by common_exec().

{
   struct chanspy_translation_helper csth;
   int running = 0, res, x = 0;
   char inp[24] = {0};
   char *name;
   struct ast_frame *f;
   struct ast_silence_generator *silgen = NULL;
   struct ast_autochan *spyee_bridge_autochan = NULL;
   const char *spyer_name;
   struct ast_channel *chans[] = { chan, spyee_autochan->chan };

   ast_channel_lock(chan);
   spyer_name = ast_strdupa(chan->name);
   ast_channel_unlock(chan);

   /* We now hold the channel lock on spyee */

   if (ast_check_hangup(chan) || ast_check_hangup(spyee_autochan->chan)) {
      return 0;
   }

   ast_channel_lock(spyee_autochan->chan);
   name = ast_strdupa(spyee_autochan->chan->name);
   ast_channel_unlock(spyee_autochan->chan);

   ast_verb(2, "Spying on channel %s\n", name);
   ast_manager_event_multichan(EVENT_FLAG_CALL, "ChanSpyStart", 2, chans,
         "SpyerChannel: %s\r\n"
         "SpyeeChannel: %s\r\n",
         spyer_name, name);

   memset(&csth, 0, sizeof(csth));
   ast_copy_flags(&csth.flags, flags, AST_FLAGS_ALL);

   /* This is the audiohook which gives us the audio off the channel we are
      spying on.
   */
   ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");

   if (start_spying(spyee_autochan, spyer_name, &csth.spy_audiohook)) {
      ast_audiohook_destroy(&csth.spy_audiohook);
      return 0;
   }

   if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
      /* This audiohook will let us inject audio from our channel into the
         channel we are currently spying on.
      */
      ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");

      if (start_spying(spyee_autochan, spyer_name, &csth.whisper_audiohook)) {
         ast_log(LOG_WARNING, "Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
      }
   }

   if (ast_test_flag(flags, OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
      /* And this hook lets us inject audio into the channel that the spied on
         channel is currently bridged with.
      */
      ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy");

      if ((spyee_bridge_autochan = ast_autochan_setup(ast_bridged_channel(spyee_autochan->chan)))) {
         ast_channel_lock(spyee_bridge_autochan->chan);
         if (start_spying(spyee_bridge_autochan, spyer_name, &csth.bridge_whisper_audiohook)) {
            ast_log(LOG_WARNING, "Unable to attach barge audiohook on spyee %s. Barge mode disabled!\n", name);
         }
         ast_channel_unlock(spyee_bridge_autochan->chan);
      }
   }

   ast_channel_lock(chan);
   ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY);
   ast_channel_unlock(chan);

   csth.volfactor = *volfactor;

   if (csth.volfactor) {
      csth.spy_audiohook.options.read_volume = csth.volfactor;
      csth.spy_audiohook.options.write_volume = csth.volfactor;
   }

   csth.fd = fd;

   if (ast_test_flag(flags, OPTION_PRIVATE))
      silgen = ast_channel_start_silence_generator(chan);
   else
      ast_activate_generator(chan, &spygen, &csth);

   /* We can no longer rely on 'spyee' being an actual channel;
      it can be hung up and freed out from under us. However, the
      channel destructor will put NULL into our csth.spy.chan
      field when that happens, so that is our signal that the spyee
      channel has gone away.
   */

   /* Note: it is very important that the ast_waitfor() be the first
      condition in this expression, so that if we wait for some period
      of time before receiving a frame from our spying channel, we check
      for hangup on the spied-on channel _after_ knowing that a frame
      has arrived, since the spied-on channel could have gone away while
      we were waiting
   */
   while ((res = ast_waitfor(chan, -1) > -1) && csth.spy_audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING) {
      if (!(f = ast_read(chan)) || ast_check_hangup(chan)) {
         running = -1;
         break;
      }

      if (ast_test_flag(flags, OPTION_BARGE) && f->frametype == AST_FRAME_VOICE) {
         ast_audiohook_lock(&csth.whisper_audiohook);
         ast_audiohook_lock(&csth.bridge_whisper_audiohook);
         ast_audiohook_write_frame(&csth.whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
         ast_audiohook_write_frame(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
         ast_audiohook_unlock(&csth.whisper_audiohook);
         ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
         ast_frfree(f);
         continue;
      } else if (ast_test_flag(flags, OPTION_WHISPER) && f->frametype == AST_FRAME_VOICE) {
         ast_audiohook_lock(&csth.whisper_audiohook);
         ast_audiohook_write_frame(&csth.whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
         ast_audiohook_unlock(&csth.whisper_audiohook);
         ast_frfree(f);
         continue;
      }
      
      res = (f->frametype == AST_FRAME_DTMF) ? f->subclass.integer : 0;
      ast_frfree(f);
      if (!res)
         continue;

      if (x == sizeof(inp))
         x = 0;

      if (res < 0) {
         running = -1;
         break;
      }

      if (ast_test_flag(flags, OPTION_EXIT)) {
         char tmp[2];
         tmp[0] = res;
         tmp[1] = '\0';
         if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
            ast_debug(1, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
            pbx_builtin_setvar_helper(chan, "SPY_CHANNEL", name);
            running = -2;
            break;
         } else {
            ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
         }
      } else if (res >= '0' && res <= '9') {
         if (ast_test_flag(flags, OPTION_DTMF_SWITCH_MODES)) {
            change_spy_mode(res, flags);
         } else {
            inp[x++] = res;
         }
      }

      if (res == user_options->cycle) {
         running = 0;
         break;
      } else if (res == user_options->exit) {
         running = -2;
         break;
      } else if (res == user_options->volume) {
         if (!ast_strlen_zero(inp)) {
            running = atoi(inp);
            break;
         }

         (*volfactor)++;
         if (*volfactor > 4)
            *volfactor = -4;
         ast_verb(3, "Setting spy volume on %s to %d\n", chan->name, *volfactor);

         csth.volfactor = *volfactor;
         csth.spy_audiohook.options.read_volume = csth.volfactor;
         csth.spy_audiohook.options.write_volume = csth.volfactor;
      }
   }

   if (ast_test_flag(flags, OPTION_PRIVATE))
      ast_channel_stop_silence_generator(chan, silgen);
   else
      ast_deactivate_generator(chan);

   ast_channel_lock(chan);
   ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
   ast_channel_unlock(chan);

   if (ast_test_flag(flags, OPTION_WHISPER | OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
      ast_audiohook_lock(&csth.whisper_audiohook);
      ast_audiohook_detach(&csth.whisper_audiohook);
      ast_audiohook_unlock(&csth.whisper_audiohook);
      ast_audiohook_destroy(&csth.whisper_audiohook);
   }

   if (ast_test_flag(flags, OPTION_BARGE | OPTION_DTMF_SWITCH_MODES)) {
      ast_audiohook_lock(&csth.bridge_whisper_audiohook);
      ast_audiohook_detach(&csth.bridge_whisper_audiohook);
      ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
      ast_audiohook_destroy(&csth.bridge_whisper_audiohook);
   }

   ast_audiohook_lock(&csth.spy_audiohook);
   ast_audiohook_detach(&csth.spy_audiohook);
   ast_audiohook_unlock(&csth.spy_audiohook);
   ast_audiohook_destroy(&csth.spy_audiohook);

   if (spyee_bridge_autochan) {
      ast_autochan_destroy(spyee_bridge_autochan);
   }

   ast_verb(2, "Done Spying on channel %s\n", name);
   ast_manager_event(chan, EVENT_FLAG_CALL, "ChanSpyStop", "SpyeeChannel: %s\r\n", name);

   return running;
}
static int chanspy_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 1026 of file app_chanspy.c.

References args, AST_APP_ARG, ast_app_parse_options(), ast_clear_flag, ast_config_AST_MONITOR_DIR, AST_DECLARE_APP_ARGS, AST_FILE_MODE, AST_FLAGS_ALL, AST_FORMAT_SLINEAR, ast_log(), ast_set_flag, ast_set_write_format(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_verb, common_exec(), spy_dtmf_options::cycle, spy_dtmf_options::exit, LOG_ERROR, LOG_NOTICE, LOG_WARNING, mailbox, OPT_ARG_ARRAY_SIZE, OPT_ARG_CYCLE, OPT_ARG_ENFORCED, OPT_ARG_EXIT, OPT_ARG_GROUP, OPT_ARG_NAME, OPT_ARG_RECORD, OPT_ARG_VOLUME, OPTION_DTMF_CYCLE, OPTION_DTMF_EXIT, OPTION_ENFORCED, OPTION_EXITONHANGUP, OPTION_GROUP, OPTION_NAME, OPTION_PRIVATE, OPTION_RECORD, OPTION_VOLUME, OPTION_WHISPER, parse(), spy_opts, and ast_channel::writeformat.

Referenced by load_module().

{
   char *myenforced = NULL;
   char *mygroup = NULL;
   char *recbase = NULL;
   int fd = 0;
   struct ast_flags flags;
   struct spy_dtmf_options user_options = {
      .cycle = '*',
      .volume = '#',
      .exit = '\0',
   };
   int oldwf = 0;
   int volfactor = 0;
   int res;
   char *mailbox = NULL;
   char *name_context = NULL;
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(spec);
      AST_APP_ARG(options);
   );
   char *opts[OPT_ARG_ARRAY_SIZE];
   char *parse = ast_strdupa(data);

   AST_STANDARD_APP_ARGS(args, parse);

   if (args.spec && !strcmp(args.spec, "all"))
      args.spec = NULL;

   if (args.options) {
      char tmp;
      ast_app_parse_options(spy_opts, &flags, opts, args.options);
      if (ast_test_flag(&flags, OPTION_GROUP))
         mygroup = opts[OPT_ARG_GROUP];

      if (ast_test_flag(&flags, OPTION_RECORD) &&
         !(recbase = opts[OPT_ARG_RECORD]))
         recbase = "chanspy";

      if (ast_test_flag(&flags, OPTION_DTMF_EXIT) && opts[OPT_ARG_EXIT]) {
         tmp = opts[OPT_ARG_EXIT][0];
         if (strchr("0123456789*#", tmp) && tmp != '\0') {
            user_options.exit = tmp;
         } else {
            ast_log(LOG_NOTICE, "Argument for option 'x' must be a valid DTMF digit.");
         }
      }

      if (ast_test_flag(&flags, OPTION_DTMF_CYCLE) && opts[OPT_ARG_CYCLE]) {
         tmp = opts[OPT_ARG_CYCLE][0];
         if (strchr("0123456789*#", tmp) && tmp != '\0') {
            user_options.cycle = tmp;
         } else {
            ast_log(LOG_NOTICE, "Argument for option 'c' must be a valid DTMF digit.");
         }
      }

      if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
         int vol;

         if ((sscanf(opts[OPT_ARG_VOLUME], "%30d", &vol) != 1) || (vol > 4) || (vol < -4))
            ast_log(LOG_NOTICE, "Volume factor must be a number between -4 and 4\n");
         else
            volfactor = vol;
      }

      if (ast_test_flag(&flags, OPTION_PRIVATE))
         ast_set_flag(&flags, OPTION_WHISPER);

      if (ast_test_flag(&flags, OPTION_ENFORCED))
         myenforced = opts[OPT_ARG_ENFORCED];

      if (ast_test_flag(&flags, OPTION_NAME)) {
         if (!ast_strlen_zero(opts[OPT_ARG_NAME])) {
            char *delimiter;
            if ((delimiter = strchr(opts[OPT_ARG_NAME], '@'))) {
               mailbox = opts[OPT_ARG_NAME];
               *delimiter++ = '\0';
               name_context = delimiter;
            } else {
               mailbox = opts[OPT_ARG_NAME];
            }
         }
      }
   } else {
      ast_clear_flag(&flags, AST_FLAGS_ALL);
   }

   oldwf = chan->writeformat;
   if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
      ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
      return -1;
   }

   if (recbase) {
      char filename[PATH_MAX];

      snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
      if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
         ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
         fd = 0;
      }
   }

   res = common_exec(chan, &flags, volfactor, fd, &user_options, mygroup, myenforced, args.spec, NULL, NULL, mailbox, name_context);

   if (fd)
      close(fd);

   if (oldwf && ast_set_write_format(chan, oldwf) < 0)
      ast_log(LOG_ERROR, "Could Not Set Write Format.\n");

   if (ast_test_flag(&flags, OPTION_EXITONHANGUP)) {
      ast_verb(3, "Stopped spying due to the spied-on channel hanging up.\n");
   }

   return res;
}
static int common_exec ( struct ast_channel chan,
struct ast_flags flags,
int  volfactor,
const int  fd,
struct spy_dtmf_options user_options,
const char *  mygroup,
const char *  myenforced,
const char *  spec,
const char *  exten,
const char *  context,
const char *  mailbox,
const char *  name_context 
) [static]

Definition at line 759 of file app_chanspy.c.

References ast_channel::_state, ARRAY_LEN, ast_answer(), ast_app_sayname(), ast_app_separate_args(), ast_autochan_destroy(), ast_autochan_setup(), ast_bridged_channel(), ast_channel_get_by_name_prefix(), ast_channel_iterator_all_new(), ast_channel_iterator_by_exten_new(), ast_channel_iterator_by_name_new(), ast_channel_iterator_destroy(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_setoption(), ast_channel_unlock, ast_channel_unref, ast_check_hangup(), ast_clear_flag, ast_copy_string(), ast_debug, ast_fileexists(), AST_FLAG_SPYING, ast_goto_if_exists(), AST_MAX_CONTEXT, AST_NAME_STRLEN, AST_OPTION_TXGAIN, ast_say_character_str(), ast_say_digits(), ast_set_flag, AST_STATE_UP, ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_waitfordigit(), ast_waitstream(), ast_autochan::chan, channel_spy(), ast_channel::context, exitcontext, ext, ast_channel::language, ast_channel::macrocontext, ast_channel::name, next_channel(), NUM_SPYGROUPS, OPTION_BRIDGED, OPTION_DAHDI_SCAN, OPTION_EXIT, OPTION_EXITONHANGUP, OPTION_NAME, OPTION_NOTECH, OPTION_QUIET, OPTION_STOP, pbx_builtin_getvar_helper(), S_OR, strcasestr(), and strsep().

Referenced by chanspy_exec(), dahdiscan_exec(), and extenspy_exec().

{
   char nameprefix[AST_NAME_STRLEN];
   char peer_name[AST_NAME_STRLEN + 5];
   char exitcontext[AST_MAX_CONTEXT] = "";
   signed char zero_volume = 0;
   int waitms;
   int res;
   char *ptr;
   int num;
   int num_spyed_upon = 1;
   struct ast_channel_iterator *iter = NULL;

   if (ast_test_flag(flags, OPTION_EXIT)) {
      const char *c;
      ast_channel_lock(chan);
      if ((c = pbx_builtin_getvar_helper(chan, "SPY_EXIT_CONTEXT"))) {
         ast_copy_string(exitcontext, c, sizeof(exitcontext));
      } else if (!ast_strlen_zero(chan->macrocontext)) {
         ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext));
      } else {
         ast_copy_string(exitcontext, chan->context, sizeof(exitcontext));
      }
      ast_channel_unlock(chan);
   }

   if (chan->_state != AST_STATE_UP)
      ast_answer(chan);

   ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */

   waitms = 100;

   for (;;) {
      struct ast_autochan *autochan = NULL, *next_autochan = NULL;
      struct ast_channel *prev = NULL;

      if (!ast_test_flag(flags, OPTION_QUIET) && num_spyed_upon) {
         res = ast_streamfile(chan, "beep", chan->language);
         if (!res)
            res = ast_waitstream(chan, "");
         else if (res < 0) {
            ast_clear_flag(chan, AST_FLAG_SPYING);
            break;
         }
         if (!ast_strlen_zero(exitcontext)) {
            char tmp[2];
            tmp[0] = res;
            tmp[1] = '\0';
            if (!ast_goto_if_exists(chan, exitcontext, tmp, 1))
               goto exit;
            else
               ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
         }
      }

      /* Set up the iterator we'll be using during this call */
      if (!ast_strlen_zero(spec)) {
         iter = ast_channel_iterator_by_name_new(spec, strlen(spec));
      } else if (!ast_strlen_zero(exten)) {
         iter = ast_channel_iterator_by_exten_new(exten, context);
      } else {
         iter = ast_channel_iterator_all_new();
      }

      if (!iter) {
         return -1;
      }

      res = ast_waitfordigit(chan, waitms);
      if (res < 0) {
         ast_clear_flag(chan, AST_FLAG_SPYING);
         break;
      }
      if (!ast_strlen_zero(exitcontext)) {
         char tmp[2];
         tmp[0] = res;
         tmp[1] = '\0';
         if (!ast_goto_if_exists(chan, exitcontext, tmp, 1))
            goto exit;
         else
            ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
      }

      /* reset for the next loop around, unless overridden later */
      waitms = 100;
      num_spyed_upon = 0;

      for (autochan = next_channel(iter, autochan, chan);
           autochan;
          prev = autochan->chan, ast_autochan_destroy(autochan),
           autochan = next_autochan ? next_autochan : 
            next_channel(iter, autochan, chan), next_autochan = NULL) {
         int igrp = !mygroup;
         int ienf = !myenforced;
         char *s;

         if (autochan->chan == prev) {
            ast_autochan_destroy(autochan);
            break;
         }

         if (ast_check_hangup(chan)) {
            ast_autochan_destroy(autochan);
            break;
         }

         if (ast_test_flag(flags, OPTION_BRIDGED) && !ast_bridged_channel(autochan->chan)) {
            continue;
         }

         if (ast_check_hangup(autochan->chan) || ast_test_flag(autochan->chan, AST_FLAG_SPYING)) {
            continue;
         }

         if (mygroup) {
            int num_groups = 0;
            int num_mygroups = 0;
            char dup_group[512];
            char dup_mygroup[512];
            char *groups[NUM_SPYGROUPS];
            char *mygroups[NUM_SPYGROUPS];
            const char *group = NULL;
            int x;
            int y;
            ast_copy_string(dup_mygroup, mygroup, sizeof(dup_mygroup));
            num_mygroups = ast_app_separate_args(dup_mygroup, ':', mygroups,
               ARRAY_LEN(mygroups));

            /* Before dahdi scan was part of chanspy, it would use the "GROUP" variable 
             * rather than "SPYGROUP", this check is done to preserve expected behavior */
            if (ast_test_flag(flags, OPTION_DAHDI_SCAN)) {
               group = pbx_builtin_getvar_helper(autochan->chan, "GROUP");
            } else {
               group = pbx_builtin_getvar_helper(autochan->chan, "SPYGROUP");
            }

            if (!ast_strlen_zero(group)) {
               ast_copy_string(dup_group, group, sizeof(dup_group));
               num_groups = ast_app_separate_args(dup_group, ':', groups,
                  ARRAY_LEN(groups));
            }

            for (y = 0; y < num_mygroups; y++) {
               for (x = 0; x < num_groups; x++) {
                  if (!strcmp(mygroups[y], groups[x])) {
                     igrp = 1;
                     break;
                  }
               }
            }
         }

         if (!igrp) {
            continue;
         }
         if (myenforced) {
            char ext[AST_CHANNEL_NAME + 3];
            char buffer[512];
            char *end;

            snprintf(buffer, sizeof(buffer) - 1, ":%s:", myenforced);

            ast_copy_string(ext + 1, autochan->chan->name, sizeof(ext) - 1);
            if ((end = strchr(ext, '-'))) {
               *end++ = ':';
               *end = '\0';
            }

            ext[0] = ':';

            if (strcasestr(buffer, ext)) {
               ienf = 1;
            }
         }

         if (!ienf) {
            continue;
         }

         strcpy(peer_name, "spy-");
         strncat(peer_name, autochan->chan->name, AST_NAME_STRLEN - 4 - 1);
         ptr = strchr(peer_name, '/');
         *ptr++ = '\0';
         ptr = strsep(&ptr, "-");

         for (s = peer_name; s < ptr; s++)
            *s = tolower(*s);

         if (!ast_test_flag(flags, OPTION_QUIET)) {
            if (ast_test_flag(flags, OPTION_NAME)) {
               const char *local_context = S_OR(name_context, "default");
               const char *local_mailbox = S_OR(mailbox, ptr);
               res = ast_app_sayname(chan, local_mailbox, local_context);
            }
            if (!ast_test_flag(flags, OPTION_NAME) || res < 0) {
               if (!ast_test_flag(flags, OPTION_NOTECH)) {
                  if (ast_fileexists(peer_name, NULL, NULL) > 0) {
                     res = ast_streamfile(chan, peer_name, chan->language);
                     if (!res) {
                        res = ast_waitstream(chan, "");
                     }
                     if (res) {
                        ast_autochan_destroy(autochan);
                        break;
                     }
                  } else {
                     res = ast_say_character_str(chan, peer_name, "", chan->language);
                  }
               }
               if ((num = atoi(ptr)))
                  ast_say_digits(chan, atoi(ptr), "", chan->language);
            }
         }

         res = channel_spy(chan, autochan, &volfactor, fd, user_options, flags, exitcontext);
         num_spyed_upon++;

         if (res == -1) {
            ast_autochan_destroy(autochan);
            goto exit;
         } else if (res == -2) {
            res = 0;
            ast_autochan_destroy(autochan);
            goto exit;
         } else if (res > 1 && spec) {
            struct ast_channel *next;

            snprintf(nameprefix, AST_NAME_STRLEN, "%s/%d", spec, res);

            if ((next = ast_channel_get_by_name_prefix(nameprefix, strlen(nameprefix)))) {
               next_autochan = ast_autochan_setup(next);
               next = ast_channel_unref(next);
            } else {
               /* stay on this channel, if it is still valid */
               if (!ast_check_hangup(autochan->chan)) {
                  next_autochan = ast_autochan_setup(autochan->chan);
               } else {
                  /* the channel is gone */
                  next_autochan = NULL;
               }
            }
         } else if (res == 0 && ast_test_flag(flags, OPTION_EXITONHANGUP)) {
            goto exit;
         }
      }

      iter = ast_channel_iterator_destroy(iter);

      if (res == -1 || ast_check_hangup(chan))
         break;
      if (ast_test_flag(flags, OPTION_STOP) && !next_autochan) {
         break;
      }
   }
exit:

   ast_clear_flag(chan, AST_FLAG_SPYING);

   ast_channel_setoption(chan, AST_OPTION_TXGAIN, &zero_volume, sizeof(zero_volume), 0);

   return res;
}
static int dahdiscan_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 1265 of file app_chanspy.c.

References ast_clear_flag, AST_FLAGS_ALL, AST_FORMAT_SLINEAR, ast_log(), ast_set_flag, ast_set_write_format(), ast_strdupa, ast_strlen_zero(), common_exec(), spy_dtmf_options::cycle, LOG_ERROR, OPTION_DAHDI_SCAN, OPTION_DTMF_CYCLE, OPTION_DTMF_EXIT, and ast_channel::writeformat.

Referenced by load_module().

{
   const char *spec = "DAHDI";
   struct ast_flags flags;
   struct spy_dtmf_options user_options = {
      .cycle = '#',
      .volume = '\0',
      .exit = '*',
   };
   int oldwf = 0;
   int res;
   char *mygroup = NULL;

   ast_clear_flag(&flags, AST_FLAGS_ALL);

   if (!ast_strlen_zero(data)) {
      mygroup = ast_strdupa(data);
   }
   ast_set_flag(&flags, OPTION_DTMF_EXIT);
   ast_set_flag(&flags, OPTION_DTMF_CYCLE);
   ast_set_flag(&flags, OPTION_DAHDI_SCAN);

   oldwf = chan->writeformat;
   if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
      ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
      return -1;
   }

   res = common_exec(chan, &flags, 0, 0, &user_options, mygroup, NULL, spec, NULL, NULL, NULL, NULL);

   if (oldwf && ast_set_write_format(chan, oldwf) < 0)
      ast_log(LOG_ERROR, "Could Not Set Write Format.\n");

   return res;
}
static int extenspy_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 1145 of file app_chanspy.c.

References args, AST_APP_ARG, ast_app_parse_options(), ast_clear_flag, ast_config_AST_MONITOR_DIR, AST_DECLARE_APP_ARGS, AST_FILE_MODE, AST_FLAGS_ALL, AST_FORMAT_SLINEAR, ast_log(), ast_set_flag, ast_set_write_format(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, common_exec(), context, ast_channel::context, spy_dtmf_options::cycle, spy_dtmf_options::exit, exten, LOG_ERROR, LOG_NOTICE, LOG_WARNING, mailbox, OPT_ARG_ARRAY_SIZE, OPT_ARG_CYCLE, OPT_ARG_EXIT, OPT_ARG_GROUP, OPT_ARG_NAME, OPT_ARG_RECORD, OPT_ARG_VOLUME, OPTION_DTMF_CYCLE, OPTION_DTMF_EXIT, OPTION_GROUP, OPTION_NAME, OPTION_PRIVATE, OPTION_RECORD, OPTION_VOLUME, OPTION_WHISPER, parse(), spy_opts, and ast_channel::writeformat.

Referenced by load_module().

{
   char *ptr, *exten = NULL;
   char *mygroup = NULL;
   char *recbase = NULL;
   int fd = 0;
   struct ast_flags flags;
   struct spy_dtmf_options user_options = {
      .cycle = '*',
      .volume = '#',
      .exit = '\0',
   };
   int oldwf = 0;
   int volfactor = 0;
   int res;
   char *mailbox = NULL;
   char *name_context = NULL;
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(context);
      AST_APP_ARG(options);
   );
   char *parse = ast_strdupa(data);

   AST_STANDARD_APP_ARGS(args, parse);
   if (!ast_strlen_zero(args.context) && (ptr = strchr(args.context, '@'))) {
      exten = args.context;
      *ptr++ = '\0';
      args.context = ptr;
   }

   if (ast_strlen_zero(args.context))
      args.context = ast_strdupa(chan->context);

   if (args.options) {
      char *opts[OPT_ARG_ARRAY_SIZE];
      char tmp;

      ast_app_parse_options(spy_opts, &flags, opts, args.options);
      if (ast_test_flag(&flags, OPTION_GROUP))
         mygroup = opts[OPT_ARG_GROUP];

      if (ast_test_flag(&flags, OPTION_RECORD) &&
         !(recbase = opts[OPT_ARG_RECORD]))
         recbase = "chanspy";

      if (ast_test_flag(&flags, OPTION_DTMF_EXIT) && opts[OPT_ARG_EXIT]) {
         tmp = opts[OPT_ARG_EXIT][0];
         if (strchr("0123456789*#", tmp) && tmp != '\0') {
            user_options.exit = tmp;
         } else {
            ast_log(LOG_NOTICE, "Argument for option 'x' must be a valid DTMF digit.");
         }
      }

      if (ast_test_flag(&flags, OPTION_DTMF_CYCLE) && opts[OPT_ARG_CYCLE]) {
         tmp = opts[OPT_ARG_CYCLE][0];
         if (strchr("0123456789*#", tmp) && tmp != '\0') {
            user_options.cycle = tmp;
         } else {
            ast_log(LOG_NOTICE, "Argument for option 'c' must be a valid DTMF digit.");
         }
      }

      if (ast_test_flag(&flags, OPTION_VOLUME) && opts[OPT_ARG_VOLUME]) {
         int vol;

         if ((sscanf(opts[OPT_ARG_VOLUME], "%30d", &vol) != 1) || (vol > 4) || (vol < -4))
            ast_log(LOG_NOTICE, "Volume factor must be a number between -4 and 4\n");
         else
            volfactor = vol;
      }

      if (ast_test_flag(&flags, OPTION_PRIVATE))
         ast_set_flag(&flags, OPTION_WHISPER);

      if (ast_test_flag(&flags, OPTION_NAME)) {
         if (!ast_strlen_zero(opts[OPT_ARG_NAME])) {
            char *delimiter;
            if ((delimiter = strchr(opts[OPT_ARG_NAME], '@'))) {
               mailbox = opts[OPT_ARG_NAME];
               *delimiter++ = '\0';
               name_context = delimiter;
            } else {
               mailbox = opts[OPT_ARG_NAME];
            }
         }
      }

   } else {
      ast_clear_flag(&flags, AST_FLAGS_ALL);
   }

   oldwf = chan->writeformat;
   if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
      ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
      return -1;
   }

   if (recbase) {
      char filename[PATH_MAX];

      snprintf(filename, sizeof(filename), "%s/%s.%d.raw", ast_config_AST_MONITOR_DIR, recbase, (int) time(NULL));
      if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, AST_FILE_MODE)) <= 0) {
         ast_log(LOG_WARNING, "Cannot open '%s' for recording\n", filename);
         fd = 0;
      }
   }


   res = common_exec(chan, &flags, volfactor, fd, &user_options, mygroup, NULL, NULL, exten, args.context, mailbox, name_context);

   if (fd)
      close(fd);

   if (oldwf && ast_set_write_format(chan, oldwf) < 0)
      ast_log(LOG_ERROR, "Could Not Set Write Format.\n");

   return res;
}
static int load_module ( void  ) [static]
static struct ast_autochan* next_channel ( struct ast_channel_iterator iter,
struct ast_autochan autochan,
struct ast_channel chan 
) [static, read]

Definition at line 731 of file app_chanspy.c.

References ast_autochan_setup(), ast_channel_iterator_next(), ast_channel_unref, and ast_channel::name.

Referenced by common_exec().

{
   struct ast_channel *next;
   struct ast_autochan *autochan_store;
   const size_t pseudo_len = strlen("DAHDI/pseudo");

   if (!iter) {
      return NULL;
   }

redo:
   if (!(next = ast_channel_iterator_next(iter))) {
      return NULL;
   }

   if (!strncmp(next->name, "DAHDI/pseudo", pseudo_len)) {
      goto redo;
   } else if (next == chan) {
      goto redo;
   }

   autochan_store = ast_autochan_setup(next);
   ast_channel_unref(next);

   return autochan_store;
}
static void* spy_alloc ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 420 of file app_chanspy.c.

{
   /* just store the data pointer in the channel structure */
   return data;
}
static int spy_generate ( struct ast_channel chan,
void *  data,
int  len,
int  samples 
) [static]

Definition at line 431 of file app_chanspy.c.

References AST_AUDIOHOOK_DIRECTION_BOTH, AST_AUDIOHOOK_DIRECTION_READ, ast_audiohook_lock, ast_audiohook_read_frame(), AST_AUDIOHOOK_STATUS_RUNNING, ast_audiohook_unlock, AST_FORMAT_SLINEAR, ast_frfree, AST_LIST_NEXT, ast_log(), ast_test_flag, ast_write(), ast_frame::data, ast_frame::datalen, errno, f, chanspy_translation_helper::fd, chanspy_translation_helper::flags, LOG_WARNING, OPTION_READONLY, ast_frame::ptr, chanspy_translation_helper::spy_audiohook, and ast_audiohook::status.

{
   struct chanspy_translation_helper *csth = data;
   struct ast_frame *f, *cur;

   ast_audiohook_lock(&csth->spy_audiohook);
   if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
      /* Channel is already gone more than likely */
      ast_audiohook_unlock(&csth->spy_audiohook);
      return -1;
   }

   if (ast_test_flag(&csth->flags, OPTION_READONLY)) {
      /* Option 'o' was set, so don't mix channel audio */
      f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_READ, AST_FORMAT_SLINEAR);
   } else {
      f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
   }

   ast_audiohook_unlock(&csth->spy_audiohook);

   if (!f)
      return 0;

   for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
      if (ast_write(chan, cur)) {
         ast_frfree(f);
         return -1;
      }

      if (csth->fd) {
         if (write(csth->fd, cur->data.ptr, cur->datalen) < 0) {
            ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
         }
      }
   }

   ast_frfree(f);

   return 0;
}
static void spy_release ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 426 of file app_chanspy.c.

{
   /* nothing to do */
}
static int start_spying ( struct ast_autochan autochan,
const char *  spychan_name,
struct ast_audiohook audiohook 
) [static]
static int unload_module ( void  ) [static]

Definition at line 1301 of file app_chanspy.c.

References ast_unregister_application().


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Listen to the audio of an active channel" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 1323 of file app_chanspy.c.

const char app_chan[] = "ChanSpy" [static]

Definition at line 344 of file app_chanspy.c.

const char app_dahdiscan[] = "DAHDIScan" [static]

Definition at line 348 of file app_chanspy.c.

const char app_ext[] = "ExtenSpy" [static]

Definition at line 346 of file app_chanspy.c.

Definition at line 1323 of file app_chanspy.c.

struct ast_app_option spy_opts[128] = { [ 'b' ] = { .flag = OPTION_BRIDGED }, [ 'B' ] = { .flag = OPTION_BARGE }, [ 'c' ] = { .flag = OPTION_DTMF_CYCLE , .arg_index = OPT_ARG_CYCLE + 1 }, [ 'd' ] = { .flag = OPTION_DTMF_SWITCH_MODES }, [ 'e' ] = { .flag = OPTION_ENFORCED , .arg_index = OPT_ARG_ENFORCED + 1 }, [ 'E' ] = { .flag = OPTION_EXITONHANGUP }, [ 'g' ] = { .flag = OPTION_GROUP , .arg_index = OPT_ARG_GROUP + 1 }, [ 'n' ] = { .flag = OPTION_NAME , .arg_index = OPT_ARG_NAME + 1 }, [ 'o' ] = { .flag = OPTION_READONLY }, [ 'q' ] = { .flag = OPTION_QUIET }, [ 'r' ] = { .flag = OPTION_RECORD , .arg_index = OPT_ARG_RECORD + 1 }, [ 's' ] = { .flag = OPTION_NOTECH }, [ 'S' ] = { .flag = OPTION_STOP }, [ 'v' ] = { .flag = OPTION_VOLUME , .arg_index = OPT_ARG_VOLUME + 1 }, [ 'w' ] = { .flag = OPTION_WHISPER }, [ 'W' ] = { .flag = OPTION_PRIVATE }, [ 'x' ] = { .flag = OPTION_DTMF_EXIT , .arg_index = OPT_ARG_EXIT + 1 }, [ 'X' ] = { .flag = OPTION_EXIT },} [static]

Definition at line 402 of file app_chanspy.c.

Referenced by chanspy_exec(), and extenspy_exec().

struct ast_generator spygen [static]
Initial value:
 {
   .alloc = spy_alloc,
   .release = spy_release,
   .generate = spy_generate,
}

Definition at line 473 of file app_chanspy.c.