Wed Jan 8 2020 09:50:21

Asterisk developer's documentation


smdi.h File Reference

SMDI support for Asterisk. More...

#include <termios.h>
#include <time.h>
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/astobj.h"
#include "asterisk/optional_api.h"

Go to the source code of this file.

Data Structures

struct  ast_smdi_md_message
 An SMDI message desk message. More...
 
struct  ast_smdi_mwi_message
 An SMDI message waiting indicator message. More...
 

Macros

#define SMDI_MAX_FILENAME_LEN   256
 
#define SMDI_MAX_STATION_NUM_LEN   10
 
#define SMDI_MESG_DESK_NUM_LEN   3
 
#define SMDI_MESG_DESK_TERM_LEN   4
 
#define SMDI_MWI_FAIL_CAUSE_LEN   3
 

Functions

struct ast_smdi_interfaceast_smdi_interface_find (const char *iface_name)
 Find an SMDI interface with the specified name. More...
 
void ast_smdi_interface_unref (struct ast_smdi_interface *iface)
 
void ast_smdi_md_message_destroy (struct ast_smdi_md_message *msg)
 ast_smdi_md_message destructor. More...
 
struct ast_smdi_md_messageast_smdi_md_message_pop (struct ast_smdi_interface *iface)
 Get the next SMDI message from the queue. More...
 
void ast_smdi_md_message_putback (struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg)
 Put an SMDI message back in the front of the queue. More...
 
struct ast_smdi_md_messageast_smdi_md_message_wait (struct ast_smdi_interface *iface, int timeout)
 Get the next SMDI message from the queue. More...
 
void ast_smdi_mwi_message_destroy (struct ast_smdi_mwi_message *msg)
 ast_smdi_mwi_message destructor. More...
 
struct ast_smdi_mwi_messageast_smdi_mwi_message_pop (struct ast_smdi_interface *iface)
 Get the next SMDI message from the queue. More...
 
void ast_smdi_mwi_message_putback (struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg)
 Put an SMDI message back in the front of the queue. More...
 
struct ast_smdi_mwi_messageast_smdi_mwi_message_wait (struct ast_smdi_interface *iface, int timeout)
 Get the next SMDI message from the queue. More...
 
struct ast_smdi_mwi_messageast_smdi_mwi_message_wait_station (struct ast_smdi_interface *iface, int timeout, const char *station)
 
int ast_smdi_mwi_set (struct ast_smdi_interface *iface, const char *mailbox)
 Set the MWI indicator for a mailbox. More...
 
int ast_smdi_mwi_unset (struct ast_smdi_interface *iface, const char *mailbox)
 Unset the MWI indicator for a mailbox. More...
 

Detailed Description

SMDI support for Asterisk.

Author
Matthew A. Nicholson mnich.nosp@m.olso.nosp@m.n@dig.nosp@m.ium..nosp@m.com
Russell Bryant russe.nosp@m.ll@d.nosp@m.igium.nosp@m..com

Definition in file smdi.h.

Macro Definition Documentation

#define SMDI_MAX_FILENAME_LEN   256

Definition at line 46 of file smdi.h.

#define SMDI_MAX_STATION_NUM_LEN   10

Definition at line 45 of file smdi.h.

#define SMDI_MESG_DESK_NUM_LEN   3

Definition at line 42 of file smdi.h.

#define SMDI_MESG_DESK_TERM_LEN   4

Definition at line 43 of file smdi.h.

#define SMDI_MWI_FAIL_CAUSE_LEN   3

Definition at line 44 of file smdi.h.

Function Documentation

struct ast_smdi_interface* ast_smdi_interface_find ( const char *  iface_name)

Find an SMDI interface with the specified name.

Parameters
iface_namethe name/port of the interface to search for.
Returns
a pointer to the interface located or NULL if none was found. This actually returns an ASTOBJ reference and should be released using ASTOBJ_UNREF(iface, ast_smdi_interface_destroy).

Definition at line 627 of file res_smdi.c.

References ASTOBJ_CONTAINER_FIND, and smdi_ifaces.

Referenced by actual_load_config(), mkintf(), and smdi_msg_retrieve_read().

628 {
629  return (ASTOBJ_CONTAINER_FIND(&smdi_ifaces, iface_name));
630 }
static struct ast_smdi_interface_container smdi_ifaces
#define ASTOBJ_CONTAINER_FIND(container, namestr)
Find an object in a container.
Definition: astobj.h:401
void ast_smdi_interface_unref ( struct ast_smdi_interface iface)

