DAHDI timing interface. More...
#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: 199744 $") | |
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 __MODULE_INFO_SECTION | __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "DAHDI Timing Interface" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .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 |
DAHDI timing interface.
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" |
Definition at line 140 of file res_timing_dahdi.c.
Referenced by dahdi_test_timer().
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: 199744 $" | |||
) |
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().
{ int fd; int x = 160; fd = open("/dev/dahdi/timer", O_RDWR); if (fd < 0) { return -1; } if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) { 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); close(fd); return -1; } if ((x = ast_wait_for_input(fd, 300)) < 0) { 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); close(fd); return -1; } if (!x) { const char dahdi_timer_error[] = { "Asterisk has detected a problem with your DAHDI configuration and will shutdown for your protection. You have options:" "\n\t1. You only have to compile DAHDI support into Asterisk if you need it. One option is to recompile without DAHDI support." "\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." "\n\t3. If you need DAHDI services, you must correctly configure DAHDI." }; ast_log(LOG_ERROR, "%s\n" SEE_TIMING, dahdi_timer_error); usleep(100); close(fd); return -1; } close(fd); return 0; }
static void dahdi_timer_ack | ( | int | handle, |
unsigned int | quantity | ||
) | [static] |
Definition at line 96 of file res_timing_dahdi.c.
{ ioctl(handle, DAHDI_TIMERACK, &quantity); }
static void dahdi_timer_close | ( | int | handle | ) | [static] |
Definition at line 74 of file res_timing_dahdi.c.
{ close(handle); }
static int dahdi_timer_disable_continuous | ( | int | handle | ) | [static] |
Definition at line 108 of file res_timing_dahdi.c.
{ int flags = -1; return ioctl(handle, DAHDI_TIMERPONG, &flags) ? -1 : 0; }
static int dahdi_timer_enable_continuous | ( | int | handle | ) | [static] |
Definition at line 101 of file res_timing_dahdi.c.
{ int flags = 1; return ioctl(handle, DAHDI_TIMERPING, &flags) ? -1 : 0; }
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.
{ int res; int event; res = ioctl(handle, DAHDI_GETEVENT, &event); if (res) { event = DAHDI_EVENT_TIMER_EXPIRED; } switch (event) { case DAHDI_EVENT_TIMER_PING: return AST_TIMING_EVENT_CONTINUOUS; case DAHDI_EVENT_TIMER_EXPIRED: default: return AST_TIMING_EVENT_EXPIRED; } }
static unsigned int dahdi_timer_get_max_rate | ( | int | handle | ) | [static] |
Definition at line 135 of file res_timing_dahdi.c.
{
return 1000;
}
static int dahdi_timer_open | ( | void | ) | [static] |
Definition at line 69 of file res_timing_dahdi.c.
{ return open("/dev/dahdi/timer", O_RDWR); }
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.
{ int samples; /* DAHDI timers are configured using a number of samples, * based on an 8 kHz sample rate. */ samples = (unsigned int) roundf((8000.0 / ((float) rate))); if (ioctl(handle, DAHDI_TIMERCONFIG, &samples)) { ast_log(LOG_ERROR, "Failed to configure DAHDI timing fd for %u sample timer ticks\n", samples); return -1; } return 0; }
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(), and timing_funcs_handle.
{ if (dahdi_test_timer()) { return AST_MODULE_LOAD_DECLINE; } return (timing_funcs_handle = ast_register_timing_interface(&dahdi_timing)) ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE; }
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.
{ if (timing_funcs_handle) { return ast_unregister_timing_interface(timing_funcs_handle); } return 0; }
struct ast_module_info __MODULE_INFO_SECTION __mod_info = { __MODULE_INFO_GLOBALS .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "DAHDI Timing Interface" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .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] |
Definition at line 56 of file res_timing_dahdi.c.
void* timing_funcs_handle [static] |
Definition at line 45 of file res_timing_dahdi.c.
Referenced by load_module(), and unload_module().