Asterisk - The Open Source Telephony Project  18.5.0
smdi.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2005-2008, Digium, Inc.
5  *
6  * Matthew A. Nicholson <[email protected]>
7  * Russell Bryant <[email protected]>
8  *
9  * See http://www.asterisk.org for more information about
10  * the Asterisk project. Please do not directly contact
11  * any of the maintainers of this project for assistance;
12  * the project provides a web site, mailing lists and IRC
13  * channels for your use.
14  *
15  * This program is free software, distributed under the terms of
16  * the GNU General Public License Version 2. See the LICENSE file
17  * at the top of the source tree.
18  */
19 
20 /*!
21  * \file
22  * \brief SMDI support for Asterisk.
23  * \author Matthew A. Nicholson <[email protected]>
24  * \author Russell Bryant <[email protected]>
25  */
26 
27 #ifndef ASTERISK_SMDI_H
28 #define ASTERISK_SMDI_H
29 
30 #include <termios.h>
31 #include <time.h>
32 
33 #include "asterisk/config.h"
34 #include "asterisk/module.h"
35 #include "asterisk/optional_api.h"
36 
37 #define SMDI_MESG_NAME_LEN 80
38 #define SMDI_MESG_DESK_NUM_LEN 3
39 #define SMDI_MESG_DESK_TERM_LEN 4
40 #define SMDI_MWI_FAIL_CAUSE_LEN 3
41 #define SMDI_MAX_STATION_NUM_LEN 10
42 #define SMDI_MAX_FILENAME_LEN 256
43 
44 /*!
45  * \brief An SMDI message waiting indicator message.
46  *
47  * The ast_smdi_mwi_message structure contains the parsed out parts of an smdi
48  * message. Each ast_smdi_interface structure has a message queue consisting
49  * ast_smdi_mwi_message structures.
50  */
53  char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */
54  char cause[SMDI_MWI_FAIL_CAUSE_LEN + 1]; /* the type of failure */
55  struct timeval timestamp; /* a timestamp for the message */
56 };
57 
58 /*!
59  * \brief An SMDI message desk message.
60  *
61  * The ast_smdi_md_message structure contains the parsed out parts of an smdi
62  * message. Each ast_smdi_interface structure has a message queue consisting
63  * ast_smdi_md_message structures.
64  */
67  char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN + 1]; /* message desk number */
68  char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN + 1]; /* message desk terminal */
69  char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */
70  char calling_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* calling station number */
71  char type; /* the type of the call */
72  struct timeval timestamp; /* a timestamp for the message */
73 };
74 
75 /*!
76  * \brief SMDI interface structure.
77  *
78  * The ast_smdi_interface structure holds information on a serial port that
79  * should be monitored for SMDI activity. The structure contains a message
80  * queue of messages that have been received on the interface.
81  */
82 struct ast_smdi_interface;
83 
84 /*!
85  * \brief Get the next SMDI message from the queue.
86  * \param iface a pointer to the interface to use.
87  *
88  * This function pulls the first unexpired message from the SMDI message queue
89  * on the specified interface. It will purge all expired SMDI messages before
90  * returning.
91  *
92  * \return the next SMDI message, or NULL if there were no pending messages.
93  */
95  (struct ast_smdi_interface *iface),
96  { return NULL; });
97 
98 /*!
99  * \brief Get the next SMDI message from the queue.
100  * \param iface a pointer to the interface to use.
101  * \param timeout the time to wait before returning in milliseconds.
102  *
103  * This function pulls a message from the SMDI message queue on the specified
104  * interface. If no message is available this function will wait the specified
105  * amount of time before returning.
106  *
107  * \return the next SMDI message, or NULL if there were no pending messages and
108  * the timeout has expired.
109  */
111  (struct ast_smdi_interface *iface, int timeout),
112  { return NULL; });
113 
114 /*!
115  * \brief Get the next SMDI message from the queue.
116  * \param iface a pointer to the interface to use.
117  *
118  * This function pulls the first unexpired message from the SMDI message queue
119  * on the specified interface. It will purge all expired SMDI messages before
120  * returning.
121  *
122  * \return the next SMDI message, or NULL if there were no pending messages.
123  */
125  (struct ast_smdi_interface *iface),
126  { return NULL; });
127 
128 /*!
129  * \brief Get the next SMDI message from the queue.
130  * \param iface a pointer to the interface to use.
131  * \param timeout the time to wait before returning in milliseconds.
132  *
133  * This function pulls a message from the SMDI message queue on the specified
134  * interface. If no message is available this function will wait the specified
135  * amount of time before returning.
136  *
137  * \return the next SMDI message, or NULL if there were no pending messages and
138  * the timeout has expired.
139  */
141  (struct ast_smdi_interface *iface, int timeout),
142  { return NULL; });
143 
145  (struct ast_smdi_interface *iface, int timeout, const char *station),
146  { return NULL; });
147 
148 /*!
149  * \brief Find an SMDI interface with the specified name.
150  * \param iface_name the name/port of the interface to search for.
151  *
152  * \return an ao2 reference to the interface located or NULL if none was found.
153  */
155  (const char *iface_name),
156  { return NULL; });
157 
158 /*!
159  * \brief Set the MWI indicator for a mailbox.
160  * \param iface the interface to use.
161  * \param mailbox the mailbox to use.
162  */
164  (struct ast_smdi_interface *iface, const char *mailbox),
165  { return -1; });
166 
167 /*!
168  * \brief Unset the MWI indicator for a mailbox.
169  * \param iface the interface to use.
170  * \param mailbox the mailbox to use.
171  */
173  (struct ast_smdi_interface *iface, const char *mailbox),
174  { return -1; });
175 
176 #endif /* !ASTERISK_SMDI_H */
Optional API function macros.
Time-related functions and macros.
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.
Definition: res_smdi.c:550
#define SMDI_MAX_STATION_NUM_LEN
Definition: smdi.h:41
struct ast_smdi_interface * ast_smdi_interface_find(const char *iface_name)
Find an SMDI interface with the specified name.
Definition: res_smdi.c:563
static int timeout
Definition: cdr_mysql.c:86
#define AST_OPTIONAL_API(result, name, proto, stub)
Declare an optional API function.
Definition: optional_api.h:230
#define NULL
Definition: resample.c:96
char name[SMDI_MESG_NAME_LEN]
Definition: smdi.h:52
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.
Definition: res_smdi.c:539
char cause[SMDI_MWI_FAIL_CAUSE_LEN+1]
Definition: smdi.h:54
int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
Set the MWI indicator for a mailbox.
Definition: res_smdi.c:309
Configuration File Parser.
struct ast_smdi_md_message * ast_smdi_md_message_pop(struct ast_smdi_interface *iface)
Get the next SMDI message from the queue.
Definition: res_smdi.c:534
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
Definition: chan_mgcp.c:204
#define SMDI_MESG_DESK_NUM_LEN
Definition: smdi.h:38
#define SMDI_MESG_DESK_TERM_LEN
Definition: smdi.h:39
#define SMDI_MESG_NAME_LEN
Definition: smdi.h:37
An SMDI message desk message.
Definition: smdi.h:65
#define SMDI_MWI_FAIL_CAUSE_LEN
Definition: smdi.h:40
struct ast_smdi_mwi_message * ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface)
Get the next SMDI message from the queue.
Definition: res_smdi.c:545
char fwd_st[SMDI_MAX_STATION_NUM_LEN+1]
Definition: smdi.h:53
struct timeval timestamp
Definition: smdi.h:55
int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
Unset the MWI indicator for a mailbox.
Definition: res_smdi.c:314
struct ast_smdi_mwi_message * ast_smdi_mwi_message_wait_station(struct ast_smdi_interface *iface, int timeout, const char *station)
Definition: res_smdi.c:556
Asterisk module definitions.
An SMDI message waiting indicator message.
Definition: smdi.h:51