Thu Apr 28 2011 17:15:27

Asterisk developer's documentation


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, void *data)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info
__MODULE_INFO_SECTION 
__mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Flash channel application" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
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 119 of file app_flash.c.

static void __unreg_module ( void  ) [static]

Definition at line 119 of file app_flash.c.

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

Definition at line 65 of file app_flash.c.

Referenced by flash_exec().

{
   /* Avoid the silly dahdi_waitevent which ignores a bunch of events */
   int i,j=0;
   i = DAHDI_IOMUX_SIGEVENT;
   if (ioctl(fd, DAHDI_IOMUX, &i) == -1) return -1;
   if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) return -1;
   return j;
}
static int flash_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 75 of file app_flash.c.

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

Referenced by load_module().

{
   int res = -1;
   int x;
   struct dahdi_params dahdip;

   if (strcasecmp(chan->tech->type, "DAHDI")) {
      ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", chan->name);
      return -1;
   }
   
   memset(&dahdip, 0, sizeof(dahdip));
   res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip);
   if (!res) {
      if (dahdip.sigtype & __DAHDI_SIG_FXS) {
         x = DAHDI_FLASH;
         res = ioctl(chan->fds[0], DAHDI_HOOK, &x);
         if (!res || (errno == EINPROGRESS)) {
            if (res) {
               /* Wait for the event to finish */
               dahdi_wait_event(chan->fds[0]);
            }
            res = ast_safe_sleep(chan, 1000);
            ast_verb(3, "Flashed channel %s\n", chan->name);
         } else
            ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
      } else
         ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
   } else
      ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));

   return res;
}
static int load_module ( void  ) [static]

Definition at line 114 of file app_flash.c.

References ast_register_application_xml, and flash_exec().

static int unload_module ( void  ) [static]

Definition at line 109 of file app_flash.c.

References ast_unregister_application().


Variable Documentation

struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Flash channel application" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 119 of file app_flash.c.

char* app = "Flash" [static]

Definition at line 63 of file app_flash.c.

Definition at line 119 of file app_flash.c.