Asterisk - The Open Source Telephony Project GIT-master-27fb039
Loading...
Searching...
No Matches
Functions | Variables
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)
 
struct ast_moduleAST_MODULE_SELF_SYM (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 = ASTERISK_GPL_KEY , .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 const 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

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 121 of file app_flash.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 121 of file app_flash.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 121 of file app_flash.c.

◆ dahdi_wait_event()

static int dahdi_wait_event ( int  fd)
inlinestatic

Definition at line 67 of file app_flash.c.

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

Referenced by flash_exec().

◆ flash_exec()

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

Definition at line 77 of file app_flash.c.

78{
79 int res = -1;
80 int x;
81 struct dahdi_params dahdip;
82
83 if (strcasecmp(ast_channel_tech(chan)->type, "DAHDI")) {
84 ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", ast_channel_name(chan));
85 return -1;
86 }
87
88 memset(&dahdip, 0, sizeof(dahdip));
89 res = ioctl(ast_channel_fd(chan, 0), DAHDI_GET_PARAMS, &dahdip);
90 if (!res) {
91 if (dahdip.sigtype & __DAHDI_SIG_FXS) {
92 x = DAHDI_FLASH;
93 res = ioctl(ast_channel_fd(chan, 0), DAHDI_HOOK, &x);
94 if (!res || (errno == EINPROGRESS)) {
95 if (res) {
96 /* Wait for the event to finish */
98 }
99 res = ast_safe_sleep(chan, 1000);
100 ast_verb(3, "Flashed channel %s\n", ast_channel_name(chan));
101 } else
102 ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", ast_channel_name(chan), strerror(errno));
103 } else
104 ast_log(LOG_WARNING, "%s is not an FXO Channel\n", ast_channel_name(chan));
105 } else
106 ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", ast_channel_name(chan), strerror(errno));
107
108 return res;
109}
static int dahdi_wait_event(int fd)
Definition app_flash.c:67
#define ast_log
Definition astobj2.c:42
static const char type[]
const char * ast_channel_name(const struct ast_channel *chan)
int ast_channel_fd(const struct ast_channel *chan, int which)
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition channel.c:1560
#define ast_verb(level,...)
#define LOG_WARNING
int errno
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648

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

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 116 of file app_flash.c.

117{
119}
static char * app
Definition app_flash.c:65
static int flash_exec(struct ast_channel *chan, const char *data)
Definition app_flash.c:77
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition module.h:640

References app, ast_register_application_xml, and flash_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 111 of file app_flash.c.

112{
114}
int ast_unregister_application(const char *app)
Unregister an application.
Definition pbx_app.c:392

References app, and ast_unregister_application().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Flash channel application" , .key = ASTERISK_GPL_KEY , .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 121 of file app_flash.c.

◆ app

char* app = "Flash"
static

Definition at line 65 of file app_flash.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 121 of file app_flash.c.