app_flash.c File Reference

App to flash a DAHDI trunk. More...

#include "asterisk.h"
#include <dahdi/user.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/image.h"

Include dependency graph for app_flash.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int dahdi_wait_event (int fd)
static int flash_exec (struct ast_channel *chan, const char *data)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static char * app = "Flash"
static struct ast_module_infoast_module_info = &__mod_info


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 120 of file app_flash.c.

static void __unreg_module ( void   )  [static]

Definition at line 120 of file app_flash.c.

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

Definition at line 66 of file app_flash.c.

Referenced by analog_ss_thread(), flash_exec(), and my_wait_event().

00067 {
00068    /* Avoid the silly dahdi_waitevent which ignores a bunch of events */
00069    int i,j=0;
00070    i = DAHDI_IOMUX_SIGEVENT;
00071    if (ioctl(fd, DAHDI_IOMUX, &i) == -1) return -1;
00072    if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) return -1;
00073    return j;
00074 }

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

Definition at line 76 of file app_flash.c.

References ast_channel_fd(), ast_channel_name(), ast_channel_tech(), ast_log, ast_safe_sleep(), ast_verb, dahdi_wait_event(), errno, LOG_WARNING, and type.

Referenced by load_module().

00077 {
00078    int res = -1;
00079    int x;
00080    struct dahdi_params dahdip;
00081 
00082    if (strcasecmp(ast_channel_tech(chan)->type, "DAHDI")) {
00083       ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", ast_channel_name(chan));
00084       return -1;
00085    }
00086    
00087    memset(&dahdip, 0, sizeof(dahdip));
00088    res = ioctl(ast_channel_fd(chan, 0), DAHDI_GET_PARAMS, &dahdip);
00089    if (!res) {
00090       if (dahdip.sigtype & __DAHDI_SIG_FXS) {
00091          x = DAHDI_FLASH;
00092          res = ioctl(ast_channel_fd(chan, 0), DAHDI_HOOK, &x);
00093          if (!res || (errno == EINPROGRESS)) {
00094             if (res) {
00095                /* Wait for the event to finish */
00096                dahdi_wait_event(ast_channel_fd(chan, 0));
00097             }
00098             res = ast_safe_sleep(chan, 1000);
00099             ast_verb(3, "Flashed channel %s\n", ast_channel_name(chan));
00100          } else
00101             ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", ast_channel_name(chan), strerror(errno));
00102       } else
00103          ast_log(LOG_WARNING, "%s is not an FXO Channel\n", ast_channel_name(chan));
00104    } else
00105       ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", ast_channel_name(chan), strerror(errno));
00106 
00107    return res;
00108 }

static int load_module ( void   )  [static]

Definition at line 115 of file app_flash.c.

References ast_register_application_xml, and flash_exec().

00116 {
00117    return ast_register_application_xml(app, flash_exec);
00118 }

static int unload_module ( void   )  [static]

Definition at line 110 of file app_flash.c.

References ast_unregister_application().

00111 {
00112    return ast_unregister_application(app);
00113 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 120 of file app_flash.c.

char* app = "Flash" [static]

Definition at line 64 of file app_flash.c.

Definition at line 120 of file app_flash.c.


Generated on Thu Apr 16 06:28:28 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6