Fri Sep 25 19:28:15 2009

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-2006, Digium, Inc.
00005  *
00006  * Matthew A. Nicholson <mnicholson@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! 
00020  * \file
00021  * \brief SMDI support for Asterisk.
00022  * \author Matthew A. Nicholson <mnicholson@digium.com>
00023  */
00024 
00025 
00026 /* C is simply a ego booster for those who want to do objects the hard way. */
00027 
00028 
00029 #ifndef ASTERISK_SMDI_H
00030 #define ASTERISK_SMDI_H
00031 
00032 #include <termios.h>
00033 #include <time.h>
00034 
00035 #include "asterisk/config.h"
00036 #include "asterisk/module.h"
00037 #include "asterisk/astobj.h"
00038 
00039 #define SMDI_MESG_DESK_NUM_LEN 3
00040 #define SMDI_MESG_DESK_TERM_LEN 4
00041 #define SMDI_MWI_FAIL_CAUSE_LEN 3
00042 #define SMDI_MAX_STATION_NUM_LEN 10
00043 #define SMDI_MAX_FILENAME_LEN 256
00044 
00045 /*!
00046  * \brief An SMDI message waiting indicator message.
00047  *
00048  * The ast_smdi_mwi_message structure contains the parsed out parts of an smdi
00049  * message.  Each ast_smdi_interface structure has a message queue consisting
00050  * ast_smdi_mwi_message structures. 
00051  */
00052 struct ast_smdi_mwi_message {
00053    ASTOBJ_COMPONENTS(struct ast_smdi_mwi_message);
00054    char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1];      /* forwarding station number */
00055    char cause[SMDI_MWI_FAIL_CAUSE_LEN + 1];     /* the type of failure */
00056    struct timeval timestamp;           /* a timestamp for the message */
00057 };
00058 
00059 /*!
00060  * \brief An SMDI message desk message.
00061  *
00062  * The ast_smdi_md_message structure contains the parsed out parts of an smdi
00063  * message.  Each ast_smdi_interface structure has a message queue consisting
00064  * ast_smdi_md_message structures. 
00065  */
00066 struct ast_smdi_md_message {
00067    ASTOBJ_COMPONENTS(struct ast_smdi_md_message);
00068    char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN + 1];    /* message desk number */
00069    char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN + 1];  /* message desk terminal */
00070    char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1];      /* forwarding station number */
00071    char calling_st[SMDI_MAX_STATION_NUM_LEN + 1];     /* calling station number */
00072    char type;                 /* the type of the call */
00073    struct timeval timestamp;           /* a timestamp for the message */
00074 };
00075 
00076 /*! \brief SMDI message desk message queue. */
00077 struct ast_smdi_md_queue {
00078    ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_md_message);
00079 };
00080 
00081 /*! \brief SMDI message waiting indicator message queue. */
00082 struct ast_smdi_mwi_queue {
00083    ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_mwi_message);
00084 };
00085 
00086 /*! 
00087  * \brief SMDI interface structure.
00088  *
00089  * The ast_smdi_interface structure holds information on a serial port that
00090  * should be monitored for SMDI activity.  The structure contains a message
00091  * queue of messages that have been recieved on the interface.
00092  */
00093 struct ast_smdi_interface {
00094    ASTOBJ_COMPONENTS_FULL(struct ast_smdi_interface, SMDI_MAX_FILENAME_LEN, 1);
00095    struct ast_smdi_md_queue md_q;
00096    struct ast_smdi_mwi_queue mwi_q;
00097    FILE *file;
00098    int fd;
00099    pthread_t thread;
00100    struct termios mode;
00101    int msdstrip;
00102    long msg_expiry;
00103 };
00104 
00105 
00106 /* MD message queue functions */
00107 struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface);
00108 struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout);
00109 void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg);
00110 
00111 /* MWI message queue functions */
00112 struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface);
00113 struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout);
00114 void ast_smdi_mwi_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg);
00115 
00116 struct ast_smdi_interface *ast_smdi_interface_find(const char *iface_name);
00117 
00118 /* MWI functions */
00119 int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox);
00120 int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox);
00121 
00122 void ast_smdi_md_message_destroy(struct ast_smdi_md_message *msg);
00123 void ast_smdi_mwi_message_destroy(struct ast_smdi_mwi_message *msg);
00124 
00125 void ast_smdi_interface_destroy(struct ast_smdi_interface *iface);
00126 
00127 #endif /* !ASTERISK_SMDI_H */

Generated on Fri Sep 25 19:28:15 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.5