![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
smdi.h File Reference
Definition in file smdi.h.
#include <termios.h>
#include <time.h>
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/astobj.h"
Include dependency graph for smdi.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | ast_smdi_interface |
| SMDI interface structure. More... | |
| struct | ast_smdi_md_message |
| An SMDI message desk message. More... | |
| struct | ast_smdi_md_queue |
| SMDI message desk message queue. More... | |
| struct | ast_smdi_mwi_message |
| An SMDI message waiting indicator message. More... | |
| struct | ast_smdi_mwi_queue |
| SMDI message waiting indicator message queue. More... | |
Defines | |
| #define | SMDI_MAX_FILENAME_LEN 256 |
| #define | SMDI_MAX_STATION_NUM_LEN 10 |
| #define | SMDI_MESG_DESK_NUM_LEN 3 |
| #define | SMDI_MESG_DESK_TERM_LEN 4 |
| #define | SMDI_MWI_FAIL_CAUSE_LEN 3 |
Functions | |
| void | ast_smdi_interface_destroy (struct ast_smdi_interface *iface) |
| ast_smdi_interface destructor. | |
| ast_smdi_interface * | ast_smdi_interface_find (const char *iface_name) |
| Find an SMDI interface with the specified name. | |
| void | ast_smdi_md_message_destroy (struct ast_smdi_md_message *msg) |
| ast_smdi_md_message destructor. | |
| ast_smdi_md_message * | ast_smdi_md_message_pop (struct ast_smdi_interface *iface) |
| Get the next SMDI message from the queue. | |
| 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. | |
| ast_smdi_md_message * | ast_smdi_md_message_wait (struct ast_smdi_interface *iface, int timeout) |
| Get the next SMDI message from the queue. | |
| void | ast_smdi_mwi_message_destroy (struct ast_smdi_mwi_message *msg) |
| ast_smdi_mwi_message destructor. | |
| ast_smdi_mwi_message * | ast_smdi_mwi_message_pop (struct ast_smdi_interface *iface) |
| Get the next SMDI message from the queue. | |
| 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. | |
| ast_smdi_mwi_message * | ast_smdi_mwi_message_wait (struct ast_smdi_interface *iface, int timeout) |
| Get the next SMDI message from the queue. | |
| int | ast_smdi_mwi_set (struct ast_smdi_interface *iface, const char *mailbox) |
| Set the MWI indicator for a mailbox. | |
| int | ast_smdi_mwi_unset (struct ast_smdi_interface *iface, const char *mailbox) |
| Unset the MWI indicator for a mailbox. | |
|
|
|
|
|
Definition at line 42 of file smdi.h. Referenced by smdi_read(). |
|
|
Definition at line 39 of file smdi.h. Referenced by smdi_read(). |
|
|
Definition at line 40 of file smdi.h. Referenced by smdi_read(). |
|
|
|
|
|
|
Find an SMDI interface with the specified name.
Definition at line 323 of file res_smdi.c. References ASTOBJ_CONTAINER_FIND, and smdi_ifaces. 00324 { 00325 return (ASTOBJ_CONTAINER_FIND(&smdi_ifaces, iface_name)); 00326 }
|
|
|
ast_smdi_md_message destructor.
Definition at line 477 of file res_smdi.c. References free. Referenced by ast_smdi_interface_destroy(), and ast_smdi_md_message_pop(). 00478 { 00479 free(msg); 00480 }
|
|
|
Get the next SMDI message from the queue.
Definition at line 189 of file res_smdi.c. References ast_log(), ast_smdi_md_message_destroy(), ASTOBJ_CONTAINER_UNLINK_START, ASTOBJ_UNREF, LOG_NOTICE, ast_smdi_interface::md_q, ast_smdi_interface::msg_expiry, and ast_smdi_md_message::timestamp. Referenced by ast_smdi_md_message_wait(). 00190 { 00191 struct ast_smdi_md_message *md_msg = ASTOBJ_CONTAINER_UNLINK_START(&iface->md_q); 00192 struct timeval now; 00193 long elapsed = 0; 00194 00195 /* purge old messages */ 00196 now = ast_tvnow(); 00197 while (md_msg) { 00198 elapsed = ast_tvdiff_ms(now, md_msg->timestamp); 00199 00200 if (elapsed > iface->msg_expiry) { 00201 /* found an expired message */ 00202 ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy); 00203 ast_log(LOG_NOTICE, "Purged expired message from %s SMDI MD message queue. Message was %ld milliseconds too old.\n", 00204 iface->name, elapsed - iface->msg_expiry); 00205 md_msg = ASTOBJ_CONTAINER_UNLINK_START(&iface->md_q); 00206 } 00207 else { 00208 /* good message, return it */ 00209 break; 00210 } 00211 } 00212 00213 return md_msg; 00214 }
|
|
||||||||||||
|
Put an SMDI message back in the front of the queue.
Definition at line 160 of file res_smdi.c. References ASTOBJ_CONTAINER_LINK_START, and ast_smdi_interface::md_q. 00161 { 00162 ASTOBJ_CONTAINER_LINK_START(&iface->md_q, md_msg); 00163 }
|
|
||||||||||||
|
Get the next SMDI message from the queue.
Definition at line 228 of file res_smdi.c. References ast_smdi_md_message_pop(). Referenced by ss_thread(). 00229 { 00230 struct timeval start; 00231 long diff = 0; 00232 struct ast_smdi_md_message *msg; 00233 00234 start = ast_tvnow(); 00235 while (diff < timeout) { 00236 00237 if ((msg = ast_smdi_md_message_pop(iface))) 00238 return msg; 00239 00240 /* check timeout */ 00241 diff = ast_tvdiff_ms(ast_tvnow(), start); 00242 } 00243 00244 return (ast_smdi_md_message_pop(iface)); 00245 }
|
|
|
ast_smdi_mwi_message destructor.
Definition at line 483 of file res_smdi.c. References free. Referenced by ast_smdi_interface_destroy(), and ast_smdi_mwi_message_pop(). 00484 { 00485 free(msg); 00486 }
|
|
|
Get the next SMDI message from the queue.
Definition at line 257 of file res_smdi.c. References ast_log(), ast_smdi_mwi_message_destroy(), ASTOBJ_CONTAINER_UNLINK_START, ASTOBJ_UNREF, LOG_NOTICE, ast_smdi_interface::msg_expiry, ast_smdi_interface::mwi_q, and ast_smdi_mwi_message::timestamp. Referenced by ast_smdi_mwi_message_wait(). 00258 { 00259 struct ast_smdi_mwi_message *mwi_msg = ASTOBJ_CONTAINER_UNLINK_START(&iface->mwi_q); 00260 struct timeval now; 00261 long elapsed = 0; 00262 00263 /* purge old messages */ 00264 now = ast_tvnow(); 00265 while (mwi_msg) { 00266 elapsed = ast_tvdiff_ms(now, mwi_msg->timestamp); 00267 00268 if (elapsed > iface->msg_expiry) { 00269 /* found an expired message */ 00270 ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy); 00271 ast_log(LOG_NOTICE, "Purged expired message from %s SMDI MWI message queue. Message was %ld milliseconds too old.\n", 00272 iface->name, elapsed - iface->msg_expiry); 00273 mwi_msg = ASTOBJ_CONTAINER_UNLINK_START(&iface->mwi_q); 00274 } 00275 else { 00276 /* good message, return it */ 00277 break; 00278 } 00279 } 00280 00281 return mwi_msg; 00282 }
|
|
||||||||||||
|
Put an SMDI message back in the front of the queue.
Definition at line 174 of file res_smdi.c. References ASTOBJ_CONTAINER_LINK_START, and ast_smdi_interface::mwi_q. 00175 { 00176 ASTOBJ_CONTAINER_LINK_START(&iface->mwi_q, mwi_msg); 00177 }
|
|
||||||||||||
|
Get the next SMDI message from the queue.
Definition at line 296 of file res_smdi.c. References ast_smdi_mwi_message_pop(). 00297 { 00298 struct timeval start; 00299 long diff = 0; 00300 struct ast_smdi_mwi_message *msg; 00301 00302 start = ast_tvnow(); 00303 while (diff < timeout) { 00304 00305 if ((msg = ast_smdi_mwi_message_pop(iface))) 00306 return msg; 00307 00308 /* check timeout */ 00309 diff = ast_tvdiff_ms(ast_tvnow(), start); 00310 } 00311 00312 return (ast_smdi_mwi_message_pop(iface)); 00313 }
|
|
||||||||||||
|
Set the MWI indicator for a mailbox.
Definition at line 92 of file res_smdi.c. References ast_log(), ASTOBJ_UNLOCK, ASTOBJ_WRLOCK, file, LOG_DEBUG, LOG_ERROR, ast_smdi_interface::msdstrip, and option_debug. 00093 { 00094 FILE *file; 00095 int i; 00096 00097 file = fopen(iface->name, "w"); 00098 if(!file) { 00099 ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno)); 00100 return 1; 00101 } 00102 00103 ASTOBJ_WRLOCK(iface); 00104 00105 fprintf(file, "OP:MWI "); 00106 00107 for(i = 0; i < iface->msdstrip; i++) 00108 fprintf(file, "0"); 00109 00110 fprintf(file, "%s!\x04", mailbox); 00111 fclose(file); 00112 00113 ASTOBJ_UNLOCK(iface); 00114 if (option_debug) 00115 ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name); 00116 return 0; 00117 }
|
|
||||||||||||
|
Unset the MWI indicator for a mailbox.
Definition at line 124 of file res_smdi.c. References ast_log(), ASTOBJ_UNLOCK, ASTOBJ_WRLOCK, file, LOG_DEBUG, LOG_ERROR, ast_smdi_interface::msdstrip, and option_debug. 00125 { 00126 FILE *file; 00127 int i; 00128 00129 file = fopen(iface->name, "w"); 00130 if(!file) { 00131 ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno)); 00132 return 1; 00133 } 00134 00135 ASTOBJ_WRLOCK(iface); 00136 00137 fprintf(file, "RMV:MWI "); 00138 00139 for(i = 0; i < iface->msdstrip; i++) 00140 fprintf(file, "0"); 00141 00142 fprintf(file, "%s!\x04", mailbox); 00143 fclose(file); 00144 00145 ASTOBJ_UNLOCK(iface); 00146 if (option_debug) 00147 ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name); 00148 return 0; 00149 }
|