Sat Aug 6 00:39:34 2011

Asterisk developer's documentation


app_flash.c File Reference

App to flash a DAHDI trunk. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.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"
#include "asterisk/dahdi_compat.h"

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
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 struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Flash channel application" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, }
static char * app = "Flash"
static const struct ast_module_infoast_module_info = &__mod_info
static char * dahdi_descrip
static char * dahdi_synopsis = "Flashes a DAHDI trunk"
static char * zap_descrip
static char * zap_synopsis = "Flashes a Zap trunk"


Detailed Description

App to flash a DAHDI trunk.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_flash.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 136 of file app_flash.c.

static void __unreg_module ( void   )  [static]

Definition at line 136 of file app_flash.c.

static int flash_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 82 of file app_flash.c.

References ast_log(), ast_module_user_add, ast_module_user_remove, ast_safe_sleep(), ast_verbose(), dahdi_chan_name, errno, ast_channel::fds, LOG_WARNING, ast_channel::name, option_verbose, ast_channel::tech, ast_channel_tech::type, VERBOSE_PREFIX_3, and zt_wait_event().

Referenced by load_module().

00083 {
00084    int res = -1;
00085    int x;
00086    struct ast_module_user *u;
00087    struct dahdi_params ztp;
00088    u = ast_module_user_add(chan);
00089    if (!strcasecmp(chan->tech->type, dahdi_chan_name)) {
00090       memset(&ztp, 0, sizeof(ztp));
00091       res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &ztp);
00092       if (!res) {
00093          if (ztp.sigtype & __DAHDI_SIG_FXS) {
00094             x = DAHDI_FLASH;
00095             res = ioctl(chan->fds[0], DAHDI_HOOK, &x);
00096             if (!res || (errno == EINPROGRESS)) {
00097                if (res) {
00098                   /* Wait for the event to finish */
00099                   zt_wait_event(chan->fds[0]);
00100                }
00101                res = ast_safe_sleep(chan, 1000);
00102                if (option_verbose > 2)
00103                   ast_verbose(VERBOSE_PREFIX_3 "Flashed channel %s\n", chan->name);
00104             } else
00105                ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
00106          } else
00107             ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
00108       } else
00109          ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
00110    } else
00111       ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", chan->name);
00112    ast_module_user_remove(u);
00113    return res;
00114 }

static int load_module ( void   )  [static]

Definition at line 127 of file app_flash.c.

References ast_register_application(), CHAN_ZAP_MODE, dahdi_chan_mode, and flash_exec().

00128 {
00129    if (*dahdi_chan_mode == CHAN_ZAP_MODE) {
00130       return ast_register_application(app, flash_exec, zap_synopsis, zap_descrip);
00131    } else {
00132       return ast_register_application(app, flash_exec, dahdi_synopsis, dahdi_descrip);
00133    }
00134 }

static int unload_module ( void   )  [static]

Definition at line 116 of file app_flash.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00117 {
00118    int res;
00119 
00120    res = ast_unregister_application(app);
00121 
00122    ast_module_user_hangup_all();
00123 
00124    return res;
00125 }

static int zt_wait_event ( int  fd  )  [inline, static]

Definition at line 72 of file app_flash.c.

Referenced by flash_exec().

00073 {
00074    /* Avoid the silly zt_waitevent which ignores a bunch of events */
00075    int i,j=0;
00076    i = DAHDI_IOMUX_SIGEVENT;
00077    if (ioctl(fd, DAHDI_IOMUX, &i) == -1) return -1;
00078    if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) return -1;
00079    return j;
00080 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Flash channel application" , .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static]

Definition at line 136 of file app_flash.c.

char* app = "Flash" [static]

Definition at line 54 of file app_flash.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 136 of file app_flash.c.

char* dahdi_descrip [static]

Initial value:

 
"Performs a flash on a DAHDI trunk.  This can be used\n"
"to access features provided on an incoming analogue circuit\n"
"such as conference and call waiting. Use with SendDTMF() to\n"
"perform external transfers\n"

Definition at line 58 of file app_flash.c.

char* dahdi_synopsis = "Flashes a DAHDI trunk" [static]

Definition at line 56 of file app_flash.c.

char* zap_descrip [static]

Initial value:

 
"Performs a flash on a Zap trunk.  This can be used\n"
"to access features provided on an incoming analogue circuit\n"
"such as conference and call waiting. Use with SendDTMF() to\n"
"perform external transfers\n"

Definition at line 66 of file app_flash.c.

char* zap_synopsis = "Flashes a Zap trunk" [static]

Definition at line 64 of file app_flash.c.


Generated on Sat Aug 6 00:39:34 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7