Asterisk - The Open Source Telephony Project
18.5.0
|
Generic Linux Telephony Interface driver. More...
#include "asterisk.h"
#include <ctype.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <linux/telephony.h>
#include <linux/version.h>
#include <linux/ixjuser.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/callerid.h"
#include "asterisk/causes.h"
#include "asterisk/stringfields.h"
#include "asterisk/musiconhold.h"
#include "asterisk/format_cache.h"
#include "asterisk/format_compatibility.h"
#include "chan_phone.h"
Go to the source code of this file.
Data Structures | |
struct | phone_pvt |
Macros | |
#define | DEFAULT_CALLER_ID "Unknown" |
#define | DEFAULT_GAIN 0x100 |
#define | IXJ_PHONE_RING_START(x) ioctl(p->fd, PHONE_RING_START, &x); |
#define | MODE_DIALTONE 1 |
#define | MODE_FXO 3 |
#define | MODE_FXS 4 |
#define | MODE_IMMEDIATE 2 |
#define | MODE_SIGMA 5 |
#define | PHONE_MAX_BUF 480 |
#define | QNDRV_VER 100 |
Functions | |
static int | __unload_module (void) |
AST_MODULE_INFO_STANDARD_DEPRECATED (ASTERISK_GPL_KEY, "Linux Telephony API Support") | |
static void * | do_monitor (void *data) |
static int | load_module (void) |
static struct phone_pvt * | mkif (const char *iface, int mode, int txgain, int rxgain) |
static int | parse_gain_value (const char *gain_type, const char *value) |
static int | phone_answer (struct ast_channel *ast) |
static int | phone_call (struct ast_channel *ast, const char *dest, int timeout) |
static void | phone_check_exception (struct phone_pvt *i) |
static int | phone_digit_begin (struct ast_channel *ast, char digit) |
static int | phone_digit_end (struct ast_channel *ast, char digit, unsigned int duration) |
static struct ast_frame * | phone_exception (struct ast_channel *ast) |
static int | phone_fixup (struct ast_channel *old, struct ast_channel *new) |
static int | phone_hangup (struct ast_channel *ast) |
static int | phone_indicate (struct ast_channel *chan, int condition, const void *data, size_t datalen) |
static void | phone_mini_packet (struct phone_pvt *i) |
static struct ast_channel * | phone_new (struct phone_pvt *i, int state, char *cntx, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor) |
static struct ast_frame * | phone_read (struct ast_channel *ast) |
static struct ast_channel * | phone_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause) |
static int | phone_send_text (struct ast_channel *ast, const char *text) |
static int | phone_setup (struct ast_channel *ast) |
static int | phone_write (struct ast_channel *ast, struct ast_frame *frame) |
static int | phone_write_buf (struct phone_pvt *p, const char *buf, int len, int frlen, int swap) |
static int | restart_monitor (void) |
static int | unload_module (void) |
Variables | |
static char | cid_name [AST_MAX_EXTENSION] |
static char | cid_num [AST_MAX_EXTENSION] |
static const char | config [] = "phone.conf" |
static char | context [AST_MAX_EXTENSION] = "default" |
static struct ast_channel_tech * | cur_tech |
static int | echocancel = AEC_OFF |
static struct phone_pvt * | iflist = NULL |
static ast_mutex_t | iflock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static char | language [MAX_LANGUAGE] = "" |
static unsigned int | monitor |
static pthread_t | monitor_thread = AST_PTHREADT_NULL |
static ast_mutex_t | monlock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} } |
static struct ast_channel_tech | phone_tech |
static struct ast_channel_tech | phone_tech_fxs |
static struct ast_format_cap * | prefcap |
static int | silencesupression = 0 |
static const char | tdesc [] = "Standard Linux Telephony API Driver" |
Generic Linux Telephony Interface driver.
Definition in file chan_phone.c.
#define DEFAULT_CALLER_ID "Unknown" |
Definition at line 89 of file chan_phone.c.
Referenced by phone_call().
#define DEFAULT_GAIN 0x100 |
Definition at line 91 of file chan_phone.c.
Referenced by load_module(), and parse_gain_value().
#define IXJ_PHONE_RING_START | ( | x | ) | ioctl(p->fd, PHONE_RING_START, &x); |
Definition at line 86 of file chan_phone.c.
Referenced by phone_call().
#define MODE_DIALTONE 1 |
Definition at line 127 of file chan_phone.c.
Referenced by load_module(), and phone_check_exception().
#define MODE_FXO 3 |
Definition at line 129 of file chan_phone.c.
Referenced by load_module(), mkif(), phone_answer(), phone_exception(), and phone_hangup().
#define MODE_FXS 4 |
Definition at line 130 of file chan_phone.c.
Referenced by load_module(), mkif(), phone_call(), phone_check_exception(), phone_new(), phone_read(), phone_request(), phone_setup(), and phone_write().
#define MODE_IMMEDIATE 2 |
Definition at line 128 of file chan_phone.c.
Referenced by load_module(), and phone_check_exception().
#define MODE_SIGMA 5 |
Definition at line 131 of file chan_phone.c.
Referenced by do_monitor(), load_module(), and phone_check_exception().
#define PHONE_MAX_BUF 480 |
Definition at line 90 of file chan_phone.c.
Referenced by phone_read().
#define QNDRV_VER 100 |
Definition at line 76 of file chan_phone.c.
|
static |
Definition at line 1313 of file chan_phone.c.
References ao2_ref, ast_channel_unregister(), ast_free, ast_log, ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, AST_PTHREADT_STOP, ast_softhangup(), AST_SOFTHANGUP_APPUNLOAD, ast_channel_tech::capabilities, phone_pvt::fd, iflist, iflock, LOG_WARNING, monitor, monitor_thread, monlock, phone_pvt::next, NULL, and phone_pvt::owner.
Referenced by load_module(), and unload_module().
AST_MODULE_INFO_STANDARD_DEPRECATED | ( | ASTERISK_GPL_KEY | , |
"Linux Telephony API Support" | |||
) |
Referenced by load_module().
|
static |
Definition at line 1031 of file chan_phone.c.
References ast_debug, ast_log, ast_mutex_lock, ast_mutex_unlock, ast_poll, ast_poll2(), ast_realloc, ast_tv(), ast_tvzero(), DialTone, phone_pvt::dialtone, errno, phone_pvt::fd, iflist, iflock, LOG_ERROR, LOG_WARNING, phone_pvt::mode, MODE_SIGMA, monitor, phone_pvt::next, NULL, phone_pvt::owner, phone_check_exception(), phone_mini_packet(), and tmp().
Referenced by restart_monitor().
|
static |
Definition at line 1378 of file chan_phone.c.
References __unload_module(), ast_callerid_split(), ast_channel_register(), ast_config_destroy(), ast_config_load, ast_copy_string(), ast_format_cap_alloc, ast_format_cap_append, ast_format_cap_append_from_cap(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_remove_by_type(), ast_format_g723, ast_format_g729, ast_format_slin, ast_format_ulaw, ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_UNKNOWN, AST_MODULE_INFO_STANDARD_DEPRECATED(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_mutex_lock, ast_mutex_unlock, ast_true(), ast_variable_browse(), ASTERISK_GPL_KEY, ast_channel_tech::capabilities, phone_pvt::cid_name, phone_pvt::cid_num, config, CONFIG_STATUS_FILEINVALID, phone_pvt::context, DEFAULT_GAIN, echocancel, iflist, iflock, phone_pvt::language, LOG_ERROR, LOG_WARNING, mkif(), phone_pvt::mode, MODE_DIALTONE, MODE_FXO, MODE_FXS, MODE_IMMEDIATE, MODE_SIGMA, ast_variable::name, ast_variable::next, phone_pvt::next, parse_gain_value(), phone_tech_fxs, restart_monitor(), phone_pvt::rxgain, phone_pvt::silencesupression, tmp(), phone_pvt::txgain, and ast_variable::value.
|
static |
Definition at line 1190 of file chan_phone.c.
References ao2_cleanup, ast_calloc, ast_copy_string(), ast_debug, ast_fd_set_flags, ast_free, ast_log, phone_pvt::cid_name, phone_pvt::cid_num, phone_pvt::context, phone_pvt::cpt, phone_pvt::dev, phone_pvt::dialtone, echocancel, errno, phone_pvt::ext, phone_pvt::fd, phone_pvt::language, phone_pvt::lastformat, phone_pvt::lastinput, LOG_WARNING, phone_pvt::ministate, phone_pvt::mode, MODE_FXO, MODE_FXS, phone_pvt::next, NULL, phone_pvt::obuflen, phone_pvt::owner, phone_pvt::rxgain, phone_pvt::silencesupression, tmp(), and phone_pvt::txgain.
Referenced by load_module().
|
static |
Definition at line 1291 of file chan_phone.c.
References ast_log, config, DEFAULT_GAIN, and LOG_ERROR.
Referenced by load_module().
|
static |
Definition at line 471 of file chan_phone.c.
References ast_channel_name(), ast_channel_rings_set(), ast_channel_tech_pvt(), ast_debug, ast_setstate(), AST_STATE_UP, c, errno, phone_pvt::fd, phone_pvt::mode, MODE_FXO, and phone_setup().
|
static |
Definition at line 300 of file chan_phone.c.
References ast_channel_connected(), ast_channel_fd(), ast_channel_name(), ast_channel_tech_pvt(), AST_CONTROL_RINGING, ast_copy_string(), ast_debug, ast_localtime(), ast_log, ast_queue_control(), ast_setstate(), AST_STATE_DOWN, AST_STATE_RESERVED, AST_STATE_RINGING, ast_strlen_zero, ast_tvnow(), DEFAULT_CALLER_ID, digit, IXJ_PHONE_RING_START, LOG_WARNING, phone_pvt::mode, MODE_FXS, name, NULL, phone_digit_end(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, and ast_tm::tm_mon.
|
static |
Definition at line 936 of file chan_phone.c.
References ao2_cleanup, ast_canmatch_extension(), ast_debug, ast_exists_extension(), AST_MAX_EXTENSION, ast_module_ref, ast_module_unref, AST_STATE_RING, ast_verbose(), phone_pvt::cid_num, phone_pvt::context, phone_pvt::cpt, phone_pvt::dialtone, digit, phone_pvt::ext, phone_pvt::fd, phone_pvt::lastformat, phone_pvt::mode, MODE_DIALTONE, MODE_FXS, MODE_IMMEDIATE, MODE_SIGMA, NULL, phone_new(), and ast_module_info::self.
Referenced by do_monitor().
|
static |
Definition at line 250 of file chan_phone.c.
|
static |
Definition at line 256 of file chan_phone.c.
References ao2_cleanup, ast_channel_tech_pvt(), ast_debug, ast_log, phone_pvt::fd, phone_pvt::lastformat, LOG_WARNING, and NULL.
Referenced by phone_call().
|
static |
Definition at line 503 of file chan_phone.c.
References ast_channel_tech_pvt(), AST_CONTROL_ANSWER, ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_NULL, ast_log, ast_setstate(), AST_STATE_RINGING, AST_STATE_UP, ast_tv(), ast_verbose(), ast_frame::data, ast_frame::datalen, ast_frame::delivery, digit, phone_pvt::fd, phone_pvt::fr, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::mallocd, phone_pvt::mode, MODE_FXO, NULL, ast_frame::offset, phone_setup(), ast_frame::ptr, ast_frame::samples, ast_frame::src, and ast_frame::subclass.
|
static |
Definition at line 242 of file chan_phone.c.
References ast_channel_tech_pvt(), and phone_pvt::owner.
|
static |
Definition at line 355 of file chan_phone.c.
References ao2_cleanup, ast_channel_name(), ast_channel_tech_pvt(), ast_channel_tech_pvt_set(), ast_debug, ast_log, ast_module_unref, ast_setstate(), AST_STATE_DOWN, ast_verb, phone_pvt::cpt, phone_pvt::dialtone, errno, phone_pvt::ext, phone_pvt::fd, phone_pvt::lastformat, phone_pvt::lastinput, LOG_WARNING, phone_pvt::ministate, phone_pvt::mode, MODE_FXO, NULL, phone_pvt::obuflen, restart_monitor(), and ast_module_info::self.
|
static |
Definition at line 211 of file chan_phone.c.
References ao2_cleanup, ast_channel_name(), ast_channel_tech_pvt(), AST_CONTROL_FLASH, AST_CONTROL_HOLD, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, ast_debug, ast_log, ast_moh_start(), ast_moh_stop(), phone_pvt::fd, phone_pvt::lastformat, LOG_WARNING, and NULL.
|
static |
Definition at line 924 of file chan_phone.c.
References ast_log, phone_pvt::buf, errno, phone_pvt::fd, and LOG_WARNING.
Referenced by do_monitor().
|
static |
Definition at line 855 of file chan_phone.c.
References ast_party_caller::ani, ao2_cleanup, ao2_ref, ast_channel_alloc, ast_channel_caller(), ast_channel_context_set(), ast_channel_exten_set(), ast_channel_fd(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats_set(), ast_channel_rings_set(), ast_channel_set_fd(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_tech_pvt_set(), ast_channel_tech_set(), ast_channel_unlock, ast_format_cap_alloc, ast_format_cap_append, ast_format_cap_append_from_cap(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_format(), ast_format_cap_remove(), ast_format_slin, ast_hangup(), ast_log, AST_MEDIA_TYPE_UNKNOWN, ast_module_ref, ast_pbx_start(), AST_STATE_DOWN, AST_STATE_RING, ast_strdup, ast_strlen_zero, phone_pvt::cid_name, phone_pvt::cid_num, phone_pvt::context, phone_pvt::cpt, phone_pvt::dev, phone_pvt::ext, phone_pvt::fd, phone_pvt::language, LOG_WARNING, phone_pvt::mode, MODE_FXS, NULL, ast_party_id::number, phone_pvt::owner, ast_module_info::self, ast_party_number::str, tmp(), and ast_party_number::valid.
Referenced by phone_check_exception(), and phone_request().
|
static |
Definition at line 563 of file chan_phone.c.
References ast_channel_flags(), ast_channel_tech_pvt(), ast_clear_flag, AST_FLAG_BLOCKING, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_type(), ast_format_slin, ast_frame_byteswap_le, AST_FRAME_IMAGE, AST_FRAME_NULL, AST_FRAME_VIDEO, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log, AST_MEDIA_TYPE_AUDIO, AST_MEDIA_TYPE_IMAGE, ast_tv(), phone_pvt::buf, CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, ast_frame::delivery, errno, phone_pvt::fd, ast_frame_subclass::format, phone_pvt::fr, ast_frame::frametype, phone_pvt::lastinput, LOG_WARNING, ast_frame::mallocd, phone_pvt::mode, MODE_FXS, NULL, ast_frame::offset, PHONE_MAX_BUF, ast_frame::ptr, ast_frame::samples, ast_frame::src, and ast_frame::subclass.
|
static |
Definition at line 1251 of file chan_phone.c.
References AST_CAUSE_BUSY, ast_format_cap_get_names(), ast_format_cap_iscompatible(), AST_FORMAT_CAP_NAMES_LEN, ast_log, ast_mutex_lock, ast_mutex_unlock, AST_STATE_DOWN, ast_str_alloca, ast_channel_tech::capabilities, phone_pvt::context, ast_channel::data, phone_pvt::dev, iflist, iflock, LOG_ERROR, LOG_NOTICE, phone_pvt::mode, MODE_FXS, name, phone_pvt::next, NULL, phone_pvt::owner, phone_new(), restart_monitor(), and tmp().
|
static |
Definition at line 654 of file chan_phone.c.
References ast_channel_tech_pvt(), and phone_write_buf().
|
static |
Definition at line 404 of file chan_phone.c.
References ao2_replace, ast_channel_rawreadformat(), ast_channel_tech_pvt(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_g723, ast_format_g729, ast_format_get_name(), ast_format_slin, ast_format_ulaw, ast_log, phone_pvt::fd, phone_pvt::lastinput, LOG_WARNING, phone_pvt::mode, and MODE_FXS.
Referenced by phone_answer(), phone_exception(), and phone_write().
|
static |
Definition at line 661 of file chan_phone.c.
References ao2_replace, ast_channel_tech_pvt(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_compatibility_format2bitfield(), ast_format_g723, ast_format_g729, ast_format_get_name(), ast_format_slin, ast_format_ulaw, AST_FRAME_IMAGE, AST_FRAME_VOICE, ast_log, ast_setstate(), AST_STATE_UP, ast_frame::data, ast_frame::datalen, errno, phone_pvt::fd, ast_frame_subclass::format, ast_frame::frametype, phone_pvt::lastformat, phone_pvt::lastinput, LOG_WARNING, phone_pvt::mode, MODE_FXS, phone_pvt::obuflen, phone_setup(), phone_write_buf(), ast_frame::ptr, phone_pvt::silencesupression, and ast_frame::subclass.
|
static |
Definition at line 620 of file chan_phone.c.
References ast_log, ast_swapcopy_samples(), phone_pvt::fd, if(), len(), LOG_WARNING, phone_pvt::obuf, and phone_pvt::obuflen.
Referenced by phone_send_text(), and phone_write().
|
static |
Definition at line 1153 of file chan_phone.c.
References ast_log, ast_mutex_lock, ast_mutex_unlock, ast_pthread_create_background, AST_PTHREADT_NULL, AST_PTHREADT_STOP, do_monitor(), iflock, LOG_ERROR, LOG_WARNING, monitor, monitor_thread, monlock, and NULL.
Referenced by load_module(), phone_hangup(), and phone_request().
|
static |
|
static |
Definition at line 160 of file chan_phone.c.
|
static |
Definition at line 159 of file chan_phone.c.
|
static |
Definition at line 94 of file chan_phone.c.
Referenced by load_module(), and parse_gain_value().
|
static |
Definition at line 97 of file chan_phone.c.
|
static |
Definition at line 209 of file chan_phone.c.
|
static |
Definition at line 102 of file chan_phone.c.
Referenced by load_module(), and mkif().
Referenced by __unload_module(), do_monitor(), load_module(), and phone_request().
|
static |
Definition at line 109 of file chan_phone.c.
Referenced by __unload_module(), do_monitor(), load_module(), phone_request(), and restart_monitor().
|
static |
Definition at line 100 of file chan_phone.c.
|
static |
Definition at line 116 of file chan_phone.c.
Referenced by __unload_module(), ast_cc_agent_set_interfaces_chanvar(), ast_cc_call_init(), ast_cc_extension_monitor_add_dialstring(), ast_handle_cc_control_frame(), ast_monitor_start(), cc_cli_print_monitor_stats(), cc_device_monitor_init(), cc_extension_monitor_init(), cc_generic_is_device_available(), cc_interface_tree_destroy(), cc_interfaces_datastore_init(), do_monitor(), find_sip_monitor_instance_by_suspension_entry(), register_aor_core(), register_contact_transport_remove_cb(), register_contact_transport_shutdown_cb(), registrar_contact_delete(), registration_transport_monitor_setup(), and restart_monitor().
|
static |
Definition at line 120 of file chan_phone.c.
Referenced by __unload_module(), and restart_monitor().
|
static |
Definition at line 113 of file chan_phone.c.
Referenced by __unload_module(), and restart_monitor().
|
static |
Definition at line 175 of file chan_phone.c.
|
static |
Definition at line 191 of file chan_phone.c.
Referenced by load_module().
|
static |
Definition at line 106 of file chan_phone.c.
|
static |
Definition at line 104 of file chan_phone.c.
|
static |
Definition at line 93 of file chan_phone.c.