#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <zaptel/zaptel.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/image.h"
#include "asterisk/options.h"
Go to the source code of this file.
Functions | |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Flash channel application") | |
static int | flash_exec (struct ast_channel *chan, void *data) |
static int | load_module (void) |
static int | unload_module (void) |
static int | zt_wait_event (int fd) |
Variables | |
static char * | app = "Flash" |
static char * | descrip |
static char * | synopsis = "Flashes a Zap Trunk" |
Definition in file app_flash.c.
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"Flash channel application" | ||||
) |
static int flash_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 73 of file app_flash.c.
References ast_log(), ast_module_user_add, ast_module_user_remove, ast_safe_sleep(), ast_verbose(), ast_channel::fds, LOG_WARNING, option_verbose, ast_channel::tech, ast_channel_tech::type, VERBOSE_PREFIX_3, and zt_wait_event().
Referenced by load_module().
00074 { 00075 int res = -1; 00076 int x; 00077 struct ast_module_user *u; 00078 struct zt_params ztp; 00079 u = ast_module_user_add(chan); 00080 if (!strcasecmp(chan->tech->type, "Zap")) { 00081 memset(&ztp, 0, sizeof(ztp)); 00082 res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp); 00083 if (!res) { 00084 if (ztp.sigtype & __ZT_SIG_FXS) { 00085 x = ZT_FLASH; 00086 res = ioctl(chan->fds[0], ZT_HOOK, &x); 00087 if (!res || (errno == EINPROGRESS)) { 00088 if (res) { 00089 /* Wait for the event to finish */ 00090 zt_wait_event(chan->fds[0]); 00091 } 00092 res = ast_safe_sleep(chan, 1000); 00093 if (option_verbose > 2) 00094 ast_verbose(VERBOSE_PREFIX_3 "Flashed channel %s\n", chan->name); 00095 } else 00096 ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno)); 00097 } else 00098 ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name); 00099 } else 00100 ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno)); 00101 } else 00102 ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name); 00103 ast_module_user_remove(u); 00104 return res; 00105 }
static int load_module | ( | void | ) | [static] |
Definition at line 118 of file app_flash.c.
References ast_register_application(), and flash_exec().
00119 { 00120 return ast_register_application(app, flash_exec, synopsis, descrip); 00121 }
static int unload_module | ( | void | ) | [static] |
Definition at line 107 of file app_flash.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00108 { 00109 int res; 00110 00111 res = ast_unregister_application(app); 00112 00113 ast_module_user_hangup_all(); 00114 00115 return res; 00116 }
static int zt_wait_event | ( | int | fd | ) | [inline, static] |
Definition at line 63 of file app_flash.c.
00064 { 00065 /* Avoid the silly zt_waitevent which ignores a bunch of events */ 00066 int i,j=0; 00067 i = ZT_IOMUX_SIGEVENT; 00068 if (ioctl(fd, ZT_IOMUX, &i) == -1) return -1; 00069 if (ioctl(fd, ZT_GETEVENT, &j) == -1) return -1; 00070 return j; 00071 }
char* app = "Flash" [static] |
Definition at line 53 of file app_flash.c.
char* descrip [static] |
Initial value:
" Flash(): Sends a flash on a zap trunk. This is only a hack for\n" "people who want to perform transfers and such via AGI and is generally\n" "quite useless oths application will only work on Zap trunks.\n"
Definition at line 57 of file app_flash.c.
char* synopsis = "Flashes a Zap Trunk" [static] |
Definition at line 55 of file app_flash.c.