Wed Jan 8 2020 09:49:53

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"

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static char * app = "Flash"
 
static struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

App to flash a DAHDI trunk.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

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)
inlinestatic

Definition at line 66 of file app_flash.c.

Referenced by flash_exec().

67 {
68  /* Avoid the silly dahdi_waitevent which ignores a bunch of events */
69  int i,j=0;
70  i = DAHDI_IOMUX_SIGEVENT;
71  if (ioctl(fd, DAHDI_IOMUX, &i) == -1) return -1;
72  if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) return -1;
73  return j;
74 }
static int flash_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 76 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().

77 {
78  int res = -1;
79  int x;
80  struct dahdi_params dahdip;
81 
82  if (strcasecmp(chan->tech->type, "DAHDI")) {
83  ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", chan->name);
84  return -1;
85  }
86 
87  memset(&dahdip, 0, sizeof(dahdip));
88  res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip);
89  if (!res) {
90  if (dahdip.sigtype & __DAHDI_SIG_FXS) {
91  x = DAHDI_FLASH;
92  res = ioctl(chan->fds[0], DAHDI_HOOK, &x);
93  if (!res || (errno == EINPROGRESS)) {
94  if (res) {
95  /* Wait for the event to finish */
96  dahdi_wait_event(chan->fds[0]);
97  }
98  res = ast_safe_sleep(chan, 1000);
99  ast_verb(3, "Flashed channel %s\n", chan->name);
100  } else
101  ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
102  } else
103  ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
104  } else
105  ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
106 
107  return res;
108 }
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1916
const char *const type
Definition: channel.h:508
#define LOG_WARNING
Definition: logger.h:144
#define ast_verb(level,...)
Definition: logger.h:243
static int dahdi_wait_event(int fd)
Definition: app_flash.c:66
int fds[AST_MAX_FDS]
Definition: channel.h:829
const ast_string_field name
Definition: channel.h:787
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
int errno
struct ast_channel_tech * tech
Definition: channel.h:743
static int load_module ( void  )
static

Definition at line 115 of file app_flash.c.

References ast_register_application_xml, and flash_exec().

116 {
118 }
static char * app
Definition: app_flash.c:64
static int flash_exec(struct ast_channel *chan, const char *data)
Definition: app_flash.c:76
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int unload_module ( void  )
static

Definition at line 110 of file app_flash.c.

References ast_unregister_application().

111 {
113 }
static char * app
Definition: app_flash.c:64
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
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.