59 #define AST_NAME_STRLEN 256
60 #define NUM_SPYGROUPS 128
504 }
else if (digit ==
'5') {
507 }
else if (digit ==
'6') {
518 int running = 0, res, x = 0;
524 const char *spyer_name;
542 ast_verb(2,
"Spying on channel %s\n", name);
544 "SpyerChannel: %s\r\n"
545 "SpyeeChannel: %s\r\n",
548 memset(&csth, 0,
sizeof(csth));
568 ast_log(
LOG_WARNING,
"Unable to attach whisper audiohook to spyee %s. Whisper mode disabled!\n", name);
581 ast_log(
LOG_WARNING,
"Unable to attach barge audiohook on spyee %s. Barge mode disabled!\n", name);
647 if (x ==
sizeof(inp))
660 ast_debug(1,
"Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
665 ast_debug(2,
"Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
667 }
else if (res >=
'0' && res <=
'9') {
675 if (res == user_options->
cycle) {
678 }
else if (res == user_options->
exit) {
681 }
else if (res == user_options->
volume) {
690 ast_verb(3,
"Setting spy volume on %s to %d\n", chan->
name, *volfactor);
726 if (spyee_bridge_autochan) {
730 ast_verb(2,
"Done Spying on channel %s\n", name);
741 const size_t pseudo_len = strlen(
"DAHDI/pseudo");
752 if (!strncmp(next->
name,
"DAHDI/pseudo", pseudo_len)) {
755 }
else if (next == chan) {
763 return autochan_store;
768 const char *mygroup,
const char *myenforced,
const char *spec,
const char *
exten,
769 const char *
context,
const char *
mailbox,
const char *name_context)
773 signed char zero_volume = 0;
776 int num_spyed_upon = 1;
800 struct ast_autochan *autochan = NULL, *next_autochan = NULL;
818 ast_debug(2,
"Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
850 ast_debug(2,
"Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext);
861 autochan = next_autochan ? next_autochan :
862 next_channel(iter, autochan, chan), next_autochan = NULL) {
864 int ienf = !myenforced;
866 if (autochan->
chan == prev) {
886 int num_mygroups = 0;
888 char dup_mygroup[512];
891 const char *
group = NULL;
912 for (y = 0; y < num_mygroups; y++) {
913 for (x = 0; x < num_groups; x++) {
914 if (!strcmp(mygroups[y], groups[x])) {
930 snprintf(buffer,
sizeof(buffer) - 1,
":%s:", myenforced);
933 if ((end = strchr(ext,
'-'))) {
954 strcpy(peer_name,
"spy-");
956 if ((ptr = strchr(peer_name,
'/'))) {
958 for (s = peer_name; s < ptr; s++) {
961 if ((s = strchr(ptr,
'-'))) {
967 const char *local_context =
S_OR(name_context,
"default");
968 const char *local_mailbox =
S_OR(mailbox, ptr);
991 if (ptr && (num = atoi(ptr))) {
997 res =
channel_spy(chan, autochan, &volfactor, fd, user_options, flags, exitcontext);
1004 }
else if (res == -2) {
1009 }
else if (res > 1 && spec) {
1023 next_autochan = NULL;
1052 char *myenforced = NULL;
1053 char *mygroup = NULL;
1054 char *recbase = NULL;
1066 char *name_context = NULL;
1076 if (
args.spec && !strcmp(
args.spec,
"all"))
1087 recbase =
"chanspy";
1091 if (strchr(
"0123456789*#", tmp) && tmp !=
'\0') {
1092 user_options.
exit = tmp;
1100 if (strchr(
"0123456789*#", tmp) && tmp !=
'\0') {
1101 user_options.
cycle = tmp;
1110 if ((sscanf(opts[OPT_ARG_VOLUME],
"%30d", &vol) != 1) || (vol > 4) || (vol < -4))
1125 if ((delimiter = strchr(opts[OPT_ARG_NAME],
'@'))) {
1127 *delimiter++ =
'\0';
1128 name_context = delimiter;
1145 char filename[PATH_MAX];
1148 if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC,
AST_FILE_MODE)) <= 0) {
1154 res =
common_exec(chan, &flags, volfactor, fd, &user_options, mygroup, myenforced,
args.spec, NULL, NULL, mailbox, name_context);
1163 ast_verb(3,
"Stopped spying due to the spied-on channel hanging up.\n");
1171 char *ptr, *
exten = NULL;
1172 char *mygroup = NULL;
1173 char *recbase = NULL;
1185 char *name_context = NULL;
1194 exten =
args.context;
1212 recbase =
"chanspy";
1216 if (strchr(
"0123456789*#", tmp) && tmp !=
'\0') {
1217 user_options.
exit = tmp;
1225 if (strchr(
"0123456789*#", tmp) && tmp !=
'\0') {
1226 user_options.
cycle = tmp;
1235 if ((sscanf(opts[OPT_ARG_VOLUME],
"%30d", &vol) != 1) || (vol > 4) || (vol < -4))
1247 if ((delimiter = strchr(opts[OPT_ARG_NAME],
'@'))) {
1249 *delimiter++ =
'\0';
1250 name_context = delimiter;
1269 char filename[PATH_MAX];
1272 if ((fd = open(filename, O_CREAT | O_WRONLY | O_TRUNC,
AST_FILE_MODE)) <= 0) {
1279 res =
common_exec(chan, &flags, volfactor, fd, &user_options, mygroup, NULL, NULL, exten,
args.context, mailbox, name_context);
1292 const char *spec =
"DAHDI";
1301 char *mygroup = NULL;
1319 res =
common_exec(chan, &flags, 0, 0, &user_options, mygroup, NULL, spec, NULL, NULL, NULL, NULL);
union ast_frame_subclass subclass
#define ast_channel_lock(chan)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
struct ast_frame * ast_audiohook_read_frame(struct ast_audiohook *audiohook, size_t samples, enum ast_audiohook_direction direction, format_t format)
Reads a frame in from the audiohook structure.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
Asterisk locking-related definitions:
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Asterisk main include file. File version handling, generic pbx functions.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction, struct ast_frame *frame)
Writes a frame into the audiohook structure.
static int dahdiscan_exec(struct ast_channel *chan, const char *data)
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_test_flag(p, flag)
int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params)
Support for translation of data formats. translate.c.
static const char app_chan[]
char context[AST_MAX_CONTEXT]
#define ast_set_flag(p, flag)
int ast_audiohook_init(struct ast_audiohook *audiohook, enum ast_audiohook_type type, const char *source)
Initialize an audiohook structure.
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)
struct ast_audiohook spy_audiohook
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_say_digits(struct ast_channel *chan, int num, const char *ints, const char *lang)
says digits
int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audiohook)
Attach audiohook to channel.
struct ast_channel * chan
#define ast_copy_flags(dest, src, flagz)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
struct ast_audiohook bridge_whisper_audiohook
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
int ast_unregister_application(const char *app)
Unregister an application.
int ast_audiohook_destroy(struct ast_audiohook *audiohook)
Destroys an audiohook structure.
#define ast_verb(level,...)
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
static const char app_ext[]
#define ast_manager_event(chan, category, event, contents,...)
static int extenspy_exec(struct ast_channel *chan, const char *data)
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
#define ast_audiohook_unlock(ah)
Unlock an audiohook.
static char exitcontext[AST_MAX_CONTEXT]
#define ast_debug(level,...)
Log a DEBUG message.
static void * spy_alloc(struct ast_channel *chan, void *data)
General Asterisk PBX channel definitions.
Asterisk file paths, configured in asterisk.conf.
static int spy_generate(struct ast_channel *chan, void *data, int len, int samples)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
static const char app_dahdiscan[]
static struct ast_app_option spy_opts[128]
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
int ast_app_sayname(struct ast_channel *chan, const char *mailbox, const char *context)
Given a mailbox and context, play that mailbox owner's name to the channel specified.
Core PBX routines and definitions.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_strdupa(s)
duplicate a string in memory from the stack
"smart" channels that update automatically if a channel is masqueraded
int ast_audiohook_detach(struct ast_audiohook *audiohook)
Detach audiohook from channel.
static struct ast_generator spygen
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
enum ast_channel_state _state
struct ast_channel * ast_bridged_channel(struct ast_channel *chan)
Find bridged channel.
static int load_module(void)
struct ast_channel_iterator * ast_channel_iterator_by_exten_new(const char *exten, const char *context)
Create a new channel iterator based on extension.
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority)
#define ast_channel_unlock(chan)
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
void *(* alloc)(struct ast_channel *chan, void *params)
static int unload_module(void)
static void parse(struct mgcp_request *req)
const char * ast_config_AST_MONITOR_DIR
char macrocontext[AST_MAX_CONTEXT]
int ast_say_character_str(struct ast_channel *chan, const char *num, const char *ints, const char *lang)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Structure used to handle boolean flags.
struct ast_channel_iterator * ast_channel_iterator_by_name_new(const char *name, size_t name_len)
Create a new channel iterator based on name.
#define ast_clear_flag(p, flag)
void ast_autochan_destroy(struct ast_autochan *autochan)
destroy an ast_autochan structure
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
int ast_waitfordigit(struct ast_channel *c, int ms)
Waits for a digit.
static void spy_release(struct ast_channel *chan, void *data)
struct ast_autochan * ast_autochan_setup(struct ast_channel *chan)
set up a new ast_autochan structure
void ast_deactivate_generator(struct ast_channel *chan)
struct ast_audiohook_options options
static void change_spy_mode(const char digit, struct ast_flags *flags)
static int start_spying(struct ast_autochan *autochan, const char *spychan_name, struct ast_audiohook *audiohook)
#define AST_FORMAT_SLINEAR
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Data structure associated with a single frame of data.
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
Options provided by main asterisk program.
unsigned int ast_app_separate_args(char *buf, char delim, char **array, int arraylen)
enum ast_audiohook_status status
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)
#define AST_APP_ARG(name)
Define an application argument.
enum ast_frame_type frametype
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static char context[AST_MAX_CONTEXT]
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
Say numbers and dates (maybe words one day too)
static struct ast_autochan * next_channel(struct ast_channel_iterator *iter, struct ast_autochan *autochan, struct ast_channel *chan)
#define ASTERISK_GPL_KEY
The text the key() function should return.
#define ast_audiohook_lock(ah)
Lock an audiohook.
Asterisk module definitions.
char * strcasestr(const char *, const char *)
union ast_frame::@172 data
static int chanspy_exec(struct ast_channel *chan, const char *data)
const ast_string_field language
struct ast_audiohook whisper_audiohook
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
static char mailbox[AST_MAX_EXTENSION]
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define AST_OPTION_TXGAIN
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.