Wed Jan 8 2020 09:49:51

Asterisk developer's documentation


smdi.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- A telephony toolkit for Linux.
3  *
4  * Copyright (C) 2005-2008, Digium, Inc.
5  *
6  * Matthew A. Nicholson <mnicholson@digium.com>
7  * Russell Bryant <russell@digium.com>
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 <mnicholson@digium.com>
24  * \author Russell Bryant <russell@digium.com>
25  */
26 
27 
28 /* C is simply a ego booster for those who want to do objects the hard way. */
29 
30 
31 #ifndef ASTERISK_SMDI_H
32 #define ASTERISK_SMDI_H
33 
34 #include <termios.h>
35 #include <time.h>
36 
37 #include "asterisk/config.h"
38 #include "asterisk/module.h"
39 #include "asterisk/astobj.h"
40 #include "asterisk/optional_api.h"
41 
42 #define SMDI_MESG_DESK_NUM_LEN 3
43 #define SMDI_MESG_DESK_TERM_LEN 4
44 #define SMDI_MWI_FAIL_CAUSE_LEN 3
45 #define SMDI_MAX_STATION_NUM_LEN 10
46 #define SMDI_MAX_FILENAME_LEN 256
47 
48 /*!
49  * \brief An SMDI message waiting indicator message.
50  *
51  * The ast_smdi_mwi_message structure contains the parsed out parts of an smdi
52  * message. Each ast_smdi_interface structure has a message queue consisting
53  * ast_smdi_mwi_message structures.
54  */
57  char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */
58  char cause[SMDI_MWI_FAIL_CAUSE_LEN + 1]; /* the type of failure */
59  struct timeval timestamp; /* a timestamp for the message */
60 };
61 
62 /*!
63  * \brief An SMDI message desk message.
64  *
65  * The ast_smdi_md_message structure contains the parsed out parts of an smdi
66  * message. Each ast_smdi_interface structure has a message queue consisting
67  * ast_smdi_md_message structures.
68  */
71  char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN + 1]; /* message desk number */
72  char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN + 1]; /* message desk terminal */
73  char fwd_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* forwarding station number */
74  char calling_st[SMDI_MAX_STATION_NUM_LEN + 1]; /* calling station number */
75  char type; /* the type of the call */
76  struct timeval timestamp; /* a timestamp for the message */
77 };
78 
79 /*!
80  * \brief SMDI interface structure.
81  *
82  * The ast_smdi_interface structure holds information on a serial port that
83  * should be monitored for SMDI activity. The structure contains a message
84  * queue of messages that have been received on the interface.
85  */
86 struct ast_smdi_interface;
87 
89  (struct ast_smdi_interface *iface),
90  { return; });
91 
92 /*!
93  * \brief Get the next SMDI message from the queue.
94  * \param iface a pointer to the interface to use.
95  *
96  * This function pulls the first unexpired message from the SMDI message queue
97  * on the specified interface. It will purge all expired SMDI messages before
98  * returning.
99  *
100  * \return the next SMDI message, or NULL if there were no pending messages.
101  */
103  (struct ast_smdi_interface *iface),
104  { return NULL; });
105 
106 /*!
107  * \brief Get the next SMDI message from the queue.
108  * \param iface a pointer to the interface to use.
109  * \param timeout the time to wait before returning in milliseconds.
110  *
111  * This function pulls a message from the SMDI message queue on the specified
112  * interface. If no message is available this function will wait the specified
113  * amount of time before returning.
114  *
115  * \return the next SMDI message, or NULL if there were no pending messages and
116  * the timeout has expired.
117  */
119  (struct ast_smdi_interface *iface, int timeout),
120  { return NULL; });
121 
122 /*!
123  * \brief Put an SMDI message back in the front of the queue.
124  * \param iface a pointer to the interface to use.
125  * \param msg a pointer to the message to use.
126  *
127  * This function puts a message back in the front of the specified queue. It
128  * should be used if a message was popped but is not going to be processed for
129  * some reason, and the message needs to be returned to the queue.
130  */
132  (struct ast_smdi_interface *iface, struct ast_smdi_md_message *msg),
133  { return; });
134 
135 /*!
136  * \brief Get the next SMDI message from the queue.
137  * \param iface a pointer to the interface to use.
138  *
139  * This function pulls the first unexpired message from the SMDI message queue
140  * on the specified interface. It will purge all expired SMDI messages before
141  * returning.
142  *
143  * \return the next SMDI message, or NULL if there were no pending messages.
144  */
146  (struct ast_smdi_interface *iface),
147  { return NULL; });
148 
149 /*!
150  * \brief Get the next SMDI message from the queue.
151  * \param iface a pointer to the interface to use.
152  * \param timeout the time to wait before returning in milliseconds.
153  *
154  * This function pulls a message from the SMDI message queue on the specified
155  * interface. If no message is available this function will wait the specified
156  * amount of time before returning.
157  *
158  * \return the next SMDI message, or NULL if there were no pending messages and
159  * the timeout has expired.
160  */
162  (struct ast_smdi_interface *iface, int timeout),
163  { return NULL; });
164 
166  (struct ast_smdi_interface *iface, int timeout, const char *station),
167  { return NULL; });
168 
169 /*!
170  * \brief Put an SMDI message back in the front of the queue.
171  * \param iface a pointer to the interface to use.
172  * \param msg a pointer to the message to use.
173  *
174  * This function puts a message back in the front of the specified queue. It
175  * should be used if a message was popped but is not going to be processed for
176  * some reason, and the message needs to be returned to the queue.
177  */
179  (struct ast_smdi_interface *iface, struct ast_smdi_mwi_message *msg),
180  { return; });
181 
182 /*!
183  * \brief Find an SMDI interface with the specified name.
184  * \param iface_name the name/port of the interface to search for.
185  *
186  * \return a pointer to the interface located or NULL if none was found. This
187  * actually returns an ASTOBJ reference and should be released using
188  * #ASTOBJ_UNREF(iface, ast_smdi_interface_destroy).
189  */
191  (const char *iface_name),
192  { return NULL; });
193 
194 /*!
195  * \brief Set the MWI indicator for a mailbox.
196  * \param iface the interface to use.
197  * \param mailbox the mailbox to use.
198  */
200  (struct ast_smdi_interface *iface, const char *mailbox),
201  { return -1; });
202 
203 /*!
204  * \brief Unset the MWI indicator for a mailbox.
205  * \param iface the interface to use.
206  * \param mailbox the mailbox to use.
207  */
209  (struct ast_smdi_interface *iface, const char *mailbox),
210  { return -1; });
211 
212 /*! \brief ast_smdi_md_message destructor. */
214  (struct ast_smdi_md_message *msg),
215  { return; });
216 
217 /*! \brief ast_smdi_mwi_message destructor. */
219  (struct ast_smdi_mwi_message *msg),
220  { return; });
221 
222 #endif /* !ASTERISK_SMDI_H */
char fwd_st[SMDI_MAX_STATION_NUM_LEN+1]
Definition: smdi.h:73
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:614
char mesg_desk_num[SMDI_MESG_DESK_NUM_LEN+1]
Definition: smdi.h:70
char calling_st[SMDI_MAX_STATION_NUM_LEN+1]
Definition: smdi.h:74
#define SMDI_MAX_STATION_NUM_LEN
Definition: smdi.h:45
struct ast_smdi_interface * ast_smdi_interface_find(const char *iface_name)
Find an SMDI interface with the specified name.
Definition: res_smdi.c:627
Configuration File Parser.
#define AST_OPTIONAL_API(result, name, proto, stub)
Define an optional API function.
Definition: optional_api.h:233
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:603
char cause[SMDI_MWI_FAIL_CAUSE_LEN+1]
Definition: smdi.h:58
#define ASTOBJ_COMPONENTS(type)
Add ASTOBJ components to a struct (with locking support).
Definition: astobj.h:173
int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
Set the MWI indicator for a mailbox.
Definition: res_smdi.c:319
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:598
void ast_smdi_interface_unref(struct ast_smdi_interface *iface)
Definition: res_smdi.c:259
#define SMDI_MESG_DESK_NUM_LEN
Definition: smdi.h:42
void ast_smdi_md_message_destroy(struct ast_smdi_md_message *msg)
ast_smdi_md_message destructor.
Definition: res_smdi.c:824
#define SMDI_MESG_DESK_TERM_LEN
Definition: smdi.h:43
An SMDI message desk message.
Definition: smdi.h:69
char mesg_desk_term[SMDI_MESG_DESK_TERM_LEN+1]
Definition: smdi.h:72
A set of macros implementing objects and containers. Macros are used for maximum performance, to support multiple inheritance, and to be easily integrated into existing structures without additional malloc calls, etc.
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.
Definition: res_smdi.c:329
#define SMDI_MWI_FAIL_CAUSE_LEN
Definition: smdi.h:44
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:609
char fwd_st[SMDI_MAX_STATION_NUM_LEN+1]
Definition: smdi.h:56
struct timeval timestamp
Definition: smdi.h:59
void ast_smdi_mwi_message_destroy(struct ast_smdi_mwi_message *msg)
ast_smdi_mwi_message destructor.
Definition: res_smdi.c:829
struct timeval timestamp
Definition: smdi.h:76
int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
Unset the MWI indicator for a mailbox.
Definition: res_smdi.c:324
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:620
Asterisk module definitions.
An SMDI message waiting indicator message.
Definition: smdi.h:55
static char mailbox[AST_MAX_EXTENSION]
Definition: chan_mgcp.c:197
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.
Definition: res_smdi.c:337