Definition at line 259 of file res_smdi.c.

References ast_smdi_interface_destroy(), ASTOBJ_UNREF, and mailbox_mapping::iface.

Referenced by destroy_dahdi_pvt().

260 {
262 }
static void ast_smdi_interface_destroy(struct ast_smdi_interface *iface)
Definition: res_smdi.c:231
#define ASTOBJ_UNREF(object, destructor)
Decrement the reference count on an object.
Definition: astobj.h:218
void ast_smdi_md_message_destroy ( struct ast_smdi_md_message msg)

ast_smdi_md_message destructor.

Definition at line 824 of file res_smdi.c.

References ast_free.

Referenced by __analog_ss_thread(), analog_ss_thread(), ast_smdi_interface_destroy(), smdi_msg_datastore_destroy(), smdi_msg_retrieve_read(), smdi_read(), and unref_msg().

825 {
826  ast_free(msg);
827 }
#define ast_free(a)
Definition: astmm.h:97
struct ast_smdi_md_message* ast_smdi_md_message_pop ( struct ast_smdi_interface iface)

Get the next SMDI message from the queue.

Parameters
ifacea 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.

Returns
the next SMDI message, or NULL if there were no pending messages.

Definition at line 598 of file res_smdi.c.

References SMDI_MD, and smdi_msg_pop().

599 {
600  return smdi_msg_pop(iface, SMDI_MD);
601 }
static void * smdi_msg_pop(struct ast_smdi_interface *iface, enum smdi_message_type type)
Definition: res_smdi.c:456
void ast_smdi_md_message_putback ( struct ast_smdi_interface iface,
struct ast_smdi_md_message msg 
)

Put an SMDI message back in the front of the queue.

Parameters
ifacea pointer to the interface to use.
msga pointer to the message to use.

This function puts a message back in the front of the specified queue. It should be used if a message was popped but is not going to be processed for some reason, and the message needs to be returned to the queue.

Definition at line 329 of file res_smdi.c.

References ast_cond_broadcast, ast_mutex_lock, ast_mutex_unlock, ASTOBJ_CONTAINER_LINK_START, mailbox_mapping::iface, ast_smdi_interface::md_q, ast_smdi_interface::md_q_cond, and ast_smdi_interface::md_q_lock.

330 {
331  ast_mutex_lock(&iface->md_q_lock);
332  ASTOBJ_CONTAINER_LINK_START(&iface->md_q, md_msg);
333  ast_cond_broadcast(&iface->md_q_cond);
334  ast_mutex_unlock(&iface->md_q_lock);
335 }
struct ast_smdi_md_queue md_q
Definition: res_smdi.c:173
ast_mutex_t md_q_lock
Definition: res_smdi.c:174
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ASTOBJ_CONTAINER_LINK_START(container, newobj)
Add an object to the front of a container.
Definition: astobj.h:610
#define ast_cond_broadcast(cond)
Definition: lock.h:170
ast_cond_t md_q_cond
Definition: res_smdi.c:175
#define ast_mutex_unlock(a)
Definition: lock.h:156
struct ast_smdi_md_message* ast_smdi_md_message_wait ( struct ast_smdi_interface iface,
int  timeout 
)

Get the next SMDI message from the queue.

Parameters
ifacea pointer to the interface to use.
timeoutthe 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.

Returns
the next SMDI message, or NULL if there were no pending messages and the timeout has expired.

Definition at line 603 of file res_smdi.c.

References SMDI_MD, and smdi_message_wait().

Referenced by __analog_ss_thread(), and analog_ss_thread().

604 {
605  struct ast_flags options = { 0 };
606  return smdi_message_wait(iface, timeout, SMDI_MD, NULL, options);
607 }
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)
Definition: res_smdi.c:542
Structure used to handle boolean flags.
Definition: utils.h:200
void ast_smdi_mwi_message_destroy ( struct ast_smdi_mwi_message msg)

ast_smdi_mwi_message destructor.

Definition at line 829 of file res_smdi.c.

References ast_free.

Referenced by ast_smdi_interface_destroy(), run_externnotify(), smdi_read(), and unref_msg().

830 {
831  ast_free(msg);
832 }
#define ast_free(a)
Definition: astmm.h:97
struct ast_smdi_mwi_message* ast_smdi_mwi_message_pop ( struct ast_smdi_interface iface)

Get the next SMDI message from the queue.

Parameters
ifacea 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.

Returns
the next SMDI message, or NULL if there were no pending messages.

Definition at line 609 of file res_smdi.c.

