Thu Jul 9 13:40:44 2009

Asterisk developer's documentation


app_flash.c File Reference

App to flash a DAHDI trunk. More...

#include "asterisk.h"
#include <sys/ioctl.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"

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, void *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_DEFAULT , .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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, }
static char * app = "Flash"
static const struct ast_module_infoast_module_info = &__mod_info
static char * descrip
static char * synopsis = "Flashes a DAHDI 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 112 of file app_flash.c.

static void __unreg_module ( void   )  [static]

Definition at line 112 of file app_flash.c.

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

Definition at line 58 of file app_flash.c.

00059 {
00060    /* Avoid the silly dahdi_waitevent which ignores a bunch of events */
00061    int i,j=0;
00062    i = DAHDI_IOMUX_SIGEVENT;
00063    if (ioctl(fd, DAHDI_IOMUX, &i) == -1) return -1;
00064    if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) return -1;
00065    return j;
00066 }

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

Definition at line 68 of file app_flash.c.

References ast_log(), ast_safe_sleep(), ast_verb, chan, dahdi_wait_event(), errno, ast_channel::fds, LOG_WARNING, ast_channel::name, ast_channel::tech, and ast_channel_tech::type.

Referenced by load_module().

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

static int load_module ( void   )  [static]

Definition at line 107 of file app_flash.c.

References ast_register_application, and flash_exec().

00108 {
00109    return ast_register_application(app, flash_exec, synopsis, descrip);
00110 }

static int unload_module ( void   )  [static]

Definition at line 102 of file app_flash.c.

References ast_unregister_application().

00103 {
00104    return ast_unregister_application(app);
00105 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .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 = "068e67f60f50dd9ee86464c05884a49d" , .load = load_module, .unload = unload_module, } [static]

Definition at line 112 of file app_flash.c.

char* app = "Flash" [static]

Definition at line 47 of file app_flash.c.

const struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 112 of file app_flash.c.

char* 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 51 of file app_flash.c.

char* synopsis = "Flashes a DAHDI Trunk" [static]

Definition at line 49 of file app_flash.c.


Generated on Thu Jul 9 13:40:44 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7