Asterisk - The Open Source Telephony Project
21.4.1
|
SMDI support for Asterisk. More...
#include "asterisk.h"
#include <termios.h>
#include <sys/time.h>
#include <time.h>
#include <ctype.h>
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/smdi.h"
#include "asterisk/config.h"
#include "asterisk/io.h"
#include "asterisk/stringfields.h"
#include "asterisk/linkedlists.h"
#include "asterisk/app.h"
#include "asterisk/mwi.h"
#include "asterisk/pbx.h"
#include "asterisk/channel.h"
Go to the source code of this file.
Data Structures | |
struct | ast_smdi_interface |
struct | mailbox_mapping |
A mapping between an SMDI mailbox ID and an Asterisk mailbox. More... | |
struct | smdi_msg_datastore |
Macros | |
#define | AST_API_MODULE |
#define | DEFAULT_POLLING_INTERVAL 10 |
#define | SMDI_MSG_EXPIRY_TIME 30000 /* 30 seconds */ |
#define | SMDI_RETRIEVE_TIMEOUT_DEFAULT 3000 |
Enumerations | |
enum | { OPT_SEARCH_TERMINAL = (1 << 0), OPT_SEARCH_NUMBER = (1 << 1) } |
enum | smdi_message_type { SMDI_MWI, SMDI_MD } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static struct ast_smdi_interface * | alloc_smdi_interface (void) |
static | AO2_GLOBAL_OBJ_STATIC (smdi_ifaces) |
static void | append_mailbox_mapping (struct ast_variable *var, struct ast_smdi_interface *iface) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
struct ast_smdi_interface *AST_OPTIONAL_API_NAME() | ast_smdi_interface_find (const char *iface_name) |
Find an SMDI interface with the specified name. More... | |
struct ast_smdi_md_message *AST_OPTIONAL_API_NAME() | ast_smdi_md_message_pop (struct ast_smdi_interface *iface) |
Get the next SMDI message from the queue. More... | |
static void | ast_smdi_md_message_push (struct ast_smdi_interface *iface, struct ast_smdi_md_message *md_msg) |
struct ast_smdi_md_message *AST_OPTIONAL_API_NAME() | ast_smdi_md_message_wait (struct ast_smdi_interface *iface, int timeout) |
Get the next SMDI message from the queue. More... | |
struct ast_smdi_mwi_message *AST_OPTIONAL_API_NAME() | ast_smdi_mwi_message_pop (struct ast_smdi_interface *iface) |
Get the next SMDI message from the queue. More... | |
static void | ast_smdi_mwi_message_push (struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *mwi_msg) |
struct ast_smdi_mwi_message *AST_OPTIONAL_API_NAME() | ast_smdi_mwi_message_wait (struct ast_smdi_interface *iface, int timeout) |
Get the next SMDI message from the queue. More... | |
struct ast_smdi_mwi_message *AST_OPTIONAL_API_NAME() | ast_smdi_mwi_message_wait_station (struct ast_smdi_interface *iface, int timeout, const char *station) |
int AST_OPTIONAL_API_NAME() | ast_smdi_mwi_set (struct ast_smdi_interface *iface, const char *mailbox) |
Set the MWI indicator for a mailbox. More... | |
int AST_OPTIONAL_API_NAME() | ast_smdi_mwi_unset (struct ast_smdi_interface *iface, const char *mailbox) |
Unset the MWI indicator for a mailbox. More... | |
static void | destroy_all_mailbox_mappings (void) |
static void | destroy_mailbox_mapping (struct mailbox_mapping *mm) |
static int | load_module (void) |
Load the module. More... | |
static int | lock_msg_q (struct ast_smdi_interface *iface, enum smdi_message_type type) |
static struct timeval | msg_timestamp (void *msg, enum smdi_message_type type) |
static void * | mwi_monitor_handler (void *data) |
static void | poll_mailbox (struct mailbox_mapping *mm) |
static void | purge_old_messages (struct ast_smdi_interface *iface, enum smdi_message_type type) |
static int | reload (void) |
static int | smdi_ifaces_cmp_fn (void *obj, void *data, int flags) |
static void | smdi_interface_destroy (void *obj) |
static int | smdi_load (int reload) |
static int | smdi_md_q_cmp_fn (void *obj, void *arg, int flags) |
static void * | smdi_message_wait (struct ast_smdi_interface *iface, int timeout, enum smdi_message_type type, const char *search_key, struct ast_flags options) |
static void | smdi_msg_datastore_destroy (void *data) |
static void * | smdi_msg_find (struct ast_smdi_interface *iface, enum smdi_message_type type, const char *search_key, struct ast_flags options) |
static void * | smdi_msg_pop (struct ast_smdi_interface *iface, enum smdi_message_type type) |
static int | smdi_msg_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | smdi_msg_retrieve_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | smdi_mwi_q_cmp_fn (void *obj, void *data, int flags) |
static void * | smdi_read (void *iface_p) |
static int | smdi_toggle_mwi (struct ast_smdi_interface *iface, const char *mailbox, int on) |
static void * | unlink_from_msg_q (struct ast_smdi_interface *iface, enum smdi_message_type type) |
static int | unload_module (void) |
static int | unlock_msg_q (struct ast_smdi_interface *iface, enum smdi_message_type type) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Simplified Message Desk Interface (SMDI) Resource" , .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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_EXTENDED, .load = load_module, .unload = unload_module, .reload = reload, .load_pri = AST_MODPRI_CHANNEL_DEPEND, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static const char | config_file [] = "smdi.conf" |
struct { | |
ast_cond_t cond | |
struct timeval last_poll | |
ast_mutex_t lock | |
struct { | |
struct mailbox_mapping * first | |
struct mailbox_mapping * last | |
} mailbox_mappings | |
unsigned int polling_interval | |
unsigned int stop:1 | |
pthread_t thread | |
} | mwi_monitor |
Data that gets used by the SMDI MWI monitoring thread. More... | |
static const struct ast_datastore_info | smdi_msg_datastore_info |
static struct ast_custom_function | smdi_msg_function |
static int | smdi_msg_id |
static const struct ast_app_option | smdi_msg_ret_options [128] = { [ 't' ] = { .flag = OPT_SEARCH_TERMINAL }, [ 'n' ] = { .flag = OPT_SEARCH_NUMBER }, } |
static struct ast_custom_function | smdi_msg_retrieve_function |
SMDI support for Asterisk.
Here is a useful mailing list post that describes SMDI protocol details: http://lists.digium.com/pipermail/asterisk-dev/2003-June/000884.html
Definition in file res_smdi.c.
#define DEFAULT_POLLING_INTERVAL 10 |
10 seconds
Definition at line 204 of file res_smdi.c.
#define SMDI_RETRIEVE_TIMEOUT_DEFAULT 3000 |
In milliseconds
Definition at line 1195 of file res_smdi.c.
struct ast_smdi_interface* AST_OPTIONAL_API_NAME() ast_smdi_interface_find | ( | const char * | iface_name | ) |
Find an SMDI interface with the specified name.
iface_name | the name/port of the interface to search for. |
Definition at line 563 of file res_smdi.c.
References ao2_global_obj_ref, ao2_ref, mailbox_mapping::iface, and OBJ_SEARCH_KEY.
Referenced by mkintf().
struct ast_smdi_md_message* AST_OPTIONAL_API_NAME() ast_smdi_md_message_pop | ( | struct ast_smdi_interface * | iface | ) |
Get the next SMDI message from the queue.
iface | a pointer to the interface to use. |
This function pulls the first unexpired message from the SMDI message queue on the specified interface. It will purge all expired SMDI messages before returning.
Definition at line 534 of file res_smdi.c.
struct ast_smdi_md_message* AST_OPTIONAL_API_NAME() ast_smdi_md_message_wait | ( | struct ast_smdi_interface * | iface, |
int | timeout | ||
) |
Get the next SMDI message from the queue.
iface | a pointer to the interface to use. |
timeout | the time to wait before returning in milliseconds. |
This function pulls a message from the SMDI message queue on the specified interface. If no message is available this function will wait the specified amount of time before returning.
Definition at line 539 of file res_smdi.c.
struct ast_smdi_mwi_message* AST_OPTIONAL_API_NAME() ast_smdi_mwi_message_pop | ( | struct ast_smdi_interface * | iface | ) |
Get the next SMDI message from the queue.
iface | a pointer to the interface to use. |
This function pulls the first unexpired message from the SMDI message queue on the specified interface. It will purge all expired SMDI messages before returning.
Definition at line 545 of file res_smdi.c.
struct ast_smdi_mwi_message* AST_OPTIONAL_API_NAME() ast_smdi_mwi_message_wait | ( | struct ast_smdi_interface * | iface, |
int | timeout | ||
) |
Get the next SMDI message from the queue.
iface | a pointer to the interface to use. |
timeout | the time to wait before returning in milliseconds. |
This function pulls a message from the SMDI message queue on the specified interface. If no message is available this function will wait the specified amount of time before returning.
Definition at line 550 of file res_smdi.c.
int AST_OPTIONAL_API_NAME() ast_smdi_mwi_set | ( | struct ast_smdi_interface * | iface, |
const char * | mailbox | ||
) |
Set the MWI indicator for a mailbox.
iface | the interface to use. |
mailbox | the mailbox to use. |
Definition at line 309 of file res_smdi.c.
Referenced by poll_mailbox().
int AST_OPTIONAL_API_NAME() ast_smdi_mwi_unset | ( | struct ast_smdi_interface * | iface, |
const char * | mailbox | ||
) |
Unset the MWI indicator for a mailbox.
iface | the interface to use. |
mailbox | the mailbox to use. |
Definition at line 314 of file res_smdi.c.
Referenced by poll_mailbox().
|
static |
Load the module.
Module loading including tests for configuration or dependencies. This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE, or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails tests return AST_MODULE_LOAD_FAILURE. If the module can not load the configuration file or other non-critical problem return AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
Definition at line 1411 of file res_smdi.c.
References ast_custom_function_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and mwi_monitor.
|
static |
Definition at line 833 of file res_smdi.c.
References ast_app_has_voicemail(), ast_smdi_mwi_set(), ast_smdi_mwi_unset(), mailbox_mapping::context, mailbox_mapping::cur_state, mailbox_mapping::iface, mailbox_mapping::mailbox, and mailbox_mapping::smdi.
struct timeval last_poll |
The time that the last poll began
Definition at line 219 of file res_smdi.c.
struct { ... } mailbox_mappings |
A list of mailboxes that need to be monitored
struct { ... } mwi_monitor |
Data that gets used by the SMDI MWI monitoring thread.
Referenced by load_module().
unsigned int polling_interval |
Polling Interval for checking mailbox status
Definition at line 215 of file res_smdi.c.
|
static |
Definition at line 1187 of file res_smdi.c.
|
static |
Definition at line 1375 of file res_smdi.c.
|
static |
Definition at line 1370 of file res_smdi.c.
unsigned int stop |
Set to 1 to tell the polling thread to stop
Definition at line 217 of file res_smdi.c.
Referenced by queue_exec().
pthread_t thread |
The thread ID
Definition at line 209 of file res_smdi.c.