Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "asterisk.h"
00033
00034 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 153543 $")
00035
00036 #include <dahdi/user.h>
00037
00038 #include "asterisk/lock.h"
00039 #include "asterisk/file.h"
00040 #include "asterisk/channel.h"
00041 #include "asterisk/pbx.h"
00042 #include "asterisk/module.h"
00043 #include "asterisk/translate.h"
00044 #include "asterisk/image.h"
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 static char *app = "Flash";
00064
00065 static inline int dahdi_wait_event(int fd)
00066 {
00067
00068 int i,j=0;
00069 i = DAHDI_IOMUX_SIGEVENT;
00070 if (ioctl(fd, DAHDI_IOMUX, &i) == -1) return -1;
00071 if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) return -1;
00072 return j;
00073 }
00074
00075 static int flash_exec(struct ast_channel *chan, void *data)
00076 {
00077 int res = -1;
00078 int x;
00079 struct dahdi_params dahdip;
00080
00081 if (strcasecmp(chan->tech->type, "DAHDI")) {
00082 ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", chan->name);
00083 return -1;
00084 }
00085
00086 memset(&dahdip, 0, sizeof(dahdip));
00087 res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip);
00088 if (!res) {
00089 if (dahdip.sigtype & __DAHDI_SIG_FXS) {
00090 x = DAHDI_FLASH;
00091 res = ioctl(chan->fds[0], DAHDI_HOOK, &x);
00092 if (!res || (errno == EINPROGRESS)) {
00093 if (res) {
00094
00095 dahdi_wait_event(chan->fds[0]);
00096 }
00097 res = ast_safe_sleep(chan, 1000);
00098 ast_verb(3, "Flashed channel %s\n", chan->name);
00099 } else
00100 ast_log(LOG_WARNING, "Unable to flash channel %s: %s\n", chan->name, strerror(errno));
00101 } else
00102 ast_log(LOG_WARNING, "%s is not an FXO Channel\n", chan->name);
00103 } else
00104 ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
00105
00106 return res;
00107 }
00108
00109 static int unload_module(void)
00110 {
00111 return ast_unregister_application(app);
00112 }
00113
00114 static int load_module(void)
00115 {
00116 return ast_register_application_xml(app, flash_exec);
00117 }
00118
00119 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Flash channel application");
00120