Fri Aug 17 00:17:20 2018

Asterisk developer's documentation


smdi.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * Copyright (C) 2005-2008, Digium, Inc.
00005  *
00006  * Matthew A. Nicholson <mnicholson@digium.com>
00007  * Russell Bryant <russell@digium.com>
00008  *
00009  * See http://www.asterisk.org for more information about
00010  * the Asterisk project. Please do not directly contact
00011  * any of the maintainers of this project for assistance;
00012  * the project provides a web site, mailing lists and IRC
00013  * channels for your use.
00014  *
00015  * This program is free software, distributed under the terms of
00016  * the GNU General Public License Version 2. See the LICENSE file
00017  * at the top of the source tree.
00018  */
00019 
00020 /*! 
00021  * \file
00022  * \brief SMDI support for Asterisk.
00023  * \author Matthew A. Nicholson <mnicholson@digium.com>
00024  * \author Russell Bryant <russell@digium.com>
00025  */
00026 
00027 
00028 /* C is simply a ego booster for those who want to do objects the hard way. */
00029 
00030 
00031 #ifndef ASTERISK_SMDI_H
00032 #define ASTERISK_SMDI_H
00033 
00034 #include <termios.h>
00035 #include <time.h>
00036 
00037 #include "asterisk/config.h"
00038 #include "asterisk/module.h"
00039 #include "asterisk/astobj.h"
00040 #include "asterisk/optional_api.h"
00041 
00042 #define SMDI_MESG_DESK_NUM_LEN 3
00043 #define SMDI_MESG_DESK_TERM_LEN 4
00044 #define SMDI_MWI_FAIL_CAUSE_LEN 3
00045 #define SMDI_MAX_STATION_NUM_LEN 10
00046 #define SMDI_MAX_FILENAME_LEN 256
00047 
00048 /*!
00049  * \brief An SMDI message waiting indicator message.
00050  *
00051  * The ast_smdi_mwi_message structure contains the parsed out parts of an smdi
00052  * message.  Each ast_smdi_interface structure has a message queue consisting
00053  * ast_smdi_mwi_message structures. 
00054  */
00055 struct ast_smdi_mwi_message {
00056    ASTOBJ_COMPONENTS(struct ast_smdi_mwi_message);
00057    char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1];      /* forwarding station number */
00058    char cause[SMDI_MWI_FAIL_CAUSE_LEN + 1];     /* the type of failure */
00059    struct timeval timestamp;           /* a timestamp for the message */
00060 };
00061 
00062 /*!
00063  * \brief An SMDI message desk message.
00064  *
00065  * The ast_smdi_md_message structure contains the parsed out parts of an smdi
00066  * message.  Each ast_smdi_interface structure has a message queue consisting
00067  * ast_smdi_md_message structures. 
00068  */
00069 struct ast_smdi_md_message {
00070    ASTOBJ_COMPONENTS(struct ast_smdi_md_message);
00071    char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN + 1];    /* message desk number */
00072    char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN + 1];  /* message desk terminal */
00073    char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1];      /* forwarding station number */
00074    char calling_st[SMDI_MAX_STATION_NUM_LEN + 1];     /* calling station number */
00075    char type;                 /* the type of the call */
00076    struct timeval timestamp;           /* a timestamp for the message */
00077 };
00078 
00079 /*! 
00080  * \brief SMDI interface structure.
00081  *
00082  * The ast_smdi_interface structure holds information on a serial port that
00083  * should be monitored for SMDI activity.  The structure contains a message
00084  * queue of messages that have been received on the interface.
00085  */
00086 struct ast_smdi_interface;
00087 
00088 AST_OPTIONAL_API(void, ast_smdi_interface_unref,
00089        (struct ast_smdi_interface *iface),
00090        { return; });
00091 
00092 /*! 
00093  * \brief Get the next SMDI message from the queue.
00094  * \param iface a pointer to the interface to use.
00095  *
00096  * This function pulls the first unexpired message from the SMDI message queue
00097  * on the specified interface.  It will purge all expired SMDI messages before
00098  * returning.
00099  *
00100  * \return the next SMDI message, or NULL if there were no pending messages.
00101  */
00102 AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_pop,
00103        (struct ast_smdi_interface *iface),
00104        { return NULL; });
00105 
00106 /*!
00107  * \brief Get the next SMDI message from the queue.
00108  * \param iface a pointer to the interface to use.
00109  * \param timeout the time to wait before returning in milliseconds.
00110  *
00111  * This function pulls a message from the SMDI message queue on the specified
00112  * interface.  If no message is available this function will wait the specified
00113  * amount of time before returning.
00114  *
00115  * \return the next SMDI message, or NULL if there were no pending messages and
00116  * the timeout has expired.
00117  */
00118 AST_OPTIONAL_API(struct ast_smdi_md_message *, ast_smdi_md_message_wait,
00119        (struct ast_smdi_interface *iface, int timeout),
00120        { return NULL; });
00121 
00122 /*!
00123  * \brief Put an SMDI message back in the front of the queue.
00124  * \param iface a pointer to the interface to use.
00125  * \param msg a pointer to the message to use.
00126  *
00127  * This function puts a message back in the front of the specified queue.  It
00128  * should be used if a message was popped but is not going to be processed for
00129  * some reason, and the message needs to be returned to the queue.
00130  */
00131 AST_OPTIONAL_API(void, ast_smdi_md_message_putback,
00132        (struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg),
00133        { return; });
00134 
00135 /*!
00136  * \brief Get the next SMDI message from the queue.
00137  * \param iface a pointer to the interface to use.
00138  *
00139  * This function pulls the first unexpired message from the SMDI message queue
00140  * on the specified interface.  It will purge all expired SMDI messages before
00141  * returning.
00142  *
00143  * \return the next SMDI message, or NULL if there were no pending messages.
00144  */
00145 AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_pop,
00146        (struct ast_smdi_interface *iface),
00147        { return NULL; });
00148 
00149 /*!
00150  * \brief Get the next SMDI message from the queue.
00151  * \param iface a pointer to the interface to use.
00152  * \param timeout the time to wait before returning in milliseconds.
00153  *
00154  * This function pulls a message from the SMDI message queue on the specified
00155  * interface.  If no message is available this function will wait the specified
00156  * amount of time before returning.
00157  *
00158  * \return the next SMDI message, or NULL if there were no pending messages and
00159  * the timeout has expired.
00160  */
00161 AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_wait,
00162        (struct ast_smdi_interface *iface, int timeout),
00163        { return NULL; });
00164 
00165 AST_OPTIONAL_API(struct ast_smdi_mwi_message *, ast_smdi_mwi_message_wait_station,
00166        (struct ast_smdi_interface *iface, int   timeout, const char *station),
00167        { return NULL; });
00168 
00169 /*!
00170  * \brief Put an SMDI message back in the front of the queue.
00171  * \param iface a pointer to the interface to use.
00172  * \param msg a pointer to the message to use.
00173  *
00174  * This function puts a message back in the front of the specified queue.  It
00175  * should be used if a message was popped but is not going to be processed for
00176  * some reason, and the message needs to be returned to the queue.
00177  */
00178 AST_OPTIONAL_API(void, ast_smdi_mwi_message_putback,
00179        (struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg),
00180        { return; });
00181 
00182 /*!
00183  * \brief Find an SMDI interface with the specified name.
00184  * \param iface_name the name/port of the interface to search for.
00185  *
00186  * \return a pointer to the interface located or NULL if none was found.  This
00187  * actually returns an ASTOBJ reference and should be released using
00188  * #ASTOBJ_UNREF(iface, ast_smdi_interface_destroy).
00189  */
00190 AST_OPTIONAL_API(struct ast_smdi_interface *, ast_smdi_interface_find,
00191        (const char *iface_name),
00192        { return NULL; });
00193 
00194 /*!
00195  * \brief Set the MWI indicator for a mailbox.
00196  * \param iface the interface to use.
00197  * \param mailbox the mailbox to use.
00198  */
00199 AST_OPTIONAL_API(int, ast_smdi_mwi_set,
00200        (struct ast_smdi_interface *iface, const char *mailbox),
00201        { return -1; });
00202 
00203 /*! 
00204  * \brief Unset the MWI indicator for a mailbox.
00205  * \param iface the interface to use.
00206  * \param mailbox the mailbox to use.
00207  */
00208 AST_OPTIONAL_API(int, ast_smdi_mwi_unset,
00209        (struct ast_smdi_interface *iface, const char *mailbox),
00210        { return -1; });
00211 
00212 /*! \brief ast_smdi_md_message destructor. */
00213 AST_OPTIONAL_API(void, ast_smdi_md_message_destroy,
00214        (struct ast_smdi_md_message *msg),
00215        { return; });
00216 
00217 /*! \brief ast_smdi_mwi_message destructor. */
00218 AST_OPTIONAL_API(void, ast_smdi_mwi_message_destroy,
00219        (struct ast_smdi_mwi_message *msg),
00220        { return; });
00221 
00222 #endif /* !ASTERISK_SMDI_H */

Generated on 17 Aug 2018 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1