References smdi_msg_pop(), and SMDI_MWI.

610 {
611  return smdi_msg_pop(iface, SMDI_MWI);
612 }
static void * smdi_msg_pop(struct ast_smdi_interface *iface, enum smdi_message_type type)
Definition: res_smdi.c:456
void ast_smdi_mwi_message_putback ( struct ast_smdi_interface iface,
struct ast_smdi_mwi_message msg 
)

Put an SMDI message back in the front of the queue.

Parameters
ifacea pointer to the interface to use.
msga pointer to the message to use.

This function puts a message back in the front of the specified queue. It should be used if a message was popped but is not going to be processed for some reason, and the message needs to be returned to the queue.

Definition at line 337 of file res_smdi.c.

References ast_cond_broadcast, ast_mutex_lock, ast_mutex_unlock, ASTOBJ_CONTAINER_LINK_START, mailbox_mapping::iface, ast_smdi_interface::mwi_q, ast_smdi_interface::mwi_q_cond, and ast_smdi_interface::mwi_q_lock.

338 {
339  ast_mutex_lock(&iface->mwi_q_lock);
340  ASTOBJ_CONTAINER_LINK_START(&iface->mwi_q, mwi_msg);
342  ast_mutex_unlock(&iface->mwi_q_lock);
343 }
#define ast_mutex_lock(a)
Definition: lock.h:155
#define ASTOBJ_CONTAINER_LINK_START(container, newobj)
Add an object to the front of a container.
Definition: astobj.h:610
ast_cond_t mwi_q_cond
Definition: res_smdi.c:178
#define ast_cond_broadcast(cond)
Definition: lock.h:170
ast_mutex_t mwi_q_lock
Definition: res_smdi.c:177
struct ast_smdi_mwi_queue mwi_q
Definition: res_smdi.c:176
#define ast_mutex_unlock(a)
Definition: lock.h:156
struct ast_smdi_mwi_message* ast_smdi_mwi_message_wait ( struct ast_smdi_interface iface,
int  timeout 
)

Get the next SMDI message from the queue.

Parameters
ifacea pointer to the interface to use.
timeoutthe 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.

Returns
the next SMDI message, or NULL if there were no pending messages and the timeout has expired.

Definition at line 614 of file res_smdi.c.

References smdi_message_wait(), and SMDI_MWI.

615 {
616  struct ast_flags options = { 0 };
617  return smdi_message_wait(iface, timeout, SMDI_MWI, NULL, options);
618 }
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)
Definition: res_smdi.c:542
Structure used to handle boolean flags.
Definition: utils.h:200
struct ast_smdi_mwi_message* ast_smdi_mwi_message_wait_station ( struct ast_smdi_interface iface,
int  timeout,
const char *  station 
)

Definition at line 620 of file res_smdi.c.

References smdi_message_wait(), and SMDI_MWI.

Referenced by run_externnotify().

622 {
623  struct ast_flags options = { 0 };
624  return smdi_message_wait(iface, timeout, SMDI_MWI, station, options);
625 }
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)
Definition: res_smdi.c:542
Structure used to handle boolean flags.
Definition: utils.h:200
int ast_smdi_mwi_set ( struct ast_smdi_interface iface,
const char *  mailbox 
)

Set the MWI indicator for a mailbox.

Parameters
ifacethe interface to use.
mailboxthe mailbox to use.

Definition at line 319 of file res_smdi.c.

References mailbox_mapping::iface, mailbox_mapping::mailbox, and smdi_toggle_mwi().

Referenced by poll_mailbox(), and run_externnotify().

320 {
321  return smdi_toggle_mwi(iface, mailbox, 1);
322 }
static int smdi_toggle_mwi(struct ast_smdi_interface *iface, const char *mailbox, int on)
Definition: res_smdi.c:292
static char mailbox[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:197
int ast_smdi_mwi_unset ( struct ast_smdi_interface iface,
const char *  mailbox 
)

Unset the MWI indicator for a mailbox.

Parameters
ifacethe interface to use.
mailboxthe mailbox to use.

Definition at line 324 of file res_smdi.c.

References mailbox_mapping::iface, mailbox_mapping::mailbox, and smdi_toggle_mwi().

Referenced by poll_mailbox(), and run_externnotify().

325 {
326  return smdi_toggle_mwi(iface, mailbox, 0);
327 }
static int smdi_toggle_mwi(struct ast_smdi_interface *iface, const char *mailbox, int on)
Definition: res_smdi.c:292
static char mailbox[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:197