#include "asterisk.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
#include <dahdi/user.h>
#include "asterisk/module.h"
#include "asterisk/timing.h"
#include "asterisk/utils.h"
Go to the source code of this file.
Defines | |
#define | SEE_TIMING "For more information on Asterisk timing modules, including ways to potentially fix this problem, please see doc/timing.txt\n" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
ASTERISK_FILE_VERSION (__FILE__,"$Revision: 199745 $") | |
static int | dahdi_test_timer (void) |
static void | dahdi_timer_ack (int handle, unsigned int quantity) |
static void | dahdi_timer_close (int handle) |
static int | dahdi_timer_disable_continuous (int handle) |
static int | dahdi_timer_enable_continuous (int handle) |
static enum ast_timer_event | dahdi_timer_get_event (int handle) |
static unsigned int | dahdi_timer_get_max_rate (int handle) |
static int | dahdi_timer_open (void) |
static int | dahdi_timer_set_rate (int handle, unsigned int rate) |
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 = "DAHDI Timing Interface" , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, .load_pri = 10, } |
static struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_timing_interface | dahdi_timing |
static void * | timing_funcs_handle |
Definition in file res_timing_dahdi.c.
#define SEE_TIMING "For more information on Asterisk timing modules, including ways to potentially fix this problem, please see doc/timing.txt\n" |
static void __reg_module | ( | void | ) | [static] |
Definition at line 206 of file res_timing_dahdi.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 206 of file res_timing_dahdi.c.
ASTERISK_FILE_VERSION | ( | __FILE__ | , | |
"$Revision: 199745 $" | ||||
) |
static int dahdi_test_timer | ( | void | ) | [static] |
Definition at line 142 of file res_timing_dahdi.c.
References ast_log(), ast_wait_for_input(), LOG_ERROR, and SEE_TIMING.
Referenced by load_module().
00143 { 00144 int fd; 00145 int x = 160; 00146 00147 fd = open("/dev/dahdi/timer", O_RDWR); 00148 00149 if (fd < 0) { 00150 return -1; 00151 } 00152 00153 if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) { 00154 ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer test failed to set DAHDI_TIMERCONFIG to %d.\n" SEE_TIMING, x); 00155 close(fd); 00156 return -1; 00157 } 00158 00159 if ((x = ast_wait_for_input(fd, 300)) < 0) { 00160 ast_log(LOG_ERROR, "You have DAHDI built and drivers loaded, but the DAHDI timer could not be polled during the DAHDI timer test.\n" SEE_TIMING); 00161 close(fd); 00162 return -1; 00163 } 00164 00165 if (!x) { 00166 const char dahdi_timer_error[] = { 00167 "Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection. You have options:" 00168 "\n\t1. You only have to compile DAHDI support into Asterisk if you need it. One option is to recompile without DAHDI support." 00169 "\n\t2. You only have to load DAHDI drivers if you want to take advantage of DAHDI services. One option is to unload DAHDI modules if you don't need them." 00170 "\n\t3. If you need DAHDI services, you must correctly configure DAHDI." 00171 }; 00172 ast_log(LOG_ERROR, "%s\n" SEE_TIMING, dahdi_timer_error); 00173 usleep(100); 00174 close(fd); 00175 return -1; 00176 } 00177 00178 close(fd); 00179 00180 return 0; 00181 }
static void dahdi_timer_ack | ( | int | handle, | |
unsigned int | quantity | |||
) | [static] |
static void dahdi_timer_close | ( | int | handle | ) | [static] |
static int dahdi_timer_disable_continuous | ( | int | handle | ) | [static] |
Definition at line 108 of file res_timing_dahdi.c.
00109 { 00110 int flags = -1; 00111 00112 return ioctl(handle, DAHDI_TIMERPONG, &flags) ? -1 : 0; 00113 }
static int dahdi_timer_enable_continuous | ( | int | handle | ) | [static] |
Definition at line 101 of file res_timing_dahdi.c.
00102 { 00103 int flags = 1; 00104 00105 return ioctl(handle, DAHDI_TIMERPING, &flags) ? -1 : 0; 00106 }
static enum ast_timer_event dahdi_timer_get_event | ( | int | handle | ) | [static] |
Definition at line 115 of file res_timing_dahdi.c.
References AST_TIMING_EVENT_CONTINUOUS, and AST_TIMING_EVENT_EXPIRED.
00116 { 00117 int res; 00118 int event; 00119 00120 res = ioctl(handle, DAHDI_GETEVENT, &event); 00121 00122 if (res) { 00123 event = DAHDI_EVENT_TIMER_EXPIRED; 00124 } 00125 00126 switch (event) { 00127 case DAHDI_EVENT_TIMER_PING: 00128 return AST_TIMING_EVENT_CONTINUOUS; 00129 case DAHDI_EVENT_TIMER_EXPIRED: 00130 default: 00131 return AST_TIMING_EVENT_EXPIRED; 00132 } 00133 }
static unsigned int dahdi_timer_get_max_rate | ( | int | handle | ) | [static] |
static int dahdi_timer_open | ( | void | ) | [static] |
static int dahdi_timer_set_rate | ( | int | handle, | |
unsigned int | rate | |||
) | [static] |
Definition at line 79 of file res_timing_dahdi.c.
References ast_log(), and LOG_ERROR.
00080 { 00081 int samples; 00082 00083 /* DAHDI timers are configured using a number of samples, 00084 * based on an 8 kHz sample rate. */ 00085 samples = (unsigned int) roundf((8000.0 / ((float) rate))); 00086 00087 if (ioctl(handle, DAHDI_TIMERCONFIG, &samples)) { 00088 ast_log(LOG_ERROR, "Failed to configure DAHDI timing fd for %u sample timer ticks\n", 00089 samples); 00090 return -1; 00091 } 00092 00093 return 0; 00094 }
static int load_module | ( | void | ) | [static] |
Definition at line 183 of file res_timing_dahdi.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_timing_interface, dahdi_test_timer(), dahdi_timing, and timing_funcs_handle.
00184 { 00185 if (dahdi_test_timer()) { 00186 return AST_MODULE_LOAD_DECLINE; 00187 } 00188 00189 return (timing_funcs_handle = ast_register_timing_interface(&dahdi_timing)) ? 00190 AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE; 00191 }
static int unload_module | ( | void | ) | [static] |
Definition at line 193 of file res_timing_dahdi.c.
References ast_unregister_timing_interface(), and timing_funcs_handle.
00194 { 00195 if (timing_funcs_handle) { 00196 return ast_unregister_timing_interface(timing_funcs_handle); 00197 } 00198 00199 return 0; 00200 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "DAHDI Timing Interface" , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, .load_pri = 10, } [static] |
Definition at line 206 of file res_timing_dahdi.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 206 of file res_timing_dahdi.c.
struct ast_timing_interface dahdi_timing [static] |
void* timing_funcs_handle [static] |