2 * Asterisk -- A telephony toolkit for Linux.
4 * Copyright (C) 2005-2006, Digium, Inc.
6 * Matthew A. Nicholson <mnicholson@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief SMDI support for Asterisk.
22 * \author Matthew A. Nicholson <mnicholson@digium.com>
26 /* C is simply a ego booster for those who want to do objects the hard way. */
29 #ifndef ASTERISK_SMDI_H
30 #define ASTERISK_SMDI_H
35 #include "asterisk/config.h"
36 #include "asterisk/module.h"
37 #include "asterisk/astobj.h"
39 #define SMDI_MESG_DESK_NUM_LEN 3
40 #define SMDI_MESG_DESK_TERM_LEN 4
41 #define SMDI_MWI_FAIL_CAUSE_LEN 3
42 #define SMDI_MAX_STATION_NUM_LEN 10
43 #define SMDI_MAX_FILENAME_LEN 256
46 * \brief An SMDI message waiting indicator message.
48 * The ast_smdi_mwi_message structure contains the parsed out parts of an smdi
49 * message. Each ast_smdi_interface structure has a message queue consisting
50 * ast_smdi_mwi_message structures.
52 struct ast_smdi_mwi_message {
53 ASTOBJ_COMPONENTS(struct ast_smdi_mwi_message);
54 char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */
55 char cause[SMDI_MWI_FAIL_CAUSE_LEN + 1]; /* the type of failure */
56 struct timeval timestamp; /* a timestamp for the message */
60 * \brief An SMDI message desk message.
62 * The ast_smdi_md_message structure contains the parsed out parts of an smdi
63 * message. Each ast_smdi_interface structure has a message queue consisting
64 * ast_smdi_md_message structures.
66 struct ast_smdi_md_message {
67 ASTOBJ_COMPONENTS(struct ast_smdi_md_message);
68 char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN + 1]; /* message desk number */
69 char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN + 1]; /* message desk terminal */
70 char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */
71 char calling_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* calling station number */
72 char type; /* the type of the call */
73 struct timeval timestamp; /* a timestamp for the message */
76 /*! \brief SMDI message desk message queue. */
77 struct ast_smdi_md_queue {
78 ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_md_message);
81 /*! \brief SMDI message waiting indicator message queue. */
82 struct ast_smdi_mwi_queue {
83 ASTOBJ_CONTAINER_COMPONENTS(struct ast_smdi_mwi_message);
87 * \brief SMDI interface structure.
89 * The ast_smdi_interface structure holds information on a serial port that
90 * should be monitored for SMDI activity. The structure contains a message
91 * queue of messages that have been received on the interface.
93 struct ast_smdi_interface {
94 ASTOBJ_COMPONENTS_FULL(struct ast_smdi_interface, SMDI_MAX_FILENAME_LEN, 1);
95 struct ast_smdi_md_queue md_q;
96 struct ast_smdi_mwi_queue mwi_q;
106 /* MD message queue functions */
107 struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *iface);
108 struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout);
109 void ast_smdi_md_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg);
111 /* MWI message queue functions */
112 struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface);
113 struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout);
114 void ast_smdi_mwi_message_putback(struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg);
116 struct ast_smdi_interface *ast_smdi_interface_find(const char *iface_name);
119 int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox);
120 int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox);
122 void ast_smdi_md_message_destroy(struct ast_smdi_md_message *msg);
123 void ast_smdi_mwi_message_destroy(struct ast_smdi_mwi_message *msg);
125 void ast_smdi_interface_destroy(struct ast_smdi_interface *iface);
127 #endif /* !ASTERISK_SMDI_H */